ResponseImpl extends Response { @Override public Set<Link> getLinks() { List<Object> links = getMetadata().get(LINK); if (links == null) { return Collections.emptySet(); } Set<Link> linkSet = new LinkedHashSet<>(); for (Object value : links) { if (value instanceof Link) { linkSet.add((Link)value); } else { linkSet.add(Link.valueOf(value instanceof String ? (String)value : getHeaderAsString(value))); } } return linkSet; } protected  ResponseImpl(int status, Object entity, Annotation[] entityAnnotations, MultivaluedMap<String, Object> headers); @Override Object getEntity(); Annotation[] getEntityAnnotations(); @Override T readEntity(Class<T> entityType); @SuppressWarnings("unchecked") @Override T readEntity(GenericType<T> entityType); @Override T readEntity(Class<T> entityType, Annotation[] annotations); @SuppressWarnings("unchecked") @Override T readEntity(GenericType<T> entityType, Annotation[] annotations); @Override boolean hasEntity(); @Override boolean bufferEntity(); @Override void close(); boolean isClosed(); @Override MediaType getMediaType(); @Override Locale getLanguage(); @Override int getLength(); @Override Set<String> getAllowedMethods(); @Override Map<String, NewCookie> getCookies(); @Override EntityTag getEntityTag(); @Override Date getDate(); @Override Date getLastModified(); @Override URI getLocation(); @Override Set<Link> getLinks(); @Override boolean hasLink(String relation); @Override Link getLink(String relation); @Override Link.Builder getLinkBuilder(String relation); @Override MultivaluedMap<String, Object> getMetadata(); @Override MultivaluedMap<String, String> getStringHeaders(); @Override String getHeaderString(String name); @Override int getStatus(); @Override StatusType getStatusInfo(); @Override String toString();  }
@Test public void getsLinks() throws Exception { MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>(); Link link = new LinkBuilderImpl().uri("http: headers.put(LINK, newArrayList(link)); ResponseImpl response = new ResponseImpl(200, "foo", null, headers); assertEquals(newHashSet(link), response.getLinks()); }
@Test public void parsesLinkHeader() throws Exception { MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>(); headers.put(LINK, newArrayList("< http: ResponseImpl response = new ResponseImpl(200, "foo", null, headers); assertEquals(newHashSet(new LinkBuilderImpl().uri("http: }
@Test public void getsEmptySetIfLinkHeaderIsNotSet() throws Exception { MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>(); ResponseImpl response = new ResponseImpl(200, "foo", null, headers); assertEquals(newHashSet(), response.getLinks()); }