use of com.thinkbiganalytics.metadata.sla.spi.core.InMemorySLAProvider in project kylo by Teradata.
the class ServiceLevelAgreementRestController method testTemplate.
@POST
@Path("/test-email-template")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Tests a velocity SLA email template. This will validate and return the parsed template allowing you to preview it. If an parse exception occurs it will be indicated in the content of the response.")
@ApiResponses({ @ApiResponse(code = 200, message = "The the SLA email template.", response = VelocityEmailTemplate.class) })
public VelocityEmailTemplate testTemplate(VelocityEmailTemplate template) {
accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENT_EMAIL_TEMPLATE);
Map<String, Object> map = new HashMap();
InMemorySLAProvider slaProvider = new InMemorySLAProvider();
Metric m1 = new SimpleMetric();
com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement sla = slaProvider.builder().name("Test SLA").description("SLA Description").obligationBuilder(ObligationGroup.Condition.REQUIRED).metric(m1).build().build();
map.put("sla", sla);
SimpleServiceLevelAssessor simpleServiceLevelAssessor = new SimpleServiceLevelAssessor();
simpleServiceLevelAssessor.registerMetricAssessor(new TestMetricAssessor());
com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment assessment = simpleServiceLevelAssessor.assess(sla);
map.put("assessment", assessment);
map.put("assessmentDescription", ServiceLevelAssessmentAlertUtil.getDescription(assessment, "<br/>"));
String subject = velocityTemplateProvider.testTemplate(template.getSubject(), map);
String body = velocityTemplateProvider.testTemplate(template.getBody(), map);
return new VelocityEmailTemplate(subject, body);
}
use of com.thinkbiganalytics.metadata.sla.spi.core.InMemorySLAProvider in project kylo by Teradata.
the class TestEmail method testVelocityEmail.
@Test
public void testVelocityEmail() {
String email = "thinkbig.tester@gmail.com";
String template = getTemplate();
velocityService.registerTemplate("test", template);
Map<String, Object> map = new HashMap();
InMemorySLAProvider slaProvider = new InMemorySLAProvider();
Metric m1 = new SimpleMetric();
ServiceLevelAgreement sla = slaProvider.builder().name("Test SLA").description("Test SLA desc").obligationBuilder(ObligationGroup.Condition.REQUIRED).metric(m1).build().build();
map.put("sla", sla);
String emailBody = velocityService.mergeTemplate("test", map);
Assert.assertEquals("This is my test Test SLA and description: Test SLA desc. \n" + " Metric: this is my metric desc \n" + " ", emailBody);
int i = 0;
}
Aggregations