@Test public void testAddRelationshipCollection() { setUpExpectations(); JsonApiIdentifiable minimalEntity = createMinimalEntity(); Collection<JsonApiIdentifiable> relatedCollection = new LinkedList<>(); for (int i = 0; i < NR_ENTITIES; i++) { relatedCollection.add(createCustomMinimalEntity(String.valueOf(i))); } Response result = JsonApiResponse .createGetResponse(uriInfo) .data(minimalEntity) .addRelationship("related", relatedCollection, uriInfo.getAbsolutePath()) .build(); assertIsValidJsonApiDataResponse(result); JsonNode resultJson = extractJsonEntity(result).get("data"); Assert.assertEquals(1, resultJson.get("relationships").size()); Assert.assertTrue(resultJson.get("relationships").has("related")); JsonNode relationshipNode = resultJson.get("relationships").get("related"); assertHasValidRelationshipData(relationshipNode); for (int i = 0; i < NR_ENTITIES; i++) { Assert.assertEquals(String.valueOf(i), relationshipNode.get("data").get(i).get("id").textValue()); } }
public static RequiredEntity createGetResponse(UriInfo uriInfo) { Assert.assertNotNull(uriInfo); return new Builder(new JsonApiResponse(uriInfo, Response.Status.OK)); }
JsonApiResponse { public static RequiredEntity createGetResponse(UriInfo uriInfo) { Assert.assertNotNull(uriInfo); return new Builder(new JsonApiResponse(uriInfo, Response.Status.OK)); } }
JsonApiResponse { public static RequiredEntity createGetResponse(UriInfo uriInfo) { Assert.assertNotNull(uriInfo); return new Builder(new JsonApiResponse(uriInfo, Response.Status.OK)); } private  JsonApiResponse(UriInfo uriInfo, Response.StatusType statusCode); private  JsonApiResponse(Response.StatusType statusCode); }
JsonApiResponse { public static RequiredEntity createGetResponse(UriInfo uriInfo) { Assert.assertNotNull(uriInfo); return new Builder(new JsonApiResponse(uriInfo, Response.Status.OK)); } private  JsonApiResponse(UriInfo uriInfo, Response.StatusType statusCode); private  JsonApiResponse(Response.StatusType statusCode); static RequiredEntity createGetResponse(UriInfo uriInfo); static RequiredEntity createPostResponse(UriInfo uriInfo); static RequiredEntity createPutResponse(UriInfo uriInfo); static BuildableException createExceptionResponse(Response.Status code); }
JsonApiResponse { public static RequiredEntity createGetResponse(UriInfo uriInfo) { Assert.assertNotNull(uriInfo); return new Builder(new JsonApiResponse(uriInfo, Response.Status.OK)); } private  JsonApiResponse(UriInfo uriInfo, Response.StatusType statusCode); private  JsonApiResponse(Response.StatusType statusCode); static RequiredEntity createGetResponse(UriInfo uriInfo); static RequiredEntity createPostResponse(UriInfo uriInfo); static RequiredEntity createPutResponse(UriInfo uriInfo); static BuildableException createExceptionResponse(Response.Status code); static final String JSONAPI_TYPE; }