Search in sources :

Example 31 with DTAnalysis

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

the class AbstractDTAnalysisTest method getAnalysis.

protected static DTAnalysis getAnalysis(List<DMNMessage> dmnMessages, String id) {
    assertThat("Expected to find DTAnalysis but messages are empty.", dmnMessages, not(empty()));
    if (LOG.isDebugEnabled()) {
        LOG.debug("List<DMNMessage> dmnMessages: \n{}", ValidatorUtil.formatMessages(dmnMessages));
    }
    Map<String, DTAnalysis> as = new HashMap<>();
    for (DMNMessage dmnMessage : dmnMessages) {
        if (dmnMessage.getSourceId().equals(id) && dmnMessage instanceof DMNDTAnalysisMessage) {
            DMNDTAnalysisMessage dmndtAnalysisMessage = (DMNDTAnalysisMessage) dmnMessage;
            if (as.containsKey(id)) {
                assertThat("Inconsistency detected", as.get(id), is(dmndtAnalysisMessage.getAnalysis()));
            } else {
                as.put(id, dmndtAnalysisMessage.getAnalysis());
            }
        }
    }
    DTAnalysis analysis = as.get(id);
    assertThat("Null analysis value for key.", analysis, notNullValue());
    debugAnalysis(analysis);
    return analysis;
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) HashMap(java.util.HashMap) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis)

Example 32 with DTAnalysis

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

the class BuiltinAndOtherValuesTest method testComplexDTdates.

@Test
public void testComplexDTdates() {
    List<DMNMessage> validate = validator.validate(getReader("complexDTdates.dmn"), ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_a8a4362e-9f2d-4051-9bd6-e7356244f6b7");
    checkComplexDTDates(analysis);
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Test(org.junit.Test)

Example 33 with DTAnalysis

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

the class BuiltinAndOtherValuesTest method testWeirdYMduration.

@Test
public void testWeirdYMduration() {
    List<DMNMessage> validate = validator.validate(getReader("weirdYMduration.dmn"), ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_fe7d267b-d770-461e-8300-e09981147341");
    assertThat(analysis.getGaps(), hasSize(1));
    @SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(org.kie.dmn.feel.lang.types.impl.ComparablePeriod.parse("P1M"), RangeBoundary.CLOSED, null), new Bound(org.kie.dmn.feel.lang.types.impl.ComparablePeriod.parse("P1M"), RangeBoundary.CLOSED, null)))));
    assertThat(gaps, hasSize(1));
    // Assert GAPS same values
    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 34 with DTAnalysis

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

the class BuiltinAndOtherValuesTest method testComplexDTdatesV2.

@Test
public void testComplexDTdatesV2() {
    List<DMNMessage> validate = validator.validate(getReader("complexDTdatesV2.dmn"), ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_a8a4362e-9f2d-4051-9bd6-e7356244f6b7");
    checkComplexDTDates(analysis);
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Test(org.junit.Test)

Example 35 with DTAnalysis

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

the class Check2ndNFViolationTest method testCheck2ndNFViolationWasADash2.

@Test
public void testCheck2ndNFViolationWasADash2() {
    List<DMNMessage> validate = validator.validate(getReader("DT2ndNFWasADash2.dmn"), ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_D3F1D5B8-642B-446D-9099-DE4CB978CB94");
    assertThat(analysis.is2ndNFViolation(), is(true));
    assertThat(analysis.getCellsViolating2ndNF(), hasSize(1));
}
Also used : 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