@Test public void getSlaAgreementTest() { Agreement agreement = new Agreement(); agreement.setAccepted(true); agreement.setId(2); agreement.setPrice("222"); agreement.setProviderId("provider-id"); agreement.setSlaAgreement("sssas"); agreement.setSlaAgreementId("sla-agreement-id"); AgreementDAO agreementDAO = mock(AgreementDAO.class); when(agreementDAO.getById(2)).thenReturn(agreement); AgreementRest agreementRest = new AgreementRest(); agreementRest.agreementDAO = agreementDAO; Response response = agreementRest.getSlaAgreement(null, null, "2"); assertEquals(200, response.getStatus()); String xml = (String) response.getEntity(); assertEquals("sssas", xml); }
@GET @Path("{agreement_id}/sla") @Produces(MediaType.APPLICATION_XML) public Response getSlaAgreement(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("agreement_id") String agreementId) { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/agreements/" + agreementId); Agreement agreement = agreementDAO.getById(Integer.parseInt(agreementId)); return buildResponse(Status.OK, agreement.getSlaAgreement()); }
AgreementRest extends AbstractRest { @GET @Path("{agreement_id}/sla") @Produces(MediaType.APPLICATION_XML) public Response getSlaAgreement(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("agreement_id") String agreementId) { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/agreements/" + agreementId); Agreement agreement = agreementDAO.getById(Integer.parseInt(agreementId)); return buildResponse(Status.OK, agreement.getSlaAgreement()); } }
AgreementRest extends AbstractRest { @GET @Path("{agreement_id}/sla") @Produces(MediaType.APPLICATION_XML) public Response getSlaAgreement(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("agreement_id") String agreementId) { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/agreements/" + agreementId); Agreement agreement = agreementDAO.getById(Integer.parseInt(agreementId)); return buildResponse(Status.OK, agreement.getSlaAgreement()); }  }
AgreementRest extends AbstractRest { @GET @Path("{agreement_id}/sla") @Produces(MediaType.APPLICATION_XML) public Response getSlaAgreement(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("agreement_id") String agreementId) { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/agreements/" + agreementId); Agreement agreement = agreementDAO.getById(Integer.parseInt(agreementId)); return buildResponse(Status.OK, agreement.getSlaAgreement()); }  @GET @Produces(MediaType.APPLICATION_XML) Response getAgreements(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{agreement_id}") @Produces(MediaType.APPLICATION_XML) Response getAgreement(@PathParam("application_name") String applicationName, 
			                     @PathParam("deployment_id") String deploymentId,
			                     @PathParam("agreement_id") String agreementId); @GET @Path("{agreement_id}/sla") @Produces(MediaType.APPLICATION_XML) Response getSlaAgreement(@PathParam("application_name") String applicationName, 
			                     @PathParam("deployment_id") String deploymentId,
			                     @PathParam("agreement_id") String agreementId); @PUT @Path("{agreement_id}") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) Response acceptSlaAgreement(@PathParam("application_name") String applicationName, 
									   @PathParam("deployment_id") String deploymentId,
									   @PathParam("agreement_id") String agreementId,
									   String payload); }
AgreementRest extends AbstractRest { @GET @Path("{agreement_id}/sla") @Produces(MediaType.APPLICATION_XML) public Response getSlaAgreement(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("agreement_id") String agreementId) { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/agreements/" + agreementId); Agreement agreement = agreementDAO.getById(Integer.parseInt(agreementId)); return buildResponse(Status.OK, agreement.getSlaAgreement()); }  @GET @Produces(MediaType.APPLICATION_XML) Response getAgreements(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{agreement_id}") @Produces(MediaType.APPLICATION_XML) Response getAgreement(@PathParam("application_name") String applicationName, 
			                     @PathParam("deployment_id") String deploymentId,
			                     @PathParam("agreement_id") String agreementId); @GET @Path("{agreement_id}/sla") @Produces(MediaType.APPLICATION_XML) Response getSlaAgreement(@PathParam("application_name") String applicationName, 
			                     @PathParam("deployment_id") String deploymentId,
			                     @PathParam("agreement_id") String agreementId); @PUT @Path("{agreement_id}") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) Response acceptSlaAgreement(@PathParam("application_name") String applicationName, 
									   @PathParam("deployment_id") String deploymentId,
									   @PathParam("agreement_id") String agreementId,
									   String payload);  }