ClientElbResource { @POST @Path("/update") @Timed public Response updateClientElb(@QueryParam("clientId") String clientId, @QueryParam("clientElbUrl") String clientElbUrl) { if(clientId == null || clientElbUrl == null) { return Response.status(Response.Status.BAD_REQUEST.getStatusCode()).entity( "ClientId OR ClientElbUrl cannot be null").build(); } try { URL verifyingURL = new URL(clientElbUrl); verifyingURL.toURI(); if(verifyingURL.getHost().length() < 1 || verifyingURL.getPath().length() > 0) { throw new MalformedURLException(); } clientElbPersistenceService.updateClientElb(clientId, clientElbUrl); } catch(MalformedURLException ex) { logger.error("Malformed URL exception(no path allowed because Elb Url doesn't contain path) {} {} ", ex.getMessage(), ex.getStackTrace()); return Response.status(Response.Status.BAD_REQUEST).entity("MalformedURLException").build(); } catch(URISyntaxException ex) { logger.error("URI Syntax Exception {} {} ", ex.getMessage(), ex.getStackTrace()); return Response.status(Response.Status.BAD_REQUEST).entity("URISyntaxException").build(); } catch(Exception ex) { logger.error("Update failed for input: "+ clientId + " " + clientElbUrl + " {} {} " , ex.getMessage(), ex.getStackTrace()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } return Response.status(Response.Status.ACCEPTED).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 testUpdateClientElb() { Response response_1 = clientElbResource.updateClientElb("id1", null); Assertions.assertThat(response_1.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode()); Response response_2 = clientElbResource.updateClientElb(null, "http: Assertions.assertThat(response_2.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode()); Response response_3 = clientElbResource.updateClientElb(null, "http: Assertions.assertThat(response_3.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode()); doNothing().when(clientElbPersistenceService).updateClientElb("id1", "http: Response response_4 = clientElbResource.updateClientElb("id1", "http: Assertions.assertThat(response_4.getStatus()).isEqualTo(Response.Status.ACCEPTED.getStatusCode()); verify(clientElbPersistenceService, times(1)).updateClientElb( "id1", "http: verifyNoMoreInteractions(clientElbPersistenceService); }