@Test public void testRead() { Response res = resource.read(); assertNotNull(res); assertEquals(Status.NOT_FOUND.getStatusCode(), res.getStatus()); Mockito.verify(service).getCustom("TEST-ID"); EntityBody mockBody = Mockito.mock(EntityBody.class); Mockito.when(service.getCustom("TEST-ID")).thenReturn(mockBody); res = resource.read(); assertNotNull(res); assertEquals(Status.OK.getStatusCode(), res.getStatus()); Mockito.verify(service, Mockito.atLeast(2)).getCustom("TEST-ID"); }
@GET @Path("/") public Response read() { if (entityDefinition == null) { return Response.status(Status.NOT_FOUND).build(); } EntityBody entityBody = entityDefinition.getService().getCustom(entityId); if (entityBody == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.status(Status.OK).entity(entityBody).build(); }
CustomEntityResource { @GET @Path("/") public Response read() { if (entityDefinition == null) { return Response.status(Status.NOT_FOUND).build(); } EntityBody entityBody = entityDefinition.getService().getCustom(entityId); if (entityBody == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.status(Status.OK).entity(entityBody).build(); } }
CustomEntityResource { @GET @Path("/") public Response read() { if (entityDefinition == null) { return Response.status(Status.NOT_FOUND).build(); } EntityBody entityBody = entityDefinition.getService().getCustom(entityId); if (entityBody == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.status(Status.OK).entity(entityBody).build(); } CustomEntityResource(final String entityId, final EntityDefinition entityDefinition,
                                final ResourceHelper resourceHelper); }
CustomEntityResource { @GET @Path("/") public Response read() { if (entityDefinition == null) { return Response.status(Status.NOT_FOUND).build(); } EntityBody entityBody = entityDefinition.getService().getCustom(entityId); if (entityBody == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.status(Status.OK).entity(entityBody).build(); } CustomEntityResource(final String entityId, final EntityDefinition entityDefinition,
                                final ResourceHelper resourceHelper); @GET @Path("/") Response read(); @PUT @Path("/") Response createOrUpdatePut(final EntityBody customEntity); @POST @Path("/") Response createOrUpdatePost(@Context final UriInfo uriInfo,
                                       final EntityBody customEntity); @DELETE @Path("/") Response delete(); }
CustomEntityResource { @GET @Path("/") public Response read() { if (entityDefinition == null) { return Response.status(Status.NOT_FOUND).build(); } EntityBody entityBody = entityDefinition.getService().getCustom(entityId); if (entityBody == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.status(Status.OK).entity(entityBody).build(); } CustomEntityResource(final String entityId, final EntityDefinition entityDefinition,
                                final ResourceHelper resourceHelper); @GET @Path("/") Response read(); @PUT @Path("/") Response createOrUpdatePut(final EntityBody customEntity); @POST @Path("/") Response createOrUpdatePost(@Context final UriInfo uriInfo,
                                       final EntityBody customEntity); @DELETE @Path("/") Response delete();  }