コード例 #1
0
  @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}
                })
            .build();

    DecisionTableAnalyzer analyzer = getDecisionTableAnalyzer(table52);

    analyzer.onValidate(
        new ValidateEvent(
            new HashMap<Coordinate, List<List<CellValue<? extends Comparable<?>>>>>()));

    assertDoesNotContain("ThisRowIsRedundantTo(1)", analysisReport);
    assertDoesNotContain("ThisRowIsRedundantTo(2)", analysisReport);
    assertDoesNotContain("ThisRowIsRedundantTo(3)", analysisReport);
    assertDoesNotContain("ThisRowIsRedundantTo(4)", analysisReport);
    assertDoesNotContain("ThisRowIsRedundantTo(5)", analysisReport);
  }
コード例 #2
0
  @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"}
                })
            .build();

    DecisionTableAnalyzer analyzer = getDecisionTableAnalyzer(table52);

    analyzer.onValidate(
        new ValidateEvent(
            new HashMap<Coordinate, List<List<CellValue<? extends Comparable<?>>>>>()));

    assertContains("RedundantRows", analysisReport, 1);
    assertContains("RedundantRows", analysisReport, 2);
  }
コード例 #3
0
  @Test
  public void testRedundantRows001() throws Exception {
    GuidedDecisionTable52 table52 =
        new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable")
            .withNumericColumn("application", "LoanApplication", "amount", ">")
            .withNumericColumn("application", "LoanApplication", "amount", "<=")
            .withNumericColumn("application", "LoanApplication", "lengthYears", "==")
            .withNumericColumn("application", "LoanApplication", "deposit", "<")
            .withStringColumn("income", "IncomeSource", "type", "==")
            .withActionSetField("application", "approved", DataType.TYPE_BOOLEAN)
            .withActionSetField("application", "insuranceCost", DataType.TYPE_NUMERIC)
            .withActionSetField("application", "approvedRate", DataType.TYPE_NUMERIC)
            .withData(
                new Object[][] {
                  {1, "description", 131000, 200000, 30, 20000, "Asset", true, 0, 2},
                  {2, "description", 131000, 200000, 30, 20000, "Asset", true, 0, 2},
                  {3, "description", 100001, 130000, 20, 3000, "Job", true, 10, 6}
                })
            .build();

    DecisionTableAnalyzer analyzer = getDecisionTableAnalyzer(table52);

    analyzer.onValidate(
        new ValidateEvent(
            new HashMap<Coordinate, List<List<CellValue<? extends Comparable<?>>>>>()));

    assertContains("RedundantRows", analysisReport, 1);
    assertContains("RedundantRows", analysisReport, 2);
  }
コード例 #4
0
  @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"}})
            .build();

    DecisionTableAnalyzer analyzer = getDecisionTableAnalyzer(table52);

    analyzer.onValidate(
        new ValidateEvent(
            new HashMap<Coordinate, List<List<CellValue<? extends Comparable<?>>>>>()));

    assertContains("RedundantConditions", analysisReport);
  }
コード例 #5
0
  @Test
  public void testRedundantActionsInOneRow002() throws Exception {
    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}
                })
            .build();

    DecisionTableAnalyzer analyzer = getDecisionTableAnalyzer(table52);

    analyzer.onValidate(
        new ValidateEvent(
            new HashMap<Coordinate, List<List<CellValue<? extends Comparable<?>>>>>()));

    assertContains("ValueForFactFieldIsSetTwice(b, salary)", analysisReport);
  }
コード例 #6
0
  @Test
  public void testRedundantRowsWithConflict() throws Exception {
    GuidedDecisionTable52 table52 =
        new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable")
            .withConditionIntegerColumn("a", "Person", "age", ">")
            .withConditionIntegerColumn("d", "Account", "deposit", "<")
            .withActionSetField("a", "approved", DataType.TYPE_BOOLEAN)
            .withActionSetField("a", "approved", DataType.TYPE_BOOLEAN)
            .withData(
                new Object[][] {
                  {1, "description", 100, 0, true, true},
                  {2, "description", 100, 0, true, false}
                })
            .build();

    DecisionTableAnalyzer analyzer = getDecisionTableAnalyzer(table52);

    analyzer.onValidate(
        new ValidateEvent(
            new HashMap<Coordinate, List<List<CellValue<? extends Comparable<?>>>>>()));

    assertDoesNotContain("ThisRowIsRedundantTo(1)", analysisReport);
    assertDoesNotContain("ThisRowIsRedundantTo(2)", analysisReport);
  }