Search in sources :

Example 16 with Interval

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

the class IntervalTest method testFlatten.

@Test
public void testFlatten() {
    Interval a = new Interval(RangeBoundary.CLOSED, 0, 3, RangeBoundary.OPEN, 0, 0);
    Interval b = new Interval(RangeBoundary.CLOSED, 1, 2, RangeBoundary.CLOSED, 0, 0);
    Interval c = new Interval(RangeBoundary.CLOSED, 3, 4, RangeBoundary.CLOSED, 0, 0);
    List<Interval> result = Interval.flatten(Arrays.asList(c, b, a));
    assertThat(result, contains(new Interval(RangeBoundary.CLOSED, 0, 4, RangeBoundary.CLOSED, 0, 0)));
}
Also used : Interval(org.kie.dmn.validation.dtanalysis.model.Interval) Test(org.junit.Test)

Example 17 with Interval

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

the class IntervalTest method testNoFlatten.

@Test
public void testNoFlatten() {
    Interval a = new Interval(RangeBoundary.CLOSED, LocalDate.parse("2021-01-01"), LocalDate.parse("2021-03-31"), RangeBoundary.CLOSED, 0, 0);
    Interval b = new Interval(RangeBoundary.OPEN, LocalDate.parse("2021-04-01"), LocalDate.parse("2021-04-30"), RangeBoundary.CLOSED, 0, 0);
    List<Interval> result = Interval.flatten(Arrays.asList(b, a));
    Assertions.assertThat(result).containsExactly(a, b);
}
Also used : Interval(org.kie.dmn.validation.dtanalysis.model.Interval) Test(org.junit.Test)

Example 18 with Interval

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

the class IntervalTest method testFlatten2.

@Test
public void testFlatten2() {
    Interval a = new Interval(RangeBoundary.CLOSED, 0, 3, RangeBoundary.OPEN, 0, 0);
    Interval b = new Interval(RangeBoundary.CLOSED, 1, 2, RangeBoundary.CLOSED, 0, 0);
    Interval c = new Interval(RangeBoundary.OPEN, 3, 4, RangeBoundary.CLOSED, 0, 0);
    List<Interval> result = Interval.flatten(Arrays.asList(c, b, a));
    assertThat(result, contains(new Interval(RangeBoundary.CLOSED, 0, 3, RangeBoundary.OPEN, 0, 0), new Interval(RangeBoundary.OPEN, 3, 4, RangeBoundary.CLOSED, 0, 0)));
}
Also used : Interval(org.kie.dmn.validation.dtanalysis.model.Interval) Test(org.junit.Test)

Example 19 with Interval

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

the class IntervalTest method testFlatten4.

@Test
public void testFlatten4() {
    Interval a = new Interval(RangeBoundary.CLOSED, LocalDate.parse("2021-01-01"), LocalDate.parse("2021-03-31"), RangeBoundary.CLOSED, 0, 0);
    Interval b = new Interval(RangeBoundary.CLOSED, LocalDate.parse("2021-04-01"), LocalDate.parse("2021-04-30"), RangeBoundary.CLOSED, 0, 0);
    List<Interval> result = Interval.flatten(Arrays.asList(b, a));
    Assertions.assertThat(result).containsExactly(new Interval(RangeBoundary.CLOSED, LocalDate.parse("2021-01-01"), LocalDate.parse("2021-04-30"), RangeBoundary.CLOSED, 0, 0));
}
Also used : Interval(org.kie.dmn.validation.dtanalysis.model.Interval) Test(org.junit.Test)

Example 20 with Interval

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

the class IntervalTest method testInvertOverDomain2.

@Test
public void testInvertOverDomain2() {
    Interval a = new Interval(RangeBoundary.CLOSED, "i", "o", RangeBoundary.OPEN, 9, 8);
    Interval domain = new Interval(RangeBoundary.CLOSED, "a", "u", RangeBoundary.CLOSED, 0, 0);
    List<Interval> result = Interval.invertOverDomain(a, domain);
    assertThat(result, hasSize(2));
    assertInterval(result.get(0), RangeBoundary.CLOSED, "a", "i", RangeBoundary.OPEN, 9, 8);
    assertInterval(result.get(1), RangeBoundary.CLOSED, "o", "u", RangeBoundary.CLOSED, 9, 8);
}
Also used : Interval(org.kie.dmn.validation.dtanalysis.model.Interval) Test(org.junit.Test)

Aggregations

Interval (org.kie.dmn.validation.dtanalysis.model.Interval)20 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)4 QName (javax.xml.namespace.QName)3 ProcessedUnaryTest (org.kie.dmn.feel.codegen.feel11.ProcessedUnaryTest)3 UnaryTestListNode (org.kie.dmn.feel.lang.ast.UnaryTestListNode)3 UnaryTestNode (org.kie.dmn.feel.lang.ast.UnaryTestNode)3 UnaryTestInterpretedExecutableExpression (org.kie.dmn.feel.lang.impl.UnaryTestInterpretedExecutableExpression)3 DDTAInputClause (org.kie.dmn.validation.dtanalysis.model.DDTAInputClause)3 DDTAInputEntry (org.kie.dmn.validation.dtanalysis.model.DDTAInputEntry)3 BaseNode (org.kie.dmn.feel.lang.ast.BaseNode)2 NullNode (org.kie.dmn.feel.lang.ast.NullNode)2 InputClause (org.kie.dmn.model.api.InputClause)2 Bound (org.kie.dmn.validation.dtanalysis.model.Bound)2 DDTARule (org.kie.dmn.validation.dtanalysis.model.DDTARule)2 Hyperrectangle (org.kie.dmn.validation.dtanalysis.model.Hyperrectangle)2 StaticJavaParser.parseExpression (com.github.javaparser.StaticJavaParser.parseExpression)1 Expression (com.github.javaparser.ast.expr.Expression)1 IntegerLiteralExpr (com.github.javaparser.ast.expr.IntegerLiteralExpr)1 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)1