Search in sources :

Example 26 with Hyperrectangle

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

the class AbstractDTAnalysisTest method debugAnalysis.

protected static void debugAnalysis(DTAnalysis analysis) {
    if (!LOG.isDebugEnabled()) {
        return;
    }
    StringBuilder sbGaps = new StringBuilder("\nGaps:\n");
    for (Hyperrectangle gap : analysis.getGaps()) {
        sbGaps.append(gap.toString());
        sbGaps.append("\n");
    }
    LOG.debug(sbGaps.toString());
    DefaultPrinterConfiguration printConfig = new DefaultPrinterConfiguration();
    printConfig.addOption(new DefaultConfigurationOption(DefaultPrinterConfiguration.ConfigOption.COLUMN_ALIGN_PARAMETERS, true));
    printConfig.addOption(new DefaultConfigurationOption(DefaultPrinterConfiguration.ConfigOption.COLUMN_ALIGN_FIRST_METHOD_CHAIN, true));
    Expression printGaps = DTAnalysisMeta.printGaps(analysis);
    LOG.debug("\n" + printGaps.toString(printConfig));
    StringBuilder sbOverlaps = new StringBuilder("\nOverlaps:\n");
    for (Overlap overlap : analysis.getOverlaps()) {
        sbOverlaps.append(overlap.toString());
        sbOverlaps.append("\n");
    }
    LOG.debug(sbOverlaps.toString());
    Expression printOverlaps = DTAnalysisMeta.printOverlaps(analysis);
    LOG.debug("\n" + printOverlaps.toString(printConfig));
}
Also used : DefaultConfigurationOption(com.github.javaparser.printer.configuration.DefaultConfigurationOption) Expression(com.github.javaparser.ast.expr.Expression) Hyperrectangle(org.kie.dmn.validation.dtanalysis.model.Hyperrectangle) DefaultPrinterConfiguration(com.github.javaparser.printer.configuration.DefaultPrinterConfiguration) Overlap(org.kie.dmn.validation.dtanalysis.model.Overlap)

Example 27 with Hyperrectangle

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

the class BuiltinAndOtherValuesTest method checkComplexDTDates.

private void checkComplexDTDates(DTAnalysis analysis) {
    assertThat(analysis.getGaps(), hasSize(2));
    @SuppressWarnings({ "unchecked", "rawtypes" }) List<Hyperrectangle> gaps = Arrays.asList(new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(java.time.LocalDate.parse("2019-03-31"), RangeBoundary.CLOSED, null), new Bound(java.time.LocalDate.parse("2019-03-31"), RangeBoundary.CLOSED, null)))), new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(java.time.LocalDate.parse("2019-12-31"), RangeBoundary.CLOSED, null), new Bound(java.time.LocalDate.parse("2019-12-31"), RangeBoundary.CLOSED, null)))));
    assertThat(gaps, hasSize(2));
    // Assert GAPS same values
    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(2, 3), new Hyperrectangle(1, Arrays.asList(Interval.newFromBounds(new Bound(java.time.LocalDate.parse("2019-06-30"), RangeBoundary.CLOSED, null), new Bound(java.time.LocalDate.parse("2019-06-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)

Example 28 with Hyperrectangle

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

the class BuiltinAndOtherValuesTest method testWeirdPosNeg.

@Test
public void testWeirdPosNeg() {
    List<DMNMessage> validate = validator.validate(getReader("weirdPosNeg.dmn"), ANALYZE_DECISION_TABLE);
    DTAnalysis analysis = getAnalysis(validate, "_54ae95be-6866-4dc1-8c10-1c5a4dd15c93");
    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(new BigDecimal("0"), 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) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 29 with Hyperrectangle

use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle 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 30 with Hyperrectangle

use of org.kie.dmn.validation.dtanalysis.model.Hyperrectangle 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)

Aggregations

Hyperrectangle (org.kie.dmn.validation.dtanalysis.model.Hyperrectangle)37 Bound (org.kie.dmn.validation.dtanalysis.model.Bound)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)18 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 Expression (com.github.javaparser.ast.expr.Expression)2