ClientElbResource { @GET @Path("/findById") @Timed @Produces(MediaType.APPLICATION_JSON) public Response findByIdClientElb(@QueryParam("clientId") String clientId) { if(clientId == null) { return Response.status(Response.Status.BAD_REQUEST.getStatusCode()).entity( "ClientId cannot be null").build(); } try { String clientElbUrl = clientElbPersistenceService.findByIdClientElb(clientId); if (clientElbUrl == null) { return Response.status(Response.Status.NOT_FOUND.getStatusCode()) .entity("ClientElb with Id: " + clientId + " not found").build(); } return Response.status(Response.Status.FOUND.getStatusCode()).entity(clientElbUrl).build(); } catch(Exception ex) { logger.error("findById failed for input: "+ clientId + " {} {} ", ex.getMessage(), ex.getStackTrace()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } @Inject  ClientElbResource(ClientElbPersistenceService clientElbPersistenceService
    ); @POST @Path("/create") @Timed @Produces(MediaType.APPLICATION_JSON) Response createClientElb(@QueryParam("clientId") String clientId,
                                @QueryParam("clientElbUrl") String clientElbUrl); @GET @Path("/findById") @Timed @Produces(MediaType.APPLICATION_JSON) Response findByIdClientElb(@QueryParam("clientId") String clientId); @POST @Path("/update") @Timed Response updateClientElb(@QueryParam("clientId") String clientId,
                                    @QueryParam("clientElbUrl") String clientElbUrl); @POST @Path("/delete") @Timed Response deleteClientElb(@QueryParam("clientId") String clientId);  }
@Test public void testFindById() { when(clientElbPersistenceService.findByIdClientElb("id2")) .thenReturn("http: Response response_1 = clientElbResource.findByIdClientElb(null); Assertions.assertThat(response_1.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode()); Response response_2 = clientElbResource.findByIdClientElb("id2"); Assertions.assertThat(response_2.getStatus()).isEqualTo(Response.Status.FOUND.getStatusCode()); when(clientElbPersistenceService.findByIdClientElb("id2")) .thenReturn(null); Response response_3 = clientElbResource.findByIdClientElb("id2"); Assertions.assertThat(response_3.getStatus()).isEqualTo(Response.Status.NOT_FOUND.getStatusCode()); verify(clientElbPersistenceService, times(2)).findByIdClientElb( "id2"); verifyNoMoreInteractions(clientElbPersistenceService); }