@Test public void testGenerateAgreementId() throws Exception { server.enqueue(new MockResponse().setBody( readFile("/eu/seaclouds/planner/core/application/agreements/sla-create-template-response.json"))); server.start(); URL url = server.url("/").url(); String adp = readFile("/generated_adp.yml"); MonitoringInfo monitoring = new MonitoringInfo(new MonitoringRules(), adp); AgreementGenerator generator = new AgreementGenerator(url.toString()); String result = generator.generateAgreeemntId(adp, monitoring); assertNotNull(result); }
public String generateAgreeemntId(String templateDescription, MonitoringInfo monitoringInfo) { String result = null; String monitoring = serializeToXml(monitoringInfo); Map<String, Object> template = YamlParser.load(templateDescription); HttpEntity httpEntity = MultipartEntityBuilder.create() .addTextBody("dam", YamlParser.dump(template)) .addTextBody("rules", monitoring) .build(); String slaInfoResponse = new HttpHelper(slaUrl) .postEntity(SLA_GEN_OP, httpEntity); checkNotNull(slaInfoResponse, "Error getting SLA info"); try { ApplicationMonitorId applicationMonitoringId = new ObjectMapper() .readValue(slaInfoResponse, ApplicationMonitorId.class); result = applicationMonitoringId.getId(); } catch (IOException e) { log.error("Error AgreementTemplateId during dam generation {}", this); } return result; }
AgreementGenerator { public String generateAgreeemntId(String templateDescription, MonitoringInfo monitoringInfo) { String result = null; String monitoring = serializeToXml(monitoringInfo); Map<String, Object> template = YamlParser.load(templateDescription); HttpEntity httpEntity = MultipartEntityBuilder.create() .addTextBody("dam", YamlParser.dump(template)) .addTextBody("rules", monitoring) .build(); String slaInfoResponse = new HttpHelper(slaUrl) .postEntity(SLA_GEN_OP, httpEntity); checkNotNull(slaInfoResponse, "Error getting SLA info"); try { ApplicationMonitorId applicationMonitoringId = new ObjectMapper() .readValue(slaInfoResponse, ApplicationMonitorId.class); result = applicationMonitoringId.getId(); } catch (IOException e) { log.error("Error AgreementTemplateId during dam generation {}", this); } return result; } }
AgreementGenerator { public String generateAgreeemntId(String templateDescription, MonitoringInfo monitoringInfo) { String result = null; String monitoring = serializeToXml(monitoringInfo); Map<String, Object> template = YamlParser.load(templateDescription); HttpEntity httpEntity = MultipartEntityBuilder.create() .addTextBody("dam", YamlParser.dump(template)) .addTextBody("rules", monitoring) .build(); String slaInfoResponse = new HttpHelper(slaUrl) .postEntity(SLA_GEN_OP, httpEntity); checkNotNull(slaInfoResponse, "Error getting SLA info"); try { ApplicationMonitorId applicationMonitoringId = new ObjectMapper() .readValue(slaInfoResponse, ApplicationMonitorId.class); result = applicationMonitoringId.getId(); } catch (IOException e) { log.error("Error AgreementTemplateId during dam generation {}", this); } return result; } AgreementGenerator(String slaUrl); }
AgreementGenerator { public String generateAgreeemntId(String templateDescription, MonitoringInfo monitoringInfo) { String result = null; String monitoring = serializeToXml(monitoringInfo); Map<String, Object> template = YamlParser.load(templateDescription); HttpEntity httpEntity = MultipartEntityBuilder.create() .addTextBody("dam", YamlParser.dump(template)) .addTextBody("rules", monitoring) .build(); String slaInfoResponse = new HttpHelper(slaUrl) .postEntity(SLA_GEN_OP, httpEntity); checkNotNull(slaInfoResponse, "Error getting SLA info"); try { ApplicationMonitorId applicationMonitoringId = new ObjectMapper() .readValue(slaInfoResponse, ApplicationMonitorId.class); result = applicationMonitoringId.getId(); } catch (IOException e) { log.error("Error AgreementTemplateId during dam generation {}", this); } return result; } AgreementGenerator(String slaUrl); String generateAgreeemntId(String templateDescription, MonitoringInfo monitoringInfo); String getAgreement(String applicationMonitorId); }
AgreementGenerator { public String generateAgreeemntId(String templateDescription, MonitoringInfo monitoringInfo) { String result = null; String monitoring = serializeToXml(monitoringInfo); Map<String, Object> template = YamlParser.load(templateDescription); HttpEntity httpEntity = MultipartEntityBuilder.create() .addTextBody("dam", YamlParser.dump(template)) .addTextBody("rules", monitoring) .build(); String slaInfoResponse = new HttpHelper(slaUrl) .postEntity(SLA_GEN_OP, httpEntity); checkNotNull(slaInfoResponse, "Error getting SLA info"); try { ApplicationMonitorId applicationMonitoringId = new ObjectMapper() .readValue(slaInfoResponse, ApplicationMonitorId.class); result = applicationMonitoringId.getId(); } catch (IOException e) { log.error("Error AgreementTemplateId during dam generation {}", this); } return result; } AgreementGenerator(String slaUrl); String generateAgreeemntId(String templateDescription, MonitoringInfo monitoringInfo); String getAgreement(String applicationMonitorId);  }