@Test public void noLinks() throws IOException { Map<String, List<Link>> links = this.linkExtractor .extractLinks(createResponse("no-links")); assertLinks(Collections.<Link>emptyList(), links); }
private OperationResponse createResponse(String contentName) throws IOException { return this.responseFactory.create(HttpStatus.OK, null, FileCopyUtils.copyToByteArray(getPayloadFile(contentName))); }
@Test public void linksInTheWrongFormat() throws IOException { Map<String, List<Link>> links = this.linkExtractor .extractLinks(createResponse("wrong-format")); assertLinks(Collections.<Link>emptyList(), links); }
@Test public void singleLink() throws IOException { Map<String, List<Link>> links = this.linkExtractor .extractLinks(createResponse("single-link")); assertLinks(Arrays.asList(new Link("alpha", "http://alpha.example.com", "Alpha")), links); }
@Test public void multipleLinksWithDifferentRels() throws IOException { Map<String, List<Link>> links = this.linkExtractor .extractLinks(createResponse("multiple-links-different-rels")); assertLinks(Arrays.asList(new Link("alpha", "http://alpha.example.com", "Alpha"), new Link("bravo", "http://bravo.example.com")), links); }
@Test public void multipleLinksWithSameRels() throws IOException { Map<String, List<Link>> links = this.linkExtractor .extractLinks(createResponse("multiple-links-same-rels")); assertLinks(Arrays.asList( new Link("alpha", "http://alpha.example.com/one", "Alpha one"), new Link("alpha", "http://alpha.example.com/two")), links); }