Search in sources :

Example 16 with GraphMapping

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"));
}
Also used : ToscaNode(org.eclipse.winery.topologygraph.model.ToscaNode) ToscaEdge(org.eclipse.winery.topologygraph.model.ToscaEdge) ComplianceRuleChecker(org.eclipse.winery.compliance.checking.ComplianceRuleChecker) GraphMapping(org.jgrapht.GraphMapping) Test(org.junit.jupiter.api.Test)

Example 17 with GraphMapping

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());
}
Also used : ComplianceRuleChecker(org.eclipse.winery.compliance.checking.ComplianceRuleChecker) GraphMapping(org.jgrapht.GraphMapping) Test(org.junit.jupiter.api.Test)

Aggregations

GraphMapping (org.jgrapht.GraphMapping)17 ArrayList (java.util.ArrayList)9 ToscaIsomorphismMatcher (org.eclipse.winery.topologygraph.matching.ToscaIsomorphismMatcher)8 ToscaGraph (org.eclipse.winery.topologygraph.model.ToscaGraph)8 ToscaNode (org.eclipse.winery.topologygraph.model.ToscaNode)8 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)6 ToscaEdge (org.eclipse.winery.topologygraph.model.ToscaEdge)6 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)5 Test (org.junit.jupiter.api.Test)5 QName (javax.xml.namespace.QName)4 IToscaMatcher (org.eclipse.winery.topologygraph.matching.IToscaMatcher)4 ComplianceRuleChecker (org.eclipse.winery.compliance.checking.ComplianceRuleChecker)3 TOSCANode (org.eclipse.winery.compliance.model.TOSCANode)3 RefinementCandidate (org.eclipse.winery.model.adaptation.substitution.refinement.RefinementCandidate)3 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2