### Question:
ProviderSlot extends RestAbstract { @GET public Response getSlot(@PathParam("id") int id) throws UnirestException { logger.info("GET /" + id + "/slots"); Provider provider = providerDAO.getById(id); if(provider != null) { HttpResponse<String> response = Unirest.get(provider.getVmmUrl() + "/slots").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 getSlot(@PathParam("id") int id); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response postSlots(@PathParam("id") int id, String payload);  }### Answer:
@Test public void getSlot404Test() throws Exception { ProviderDAO providerDAO = mock(ProviderDAO.class); when(providerDAO.getById(1)).thenReturn(null); ProviderSlot providerSlot = new ProviderSlot(); providerSlot.providerDAO = providerDAO; Response response = providerSlot.getSlot(1); assertEquals(404, response.getStatus()); String providerXML = (String) response.getEntity(); assertEquals("No provider by that id found in the databae.", providerXML); }
@Test public void getSlotTest() throws Exception { mServer.addPath("/slots", payload); Provider provider = new Provider(); provider.setVmmUrl(mBaseURL); ProviderDAO providerDAO = mock(ProviderDAO.class); when(providerDAO.getById(1)).thenReturn(provider); ProviderSlot providerSlot = new ProviderSlot(); providerSlot.providerDAO = providerDAO; Response response = providerSlot.getSlot(1); assertEquals(200, response.getStatus()); String nodesJson = (String) response.getEntity(); assertEquals(payload, nodesJson); }