use of org.eclipse.winery.compliance.checking.ComplianceRuleChecker in project winery by eclipse.
the class ComplianceRuleCheckerTests method validRule_identifierInRequired_findsOne.
@Test
public void validRule_identifierInRequired_findsOne() throws Exception {
ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
checker.setToCheckTemplate(topologyTemplateToSearchIn);
checker.setIdentifierTemplate(identifier);
checker.setRequiredStructureTemplate(requiredStructure);
List<GraphMapping> violatingMappings = checker.checkComplianceRule();
assertEquals(1, violatingMappings.size());
ToscaNode identifierNode1 = checker.getIdentifierGraph().getNode("01");
ToscaNode identifierNode2 = checker.getIdentifierGraph().getNode("02");
ToscaEdge identifierEdge = checker.getIdentifierGraph().getEdge(identifierNode1, identifierNode2);
GraphMapping violatingMapping = violatingMappings.stream().findFirst().get();
assertNotNull(violatingMapping);
Map<ToscaNode, ToscaNode> resultMap = checker.getSubGraphMappingAsMap(violatingMapping, checker.getIdentifierGraph());
assertTrue(resultMap.get(identifierNode1).getId().matches("05"));
assertTrue(resultMap.get(identifierNode2).getId().matches("06"));
assertTrue(((ToscaEdge) violatingMapping.getEdgeCorrespondence(identifierEdge, false)).getId().matches("3"));
}
use of org.eclipse.winery.compliance.checking.ComplianceRuleChecker in project winery by eclipse.
the class ComplianceRuleCheckerTests method blacklist.
@Test
public void blacklist() throws Exception {
ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
checker.setToCheckTemplate(topologyTemplateToSearchIn);
checker.setRequiredStructureTemplate(null);
checker.setIdentifierTemplate(identifier);
List<GraphMapping> blacklistResult = checker.checkComplianceRule();
assertEquals(2, blacklistResult.size());
}
use of org.eclipse.winery.compliance.checking.ComplianceRuleChecker in project winery by eclipse.
the class ComplianceRuleCheckerTests method nullTemplateToCheck.
@Test
public void nullTemplateToCheck() {
ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
ComplianceCheckingException expected = null;
try {
checker.checkComplianceRule();
} catch (ComplianceCheckingException e) {
expected = e;
}
assertNotNull(expected);
assertTrue(StringUtils.equals(ComplianceCheckingException.NO_TEMPLATE_TO_CHECK, expected.getMessage()));
}
use of org.eclipse.winery.compliance.checking.ComplianceRuleChecker in project winery by eclipse.
the class ComplianceRuleCheckerTests method completeRule_noMapping.
@Test
public void completeRule_noMapping() {
ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
checker.setToCheckTemplate(topologyTemplateToSearchIn);
// test completeRule
// invalid Rule: identifier and required structure have no mapping
checker.setIdentifierTemplate(unrelatedTopology);
checker.setRequiredStructureTemplate(requiredStructure);
ComplianceCheckingException expected = null;
try {
checker.checkComplianceRule();
} catch (ComplianceCheckingException e) {
expected = e;
}
assertNotNull(expected);
assertTrue(StringUtils.equals(ComplianceCheckingException.IDENTIFIER_NOT_IN_REQUIREDSTRUCTURE, expected.getMessage()));
}
use of org.eclipse.winery.compliance.checking.ComplianceRuleChecker in project winery by eclipse.
the class ComplianceRuleCheckerTests method completeRule.
@Test
public void completeRule() {
ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
checker.setToCheckTemplate(topologyTemplateToSearchIn);
checker.setIdentifierTemplate(unrelatedTopology);
checker.setRequiredStructureTemplate(requiredStructure);
ComplianceCheckingException expected = null;
try {
checker.checkComplianceRule();
} catch (ComplianceCheckingException e) {
expected = e;
}
assertNotNull(expected);
assertTrue(StringUtils.equals(ComplianceCheckingException.IDENTIFIER_NOT_IN_REQUIREDSTRUCTURE, expected.getMessage()));
}
Aggregations