JsonApiResource extends JsonApiResourceIdentifier implements JsonLinks, JsonApiData { @Override public URI getRelationshipUri(JsonApiIdentifiable related) { URI relationshipURI = null; for (Map.Entry<String, JsonApiRelationship> entry : relationships.entrySet()) { JsonApiRelationship match = entry.getValue(); if (match.containsEntity(related)) { if (match.getData().size() == 1) { relationshipURI = match.getLinks().get(RELATED); } else { relationshipURI = match.getLinks().get(RELATED).resolve(related.getId()); } break; } } return relationshipURI; } JsonApiResource(JsonApiIdentifiable entity, URI uri); @JsonIgnoreProperties(value = {"id", "type"}) @JsonProperty("attributes") Object getEntity(); @JsonInclude(JsonInclude.Include.NON_EMPTY) Map<String, JsonApiRelationship> getRelationships(); @Override Map<String, URI> getLinks(); @Override void addLink(String name, URI ref); @Override URI getURI(); @Override boolean hasRelationshipTo(JsonApiIdentifiable related); @Override void setResourceCollectionURI(URI collectionURI); @Override JsonApiResource asSingleResource(); @Override JsonApiResourceCollection asResourceCollection(); @Override URI getRelationshipUri(JsonApiIdentifiable related); @Override JsonApiResource addRelationship(String name, JsonApiIdentifiable related, URI location); @Override JsonApiResource addRelationship(String name, Collection<? extends JsonApiIdentifiable> relatedCollection, URI location); @Override JsonApiResource restrictTo(String attribute); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testGetRelationshipURI() { JsonApiResource result = new JsonApiResource(dummyObj, uri); result.addRelationship("dummy1", dummy02, uri); Assert.assertEquals(uri, result.getRelationshipUri(dummy02)); }