Search in sources :

Example 11 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerSubsumptionResolverTest method testRedundantActionsInOneRow002.

@Test
public void testRedundantActionsInOneRow002() throws Exception {
    final GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("a", "Person", "name", "==").withActionInsertFact("Person", "b", "salary", DataType.TYPE_NUMERIC_INTEGER).withActionSetField("b", "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();
    final 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 12 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerSubsumptionResolverTest method testRedundantRows003.

@Test
public void testRedundantRows003() throws Exception {
    GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withStringColumn("application", "LoanApplication", "amount", ">").withStringColumn("person", "Person", "name", "==").withEnumColumn("income", "IncomeSource", "type", "==", "Asset,Job").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 13 with ExtendedGuidedDecisionTableBuilder

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

Example 14 with ExtendedGuidedDecisionTableBuilder

use of org.drools.workbench.services.verifier.plugin.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();
    Assert.assertEquals(1, analyzerProvider.getAnalysisReport().size());
    assertContains(analyzerProvider.getAnalysisReport(), CheckType.MISSING_RESTRICTION, Severity.NOTE);
}
Also used : ArrayList(java.util.ArrayList) ExtendedGuidedDecisionTableBuilder(org.drools.workbench.services.verifier.plugin.client.testutil.ExtendedGuidedDecisionTableBuilder) Test(org.junit.Test)

Example 15 with ExtendedGuidedDecisionTableBuilder

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

the class DecisionTableAnalyzerTest method testConditionsShouldNotBeIgnored.

// GUVNOR-2546: Verification & Validation: BRL fragments are ignored
@Test
public void testConditionsShouldNotBeIgnored() throws Exception {
    table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionBRLColumn().withActionInsertFact("Application", "a", "approved", DataType.TYPE_BOOLEAN).withData(new Object[][] { { 1, "", "description", null, true }, { 2, "", "description", null, null } }).buildTable();
    fireUpAnalyzer();
    assertContains(analyzerProvider.getAnalysisReport(), CheckType.EMPTY_RULE, Severity.WARNING, 2);
    assertDoesNotContain(CheckType.EMPTY_RULE, analyzerProvider.getAnalysisReport(), 1);
    assertContains(analyzerProvider.getAnalysisReport(), CheckType.MISSING_RESTRICTION, Severity.NOTE, 1);
    assertDoesNotContain(CheckType.MISSING_RESTRICTION, analyzerProvider.getAnalysisReport(), 2);
}
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