use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle in project drools by kiegroup.
the class MultipleModelsTest method checkAnalysis.
private void checkAnalysis(List<DMNMessage> validate) {
DTAnalysis analysis = getAnalysis(validate, "_3cde04b9-d5c9-4254-9d27-436889111406");
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(0));
}
use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle in project drools by kiegroup.
the class OverlapsMsgTest method test.
@Test
public void test() {
List<DMNMessage> validate = validator.validate(getReader("improveHF.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_CA4B40F8-2354-48B6-B323-5C4E4B2CE467");
// Assert GAPs
assertThat(analysis.getGaps(), hasSize(0));
// assert OVERLAPs
assertThat(analysis.getOverlaps(), hasSize(2));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Overlap> overlaps = Arrays.asList(new Overlap(Arrays.asList(3, 1), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null))))), new Overlap(Arrays.asList(2, 3), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("47"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null))))));
assertThat(overlaps, hasSize(2));
assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
assertThat(analysis.getOverlaps().get(0).getOverlap().asHumanFriendly(analysis.getDdtaTable()), is("[ -, >0 ]"));
assertThat(analysis.getOverlaps().get(1).getOverlap().asHumanFriendly(analysis.getDdtaTable()), is("[ >47, <=0 ]"));
}
use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle in project drools by kiegroup.
the class PosDoubleNegHalfTest method test.
@Test
public void test() {
List<DMNMessage> validate = validator.validate(getReader("posDoubleNegHalf.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_d18aa93e-3f67-4dda-9b36-93ae75835bdf");
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()));
// Overlaps:
assertThat(analysis.getOverlaps(), hasSize(0));
}
use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle in project drools by kiegroup.
the class SameMsgInAllAPITest method verify.
private void verify(List<DMNMessage> validate) {
assertThat(validate, hasSize(5));
DTAnalysis analysis = getAnalysis(validate, "_4771db14-e088-4d5a-8942-211c57ad0b42");
assertThat(analysis.getGaps(), hasSize(3));
@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("2"), RangeBoundary.OPEN, null)))), new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("4"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("6"), RangeBoundary.OPEN, null)))), new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("8"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("10"), RangeBoundary.CLOSED, null)))));
assertThat(gaps, hasSize(3));
// Assert GAPS
assertThat(analysis.getGaps(), contains(gaps.toArray()));
// assert OVERLAPs count.
assertThat(analysis.getOverlaps(), hasSize(2));
@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("3"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("4"), RangeBoundary.CLOSED, null))))), new Overlap(Arrays.asList(3, 4), new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("6"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("7"), 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(2, 1), new MaskedRule(4, 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)));
}
use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle in project drools by kiegroup.
the class GapsCube3Test method test.
@Test
public void test() {
List<DMNMessage> validate = validator.validate(getReader("GapsCube3.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_4b41743d-ff04-4855-bf0b-993d475a9d62");
assertThat(analysis.getGaps(), hasSize(4));
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(3, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("1"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("2"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("3"), RangeBoundary.CLOSED, null)))), new Hyperrectangle(3, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("1"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("2"), RangeBoundary.OPEN, null)))), new Hyperrectangle(3, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("2"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("3"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("1"), RangeBoundary.OPEN, null)))), new Hyperrectangle(3, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("2"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("3"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("1"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("3"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("1"), RangeBoundary.OPEN, null)))));
assertThat(gaps, hasSize(4));
// Assert GAPS
assertThat(analysis.getGaps(), contains(gaps.toArray()));
}
Aggregations