AppListController { @POST @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response deploy(@PathParam("id") String id, Service service) { AppCatalogSolrClient sc = new AppCatalogSolrClient(); try { sc.deployApp(id, service); } catch (SolrServerException | IOException e) { return Response.status(Status.BAD_REQUEST).entity(e.toString()).build(); } YarnServiceClient yc = new YarnServiceClient(); yc.createApp(service); String output = "{\"status\":\"Application deployed.\",\"id\":\"" + service.getName() + "\"}"; return Response.status(Status.ACCEPTED).entity(output).build(); } AppListController(); @GET @Produces(MediaType.APPLICATION_JSON) List<AppEntry> getList(); @DELETE @Path("{id}/{name}") @Produces(MediaType.APPLICATION_JSON) Response delete(@PathParam("id") String id,
      @PathParam("name") String name); @POST @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response deploy(@PathParam("id") String id, Service service);  }
@Test public void testDeploy() throws Exception { String id = "application 1"; AppListController ac = Mockito.mock(AppListController.class); Service service = new Service(); Response expected = Response.ok().build(); when(ac.deploy(id, service)).thenReturn(Response.ok().build()); final Response actual = ac.deploy(id, service); assertEquals(expected.getStatus(), actual.getStatus()); }