use of io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourcePatch in project crnk-framework by crnk-project.
the class ResourceIdControllerTest method checkPatchRelationship.
private void checkPatchRelationship(Resource resource, ResourceIdentifier scheduleId) {
JsonPath path = pathBuilder.build("/relationIdTest/" + resource.getId() + "/relationships/testLookupAlways");
Document newDocument = createDocument(scheduleId);
// WHEN PATCH
RelationshipsResourcePatch sut = new RelationshipsResourcePatch(resourceRegistry, typeParser, modificationFilters);
Response taskResponse = sut.handle(path, emptyTaskQuery, null, newDocument);
// THEN PATCH
assertThat(taskResponse.getHttpStatus()).isEqualTo(HttpStatus.NO_CONTENT_204);
// validate relationship not accessed, only id set => performance
RelationIdTestResource entity = repository.findOne(1L, new QuerySpec(RelationIdTestResource.class));
Assert.assertEquals(scheduleId != null ? Long.parseLong(scheduleId.getId()) : null, entity.getTestLookupAlwaysId());
Assert.assertNull(entity.getTestLookupAlways());
}
Aggregations