### Question:
ProviderAPI extends RestAbstract { @PUT @Path("/{id}") @Consumes(CONTENT_TYPE_XML) @Produces(CONTENT_TYPE_XML) public Response putProvider(@PathParam("id") int id, String payload) { logger.info("PUT / PAYLOAD: " + payload); Provider newProviderInfo = Converter.getProviderObject(payload); if(newProviderInfo != null) { Provider provider = providerDAO.getById(id); if(provider != null) { provider.setName(newProviderInfo.getName()); provider.setVmmUrl(newProviderInfo.getVmmUrl()); providerDAO.update(provider); newProviderInfo.setId(id); setProviderExtraInfo(newProviderInfo); String xml = Converter.getProviderXML(newProviderInfo); logger.debug("RESPONSE: " + xml); return buildResponse(Status.ACCEPTED, xml); } else { logger.info("Bad provider id: " + id); return buildResponse(Status.BAD_REQUEST, "No provider by that id."); } } else { logger.info("Bad provider updating request: " + payload); return buildResponse(Status.BAD_REQUEST, "Wrong provider XML request."); } }  @GET @Path("/") @Produces(CONTENT_TYPE_XML + ";qs=1") Response getProviders(); @GET @Path("/") @Produces(CONTENT_TYPE_JSON + ";qs=.5") Response getProvidersJSON(); @GET @Path("/{id}") @Produces(CONTENT_TYPE_XML + ";qs=1") Response getProvider(@PathParam("id") int id); @GET @Path("/{id}") @Produces(CONTENT_TYPE_JSON + ";qs=.5") Response getProviderJSON(@PathParam("id") int id); @POST @Path("/") @Consumes(CONTENT_TYPE_XML) @Produces(CONTENT_TYPE_XML) Response postProvider(String payload); @DELETE @Path("/{id}") Response deleteProvider(@PathParam("id") int id); @PUT @Path("/{id}") @Consumes(CONTENT_TYPE_XML) @Produces(CONTENT_TYPE_XML) Response putProvider(@PathParam("id") int id, String payload);  }### Answer:
@Test public void putProviderTest() throws Exception { String providerRequestXML = "<provider xmlns=\"" + PROVIDER_REGISTRY_NAMESPACE + "\" >" + "<name>Name</name>" + "<vmm-url>http...</vmm-url>" + "<slam-url>http2...</slam-url>" + "</provider>"; ProviderAPI providerAPI = new ProviderAPI(); providerAPI.providerDAO = providerDAO; List<Provider> providers = providerDAO.getAll(); int id = providers.get(0).getId(); Response response = providerAPI.putProvider(id, providerRequestXML); assertEquals(202, response.getStatus()); String providerXML = (String) response.getEntity(); JAXBContext jaxbContext = JAXBContext.newInstance(Provider.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Provider provider = (Provider) jaxbUnmarshaller.unmarshal(new StringReader(providerXML)); assertEquals("/" + id, provider.getHref()); assertEquals("Name", provider.getName()); assertEquals("http...", provider.getVmmUrl()); assertEquals("http2...", provider.getSlamUrl()); assertEquals(2, provider.getLinks().size()); assertEquals("self", provider.getLinks().get(0).getRel()); assertEquals(CONTENT_TYPE_XML, provider.getLinks().get(0).getType()); assertEquals("/" + id, provider.getLinks().get(0).getHref()); assertEquals("parent", provider.getLinks().get(1).getRel()); assertEquals(CONTENT_TYPE_XML, provider.getLinks().get(1).getType()); assertEquals("/", provider.getLinks().get(1).getHref()); response = providerAPI.putProvider(id, ""); assertEquals(400, response.getStatus()); assertEquals("Wrong provider XML request.", response.getEntity()); response = providerAPI.putProvider(Integer.MAX_VALUE, providerRequestXML); assertEquals(400, response.getStatus()); assertEquals("No provider by that id.", response.getEntity()); }