JsonApiResource extends JsonApiResourceIdentifier implements JsonLinks, JsonApiData { @Override public JsonApiResource addRelationship(String name, JsonApiIdentifiable related, URI location) { relationships.put(name, new JsonApiRelationship(related, location)); return this; } 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 addRelationship() { JsonApiResourceIdentifier dummy1Identifier = new JsonApiResourceIdentifier(dummy02); JsonApiResourceIdentifier dummy2Identifier = new JsonApiResourceIdentifier(dummy03); JsonApiResource result = new JsonApiResource(dummyObj,uri); result.addRelationship("First", dummy02, uri); result.addRelationship("Second", dummy03, anotherUri); JsonApiRelationship resultFirst = result.getRelationships().get("First"); JsonApiRelationship resultSecond = result.getRelationships().get("Second"); Assert.assertEquals(2, result.getRelationships().size()); Assert.assertEquals(dummy1Identifier, resultFirst.getData().get(0)); Assert.assertEquals(dummy2Identifier, resultSecond.getData().get(0)); Assert.assertEquals(uri, resultFirst.getLinks().get(JsonLinks.RELATED)); Assert.assertEquals(anotherUri, resultSecond.getLinks().get(JsonLinks.RELATED)); }