@Test public void getDeploymentJSONTest() throws Exception { Deployment deployment = new Deployment(); deployment.setId(1); deployment.setOvf("ovf1"); deployment.setPrice("price1"); deployment.setStatus("Status1"); deployment.setDeploymentName("XXXX"); DeploymentDAO deploymentDAO = mock(DeploymentDAO.class); when(deploymentDAO.getDeployment("XXXX")).thenReturn(deployment); DeploymentNameRest deploymentRest = new DeploymentNameRest(); deploymentRest.deploymentDAO = deploymentDAO; Response response = deploymentRest.getDeploymentJSON("2", "XXXX"); assertEquals(200, response.getStatus()); String json = (String) response.getEntity(); deployment = ModelConverter.jsonDeploymentToObject(json); assertEquals("/applications/2/deployments/1", deployment.getLinks().get(1).getHref()); assertEquals("self", deployment.getLinks().get(1).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(1).getType()); assertEquals("/applications/2/deployments", deployment.getLinks().get(0).getHref()); assertEquals("parent", deployment.getLinks().get(0).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(0).getType()); assertEquals("/applications/2/deployments/1/ovf", deployment.getLinks().get(2).getHref()); assertEquals("ovf", deployment.getLinks().get(2).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(2).getType()); assertEquals("/applications/2/deployments/1/vms", deployment.getLinks().get(3).getHref()); assertEquals("vms", deployment.getLinks().get(3).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(3).getType()); assertEquals("ovf1", deployment.getOvf()); assertEquals("price1", deployment.getPrice()); assertEquals("Status1", deployment.getStatus()); }
@GET @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") public Response getDeploymentJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_name") String deploymentName) { logger.info("GET request to path: /applications/" + applicationName + "/deploymentname/" + deploymentName + " [in JSON]"); Deployment deployment = deploymentDAO.getDeployment(deploymentName); String json = XMLBuilder.getDeploymentJSON(deployment, applicationName); return buildResponse(Status.OK, json); }
DeploymentNameRest extends AbstractRest { @GET @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") public Response getDeploymentJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_name") String deploymentName) { logger.info("GET request to path: /applications/" + applicationName + "/deploymentname/" + deploymentName + " [in JSON]"); Deployment deployment = deploymentDAO.getDeployment(deploymentName); String json = XMLBuilder.getDeploymentJSON(deployment, applicationName); return buildResponse(Status.OK, json); } }
DeploymentNameRest extends AbstractRest { @GET @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") public Response getDeploymentJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_name") String deploymentName) { logger.info("GET request to path: /applications/" + applicationName + "/deploymentname/" + deploymentName + " [in JSON]"); Deployment deployment = deploymentDAO.getDeployment(deploymentName); String json = XMLBuilder.getDeploymentJSON(deployment, applicationName); return buildResponse(Status.OK, json); }  }
DeploymentNameRest extends AbstractRest { @GET @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") public Response getDeploymentJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_name") String deploymentName) { logger.info("GET request to path: /applications/" + applicationName + "/deploymentname/" + deploymentName + " [in JSON]"); Deployment deployment = deploymentDAO.getDeployment(deploymentName); String json = XMLBuilder.getDeploymentJSON(deployment, applicationName); return buildResponse(Status.OK, json); }  @GET @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getDeploymentXML(@PathParam("application_name") String applicationName, @PathParam("deployment_name") String deploymentName); @GET @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") Response getDeploymentJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_name") String deploymentName); }
DeploymentNameRest extends AbstractRest { @GET @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") public Response getDeploymentJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_name") String deploymentName) { logger.info("GET request to path: /applications/" + applicationName + "/deploymentname/" + deploymentName + " [in JSON]"); Deployment deployment = deploymentDAO.getDeployment(deploymentName); String json = XMLBuilder.getDeploymentJSON(deployment, applicationName); return buildResponse(Status.OK, json); }  @GET @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getDeploymentXML(@PathParam("application_name") String applicationName, @PathParam("deployment_name") String deploymentName); @GET @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") Response getDeploymentJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_name") String deploymentName);  }