use of org.kie.dmn.validation.dtanalysis.model.Subsumption in project drools by kiegroup.
the class SubsumptionRulesTest method testSubsumptionRules.
@Test
public void testSubsumptionRules() {
List<DMNMessage> validate = validator.validate(getReader("Subsumption.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_82100fc5-8799-4ee2-981f-215ded39e68a");
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(2, 3), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("21"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(false, RangeBoundary.CLOSED, null), new Bound(true, RangeBoundary.OPEN, null))))), new Overlap(Arrays.asList(2, 4), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("21"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(true, RangeBoundary.CLOSED, null), new Bound(true, RangeBoundary.CLOSED, null))))));
assertThat(overlaps, hasSize(2));
// Assert OVERLAPs same values
assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
// Subsumption count.
assertThat(analysis.getSubsumptions(), hasSize(1));
List<Subsumption> results = Arrays.asList(new Subsumption(2, 4));
assertThat(results, hasSize(1));
assertThat(analysis.getSubsumptions(), contains(results.toArray()));
assertTrue("It should contain at least 1 DMNMessage for the Subsumtption", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_SUBSUMPTION_RULE)));
}
Aggregations