@Test public void getHostInfo404Test() throws Exception { ProviderDAO providerDAO = mock(ProviderDAO.class); when(providerDAO.getById(1)).thenReturn(null); ProviderHostInfo providerHostInfo = new ProviderHostInfo(); providerHostInfo.providerDAO = providerDAO; Response response = providerHostInfo.getHostInfo(1); assertEquals(404, response.getStatus()); String providerXML = (String) response.getEntity(); assertEquals("No provider by that id found in the databae.", providerXML); }
@GET public Response getHostInfo(@PathParam("id") int id) throws UnirestException { logger.info("GET /" + id + "/hostinfo"); Provider provider = providerDAO.getById(id); if(provider != null) { HttpResponse<String> response = Unirest.get(provider.getVmmUrl() + "/nodes").header("accept", "application/json").asString(); String payload = response.getBody(); return buildResponse(Status.OK, payload); } else { logger.debug("RESPONSE: 404"); return buildResponse(Status.NOT_FOUND, "No provider by that id found in the databae."); } }
ProviderHostInfo extends RestAbstract { @GET public Response getHostInfo(@PathParam("id") int id) throws UnirestException { logger.info("GET /" + id + "/hostinfo"); Provider provider = providerDAO.getById(id); if(provider != null) { HttpResponse<String> response = Unirest.get(provider.getVmmUrl() + "/nodes").header("accept", "application/json").asString(); String payload = response.getBody(); return buildResponse(Status.OK, payload); } else { logger.debug("RESPONSE: 404"); return buildResponse(Status.NOT_FOUND, "No provider by that id found in the databae."); } } }
ProviderHostInfo extends RestAbstract { @GET public Response getHostInfo(@PathParam("id") int id) throws UnirestException { logger.info("GET /" + id + "/hostinfo"); Provider provider = providerDAO.getById(id); if(provider != null) { HttpResponse<String> response = Unirest.get(provider.getVmmUrl() + "/nodes").header("accept", "application/json").asString(); String payload = response.getBody(); return buildResponse(Status.OK, payload); } else { logger.debug("RESPONSE: 404"); return buildResponse(Status.NOT_FOUND, "No provider by that id found in the databae."); } }  }
ProviderHostInfo extends RestAbstract { @GET public Response getHostInfo(@PathParam("id") int id) throws UnirestException { logger.info("GET /" + id + "/hostinfo"); Provider provider = providerDAO.getById(id); if(provider != null) { HttpResponse<String> response = Unirest.get(provider.getVmmUrl() + "/nodes").header("accept", "application/json").asString(); String payload = response.getBody(); return buildResponse(Status.OK, payload); } else { logger.debug("RESPONSE: 404"); return buildResponse(Status.NOT_FOUND, "No provider by that id found in the databae."); } }  @GET Response getHostInfo(@PathParam("id") int id); }
ProviderHostInfo extends RestAbstract { @GET public Response getHostInfo(@PathParam("id") int id) throws UnirestException { logger.info("GET /" + id + "/hostinfo"); Provider provider = providerDAO.getById(id); if(provider != null) { HttpResponse<String> response = Unirest.get(provider.getVmmUrl() + "/nodes").header("accept", "application/json").asString(); String payload = response.getBody(); return buildResponse(Status.OK, payload); } else { logger.debug("RESPONSE: 404"); return buildResponse(Status.NOT_FOUND, "No provider by that id found in the databae."); } }  @GET Response getHostInfo(@PathParam("id") int id);  }