use of org.jgrapht.GraphMapping 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.jgrapht.GraphMapping 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());
}
Aggregations