Search in sources :

Example 1 with ExtendedGuidedDecisionTableBuilder

use of org.drools.workbench.services.verifier.plugin.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(), CheckType.VALUE_FOR_ACTION_IS_SET_TWICE, Severity.WARNING);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.plugin.client.testutil.ExtendedGuidedDecisionTableBuilder) Analyzer(org.drools.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 2 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerSubsumptionResolverTest method testNoIssues.

@Test
public void testNoIssues() throws Exception {
    GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("application", "LoanApplication", "amount", ">").withConditionIntegerColumn("application", "LoanApplication", "amount", "<=").withConditionIntegerColumn("application", "LoanApplication", "lengthYears", "==").withConditionIntegerColumn("application", "LoanApplication", "deposit", "<").withStringColumn("income", "IncomeSource", "type", "==").withActionSetField("application", "approved", DataType.TYPE_BOOLEAN).withActionSetField("application", "insuranceCost", DataType.TYPE_NUMERIC_INTEGER).withActionSetField("application", "approvedRate", DataType.TYPE_NUMERIC_INTEGER).withData(new Object[][] { { 1, "", "description", 131000, 200000, 30, 20000, "Asset", true, 0, 2 }, { 2, "", "description", 10000, 100000, 20, 2000, "Job", true, 0, 4 }, { 3, "", "description", 100001, 130000, 20, 3000, "Job", true, 10, 6 }, { 4, "", "description", null, null, null, null, null, null, null, null }, { 5, "", "description", null, null, null, null, null, null, null, null } }).buildTable();
    Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
    analyzer.resetChecks();
    analyzer.analyze();
    assertDoesNotContain(CheckType.REDUNDANT_ROWS, 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.plugin.client.testutil.ExtendedGuidedDecisionTableBuilder) Analyzer(org.drools.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 3 with ExtendedGuidedDecisionTableBuilder

use of org.drools.workbench.services.verifier.plugin.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(), CheckType.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.plugin.client.testutil.ExtendedGuidedDecisionTableBuilder) Analyzer(org.drools.verifier.core.main.Analyzer) Test(org.junit.Test)

Example 4 with ExtendedGuidedDecisionTableBuilder

use of org.drools.workbench.services.verifier.plugin.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(CheckType.EMPTY_RULE, analyzerProvider.getAnalysisReport(), 1);
    assertDoesNotContain(CheckType.MISSING_ACTION, analyzerProvider.getAnalysisReport());
}
Also used : ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.plugin.client.testutil.ExtendedGuidedDecisionTableBuilder) Test(org.junit.Test)

Example 5 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerTest method ruleHasNoActionShouldNotIgnoreRetract.

@Test
public void ruleHasNoActionShouldNotIgnoreRetract() throws Exception {
    table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("a", "Person", "age", ">").withRetract().withData(DataBuilderProvider.row(0, "a").end()).buildTable();
    fireUpAnalyzer();
    assertDoesNotContain(CheckType.MISSING_ACTION, analyzerProvider.getAnalysisReport());
}
Also used : ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.plugin.client.testutil.ExtendedGuidedDecisionTableBuilder) Test(org.junit.Test)

Aggregations

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