Search in sources :

Example 11 with ExtendedGuidedDecisionTableBuilder

use of org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder in project drools-wb by kiegroup.

the class SpeedTest method noConflictTable.

@Test
public void noConflictTable() throws Exception, UpdateException {
    long baseline = System.currentTimeMillis();
    final DataBuilderProvider.DataBuilder builder = DataBuilderProvider.row(-1, true);
    for (int i = 0; i < 1000; i++) {
        builder.row(i, true);
    }
    final Object[][] data = builder.end();
    table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("$p", "Person", "age", "==").withActionSetField("$p", "approved", DataType.TYPE_BOOLEAN).withData(data).buildTable();
    long now = System.currentTimeMillis();
    logger.debug("Loading of model took.. " + (now - baseline) + " ms");
    baseline = now;
    fireUpAnalyzer();
    now = System.currentTimeMillis();
    logger.debug("Analyzing took.. " + (now - baseline) + " ms");
    baseline = now;
    setValue(1, 2, 3);
    now = System.currentTimeMillis();
    logger.debug("Update.. " + (now - baseline) + " ms");
    assertContains(analyzerProvider.getAnalysisReport(), REDUNDANT_ROWS, Severity.WARNING);
}
Also used : ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder) Test(org.junit.Test)

Example 12 with ExtendedGuidedDecisionTableBuilder

use of org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder 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 13 with ExtendedGuidedDecisionTableBuilder

use of org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder 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)

Example 14 with ExtendedGuidedDecisionTableBuilder

use of org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder in project drools-wb by kiegroup.

the class DecisionTableAnalyzerSubsumptionResolverTest method testRedundantConditions001.

@Test
public void testRedundantConditions001() throws Exception {
    GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withEnumColumn("a", "Person", "name", "==", "Toni,Eder").withConditionIntegerColumn("a", "Person", "name", "==").withData(new Object[][] { { 1, "description", "Toni", "Toni" } }).buildTable();
    Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    analyzer.resetChecks();
    analyzer.analyze();
    assertContains(analyzerProvider.getAnalysisReport(), REDUNDANT_CONDITIONS_TITLE, Severity.NOTE);
}
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)

Example 15 with ExtendedGuidedDecisionTableBuilder

use of org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder in project drools-wb by kiegroup.

the class DecisionTableAnalyzerTest method testRuleHasNoActionBRLFragmentHasAction.

// GUVNOR-2546: Verification & Validation: BRL fragments are ignored
@Test
public void testRuleHasNoActionBRLFragmentHasAction() throws Exception {
    table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("a", "Person", "age", ">").withActionBRLFragment().withData(new Object[][] { { 1, "description", 0, true } }).buildTable();
    fireUpAnalyzer();
    assertDoesNotContain(EMPTY_RULE, analyzerProvider.getAnalysisReport(), 1);
    assertDoesNotContain(RULE_HAS_NO_ACTION, analyzerProvider.getAnalysisReport());
}
Also used : ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder) Test(org.junit.Test)

Aggregations

ExtendedGuidedDecisionTableBuilder (org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder)19 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)12 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)9 Analyzer (org.drools.workbench.services.verifier.core.main.Analyzer)9 Import (org.kie.soup.project.datamodel.imports.Import)7 Ignore (org.junit.Ignore)1