Search in sources :

Example 51 with DTAnalysis

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

the class Check2ndNFViolationTest method testCheck2ndNFViolation3combo.

@Test
public void testCheck2ndNFViolation3combo() {
    List<DMNMessage> validate = validator.validate(getReader("DT2ndNF3combo.dmn"), ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_BA703D04-803A-44AA-8A31-F5EEDD4FD54E");
    assertThat(analysis.is2ndNFViolation(), is(true));
    assertThat(analysis.getContractionsViolating2ndNF(), hasSize(2));
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Test(org.junit.Test)

Example 52 with DTAnalysis

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

the class NotTest method testNOTString2.

@Test
public void testNOTString2() {
    List<DMNMessage> validate = validator.validate(getReader("DTusingNOT2.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(0));
}
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) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Test(org.junit.Test)

Example 53 with DTAnalysis

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

the class OverlapHitPolicyTest method checkAnalysis.

private void checkAnalysis(List<DMNMessage> validate) {
    DTAnalysis analysis = getAnalysis(validate, "_C4A1625B-0606-4F2D-9779-49B1A981718E");
    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(2, 3), new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("30"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("30"), RangeBoundary.CLOSED, null))))));
    assertThat(overlaps, hasSize(1));
    // Assert OVERLAPs same values
    assertThat(analysis.getOverlaps(), contains(overlaps.toArray()));
}
Also used : 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)

Example 54 with DTAnalysis

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

the class PiTest method checkAnalysis.

private void checkAnalysis(List<DMNMessage> validate) {
    DTAnalysis analysis = getAnalysis(validate, "_F32338CF-6F14-4E66-95AE-8BD4276BA75F");
    assertThat(analysis.getGaps(), hasSize(1));
    @SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(new BigDecimal("3.1415926535897932384626433832794"), RangeBoundary.CLOSED, null), new Bound(new BigDecimal("3.1415926535897932384626433832794"), 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 55 with DTAnalysis

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

the class SimpleStringNoGapTest method test.

@Test
public void test() {
    List<DMNMessage> validate = validator.validate(getReader("simpleStringNoGap.dmn"), VALIDATE_COMPILATION, VALIDATE_MODEL, ANALYZE_DECISION_TABLE);
    // Gap Analysis skipped because of free string.
    assertThat(validate, hasSize(1));
    assertTrue("It should contain DMNMessage for the skipped gap analysis", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_GAP)));
    debugValidatorMsg(validate);
    DTAnalysis analysis = getAnalysis(validate, "_3D5BDDEF-8B71-4797-8662-5026A9C2A112");
    assertThat(analysis.getGaps(), hasSize(0));
    assertThat(analysis.getOverlaps(), hasSize(0));
}
Also used : List(java.util.List) DMNMessage(org.kie.dmn.api.core.DMNMessage) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) VALIDATE_COMPILATION(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Assert.assertTrue(org.junit.Assert.assertTrue) ANALYZE_DECISION_TABLE(org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE) Test(org.junit.Test) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) VALIDATE_MODEL(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL) DMNMessage(org.kie.dmn.api.core.DMNMessage) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Test(org.junit.Test)

Aggregations

DTAnalysis (org.kie.dmn.validation.dtanalysis.model.DTAnalysis)63 DMNMessage (org.kie.dmn.api.core.DMNMessage)50 Test (org.junit.Test)46 Bound (org.kie.dmn.validation.dtanalysis.model.Bound)32 Hyperrectangle (org.kie.dmn.validation.dtanalysis.model.Hyperrectangle)32 BigDecimal (java.math.BigDecimal)25 List (java.util.List)16 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)16 Matchers.hasSize (org.hamcrest.Matchers.hasSize)16 Assert.assertTrue (org.junit.Assert.assertTrue)16 DMNMessageType (org.kie.dmn.api.core.DMNMessageType)16 ANALYZE_DECISION_TABLE (org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE)16 Overlap (org.kie.dmn.validation.dtanalysis.model.Overlap)15 Arrays (java.util.Arrays)11 Matchers.contains (org.hamcrest.Matchers.contains)11 Matchers.is (org.hamcrest.Matchers.is)7 VALIDATE_COMPILATION (org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION)7 Interval (org.kie.dmn.validation.dtanalysis.model.Interval)7 RangeBoundary (org.kie.dmn.feel.runtime.Range.RangeBoundary)6 DecisionTable (org.kie.dmn.model.api.DecisionTable)5