@Test
public void testGenerate() throws JAXBException {

    ContextInfo context = new ContextInfo("provider", "consumer", "service", new Validity(2, 0, 0));
    MonitoringRules rules = JaxbUtils.load(
            MonitoringRules.class, this.getClass().getResourceAsStream("/seacloudsRules.xml"));
    
    SlaInfo slaInfo = new SlaInfo(context, Collections.singletonMap("frontend", rules));
    TemplateGenerator g = new TemplateGenerator(slaInfo);
    
    Template t = g.generate();
    JaxbUtils.print(t);
    assertEquals(context.getProvider(), t.getContext().getAgreementResponder());
    assertEquals(context.getConsumer(), t.getContext().getAgreementInitiator());
    assertEquals(context.getService(), t.getContext().getService());
    assertEquals(2, t.getTerms().getAllTerms().getGuaranteeTerms().size());
    
    List<GuaranteeTerm> expectedGts = new ArrayList<GuaranteeTerm>();
    expectedGts.add(newGuaranteeTerm(
            "tomcat_server", 
            "tomcat_server/AvarageResponseTimeInternalComponent", 
            "AvarageResponseTime_tomcat_server_Violation NOT_EXISTS"));
    
    expectedGts.add(newGuaranteeTerm(
            "tomcat_server", 
            "tomcat_server/AppAvailable", 
            "AvarageAppAvailability_tomcat_server_Violation NOT_EXISTS"));
    List<GuaranteeTerm> actualGts = t.getTerms().getAllTerms().getGuaranteeTerms();
    for (int i = 0; i < actualGts.size(); i++) {
        GuaranteeTerm expected = expectedGts.get(i);
        GuaranteeTerm actual = expectedGts.get(i);
        
        checkGuaranteeTerm(expected, actual);
    }
}