Skip to content

Commit

Permalink
[incubator-kie-issues#506] Fix as per PR suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
BAMOE CI committed Jan 8, 2024
1 parent b4f7eb2 commit 450b848
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@

import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import static com.github.javaparser.StaticJavaParser.parseClassOrInterfaceType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@
package org.kie.dmn.feel.exceptions;

public class EndpointOfRangeNotOfNumberException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@

public class BigDecimalRangeIterator implements Iterator<BigDecimal> {

private enum Direction {
ASCENDANT,
DESCENDANT;
}

private final BigDecimal start;
private final BigDecimal end;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.kie.dmn.feel.lang.ast.forexpressioniterators;

enum Direction {
ASCENDANT,
DESCENDANT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ private ForIterationUtils() {

public static ForIteration getForIteration(EvaluationContext ctx, String name, Object start, Object end) {
validateValues(ctx, start, end);
if (start instanceof BigDecimal) {
return new ForIteration(name, (BigDecimal) start, (BigDecimal) end);
if (start instanceof BigDecimal bigDecimal) {
return new ForIteration(name, bigDecimal, (BigDecimal) end);
}
if (start instanceof LocalDate) {
return new ForIteration(name, (LocalDate) start, (LocalDate) end);
if (start instanceof LocalDate localDate) {
return new ForIteration(name, localDate, (LocalDate) end);
}
ctx.notifyEvt(() -> new ASTEventBase(FEELEvent.Severity.ERROR,
Msg.createMessage(Msg.VALUE_X_NOT_A_VALID_ENDPOINT_FOR_RANGE_BECAUSE_NOT_A_NUMBER_NOT_A_DATE, start), null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
import java.util.NoSuchElementException;

public class LocalDateRangeIterator implements Iterator<LocalDate> {

private enum Direction {
ASCENDANT,
DESCENDANT;
}

private final LocalDate start;
private final LocalDate end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

public class ZonedDateTimeRangeIterator implements Iterator<ZonedDateTime> {

private enum Direction {
ASCENDANT,
DESCENDANT;
}

private final ZonedDateTime start;
private final ZonedDateTime end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class Msg {
public static final Message2 INDEX_OUT_OF_BOUND = new Message2("Index out of bound: list of %s elements, index %s; will evaluate as FEEL null");
public static final Message2 X_TYPE_INCOMPATIBLE_WITH_Y_TYPE = new Message2("%s type incompatible with %s type");
public static final Message1 INCOMPATIBLE_TYPE_FOR_RANGE = new Message1("Type %s can not be used in a range unary test");
public static final Message1 VALUE_X_NOT_A_VALID_ENDPOINT_FOR_RANGE_BECAUSE_NOT_A_NUMBER_NOT_A_DATE = new Message1("Value %s is not a valid endpoint for range, because not a feel:number nor a feel:date");
public static final Message1 VALUE_X_NOT_A_VALID_ENDPOINT_FOR_RANGE_BECAUSE_NOT_A_NUMBER_NOT_A_DATE = new Message1("Value %s is not a valid endpoint for range, because neither a feel:number nor a feel:date");
public static final Message1 EVALUATED_TO_NULL = new Message1("%s evaluated to null");
public static final Message1 IS_NULL = new Message1("%s is null");
public static final Message0 BASE_NODE_EVALUATE_CALLED = new Message0("BaseNode evaluate called");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import java.util.List;
import java.util.stream.IntStream;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class BigDecimalRangeIteratorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.kie.dmn.feel.codegen.feel11.CodegenTestUtil.newEmptyEvaluationContext;
import static org.kie.dmn.feel.lang.ast.forexpressioniterators.ForIterationUtils.*;
import static org.kie.dmn.feel.lang.ast.forexpressioniterators.ForIterationUtils.getForIteration;
import static org.kie.dmn.feel.lang.ast.forexpressioniterators.ForIterationUtils.validateValues;
import static org.kie.dmn.feel.lang.ast.forexpressioniterators.ForIterationUtils.valueMustBeValid;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

public class ForIterationUtilsTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import java.util.List;
import java.util.stream.IntStream;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class LocalDateRangeIteratorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import java.util.List;
import java.util.stream.IntStream;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class ZonedDateTimeRangeIteratorTest {

Expand Down

0 comments on commit 450b848

Please sign in to comment.