Search in sources :

Example 16 with Analyzer

use of org.drools.workbench.services.verifier.core.main.Analyzer in project drools-wb by kiegroup.

the class DecisionTableAnalyzerFromFileTest method testFileScoreAchievementsGDST.

@Test
public void testFileScoreAchievementsGDST() throws Exception {
    analyzerProvider.getFactTypes().add(new FactTypes.FactType("Player", new HashSet<FactTypes.Field>() {

        {
            add(new FactTypes.Field("score", DataType.TYPE_NUMERIC_INTEGER));
        }
    }));
    final String xml = loadResource("Score Achievements.gdst");
    final Analyzer analyzer = analyzerProvider.makeAnalyser(GuidedDTXMLPersistence.getInstance().unmarshal(xml));
    analyzer.resetChecks();
    analyzer.analyze();
    assertOnlyContains(analyzerProvider.getAnalysisReport(), MISSING_RANGE_TITLE, SINGLE_HIT_LOST);
}
Also used : FactTypes(org.drools.workbench.services.verifier.plugin.client.api.FactTypes) Analyzer(org.drools.workbench.services.verifier.core.main.Analyzer) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 17 with Analyzer

use of org.drools.workbench.services.verifier.core.main.Analyzer in project drools-wb by kiegroup.

the class DecisionTableAnalyzerFromFileTest method testFileBaseEntitlementGDST.

@Test
public void testFileBaseEntitlementGDST() throws Exception {
    final String xml = loadResource("Base entitlement.gdst");
    final Analyzer analyzer = analyzerProvider.makeAnalyser(GuidedDTXMLPersistence.getInstance().unmarshal(xml));
    analyzer.resetChecks();
    analyzer.analyze();
    assertTrue(analyzerProvider.getAnalysisReport().isEmpty());
}
Also used : Analyzer(org.drools.workbench.services.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 18 with Analyzer

use of org.drools.workbench.services.verifier.core.main.Analyzer in project drools-wb by kiegroup.

the class DecisionTableAnalyzerFromFileTest method testFileLargeFileGDSTWithUpdate.

@Test
public void testFileLargeFileGDSTWithUpdate() throws Exception, UpdateException {
    long baseline = System.currentTimeMillis();
    final String xml = loadResource("Large file.gdst");
    final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
    long now = System.currentTimeMillis();
    System.out.println("Loading of model took.. " + (now - baseline) + " ms");
    baseline = now;
    final Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    now = System.currentTimeMillis();
    System.out.println("Indexing took.. " + (now - baseline) + " ms");
    analyzer.resetChecks();
    analyzer.analyze();
    assertOnlyContains(analyzerProvider.getAnalysisReport(), SINGLE_HIT_LOST, EMPTY_RULE);
    now = System.currentTimeMillis();
    System.out.println("Initial analysis took.. " + (now - baseline) + " ms");
    baseline = now;
    table52.getData().get(2).get(6).clearValues();
    final List<Coordinate> updates = new ArrayList<>();
    updates.add(new Coordinate(2, 6));
    analyzerProvider.getUpdateManager(table52, analyzer).update(table52, updates);
    assertOnlyContains(analyzerProvider.getAnalysisReport(), SINGLE_HIT_LOST, EMPTY_RULE);
    now = System.currentTimeMillis();
    System.out.println("Partial analysis took.. " + (now - baseline) + " ms");
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Coordinate(org.drools.workbench.services.verifier.plugin.client.Coordinate) ArrayList(java.util.ArrayList) Analyzer(org.drools.workbench.services.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 19 with Analyzer

use of org.drools.workbench.services.verifier.core.main.Analyzer in project drools-wb by kiegroup.

the class DecisionTableAnalyzerSubsumptionResolverTest method testRedundantActionsInOneRow001.

@Test
public void testRedundantActionsInOneRow001() throws Exception {
    GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("a", "Person", "name", "==").withActionSetField("a", "salary", DataType.TYPE_NUMERIC_INTEGER).withActionSetField("a", "salary", DataType.TYPE_NUMERIC_INTEGER).withData(new Object[][] { { 1, "description", "Toni", 100, 100 }, { 2, "description", "Eder", 200, null }, { 3, "description", "Michael", null, 300 }, { 4, "description", null, null, null, null, null } }).buildTable();
    Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    analyzer.resetChecks();
    analyzer.analyze();
    assertContains(analyzerProvider.getAnalysisReport(), "ValueForFactFieldIsSetTwice(a, salary)", Severity.WARNING);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder) Analyzer(org.drools.workbench.services.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 20 with Analyzer

use of org.drools.workbench.services.verifier.core.main.Analyzer in project drools-wb by kiegroup.

the class DecisionTableAnalyzerSubsumptionResolverTest method testRedundantRowsWithConflict.

@Test
public void testRedundantRowsWithConflict() throws Exception {
    GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("a", "Person", "age", ">").withConditionDoubleColumn("d", "Account", "deposit", "<").withActionSetField("a", "approved", DataType.TYPE_BOOLEAN).withActionSetField("a", "approved", DataType.TYPE_BOOLEAN).withData(new Object[][] { { 1, "description", 100, 0.0, true, true }, { 2, "description", 100, 0.0, true, false } }).buildTable();
    Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    analyzer.resetChecks();
    analyzer.analyze();
    assertDoesNotContain("ThisRowIsRedundantTo(1)", analyzerProvider.getAnalysisReport());
    assertDoesNotContain("ThisRowIsRedundantTo(2)", analyzerProvider.getAnalysisReport());
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Import(org.kie.soup.project.datamodel.imports.Import) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder) Analyzer(org.drools.workbench.services.verifier.core.main.Analyzer) Test(org.junit.Test)

Aggregations

Analyzer (org.drools.workbench.services.verifier.core.main.Analyzer)22 Test (org.junit.Test)21 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)19 ExtendedGuidedDecisionTableBuilder (org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder)9 Import (org.kie.soup.project.datamodel.imports.Import)7 ArrayList (java.util.ArrayList)5 Coordinate (org.drools.workbench.services.verifier.plugin.client.Coordinate)3 Ignore (org.junit.Ignore)3 HashSet (java.util.HashSet)1 Issue (org.drools.workbench.services.verifier.api.client.reporting.Issue)1 FactTypes (org.drools.workbench.services.verifier.plugin.client.api.FactTypes)1