SlaProxy extends AbstractProxy { public List<Penalty> getGuaranteeTermPenalties(Agreement agreement, GuaranteeTerm guaranteeTerm) { String path = String.format("/penalties?agreementId=%s&guaranteeTerm=%s", agreement.getAgreementId(), guaranteeTerm.getName()); String json = getJerseyClient().target(getEndpoint() + path).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<Penalty>>(){}); } 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);  }
@Test public void testGetAgreementPenalties() throws Exception { String violationJson = TestUtils.getStringFromPath(TestFixtures.PENALTIES_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()){ List<Penalty> penalties = getProxy().getGuaranteeTermPenalties(agreement, term); assertNotNull(penalties); } }