Search in sources :

Example 1 with Contraction

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

the class Check2ndNFViolationTest method testCheck2ndNFViolation.

@Test
public void testCheck2ndNFViolation() {
    List<DMNMessage> validate = validator.validate(getReader("DT2ndNFViolation.dmn"), ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_4e358bae-7012-42dd-acea-e88b3aa3c8b2");
    assertThat(analysis.is2ndNFViolation(), is(true));
    assertThat(analysis.getContractionsViolating2ndNF(), hasSize(1));
    Contraction c2NFViolation = analysis.getContractionsViolating2ndNF().iterator().next();
    assertThat(c2NFViolation.rule, is(1));
    assertThat(c2NFViolation.pairedRules, contains(2));
    assertThat(c2NFViolation.adjacentDimension, is(3));
    assertTrue("It should contain at DMNMessage for the 2nd NF Violation", validate.stream().anyMatch(p -> p.getSourceId().equals("_4e358bae-7012-42dd-acea-e88b3aa3c8b2") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_2NDNFVIOLATION)));
}
Also used : List(java.util.List) DMNMessage(org.kie.dmn.api.core.DMNMessage) Matchers.contains(org.hamcrest.Matchers.contains) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) Contraction(org.kie.dmn.validation.dtanalysis.model.Contraction) 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) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DMNMessage(org.kie.dmn.api.core.DMNMessage) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Contraction(org.kie.dmn.validation.dtanalysis.model.Contraction) Test(org.junit.Test)

Example 2 with Contraction

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

the class ContractionRulesTest method testContractionRules.

@Test
public void testContractionRules() {
    List<DMNMessage> validate = validator.validate(getReader("Contraction.dmn"), ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_01d9abb9-b968-49c0-b6ab-909f3e03d8d3");
    assertThat(analysis.getGaps(), hasSize(0));
    assertThat(analysis.getOverlaps(), hasSize(0));
    // Contraction count.
    assertThat(analysis.getContractions(), hasSize(2));
    List<Contraction> results = Arrays.asList(new Contraction(4, Arrays.asList(5), 2, Arrays.asList(new Interval(RangeBoundary.CLOSED, new BigDecimal("0.35"), Interval.POS_INF, RangeBoundary.CLOSED, 0, 0))), new Contraction(3, Arrays.asList(6), 1, Arrays.asList(new Interval(RangeBoundary.CLOSED, new BigDecimal("600"), Interval.POS_INF, RangeBoundary.CLOSED, 0, 0))));
    assertThat(results, hasSize(2));
    assertThat(analysis.getContractions(), contains(results.toArray()));
    assertThat("It should contain 2 DMNMessage for the Contraction", validate.stream().filter(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_CONTRACTION_RULE)).collect(Collectors.toList()), hasSize(2));
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Contraction(org.kie.dmn.validation.dtanalysis.model.Contraction) BigDecimal(java.math.BigDecimal) Interval(org.kie.dmn.validation.dtanalysis.model.Interval) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DMNMessage (org.kie.dmn.api.core.DMNMessage)2 Contraction (org.kie.dmn.validation.dtanalysis.model.Contraction)2 DTAnalysis (org.kie.dmn.validation.dtanalysis.model.DTAnalysis)2 BigDecimal (java.math.BigDecimal)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 Matchers.is (org.hamcrest.Matchers.is)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 DMNMessageType (org.kie.dmn.api.core.DMNMessageType)1 ANALYZE_DECISION_TABLE (org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE)1 Interval (org.kie.dmn.validation.dtanalysis.model.Interval)1