Search in sources :

Example 6 with ImpactAnalysisHelper

use of org.drools.impact.analysis.graph.ImpactAnalysisHelper in project drools by kiegroup.

the class GraphCollapsionTest method testSpreadsheet.

@Test
public void testSpreadsheet() throws IOException {
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId("org.drools.impact.analysis.integrationtests", "spreadsheet-test", "1.0.0");
    KieFileSystem kfs = createKieFileSystemWithClassPathResourceNames(releaseId, getClass(), "collapsion01.xls", "collapsion02.xls", "collapsion03.xls");
    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll(ImpactAnalysisProject.class);
    ImpactAnalysisKieModule analysisKieModule = (ImpactAnalysisKieModule) kieBuilder.getKieModule();
    AnalysisModel analysisModel = analysisKieModule.getAnalysisModel();
    ModelToGraphConverter converter = new ModelToGraphConverter();
    Graph graph = converter.toGraph(analysisModel);
    Graph collapsedGraph = new GraphCollapsionHelper().collapseWithRuleNamePrefix(graph);
    assertEquals(3, collapsedGraph.getNodeMap().size());
    assertLink(collapsedGraph, "mypkg2.CustomerCheck", "mypkg2.PriceCheck", ReactivityType.POSITIVE, ReactivityType.NEGATIVE);
    assertLink(collapsedGraph, "mypkg2.PriceCheck", "mypkg2.StatusCheck", ReactivityType.POSITIVE, ReactivityType.NEGATIVE);
    assertLink(collapsedGraph, "mypkg2.StatusCheck", "mypkg2.PriceCheck", ReactivityType.NEGATIVE);
    // --- impact analysis
    // Assuming that "modify" action in PriceCheck_X is changed
    // modify action in PriceCheck_X
    Node changedNode = collapsedGraph.getNodeMap().get("mypkg2.PriceCheck");
    ImpactAnalysisHelper impactFilter = new ImpactAnalysisHelper();
    Graph impactedSubGraph = impactFilter.filterImpactedNodes(collapsedGraph, changedNode);
    assertNull(impactedSubGraph.getNodeMap().get("mypkg2.CustomerCheck"));
    assertEquals(Status.CHANGED, impactedSubGraph.getNodeMap().get("mypkg2.PriceCheck").getStatus());
    assertEquals(Status.IMPACTED, impactedSubGraph.getNodeMap().get("mypkg2.StatusCheck").getStatus());
}
Also used : Graph(org.drools.impact.analysis.graph.Graph) KieFileSystem(org.kie.api.builder.KieFileSystem) AnalysisModel(org.drools.impact.analysis.model.AnalysisModel) Node(org.drools.impact.analysis.graph.Node) ImpactAnalysisKieModule(org.drools.impact.analysis.parser.internal.ImpactAnalysisKieModule) GraphCollapsionHelper(org.drools.impact.analysis.graph.GraphCollapsionHelper) KieServices(org.kie.api.KieServices) ImpactAnalysisHelper(org.drools.impact.analysis.graph.ImpactAnalysisHelper) ReleaseId(org.kie.api.builder.ReleaseId) ModelToGraphConverter(org.drools.impact.analysis.graph.ModelToGraphConverter) KieBuilder(org.kie.api.builder.KieBuilder) Test(org.junit.Test)

Aggregations

Graph (org.drools.impact.analysis.graph.Graph)6 ImpactAnalysisHelper (org.drools.impact.analysis.graph.ImpactAnalysisHelper)6 ModelToGraphConverter (org.drools.impact.analysis.graph.ModelToGraphConverter)6 AnalysisModel (org.drools.impact.analysis.model.AnalysisModel)6 Test (org.junit.Test)6 ModelBuilder (org.drools.impact.analysis.parser.ModelBuilder)4 GraphCollapsionHelper (org.drools.impact.analysis.graph.GraphCollapsionHelper)3 Node (org.drools.impact.analysis.graph.Node)2 ImpactAnalysisKieModule (org.drools.impact.analysis.parser.internal.ImpactAnalysisKieModule)2 KieServices (org.kie.api.KieServices)2 KieBuilder (org.kie.api.builder.KieBuilder)2 KieFileSystem (org.kie.api.builder.KieFileSystem)2 ReleaseId (org.kie.api.builder.ReleaseId)2 ArrayList (java.util.ArrayList)1 Order (org.drools.impact.analysis.example.domain.Order)1 Product (org.drools.impact.analysis.example.domain.Product)1 KieSession (org.kie.api.runtime.KieSession)1