use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class FailingOutputConstraintsTest method testFailingOutputConstraintsWhenOutputIsSymbol.
@Test
public void testFailingOutputConstraintsWhenOutputIsSymbol() {
List<DMNMessage> validate = validator.validate(getReader("FailingOutputConstraints2.dmn"), ANALYZE_DECISION_TABLE);
debugValidatorMsg(validate);
assertTrue("It should NOT contain DMNMessage for output outside of LoV (using a symbol in output)", validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR)));
DTAnalysis analysis = getAnalysis(validate, "_E72BD036-C550-4992-AA6D-A8AD4666C63A");
assertThat(analysis.isError(), is(false));
assertThat(analysis.getGaps(), hasSize(1));
assertThat(analysis.getOverlaps(), hasSize(0));
}
use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class FailingOutputConstraintsTest method testFailingOutputConstraints.
@Test
public void testFailingOutputConstraints() {
List<DMNMessage> validate = validator.validate(getReader("FailingOutputConstraints.dmn"), ANALYZE_DECISION_TABLE);
assertTrue("It should contain DMNMessage for output outside of LoV", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR)));
debugValidatorMsg(validate);
DTAnalysis analysis = getAnalysis(validate, "_E72BD036-C550-4992-AA6D-A8AD4666C63A");
assertThat(analysis.isError(), is(false));
assertThat(analysis.getGaps(), hasSize(1));
assertThat(analysis.getOverlaps(), hasSize(0));
}
use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class Check2ndNFViolationTest method testCheck2ndNFViolation.
@Test
public void testCheck2ndNFViolation() {
List<DMNMessage> validate = validator.validate(getReader("DT2ndNFViolation.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_4e358bae-7012-42dd-acea-e88b3aa3c8b2");
assertThat(analysis.is2ndNFViolation(), is(true));
assertThat(analysis.getContractionsViolating2ndNF(), hasSize(1));
Contraction c2NFViolation = analysis.getContractionsViolating2ndNF().iterator().next();
assertThat(c2NFViolation.rule, is(1));
assertThat(c2NFViolation.pairedRules, contains(2));
assertThat(c2NFViolation.adjacentDimension, is(3));
assertTrue("It should contain at DMNMessage for the 2nd NF Violation", validate.stream().anyMatch(p -> p.getSourceId().equals("_4e358bae-7012-42dd-acea-e88b3aa3c8b2") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_2NDNFVIOLATION)));
}
use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class StringWithoutEnumNoGapTest method test.
@Test
public void test() {
List<DMNMessage> validate = validator.validate(getReader("stringWithoutEnumNoGap.dmn"), VALIDATE_COMPILATION, VALIDATE_MODEL, ANALYZE_DECISION_TABLE);
// no gap but no enum "skip Gap analysis" message, (omit 2 overlaps DROOLS-5363), 2 masked, (omit 2 misleading as redundant with Masked).
assertThat(validate, hasSize(3));
debugValidatorMsg(validate);
DTAnalysis analysis = getAnalysis(validate, "_8b48d1c9-265c-47aa-9378-7f11d55dfe55");
assertThat(analysis.getGaps(), hasSize(0));
// assert OVERLAPs count.
assertThat(analysis.getOverlaps(), hasSize(2));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Overlap> overlaps = Arrays.asList(new Overlap(Arrays.asList(1, 3), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound("EU", RangeBoundary.CLOSED, null), new Bound("EU", RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("18"), RangeBoundary.CLOSED, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null))))), new Overlap(Arrays.asList(3, 2), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound("US", RangeBoundary.CLOSED, null), new Bound("US", RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("21"), RangeBoundary.CLOSED, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null))))));
assertThat(overlaps, hasSize(2));
// Assert OVERLAPs same values
assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
// MaskedRules count.
assertThat(analysis.getMaskedRules(), hasSize(2));
List<MaskedRule> maskedRules = Arrays.asList(new MaskedRule(1, 3), new MaskedRule(2, 3));
assertThat(maskedRules, hasSize(2));
assertThat(analysis.getMaskedRules(), contains(maskedRules.toArray()));
assertTrue("It should contain DMNMessage for the MaskedRule", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_MASKED_RULE)));
// MisleadingRules are duplicate of Masked, so are no longer displayed.
assertThat(analysis.getMisleadingRules(), hasSize(2));
List<MisleadingRule> misleadingRules = Arrays.asList(new MisleadingRule(3, 1), new MisleadingRule(3, 2));
assertThat(misleadingRules, hasSize(2));
assertThat(analysis.getMisleadingRules(), containsInAnyOrder(misleadingRules.toArray()));
assertTrue("It should NOT contain DMNMessage for the MisleadingRule", validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_MISLEADING_RULE)));
}
use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class Check1stNFViolationTest method testCheck1stNFViolationB.
@Test
public void testCheck1stNFViolationB() {
List<DMNMessage> validate = validator.validate(getReader("DT1stNFViolationB.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysisDuplicate = getAnalysis(validate, "_053034d5-0e1f-4c4a-8513-ab3c6ba538db");
assertThat(analysisDuplicate.is1stNFViolation(), is(true));
assertThat(analysisDuplicate.getDuplicateRulesTuples(), hasSize(1));
assertThat(analysisDuplicate.getDuplicateRulesTuples(), contains(Collections.singletonList(Arrays.asList(1, 2)).toArray()));
assertTrue("It should contain at DMNMessage for the 1st NF Violation", validate.stream().anyMatch(p -> p.getSourceId().equals("_053034d5-0e1f-4c4a-8513-ab3c6ba538db") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)));
}
Aggregations