private LinkFollowSpecs asProvidedElseCreate(final LinkFollowSpecs linkFollower) { if (linkFollower != null) { return linkFollower; } return LinkFollowSpecs.create(rendererContext.getFollowLinks()); }
private LinkFollowSpecs asProvidedElseCreate(final LinkFollowSpecs linkFollower) { if (linkFollower != null) { return linkFollower; } return LinkFollowSpecs.create(rendererContext.getFollowLinks()); }
@Test public void create_noCriteria() throws Exception { final List<List<String>> links = asListOfLists("a.b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.matches(JsonRepresentation.newMap()), is(true)); }
@Test public void create_noCriteria() throws Exception { final List<List<String>> links = asListOfLists("a.b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.matches(JsonRepresentation.newMap()), is(true)); }
@Test public void follow_noCriteria() throws Exception { final List<List<String>> links = asListOfLists("a.b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.matches(JsonRepresentation.newMap()), is(true)); }
@Test public void follow_noCriteria() throws Exception { final List<List<String>> links = asListOfLists("a.b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.matches(JsonRepresentation.newMap()), is(true)); }
@Test public void notMatching() throws Exception { final List<List<String>> links = asListOfLists("a.b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.follow("x").isFollowing(), is(false)); assertThat(linkFollower.follow("x").isTerminated(), is(true)); }
@Test public void simple() throws Exception { final List<List<String>> links = asListOfLists("a.b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.follow("a").isFollowing(), is(true)); assertThat(linkFollower.follow("a").isTerminated(), is(false)); }
@Test public void notMatching() throws Exception { final List<List<String>> links = asListOfLists("a.b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.follow("x").isFollowing(), is(false)); assertThat(linkFollower.follow("x").isTerminated(), is(true)); }
@Test public void simple() throws Exception { final List<List<String>> links = asListOfLists("a.b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.follow("a").isFollowing(), is(true)); assertThat(linkFollower.follow("a").isTerminated(), is(false)); }
@Test public void multiplePaths_withRelSimplifiedCriteria() throws Exception { final List<List<String>> links = asListOfLists("links[rel=urn:org.restfulobjects:rels/details;action=foo].x,links[rel=urn:org.restfulobjects:rels/details;action=bar].y"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); LinkFollowSpecs followRelVersion = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/details]"); assertThat(followRelVersion.isFollowing(), is(true)); assertThat(followRelVersion.isTerminated(), is(false)); assertThat(followRelVersion.follow("x").isFollowing(), is(true)); }
@Test public void multiplePaths_withRelSimplifiedCriteria() throws Exception { final List<List<String>> links = asListOfLists("links[rel=urn:org.restfulobjects:rels/details;action=foo].x,links[rel=urn:org.restfulobjects:rels/details;action=bar].y"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); LinkFollowSpecs followRelVersion = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/details]"); assertThat(followRelVersion.isFollowing(), is(true)); assertThat(followRelVersion.isTerminated(), is(false)); assertThat(followRelVersion.follow("x").isFollowing(), is(true)); }
@Test public void example_of_eager_loading_of_collection() throws Exception { final List<List<String>> links = asListOfLists("members[children].value"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); LinkFollowSpecs followMembers = linkFollower.follow("members[children]"); assertThat(followMembers.isFollowing(), is(true)); assertThat(followMembers.isTerminated(), is(false)); assertThat(followMembers.follow("value").isFollowing(), is(true)); assertThat(followMembers.follow("value").isTerminated(), is(false)); }
@Test public void multiplePaths_withRelFullCriteria() throws Exception { final List<List<String>> links = asListOfLists("links[rel=urn:org.restfulobjects:rels/details;action=foo].x,links[rel=urn:org.restfulobjects:rels/details;action=bar].y"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); LinkFollowSpecs followRelVersion = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/details;action=foo]"); assertThat(followRelVersion.isFollowing(), is(true)); assertThat(followRelVersion.isTerminated(), is(false)); assertThat(followRelVersion.follow("x").isFollowing(), is(true)); LinkFollowSpecs followRelUser = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/details;action=bar]"); assertThat(followRelUser.isFollowing(), is(true)); assertThat(followRelUser.isTerminated(), is(false)); assertThat(followRelUser.follow("y").isFollowing(), is(true)); }
@Test public void follow_withSingleMapCriteria() throws Exception { final List<List<String>> links = asListOfLists("a[x].b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.follow("x").isFollowing(), is(false)); final LinkFollowSpecs followA = linkFollower.follow("a"); assertThat(followA.isFollowing(), is(true)); assertThat(followA.matches(JsonRepresentation.newMap("x", "y")), is(true)); assertThat(followA.matches(JsonRepresentation.newMap("x", "z")), is(true)); assertThat(followA.matches(JsonRepresentation.newMap()), is(false)); assertThat(followA.matches(JsonRepresentation.newMap("p", "z")), is(false)); }
@Test public void multiplePaths_withCriteria() throws Exception { final List<List<String>> links = asListOfLists("links[rel=urn:org.restfulobjects:rels/version].x,links[rel=urn:org.restfulobjects:rels/user].y"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); LinkFollowSpecs followRelVersion = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/version]"); assertThat(followRelVersion.isFollowing(), is(true)); assertThat(followRelVersion.isTerminated(), is(false)); assertThat(followRelVersion.follow("x").isFollowing(), is(true)); LinkFollowSpecs followRelUser = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/user]"); assertThat(followRelUser.isFollowing(), is(true)); assertThat(followRelUser.isTerminated(), is(false)); assertThat(followRelUser.follow("y").isFollowing(), is(true)); }
@Test public void multiplePaths_withCriteria() throws Exception { final List<List<String>> links = asListOfLists("links[rel=urn:org.restfulobjects:rels/version].x,links[rel=urn:org.restfulobjects:rels/user].y"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); LinkFollowSpecs followRelVersion = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/version]"); assertThat(followRelVersion.isFollowing(), is(true)); assertThat(followRelVersion.isTerminated(), is(false)); assertThat(followRelVersion.follow("x").isFollowing(), is(true)); LinkFollowSpecs followRelUser = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/user]"); assertThat(followRelUser.isFollowing(), is(true)); assertThat(followRelUser.isTerminated(), is(false)); assertThat(followRelUser.follow("y").isFollowing(), is(true)); }
@Test public void multiplePaths_withRelFullCriteria() throws Exception { final List<List<String>> links = asListOfLists("links[rel=urn:org.restfulobjects:rels/details;action=foo].x,links[rel=urn:org.restfulobjects:rels/details;action=bar].y"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); LinkFollowSpecs followRelVersion = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/details;action=foo]"); assertThat(followRelVersion.isFollowing(), is(true)); assertThat(followRelVersion.isTerminated(), is(false)); assertThat(followRelVersion.follow("x").isFollowing(), is(true)); LinkFollowSpecs followRelUser = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/details;action=bar]"); assertThat(followRelUser.isFollowing(), is(true)); assertThat(followRelUser.isTerminated(), is(false)); assertThat(followRelUser.follow("y").isFollowing(), is(true)); }
@Test public void follow_withSingleListCriteria() throws Exception { final List<List<String>> links = asListOfLists("a[x=y].b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.follow("x").isFollowing(), is(false)); final LinkFollowSpecs followA = linkFollower.follow("a"); assertThat(followA.isFollowing(), is(true)); assertThat(followA.matches(JsonRepresentation.newMap("x", "y")), is(true)); assertThat(followA.matches(JsonRepresentation.newMap()), is(false)); assertThat(followA.matches(JsonRepresentation.newMap("x", "z")), is(false)); }
@Test public void follow_withSingleMapCriteria() throws Exception { final List<List<String>> links = asListOfLists("a[x].b.c"); final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links); assertThat(linkFollower.follow("x").isFollowing(), is(false)); final LinkFollowSpecs followA = linkFollower.follow("a"); assertThat(followA.isFollowing(), is(true)); assertThat(followA.matches(JsonRepresentation.newMap("x", "y")), is(true)); assertThat(followA.matches(JsonRepresentation.newMap("x", "z")), is(true)); assertThat(followA.matches(JsonRepresentation.newMap()), is(false)); assertThat(followA.matches(JsonRepresentation.newMap("p", "z")), is(false)); }