@Test public void getProviderTest() throws Exception { ProviderAPI providerAPI = new ProviderAPI(); providerAPI.providerDAO = providerDAO; List<Provider> providers = providerDAO.getAll(); int id = providers.get(0).getId(); Response response = providerAPI.getProvider(id); assertEquals(200, 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("Provider 1", provider.getName()); assertEquals("http: 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.getProvider(Integer.MAX_VALUE); assertEquals(404, response.getStatus()); providerXML = (String) response.getEntity(); assertEquals("No provider by that id found in the databae.", providerXML); }
@GET @Path("/{id}") @Produces(CONTENT_TYPE_XML + ";qs=1") public Response getProvider(@PathParam("id") int id) { logger.info("GET /" + id + " [XML]"); return prepareProviderResponse(id, false); }
ProviderAPI extends RestAbstract { @GET @Path("/{id}") @Produces(CONTENT_TYPE_XML + ";qs=1") public Response getProvider(@PathParam("id") int id) { logger.info("GET /" + id + " [XML]"); return prepareProviderResponse(id, false); } }
ProviderAPI extends RestAbstract { @GET @Path("/{id}") @Produces(CONTENT_TYPE_XML + ";qs=1") public Response getProvider(@PathParam("id") int id) { logger.info("GET /" + id + " [XML]"); return prepareProviderResponse(id, false); }  }
ProviderAPI extends RestAbstract { @GET @Path("/{id}") @Produces(CONTENT_TYPE_XML + ";qs=1") public Response getProvider(@PathParam("id") int id) { logger.info("GET /" + id + " [XML]"); return prepareProviderResponse(id, false); }  @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); }
ProviderAPI extends RestAbstract { @GET @Path("/{id}") @Produces(CONTENT_TYPE_XML + ";qs=1") public Response getProvider(@PathParam("id") int id) { logger.info("GET /" + id + " [XML]"); return prepareProviderResponse(id, false); }  @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);  }