use of org.kie.dmn.validation.dtanalysis.model.DTAnalysis in project drools by kiegroup.
the class Check1stNFViolationTest method testCheck1stNFViolation.
@Test
public void testCheck1stNFViolation() {
List<DMNMessage> validate = validator.validate(getReader("DT1stNFViolation.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)));
DTAnalysis analysisFIRST = getAnalysis(validate, "_1ca6acde-c1d4-4c50-8e21-f3b11e106f3d");
assertThat(analysisFIRST.is1stNFViolation(), is(true));
assertTrue("It should contain at DMNMessage for the 1st NF Violation", validate.stream().anyMatch(p -> p.getSourceId().equals("_1ca6acde-c1d4-4c50-8e21-f3b11e106f3d") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)));
DTAnalysis analysisRULE_ORDER = getAnalysis(validate, "_03522945-b520-4b45-ac5e-ef3cbd7f1eaf");
assertThat(analysisRULE_ORDER.is1stNFViolation(), is(true));
assertTrue("It should contain at DMNMessage for the 1st NF Violation", validate.stream().anyMatch(p -> p.getSourceId().equals("_03522945-b520-4b45-ac5e-ef3cbd7f1eaf") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)));
}
use of org.kie.dmn.validation.dtanalysis.model.DTAnalysis in project drools by kiegroup.
the class Check1stNFViolationTest method testCheck1stNFViolationDuplicateNoSubsumption.
@Test
public void testCheck1stNFViolationDuplicateNoSubsumption() {
List<DMNMessage> validate = validator.validate(getReader("DT1stNFViolationDuplicateNoSubsumption.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_221BF4A4-F8D4-466C-96E4-311FE3C9867B");
assertThat(analysis.is1stNFViolation(), is(true));
assertThat(analysis.getDuplicateRulesTuples(), hasSize(1));
assertThat(analysis.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.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)));
assertThat(analysis.getSubsumptions().isEmpty(), is(false));
assertTrue("No message about subsumption", validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_SUBSUMPTION_RULE)));
}
use of org.kie.dmn.validation.dtanalysis.model.DTAnalysis in project drools by kiegroup.
the class ContractionRulesTest method testContractionRules.
@Test
public void testContractionRules() {
List<DMNMessage> validate = validator.validate(getReader("Contraction.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_01d9abb9-b968-49c0-b6ab-909f3e03d8d3");
assertThat(analysis.getGaps(), hasSize(0));
assertThat(analysis.getOverlaps(), hasSize(0));
// Contraction count.
assertThat(analysis.getContractions(), hasSize(2));
List<Contraction> results = Arrays.asList(new Contraction(4, Arrays.asList(5), 2, Arrays.asList(new Interval(RangeBoundary.CLOSED, new BigDecimal("0.35"), Interval.POS_INF, RangeBoundary.CLOSED, 0, 0))), new Contraction(3, Arrays.asList(6), 1, Arrays.asList(new Interval(RangeBoundary.CLOSED, new BigDecimal("600"), Interval.POS_INF, RangeBoundary.CLOSED, 0, 0))));
assertThat(results, hasSize(2));
assertThat(analysis.getContractions(), contains(results.toArray()));
assertThat("It should contain 2 DMNMessage for the Contraction", validate.stream().filter(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_CONTRACTION_RULE)).collect(Collectors.toList()), hasSize(2));
}
use of org.kie.dmn.validation.dtanalysis.model.DTAnalysis in project drools by kiegroup.
the class DTinBKMTest method testDTnestedEverywhere.
@Test
public void testDTnestedEverywhere() {
List<DMNMessage> validate = validator.validate(getReader("dtInBKM.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_860A5A56-0C43-4B42-B1DB-7415984E5624");
assertThat(analysis.getGaps(), hasSize(0));
assertThat(analysis.getOverlaps(), hasSize(0));
assertThat(validate, hasSize(1));
assertThat(validate.get(0).getMessageType(), is(DMNMessageType.DECISION_TABLE_ANALYSIS_EMPTY));
}
use of org.kie.dmn.validation.dtanalysis.model.DTAnalysis in project drools by kiegroup.
the class BuiltinAndOtherValuesTest method testWeirdPosNeg.
@Test
public void testWeirdPosNeg() {
List<DMNMessage> validate = validator.validate(getReader("weirdPosNeg.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_54ae95be-6866-4dc1-8c10-1c5a4dd15c93");
assertThat(analysis.getGaps(), hasSize(1));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null)))));
assertThat(gaps, hasSize(1));
// Assert GAPS same values
assertThat(analysis.getGaps(), contains(gaps.toArray()));
// assert OVERLAPs count.
assertThat(analysis.getOverlaps(), hasSize(0));
}
Aggregations