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());
}
Aggregations