Search in sources :

Example 6 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerSubsumptionResolverTest method testRedundantRows002.

@Test
public void testRedundantRows002() throws Exception {
    GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withStringColumn("application", "LoanApplication", "amount", ">").withStringColumn("person", "Person", "name", "==").withStringColumn("income", "IncomeSource", "type", "==").withActionSetField("application", "approved", DataType.TYPE_STRING).withData(new Object[][] { { 1, "description", "131000", "Toni", "Asset", "true" }, { 2, "description", "131000", "Toni", "Asset", "true" }, { 3, "description", "100001", "Michael", "Job", "true" } }).buildTable();
    Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    analyzer.resetChecks();
    analyzer.analyze();
    assertContains(analyzerProvider.getAnalysisReport(), REDUNDANT_ROWS, Severity.WARNING, 1, 2);
}
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 7 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerTest method testRuleHasNoActionSet.

@Test
public void testRuleHasNoActionSet() throws Exception {
    table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("a", "Person", "age", ">").withActionSetField("a", "age", DataType.TYPE_NUMERIC_INTEGER).withActionSetField("a", "approved", DataType.TYPE_BOOLEAN).withActionSetField("a", "name", DataType.TYPE_STRING).withData(new Object[][] { { 1, "description", 0, null, null, "" }, { 2, "description", null, null, null, null } }).buildTable();
    fireUpAnalyzer();
    assertContains(analyzerProvider.getAnalysisReport(), RULE_HAS_NO_ACTION, Severity.WARNING, 1);
    assertContains(analyzerProvider.getAnalysisReport(), EMPTY_RULE, Severity.WARNING, 2);
    assertDoesNotContain(EMPTY_RULE, analyzerProvider.getAnalysisReport(), 1);
    assertDoesNotContain(RULE_HAS_NO_ACTION, analyzerProvider.getAnalysisReport(), 2);
}
Also used : ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder) Test(org.junit.Test)

Example 8 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerTest method testMissingRestrictionForBrlAction.

/**
 * Check that there is message about missing condition
 * if the action is defined as BRLAction
 */
@Test
public void testMissingRestrictionForBrlAction() throws Exception {
    table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("a", "Person", "age", ">").withActionBRLFragment().withData(new Object[][] { { 1, "description", null, true } }).buildTable();
    fireUpAnalyzer();
    assertEquals(1, analyzerProvider.getAnalysisReport().size());
    assertContains(analyzerProvider.getAnalysisReport(), RULE_HAS_NO_RESTRICTIONS_AND_WILL_ALWAYS_FIRE, Severity.NOTE);
}
Also used : ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder) Test(org.junit.Test)

Example 9 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerDeficiencyTest method testRuleIsDeficient001.

@Test
public void testRuleIsDeficient001() throws Exception {
    table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("a", "Person", "age", "==").withStringColumn("a", "Person", "name", "==").withStringColumn("a", "Person", "lastName", "==").withActionSetField("a", "salary", DataType.TYPE_NUMERIC_INTEGER).withData(new Object[][] { { 1, "description", null, "Eder", null, 100 }, { 2, "description", 10, null, null, 200 }, { 3, "description", null, "Toni", "Rikkola", 300 }, { 4, "description", null, null, null, null } }).buildTable();
    fireUpAnalyzer();
    assertDoesNotContain(DEFICIENT_ROW, analyzerProvider.getAnalysisReport(), 1);
    assertContains(analyzerProvider.getAnalysisReport(), DEFICIENT_ROW, Severity.WARNING, 2);
    assertDoesNotContain(DEFICIENT_ROW, analyzerProvider.getAnalysisReport(), 3);
    assertDoesNotContain(DEFICIENT_ROW, analyzerProvider.getAnalysisReport(), 4);
}
Also used : ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.webworker.client.testutil.ExtendedGuidedDecisionTableBuilder) Test(org.junit.Test)

Example 10 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerDeficiencyTest method testRuleIsNotDeficient.

@Test
public void testRuleIsNotDeficient() throws Exception {
    table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("a", "Person", "age", "==").withStringColumn("a", "Person", "name", "==").withStringColumn("a", "Person", "lastName", "==").withActionSetField("a", "salary", DataType.TYPE_NUMERIC_INTEGER).withData(new Object[][] { { 1, "description", null, "Eder", null, 100 }, { 2, "description", 10, null, null, 100 }, { 3, "description", null, "Toni", "Rikkola", 100 }, { 4, "description", null, null, null, null } }).buildTable();
    fireUpAnalyzer();
    assertDoesNotContain(DEFICIENT_ROW, 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