Search in sources :

Example 1 with Subsumption

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)));
}
Also used : Arrays(java.util.Arrays) RangeBoundary(org.kie.dmn.feel.runtime.Range.RangeBoundary) DMNMessage(org.kie.dmn.api.core.DMNMessage) Bound(org.kie.dmn.validation.dtanalysis.model.Bound) Interval(org.kie.dmn.validation.dtanalysis.model.Interval) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) Subsumption(org.kie.dmn.validation.dtanalysis.model.Subsumption) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) BigDecimal(java.math.BigDecimal) List(java.util.List) Hyperrectangle(org.kie.dmn.validation.dtanalysis.model.Hyperrectangle) Matchers.contains(org.hamcrest.Matchers.contains) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Overlap(org.kie.dmn.validation.dtanalysis.model.Overlap) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ANALYZE_DECISION_TABLE(org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Subsumption(org.kie.dmn.validation.dtanalysis.model.Subsumption) 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)

Aggregations

BigDecimal (java.math.BigDecimal)1 Arrays (java.util.Arrays)1 List (java.util.List)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.contains (org.hamcrest.Matchers.contains)1 Matchers.hasSize (org.hamcrest.Matchers.hasSize)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Test (org.junit.Test)1 DMNMessage (org.kie.dmn.api.core.DMNMessage)1 DMNMessageType (org.kie.dmn.api.core.DMNMessageType)1 RangeBoundary (org.kie.dmn.feel.runtime.Range.RangeBoundary)1 ANALYZE_DECISION_TABLE (org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE)1 Bound (org.kie.dmn.validation.dtanalysis.model.Bound)1 DTAnalysis (org.kie.dmn.validation.dtanalysis.model.DTAnalysis)1 Hyperrectangle (org.kie.dmn.validation.dtanalysis.model.Hyperrectangle)1 Interval (org.kie.dmn.validation.dtanalysis.model.Interval)1 Overlap (org.kie.dmn.validation.dtanalysis.model.Overlap)1 Subsumption (org.kie.dmn.validation.dtanalysis.model.Subsumption)1