@Test
  @Ignore("TODO fix GUVNOR-1677 duplication")
  public void testDuplicatedMatchNumeric() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    ConditionCol52 ageMinimum = new ConditionCol52();
    ageMinimum.setFactField("age");
    ageMinimum.setOperator(">=");
    ageMinimum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(ageMinimum);

    ConditionCol52 ageMaximum = new ConditionCol52();
    ageMaximum.setFactField("age");
    ageMaximum.setOperator("<=");
    ageMaximum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(ageMaximum);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(new BigDecimal("20")),
                new DTCellValue52("Same message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52(new BigDecimal("21")),
                new DTCellValue52(new BigDecimal("40")),
                new DTCellValue52("Same message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52(new BigDecimal("30")),
                new DTCellValue52(new BigDecimal("60")),
                new DTCellValue52("Same message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("4")),
                new DTCellValue52("Row 4 description"),
                new DTCellValue52(new BigDecimal("50")),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52("Same message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getDuplicatedMatchSize());
    assertEquals(1, analysisData.get(1).getDuplicatedMatchSize());
    assertEquals(2, analysisData.get(2).getDuplicatedMatchSize());
    assertEquals(1, analysisData.get(3).getDuplicatedMatchSize());

    assertEquals(0, analysisData.get(0).getConflictingMatchSize());
    assertEquals(0, analysisData.get(1).getConflictingMatchSize());
    assertEquals(0, analysisData.get(2).getConflictingMatchSize());
    assertEquals(0, analysisData.get(3).getConflictingMatchSize());
  }
  @Test
  public void testConflictingMatchLimitedEntry() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    LimitedEntryConditionCol52 child = new LimitedEntryConditionCol52();
    child.setFactField("age");
    child.setOperator("<");
    child.setValue(new DTCellValue52(new BigDecimal("18")));
    child.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(child);

    LimitedEntryConditionCol52 adult = new LimitedEntryConditionCol52();
    adult.setFactField("age");
    adult.setOperator(">=");
    adult.setValue(new DTCellValue52(new BigDecimal("18")));
    adult.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(adult);

    LimitedEntryConditionCol52 pensioner = new LimitedEntryConditionCol52();
    pensioner.setFactField("age");
    pensioner.setOperator(">=");
    pensioner.setValue(new DTCellValue52(new BigDecimal("65")));
    pensioner.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(pensioner);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 1 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 2 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52("Row 3 message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getConflictingMatchSize());
    assertEquals(1, analysisData.get(1).getConflictingMatchSize());
    assertEquals(1, analysisData.get(2).getConflictingMatchSize());
  }
  @Test
  public void testImpossibleMatchesDate() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    ConditionCol52 dateOfBirthMinimum = new ConditionCol52();
    dateOfBirthMinimum.setFactField("dateOfBirth");
    dateOfBirthMinimum.setOperator(">=");
    dateOfBirthMinimum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(dateOfBirthMinimum);

    ConditionCol52 dateOfBirthMaximum = new ConditionCol52();
    dateOfBirthMaximum.setFactField("dateOfBirth");
    dateOfBirthMaximum.setOperator("<=");
    dateOfBirthMaximum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(dateOfBirthMaximum);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52(dateFormat.parse("1981-01-01")),
                new DTCellValue52(dateFormat.parse("2001-01-01")),
                new DTCellValue52("Row 1 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52(dateFormat.parse("2001-01-01")),
                new DTCellValue52(dateFormat.parse("1981-01-01")),
                new DTCellValue52("Row 2 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52((Date) null),
                new DTCellValue52(dateFormat.parse("2001-01-01")),
                new DTCellValue52("Row 3 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("4")),
                new DTCellValue52("Row 4 description"),
                new DTCellValue52(dateFormat.parse("1981-01-01")),
                new DTCellValue52((Date) null),
                new DTCellValue52("Row 4 message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getImpossibleMatchesSize());
    assertEquals(1, analysisData.get(1).getImpossibleMatchesSize());
    assertEquals(0, analysisData.get(2).getImpossibleMatchesSize());
    assertEquals(0, analysisData.get(3).getImpossibleMatchesSize());
  }
  @Test
  public void testConflictingMatchCombination() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    ConditionCol52 ageMinimum = new ConditionCol52();
    ageMinimum.setFactField("age");
    ageMinimum.setOperator(">=");
    ageMinimum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(ageMinimum);

    ConditionCol52 ageMaximum = new ConditionCol52();
    ageMaximum.setFactField("age");
    ageMaximum.setOperator("<=");
    ageMaximum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(ageMaximum);

    ConditionCol52 approved = new ConditionCol52();
    approved.setFactField("approved");
    approved.setOperator("==");
    approved.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(approved);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(new BigDecimal("20")),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52("Row 1 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52(new BigDecimal("21")),
                new DTCellValue52(new BigDecimal("40")),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52("Row 2 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52(new BigDecimal("41")),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52("Row 3 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("4")),
                new DTCellValue52("Row 4 description"),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(new BigDecimal("25")),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 4 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("5")),
                new DTCellValue52("Row 5 description"),
                new DTCellValue52(new BigDecimal("26")),
                new DTCellValue52(new BigDecimal("60")),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 5 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("6")),
                new DTCellValue52("Row 6 description"),
                new DTCellValue52(new BigDecimal("50")),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 6 message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getConflictingMatchSize());
    assertEquals(0, analysisData.get(1).getConflictingMatchSize());
    assertEquals(0, analysisData.get(2).getConflictingMatchSize());
    assertEquals(0, analysisData.get(3).getConflictingMatchSize());
    assertEquals(1, analysisData.get(4).getConflictingMatchSize());
    assertEquals(1, analysisData.get(5).getConflictingMatchSize());
  }
  @Test
  public void testImpossibleMatchesString() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    ConditionCol52 name = new ConditionCol52();
    name.setFactField("name");
    name.setOperator("==");
    name.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(name);

    ConditionCol52 notName = new ConditionCol52();
    notName.setFactField("name");
    notName.setOperator("!=");
    notName.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(notName);

    ConditionCol52 nameIn = new ConditionCol52();
    nameIn.setFactField("name");
    nameIn.setOperator("in");
    nameIn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(nameIn);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52("Homer"),
                new DTCellValue52("Bart"),
                new DTCellValue52((String) null),
                new DTCellValue52("Row 1 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52("Homer"),
                new DTCellValue52("Homer"),
                new DTCellValue52((String) null),
                new DTCellValue52("Row 2 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52("Homer"),
                new DTCellValue52((String) null),
                new DTCellValue52((String) null),
                new DTCellValue52("Row 3 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("4")),
                new DTCellValue52("Row 4 description"),
                new DTCellValue52((String) null),
                new DTCellValue52("Bart"),
                new DTCellValue52((String) null),
                new DTCellValue52("Row 4 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("5")),
                new DTCellValue52("Row 5 description"),
                new DTCellValue52("Homer"),
                new DTCellValue52((String) null),
                new DTCellValue52("Marge,Lisa"),
                new DTCellValue52("Row 5 message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getImpossibleMatchesSize());
    assertEquals(1, analysisData.get(1).getImpossibleMatchesSize());
    assertEquals(0, analysisData.get(2).getImpossibleMatchesSize());
    assertEquals(0, analysisData.get(3).getImpossibleMatchesSize());
    assertEquals(1, analysisData.get(4).getImpossibleMatchesSize());
  }