Search in sources :

Example 31 with Bound

use of org.kie.dmn.validation.dtanalysis.model.Bound in project drools by kiegroup.

the class NullTest method checkNullBoolean.

private void checkNullBoolean(List<DMNMessage> validate) {
    DTAnalysis analysis = getAnalysis(validate, "_76FABA99-C6D0-4C83-81BF-92E807DBDEF8");
    assertThat(analysis.getGaps(), hasSize(1));
    @SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(true, RangeBoundary.CLOSED, null), new Bound(true, RangeBoundary.CLOSED, null)))));
    assertThat(gaps, hasSize(1));
    // Assert GAPS
    assertThat(analysis.getGaps(), contains(gaps.toArray()));
    // assert OVERLAPs count.
    assertThat(analysis.getOverlaps(), hasSize(0));
}
Also used : Hyperrectangle(org.kie.dmn.validation.dtanalysis.model.Hyperrectangle) Bound(org.kie.dmn.validation.dtanalysis.model.Bound) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis)

Example 32 with Bound

use of org.kie.dmn.validation.dtanalysis.model.Bound in project drools by kiegroup.

the class NullTest method checkNullNumber.

private void checkNullNumber(List<DMNMessage> validate) {
    DTAnalysis analysis = getAnalysis(validate, "_76FABA99-C6D0-4C83-81BF-92E807DBDEF8");
    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(Interval.POS_INF, RangeBoundary.CLOSED, null)))));
    assertThat(gaps, hasSize(1));
    // Assert GAPS
    assertThat(analysis.getGaps(), contains(gaps.toArray()));
    // assert OVERLAPs count.
    assertThat(analysis.getOverlaps(), hasSize(0));
}
Also used : Hyperrectangle(org.kie.dmn.validation.dtanalysis.model.Hyperrectangle) Bound(org.kie.dmn.validation.dtanalysis.model.Bound) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) BigDecimal(java.math.BigDecimal)

Example 33 with Bound

use of org.kie.dmn.validation.dtanalysis.model.Bound in project drools by kiegroup.

the class RuleOrderDashTest method test.

@Test
public void test() {
    List<DMNMessage> validate = validator.validate(getReader("RuleOrderDash.dmn"), ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_eb02106a-cee1-47f5-a9d9-3160c5ac868b");
    // Assert GAPS count.
    assertThat(analysis.getGaps(), hasSize(0));
    // assert OVERLAPs count.
    assertThat(analysis.getOverlaps(), hasSize(3));
    @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(new BigDecimal("60"), RangeBoundary.OPEN, null)), Interval.newFromBounds(new Bound(new BigDecimal("30"), RangeBoundary.CLOSED, 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("60"), RangeBoundary.CLOSED, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("30"), RangeBoundary.OPEN, null))))), new Overlap(Arrays.asList(2, 3, 1), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("60"), RangeBoundary.CLOSED, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("30"), RangeBoundary.CLOSED, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null))))));
    assertThat(overlaps, hasSize(3));
    // Assert OVERLAPs same values
    assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) Hyperrectangle(org.kie.dmn.validation.dtanalysis.model.Hyperrectangle) Bound(org.kie.dmn.validation.dtanalysis.model.Bound) Overlap(org.kie.dmn.validation.dtanalysis.model.Overlap) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 34 with Bound

use of org.kie.dmn.validation.dtanalysis.model.Bound in project drools by kiegroup.

the class GapsAndOverlaps1Test method test.

@Test
public void test() {
    List<DMNMessage> validate = validator.validate(getReader("GapsAndOverlaps1.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_cd2e0a28-3cc2-456b-90b6-392d9c3574af");
    assertThat(analysis.getGaps(), hasSize(17));
    @SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("1"), RangeBoundary.OPEN, null)), Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("1"), RangeBoundary.OPEN, null)), Interval.newFromBounds(new Bound(new BigDecimal("2"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("1"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("2"), RangeBoundary.OPEN, null)), Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("1"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("2"), RangeBoundary.OPEN, null)), Interval.newFromBounds(new Bound(new BigDecimal("2"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("5"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("1"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("2"), RangeBoundary.OPEN, null)), Interval.newFromBounds(new Bound(new BigDecimal("6"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("2"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("3"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, 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("4"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("5"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, 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("6"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("3"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("4"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("3"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("4"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("4"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("4"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("5"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("1"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("4"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("5"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("4"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("5"), RangeBoundary.OPEN, null), new Bound(new BigDecimal("6"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("6"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("7"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("6"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("7"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("3"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("7"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)))));
    assertThat(gaps, hasSize(17));
    // 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, 3), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("2"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("4"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("1"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("2"), RangeBoundary.CLOSED, null))))));
    assertThat(overlaps, hasSize(1));
    // Assert OVERLAPs same values
    assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) Hyperrectangle(org.kie.dmn.validation.dtanalysis.model.Hyperrectangle) Bound(org.kie.dmn.validation.dtanalysis.model.Bound) Overlap(org.kie.dmn.validation.dtanalysis.model.Overlap) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 35 with Bound

use of org.kie.dmn.validation.dtanalysis.model.Bound in project drools by kiegroup.

the class GapsXYTest method checkAnalysis.

public static void checkAnalysis(List<DMNMessage> validate) {
    DTAnalysis analysis = getAnalysis(validate, "_ce297a95-b16c-4631-8da5-e739dac9e3c4");
    assertThat(analysis.getGaps(), hasSize(3));
    @SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(Interval.NEG_INF, RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null)), Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.OPEN, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null)), Interval.newFromBounds(new Bound(new BigDecimal("0"), RangeBoundary.CLOSED, null), new Bound(Interval.POS_INF, RangeBoundary.CLOSED, null)))), new Hyperrectangle(2, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("0"), 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.OPEN, null)))));
    assertThat(gaps, hasSize(3));
    // Assert GAPS
    assertThat(analysis.getGaps(), contains(gaps.toArray()));
    // assert OVERLAPs count.
    assertThat(analysis.getOverlaps(), hasSize(0));
}
Also used : Hyperrectangle(org.kie.dmn.validation.dtanalysis.model.Hyperrectangle) Bound(org.kie.dmn.validation.dtanalysis.model.Bound) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) BigDecimal(java.math.BigDecimal)

Aggregations

Bound (org.kie.dmn.validation.dtanalysis.model.Bound)35 Hyperrectangle (org.kie.dmn.validation.dtanalysis.model.Hyperrectangle)35 DTAnalysis (org.kie.dmn.validation.dtanalysis.model.DTAnalysis)32 BigDecimal (java.math.BigDecimal)24 Test (org.junit.Test)23 DMNMessage (org.kie.dmn.api.core.DMNMessage)23 Overlap (org.kie.dmn.validation.dtanalysis.model.Overlap)17 Interval (org.kie.dmn.validation.dtanalysis.model.Interval)8 Arrays (java.util.Arrays)6 List (java.util.List)6 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)6 Matchers.contains (org.hamcrest.Matchers.contains)6 Matchers.hasSize (org.hamcrest.Matchers.hasSize)6 Assert.assertTrue (org.junit.Assert.assertTrue)6 DMNMessageType (org.kie.dmn.api.core.DMNMessageType)6 RangeBoundary (org.kie.dmn.feel.runtime.Range.RangeBoundary)6 ANALYZE_DECISION_TABLE (org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE)6 VALIDATE_COMPILATION (org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION)5 MaskedRule (org.kie.dmn.validation.dtanalysis.model.MaskedRule)4 ArrayList (java.util.ArrayList)2