@Test public void testGetAgreementViolations() throws Exception { String violationJson = TestUtils.getStringFromPath(TestFixtures.VIOLATIONS_JSON_PATH); String agreementJson = TestUtils.getStringFromPath(TestFixtures.AGREEMENT_PATH_JSON); Agreement agreement = ObjectMapperHelpers.JsonToObject(agreementJson, Agreement.class); for(int i = 0; i < agreement.getTerms().getAllTerms().getGuaranteeTerms().size(); i++){ getMockWebServer().enqueue(new MockResponse() .setBody(violationJson) .setHeader("Accept", MediaType.APPLICATION_JSON) .setHeader("Content-Type", MediaType.APPLICATION_JSON) ); } for(GuaranteeTerm term : agreement.getTerms().getAllTerms().getGuaranteeTerms()){ assertNotNull(getProxy().getGuaranteeTermViolations(agreement, term)); } }
public List<Violation> getGuaranteeTermViolations(Agreement agreement, GuaranteeTerm guaranteeTerm) { String json = getJerseyClient().target(getEndpoint() + "/violations?agreementId=" + agreement.getAgreementId() + "&guaranteeTerm=" + guaranteeTerm.getName()).request() .header("Accept", MediaType.APPLICATION_JSON) .header("Content-Type", MediaType.APPLICATION_JSON) .buildGet().invoke().readEntity(String.class); try { return mapper.readValue(json, new TypeReference<List<Violation>>(){}); } catch (IOException e) { throw new RuntimeException(e); } }
SlaProxy extends AbstractProxy { public List<Violation> getGuaranteeTermViolations(Agreement agreement, GuaranteeTerm guaranteeTerm) { String json = getJerseyClient().target(getEndpoint() + "/violations?agreementId=" + agreement.getAgreementId() + "&guaranteeTerm=" + guaranteeTerm.getName()).request() .header("Accept", MediaType.APPLICATION_JSON) .header("Content-Type", MediaType.APPLICATION_JSON) .buildGet().invoke().readEntity(String.class); try { return mapper.readValue(json, new TypeReference<List<Violation>>(){}); } catch (IOException e) { throw new RuntimeException(e); } } }
SlaProxy extends AbstractProxy { public List<Violation> getGuaranteeTermViolations(Agreement agreement, GuaranteeTerm guaranteeTerm) { String json = getJerseyClient().target(getEndpoint() + "/violations?agreementId=" + agreement.getAgreementId() + "&guaranteeTerm=" + guaranteeTerm.getName()).request() .header("Accept", MediaType.APPLICATION_JSON) .header("Content-Type", MediaType.APPLICATION_JSON) .buildGet().invoke().readEntity(String.class); try { return mapper.readValue(json, new TypeReference<List<Violation>>(){}); } catch (IOException e) { throw new RuntimeException(e); } } SlaProxy(); }
SlaProxy extends AbstractProxy { public List<Violation> getGuaranteeTermViolations(Agreement agreement, GuaranteeTerm guaranteeTerm) { String json = getJerseyClient().target(getEndpoint() + "/violations?agreementId=" + agreement.getAgreementId() + "&guaranteeTerm=" + guaranteeTerm.getName()).request() .header("Accept", MediaType.APPLICATION_JSON) .header("Content-Type", MediaType.APPLICATION_JSON) .buildGet().invoke().readEntity(String.class); try { return mapper.readValue(json, new TypeReference<List<Violation>>(){}); } catch (IOException e) { throw new RuntimeException(e); } } SlaProxy(); String addAgreement(Agreement slaAgreement); String removeAgreement(String agreementId); String notifyRulesReady(Agreement slaAgreement); Agreement getAgreement(String agreementId); Agreement getAgreementByTemplateId(String slaAgreementTemplateId); GuaranteeTermsStatus getAgreementStatus(Agreement agreement); GuaranteeTermsStatus getAgreementStatus(String agreementId); List<Violation> getGuaranteeTermViolations(Agreement agreement, GuaranteeTerm guaranteeTerm); List<Penalty> getGuaranteeTermPenalties(Agreement agreement, GuaranteeTerm guaranteeTerm); }
SlaProxy extends AbstractProxy { public List<Violation> getGuaranteeTermViolations(Agreement agreement, GuaranteeTerm guaranteeTerm) { String json = getJerseyClient().target(getEndpoint() + "/violations?agreementId=" + agreement.getAgreementId() + "&guaranteeTerm=" + guaranteeTerm.getName()).request() .header("Accept", MediaType.APPLICATION_JSON) .header("Content-Type", MediaType.APPLICATION_JSON) .buildGet().invoke().readEntity(String.class); try { return mapper.readValue(json, new TypeReference<List<Violation>>(){}); } catch (IOException e) { throw new RuntimeException(e); } } SlaProxy(); String addAgreement(Agreement slaAgreement); String removeAgreement(String agreementId); String notifyRulesReady(Agreement slaAgreement); Agreement getAgreement(String agreementId); Agreement getAgreementByTemplateId(String slaAgreementTemplateId); GuaranteeTermsStatus getAgreementStatus(Agreement agreement); GuaranteeTermsStatus getAgreementStatus(String agreementId); List<Violation> getGuaranteeTermViolations(Agreement agreement, GuaranteeTerm guaranteeTerm); List<Penalty> getGuaranteeTermPenalties(Agreement agreement, GuaranteeTerm guaranteeTerm);  }