### Question:
DefaultResource extends GenericResource implements CustomEntityReturnable { @PATCH @Path("{id}") public Response patch(@PathParam("id") final String id, final EntityBody entityBody, @Context final UriInfo uriInfo) { writeValidator.validateWriteRequest(entityBody, uriInfo, SecurityUtil.getSLIPrincipal()); return defaultResponseBuilder.build(uriInfo, twoPartTemplate, ResourceMethod.PATCH, new ResourceLogic() { @Override public Response run(Resource resource) { EntityDefinition entityDefinition = entityDefinitionStore.lookupByResourceName(resource.getResourceType()); if(entityDefinition.supportsPatch()) { resourceService.patchEntity(resource, id, entityBody); return Response.status(Response.Status.NO_CONTENT).build(); } else { return Response.status(405).build(); } } }); } DefaultResource(); @GET Response getAll(@Context final UriInfo uriInfo); @POST Response post(final EntityBody entityBody,
                         @Context final UriInfo uriInfo); @GET @Path("{id}") Response getWithId(@PathParam("id") final String id,
                              @Context final UriInfo uriInfo); @PUT @Path("{id}") Response put(@PathParam("id") final String id,
                        final EntityBody entityBody,
                        @Context final UriInfo uriInfo); @DELETE @Path("{id}") Response delete(@PathParam("id") final String id,
                           @Context final UriInfo uriInfo); @PATCH @Path("{id}") Response patch(@PathParam("id") final String id,
                          final EntityBody entityBody,
                          @Context final UriInfo uriInfo); @Override CustomEntityResource getCustomResource(final String id, final UriInfo uriInfo);  }### Answer:
@Test public void testPatch() throws URISyntaxException { String id = resourceService.postEntity(resource, createTestEntity()); setupMocks(BASE_URI + "/" + id); Response response = defaultResource.patch(id, createTestPatchEntity(), uriInfo); assertEquals("Status code should be OK", Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); Response getResponse = defaultResource.getWithId(id, uriInfo); EntityResponse entityResponse = (EntityResponse) getResponse.getEntity(); EntityBody body = (EntityBody) entityResponse.getEntity(); assertEquals("Status code should be OK", Response.Status.OK.getStatusCode(), getResponse.getStatus()); assertEquals("Should match", id, body.get("id")); assertEquals("Should match", 1234, body.get("studentUniqueStateId")); assertEquals("Should match", "Female", body.get("sex")); }