use of org.kie.dmn.validation.dtanalysis.model.Contraction 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.dtanalysis.model.Contraction 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));
}
Aggregations