Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from blackdoor/bugfix/#15_null-ptr
Fix #15
- Loading branch information
Showing
5 changed files
with
91 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package black.door.hate; | ||
|
||
import com.damnhandy.uri.template.UriTemplate; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.val; | ||
import org.junit.Test; | ||
|
||
import java.net.URI; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by nfischer on 6/16/2016. | ||
*/ | ||
public class HalLinkTest { | ||
|
||
@Test | ||
public void testSerialization(){ | ||
val link = HalLink.builder() | ||
.href(UriTemplate.fromTemplate("/~{username}")) | ||
.build(); | ||
|
||
assertTrue(new ObjectMapper().valueToTree(link).get("templated").asBoolean()); | ||
} | ||
|
||
@Test | ||
public void testIsTemplated(){ | ||
HalLink link = HalLink.builder() | ||
.href(URI.create("/path")) | ||
.build(); | ||
assertFalse(link.isTemplated()); | ||
|
||
link = HalLink.builder() | ||
.href(UriTemplate.fromTemplate("/~{username}")) | ||
.build(); | ||
assertTrue(link.isTemplated()); | ||
} | ||
|
||
@Test | ||
public void testGetHrefAsUri() throws Exception { | ||
HalLink link = HalLink.builder() | ||
.href(URI.create("/path")) | ||
.build(); | ||
assertTrue(link.getHrefAsUri().isPresent()); | ||
|
||
link = HalLink.builder() | ||
.href(UriTemplate.fromTemplate("/~{username}")) | ||
.build(); | ||
assertFalse(link.getHrefAsUri().isPresent()); | ||
} | ||
|
||
@Test | ||
public void testGetHrefAsTemplate() throws Exception { | ||
HalLink link = HalLink.builder() | ||
.href(UriTemplate.fromTemplate("/~{username}")) | ||
.build(); | ||
assertTrue(link.getHrefAsTemplate().isPresent()); | ||
|
||
link = HalLink.builder() | ||
.href(URI.create("/path")) | ||
.build(); | ||
assertFalse(link.getHrefAsTemplate().isPresent()); | ||
} | ||
} |