use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle in project drools by kiegroup.
the class MisleadingRulesTest method testMisleadingRules.
@Test
public void testMisleadingRules() {
List<DMNMessage> validate = validator.validate(getReader("MisleadingRules.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_BA703D04-803A-44AA-8A31-F5EEDD4FD54E");
assertThat(analysis.getGaps(), hasSize(0));
// assert OVERLAPs count.
assertThat(analysis.getOverlaps(), hasSize(1));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Overlap> overlaps = Arrays.asList(new Overlap(Arrays.asList(4, 2), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(false, RangeBoundary.CLOSED, null), new Bound(true, RangeBoundary.OPEN, null)), Interval.newFromBounds(new Bound("M", RangeBoundary.CLOSED, null), new Bound("M", RangeBoundary.CLOSED, null))))));
assertThat(overlaps, hasSize(1));
// Assert OVERLAPs same values
assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
// MisleadingRules count.
assertThat(analysis.getMisleadingRules(), hasSize(1));
List<MisleadingRule> misleadingRules = Arrays.asList(new MisleadingRule(4, 2));
assertThat(misleadingRules, hasSize(1));
assertThat(analysis.getMisleadingRules(), contains(misleadingRules.toArray()));
assertTrue("It should contain at least 1 DMNMessage for the MisleadingRule", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_MISLEADING_RULE)));
assertTrue("This test case is not a Masked rule example", validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_MASKED_RULE)));
}
use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle in project drools by kiegroup.
the class NotTest method testNOTnumber.
@Test
public void testNOTnumber() {
List<DMNMessage> validate = validator.validate(getReader("DTusingNOTnumber.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_d0cbacca-55d4-47dd-acc6-131add2a8a53");
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
assertThat(analysis.getGaps(), contains(gaps.toArray()));
// assert OVERLAPs count.
assertThat(analysis.getOverlaps(), hasSize(1));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Overlap> overlaps = Arrays.asList(new Overlap(Arrays.asList(1, 2), new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null))))));
assertThat(overlaps, hasSize(1));
// Assert OVERLAPs same values
assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
}
use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle in project drools by kiegroup.
the class NotTest method testNOTString.
@Test
public void testNOTString() {
List<DMNMessage> validate = validator.validate(getReader("DTusingNOT.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_b53fac34-fb12-4601-8605-c226e68292f9");
assertThat(analysis.getGaps(), hasSize(1));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound("i", RangeBoundary.CLOSED, null), new Bound("o", RangeBoundary.OPEN, null)))));
assertThat(gaps, hasSize(1));
// Assert GAPS
assertThat(analysis.getGaps(), contains(gaps.toArray()));
// assert OVERLAPs count.
assertThat(analysis.getOverlaps(), hasSize(1));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Overlap> overlaps = Arrays.asList(new Overlap(Arrays.asList(1, 2), new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound("o", RangeBoundary.CLOSED, null), new Bound("u", RangeBoundary.OPEN, null))))));
assertThat(overlaps, hasSize(1));
// Assert OVERLAPs same values
assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
}
use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle in project drools by kiegroup.
the class SRGapsOverlapsSubsumption2Test method test.
@Test
public void test() {
List<DMNMessage> validate = validator.validate(getReader("SRGapsOverlapsSubsumption2.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_ccd87aa2-7081-4338-bafa-3a2cbf27c44c");
assertThat(analysis.getGaps(), hasSize(1));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("660"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound("Fair", RangeBoundary.CLOSED, null), new Bound("Good", RangeBoundary.OPEN, null)))));
assertThat(gaps, hasSize(1));
// Assert GAPS
assertThat(analysis.getGaps(), contains(gaps.toArray()));
// assert OVERLAPs count.
assertThat(analysis.getOverlaps(), hasSize(1));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Overlap> overlaps = Arrays.asList(new Overlap(Arrays.asList(2, 4), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("660"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("660"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound("Bad", RangeBoundary.CLOSED, null), new Bound("Fair", RangeBoundary.OPEN, null))))));
assertThat(overlaps, hasSize(1));
// Assert OVERLAPs same values
assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
}
use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle 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