Search in sources :

Example 1 with Analyzer

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

the class DecisionTableAnalyzerFromFileTest method testUpdateNotNullColumn.

@Test
public void testUpdateNotNullColumn() throws Exception {
    final String xml = loadResource("Is Null Table.gdst");
    final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
    final Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    // First run
    analyzer.resetChecks();
    analyzer.analyze();
    assertContains(analyzerProvider.getAnalysisReport(), CheckType.MISSING_RESTRICTION, Severity.NOTE);
    // Update
    table52.getData().get(0).get(3).setBooleanValue(true);
    final List<Coordinate> updates = new ArrayList<>();
    updates.add(new Coordinate(0, 3));
    analyzerProvider.getUpdateManager(table52, analyzer).update(table52, updates);
    // Update
    table52.getData().get(1).get(3).setBooleanValue(true);
    final List<Coordinate> updates2 = new ArrayList<>();
    updates2.add(new Coordinate(1, 3));
    analyzerProvider.getUpdateManager(table52, analyzer).update(table52, updates2);
    assertDoesNotContain(CheckType.MISSING_RESTRICTION, analyzerProvider.getAnalysisReport());
}
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.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 2 with Analyzer

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

the class DecisionTableAnalyzerFromFileTest method testLHSConflictsArePickedUpForEachFieldOfAPattern.

@Test
public void testLHSConflictsArePickedUpForEachFieldOfAPattern() throws Exception {
    final String xml = loadResource("GUVNOR-3513.gdst");
    final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
    final Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    analyzer.resetChecks();
    analyzer.analyze();
    assertResultIsEmpty(analyzerProvider.getAnalysisReport());
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Analyzer(org.drools.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 3 with Analyzer

use of org.drools.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 Sets.Builder<FactTypes.Field>().add(new FactTypes.Field("score", DataType.TYPE_NUMERIC_INTEGER)).build()));
    final String xml = loadResource("Score Achievements.gdst");
    final Analyzer analyzer = analyzerProvider.makeAnalyser(GuidedDTXMLPersistence.getInstance().unmarshal(xml));
    analyzer.resetChecks();
    analyzer.analyze();
    assertOnlyContains(analyzerProvider.getAnalysisReport(), CheckType.MISSING_RANGE, CheckType.SINGLE_HIT_LOST);
}
Also used : FactTypes(org.drools.workbench.services.verifier.plugin.client.api.FactTypes) Analyzer(org.drools.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 4 with Analyzer

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

the class DecisionTableAnalyzerFromFileTest method testFileLargeFileGDSTWithDeletes.

@Test
public void testFileLargeFileGDSTWithDeletes() throws Exception {
    final String xml = loadResource("Large file.gdst");
    final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
    final Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    analyzer.resetChecks();
    analyzer.analyze();
    assertOnlyContains(analyzerProvider.getAnalysisReport(), CheckType.SINGLE_HIT_LOST, CheckType.EMPTY_RULE);
    long baseline = System.currentTimeMillis();
    for (int iterations = 0; iterations < 10; iterations++) {
        analyzer.removeRule(100);
        table52.getData().remove(100);
        List<Coordinate> canBeUpdated = new ArrayList<>();
        canBeUpdated.add(new Coordinate(0, 0));
        analyzerProvider.getUpdateManager(table52, analyzer).update(table52, canBeUpdated);
        long now = System.currentTimeMillis();
        System.out.println("Partial analysis took.. " + (now - baseline) + " ms");
        baseline = now;
        assertOnlyContains(analyzerProvider.getAnalysisReport(), CheckType.SINGLE_HIT_LOST, CheckType.EMPTY_RULE);
    }
}
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.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 5 with Analyzer

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

the class DecisionTableAnalyzerFromFileTest method testFilePricingLoansGDST.

@Test
@Ignore("list of admitted values is in the model and currently not accessible for the analyzer")
public void testFilePricingLoansGDST() throws Exception {
    final String xml = loadResource("Pricing loans.gdst");
    final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
    final Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    analyzer.resetChecks();
    analyzer.analyze();
    assertOnlyContains(analyzerProvider.getAnalysisReport(), CheckType.MISSING_RANGE);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Analyzer(org.drools.verifier.core.main.Analyzer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Analyzer (org.drools.verifier.core.main.Analyzer)30 Test (org.junit.Test)29 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)26 ExtendedGuidedDecisionTableBuilder (org.drools.workbench.services.verifier.plugin.client.testutil.ExtendedGuidedDecisionTableBuilder)9 Import (org.kie.soup.project.datamodel.imports.Import)7 Issue (org.drools.verifier.api.reporting.Issue)6 ArrayList (java.util.ArrayList)5 Ignore (org.junit.Ignore)4 Coordinate (org.drools.workbench.services.verifier.plugin.client.Coordinate)3 FactTypes (org.drools.workbench.services.verifier.plugin.client.api.FactTypes)2