Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for managed relationship types
Representations now track defined Rel instances, which are used by the renderers to control rel specific functionality. The core code now looks at Rel.singleton and prevents duplicate usage.
- Loading branch information
Showing
6 changed files
with
136 additions
and
17 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
46 changes: 46 additions & 0 deletions
46
src/test/java/com/theoryinpractise/halbuilder/SingleLinksTest.java
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,46 @@ | ||
package com.theoryinpractise.halbuilder; | ||
|
||
import com.theoryinpractise.halbuilder.api.Rel; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.fest.assertions.api.Fail.fail; | ||
|
||
public class SingleLinksTest { | ||
|
||
@Test | ||
public void testDuplicateSingleLinksFails() { | ||
|
||
try { | ||
new DefaultRepresentationFactory() | ||
.withRel(Rel.singleton("bar")) | ||
.newRepresentation("/foo") | ||
.withLink("bar", "/bar") | ||
.withLink("bar", "/bar"); | ||
|
||
fail("This should have failed with an InvalidStateException.)"); | ||
|
||
} catch (IllegalStateException exected) { | ||
// | ||
} | ||
} | ||
|
||
@Test | ||
public void testDuplicateSingleEmbedFails() { | ||
|
||
try { | ||
final DefaultRepresentationFactory factory = new DefaultRepresentationFactory(); | ||
|
||
factory | ||
.withRel(Rel.singleton("bar")) | ||
.newRepresentation("/foo") | ||
.withRepresentation("bar", factory.newRepresentation().withProperty("id", 1)) | ||
.withRepresentation("bar", factory.newRepresentation().withProperty("id", 1)); | ||
|
||
fail("This should have failed with an InvalidStateException.)"); | ||
|
||
} catch (IllegalStateException exected) { | ||
// | ||
} | ||
} | ||
|
||
} |