diff --git a/drools-scenario-simulation/drools-scenario-simulation-backend/src/main/java/org/drools/scenariosimulation/backend/expression/DMNFeelExpressionEvaluator.java b/drools-scenario-simulation/drools-scenario-simulation-backend/src/main/java/org/drools/scenariosimulation/backend/expression/DMNFeelExpressionEvaluator.java index 776f5b7c462..41f59a0d512 100644 --- a/drools-scenario-simulation/drools-scenario-simulation-backend/src/main/java/org/drools/scenariosimulation/backend/expression/DMNFeelExpressionEvaluator.java +++ b/drools-scenario-simulation/drools-scenario-simulation-backend/src/main/java/org/drools/scenariosimulation/backend/expression/DMNFeelExpressionEvaluator.java @@ -51,7 +51,7 @@ public class DMNFeelExpressionEvaluator extends AbstractExpressionEvaluator { private final ClassLoader classLoader; - private final CodeFunction codeFunction = new CodeFunction(); + private final CodeFunction codeFunction = CodeFunction.INSTANCE; public DMNFeelExpressionEvaluator(ClassLoader classLoader) { this.classLoader = classLoader; diff --git a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/internal/utils/DynamicDMNContextBuilder.java b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/internal/utils/DynamicDMNContextBuilder.java index f225180cbf1..9ecb89a0e6a 100644 --- a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/internal/utils/DynamicDMNContextBuilder.java +++ b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/internal/utils/DynamicDMNContextBuilder.java @@ -182,11 +182,11 @@ private Object getAsFEELBuiltinType(Object value, DMNType resultType) { case UNKNOWN: return value; case DATE: - return new DateFunction().invoke((String) value).getOrElseThrow(FailedConversionException::new); + return DateFunction.INSTANCE.invoke((String) value).getOrElseThrow(FailedConversionException::new); case TIME: - return new TimeFunction().invoke((String) value).getOrElseThrow(FailedConversionException::new); + return TimeFunction.INSTANCE.invoke((String) value).getOrElseThrow(FailedConversionException::new); case DATE_TIME: - return new DateAndTimeFunction().invoke((String) value).getOrElseThrow(FailedConversionException::new); + return DateAndTimeFunction.INSTANCE.invoke((String) value).getOrElseThrow(FailedConversionException::new); case BOOLEAN: return value; case NUMBER: @@ -194,7 +194,7 @@ private Object getAsFEELBuiltinType(Object value, DMNType resultType) { case STRING: return value; case DURATION: - return new DurationFunction().invoke((String) value).getOrElseThrow(FailedConversionException::new); + return DurationFunction.INSTANCE.invoke((String) value).getOrElseThrow(FailedConversionException::new); default: throw new IllegalArgumentException(); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/FEEL.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/FEEL.java index 1dd0f2306de..280ed3e6a0e 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/FEEL.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/FEEL.java @@ -148,7 +148,7 @@ static FEEL newInstance(ClassLoader cl, List profiles) { * Evaluates the given compiled FEEL expression using the * given EvaluationContext, and returns the result * - * @param expression a FEEL expression + * @param expr a FEEL expression * @param ctx the EvaluationContext to be used for defining * input variables and additional feel event listeners * contextual to this method call diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/codegen/feel11/ASTCompilerHelper.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/codegen/feel11/ASTCompilerHelper.java index 3e91a78d202..72b2013fcb9 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/codegen/feel11/ASTCompilerHelper.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/codegen/feel11/ASTCompilerHelper.java @@ -452,12 +452,7 @@ public BlockStmt add(TemporalConstantNode n) { Class fnClass = fn.getClass(); ClassOrInterfaceType fn_CT = parseClassOrInterfaceType(fnClass.getCanonicalName()); Expression fn_N = new NameExpr(fnClass.getCanonicalName()); - if (fnClass.getPackageName().equals(EXTENDED_FUNCTION_PACKAGE)) { - addVariableDeclaratorWithWithFieldAccess(fn_CT, INSTANCE_S, fn_N); - } else { - addVariableDeclaratorWithObjectCreation(fn_CT, - NodeList.nodeList()); - } + addVariableDeclaratorWithWithFieldAccess(fn_CT, INSTANCE_S, fn_N); fnVariableNameExpression = new NameExpr(lastVariableName.get()); } else { fnVariableNameExpression = new NullLiteralExpr(); diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/visitor/ASTTemporalConstantVisitor.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/visitor/ASTTemporalConstantVisitor.java index 631101b68fc..c6e4aafafaf 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/visitor/ASTTemporalConstantVisitor.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/visitor/ASTTemporalConstantVisitor.java @@ -70,8 +70,7 @@ public class ASTTemporalConstantVisitor extends DefaultedVisitor { DateAndTimeFunction.INSTANCE, DurationFunction.INSTANCE, org.kie.dmn.feel.runtime.functions.extended.TimeFunction.INSTANCE, - org.kie.dmn.feel.runtime.functions.extended.DateFunction.INSTANCE, - org.kie.dmn.feel.runtime.functions.extended.DurationFunction.INSTANCE); + org.kie.dmn.feel.runtime.functions.extended.DateFunction.INSTANCE); public static final Set TEMPORAL_FNS_NAMES = TEMPORAL_FNS.stream().map(FEELFunction::getName).collect(Collectors.toSet()); public ASTTemporalConstantVisitor(CompilerContext ctx) { @@ -200,10 +199,6 @@ private TemporalConstantNode buildTCNodeForDuration(FunctionInvocationNode n, FE FEELFnResult invoke = DurationFunction.INSTANCE.invoke(p0); return invoke.cata(e -> null, v -> new TemporalConstantNode(n, v, DurationFunction.INSTANCE, Collections.singletonList(p0))); - } else if (fn == org.kie.dmn.feel.runtime.functions.extended.DurationFunction.INSTANCE) { - FEELFnResult invoke = org.kie.dmn.feel.runtime.functions.extended.DurationFunction.INSTANCE.invoke(p0); - return invoke.cata(e -> null, - v -> new TemporalConstantNode(n, v, org.kie.dmn.feel.runtime.functions.extended.DurationFunction.INSTANCE, Collections.singletonList(p0))); } } return null; diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/Range.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/Range.java index a334beaeb9e..39666b6c858 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/Range.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/Range.java @@ -20,7 +20,7 @@ public interface Range { - static enum RangeBoundary { + enum RangeBoundary { OPEN, CLOSED; } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AbsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AbsFunction.java index a26dca7d032..e56db41af71 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AbsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AbsFunction.java @@ -30,7 +30,7 @@ public class AbsFunction extends BaseFEELFunction { public static final AbsFunction INSTANCE = new AbsFunction(); - AbsFunction() { + private AbsFunction() { super( "abs" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AllFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AllFunction.java index 08520f44fff..fb6bc4cdda4 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AllFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AllFunction.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -28,7 +29,7 @@ public class AllFunction public static final AllFunction INSTANCE = new AllFunction(); - public AllFunction() { + private AllFunction() { super( "all" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AnyFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AnyFunction.java index a8d3abff969..17e8d330634 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AnyFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AnyFunction.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -28,7 +29,7 @@ public class AnyFunction public static final AnyFunction INSTANCE = new AnyFunction(); - public AnyFunction() { + private AnyFunction() { super( "any" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AppendFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AppendFunction.java index ef5554da227..7d47e8ac0c5 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AppendFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AppendFunction.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -30,7 +31,7 @@ public class AppendFunction public static final AppendFunction INSTANCE = new AppendFunction(); - public AppendFunction() { + private AppendFunction() { super( "append" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctions.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctions.java index 6b90492713a..07f1728f6eb 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctions.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctions.java @@ -119,7 +119,20 @@ public class BuiltInFunctions { OverlapsAfterFunction.INSTANCE, MeetsFunction.INSTANCE, MetByFunction.INSTANCE, - ListReplaceFunction.INSTANCE + ListReplaceFunction.INSTANCE, + StringJoinFunction.INSTANCE, + + NowFunction.INSTANCE, + TodayFunction.INSTANCE, + ContextPutFunction.INSTANCE, + ContextMergeFunction.INSTANCE, + ContextFunction.INSTANCE, + RoundUpFunction.INSTANCE, + RoundDownFunction.INSTANCE, + RoundHalfUpFunction.INSTANCE, + RoundHalfDownFunction.INSTANCE, + + RangeFunction.INSTANCE, }; public static FEELFunction[] getFunctions() { diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java index 6d632bf93db..1fc173edbd2 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java @@ -23,14 +23,13 @@ import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; public class CeilingFunction extends BaseFEELFunction { public static final CeilingFunction INSTANCE = new CeilingFunction(); - public CeilingFunction() { + private CeilingFunction() { super( "ceiling" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunction.java index d6a295f4ff2..0d579f6c46c 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunction.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -29,7 +30,7 @@ public class ConcatenateFunction public static final ConcatenateFunction INSTANCE = new ConcatenateFunction(); - public ConcatenateFunction() { + private ConcatenateFunction() { super( "concatenate" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContainsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContainsFunction.java index 883d8367d0b..452a201d033 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContainsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContainsFunction.java @@ -26,7 +26,7 @@ public class ContainsFunction public static final ContainsFunction INSTANCE = new ContainsFunction(); - public ContainsFunction() { + private ContainsFunction() { super( "contains" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/ContextFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContextFunction.java similarity index 88% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/ContextFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContextFunction.java index 08ffd5e3020..5b5f5e7bb16 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/ContextFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContextFunction.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.util.HashMap; import java.util.List; @@ -24,20 +24,13 @@ import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; -/** - * Proposal DMN14-187 - * Experimental for DMN14-183, an inverse of `get entries()` - * See also: DMN14-181, DMN14-182 - */ + public class ContextFunction extends BaseFEELFunction { public static final ContextFunction INSTANCE = new ContextFunction(); - public ContextFunction() { + private ContextFunction() { super("context"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/ContextMergeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContextMergeFunction.java similarity index 85% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/ContextMergeFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContextMergeFunction.java index 5571b75efdf..05442f357e0 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/ContextMergeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContextMergeFunction.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.util.Collections; import java.util.HashMap; @@ -25,20 +25,12 @@ import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; -/** - * Proposal DMN14-187 - * Experimental for DMN14-182 - * See also: DMN14-181, DMN14-183 - */ public class ContextMergeFunction extends BaseFEELFunction { public static final ContextMergeFunction INSTANCE = new ContextMergeFunction(); - public ContextMergeFunction() { + private ContextMergeFunction() { super("context merge"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/ContextPutFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContextPutFunction.java similarity index 92% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/ContextPutFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContextPutFunction.java index 3c7a7216126..57d8173b325 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/ContextPutFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContextPutFunction.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.util.HashMap; import java.util.List; @@ -27,20 +27,13 @@ import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.feel.lang.types.impl.ImmutableFPAWrappingPOJO; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; -/** - * Proposal DMN14-187 - * Experimental for DMN14-181 - * See also: DMN14-182, DMN14-183 - */ + public class ContextPutFunction extends BaseFEELFunction { public static final ContextPutFunction INSTANCE = new ContextPutFunction(); - public ContextPutFunction() { + private ContextPutFunction() { super("context put"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CountFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CountFunction.java index 32d20f455f9..dc3033c6be4 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CountFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CountFunction.java @@ -24,14 +24,13 @@ import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; public class CountFunction extends BaseFEELFunction { public static final CountFunction INSTANCE = new CountFunction(); - public CountFunction() { + private CountFunction() { super( "count" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunction.java index 28de9b41c91..90f47217d92 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunction.java @@ -57,7 +57,7 @@ public class DateAndTimeFunction .toFormatter(); } - public DateAndTimeFunction() { + private DateAndTimeFunction() { super(FEELConversionFunctionNames.DATE_AND_TIME); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateFunction.java index 05f28b8bfde..1c2e07780e8 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateFunction.java @@ -51,7 +51,7 @@ public class DateFunction .withResolverStyle(ResolverStyle.STRICT); } - public DateFunction() { + protected DateFunction() { super(FEELConversionFunctionNames.DATE); } @@ -66,7 +66,7 @@ public FEELFnResult invoke(@ParameterName( "from" ) String val try { return FEELFnResult.ofResult(LocalDate.from(FEEL_DATE.parse(val))); } catch (DateTimeException e) { - return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "date", e)); + return manageDateTimeException(e, val); } } @@ -99,4 +99,8 @@ public FEELFnResult invoke(@ParameterName( "from" ) TemporalAc return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "date-parsing exception", e)); } } + + protected FEELFnResult manageDateTimeException(DateTimeException e, String val) { + return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "date", e)); + } } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DayOfWeekFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DayOfWeekFunction.java index becac394fe5..ff2ac9a53f8 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DayOfWeekFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DayOfWeekFunction.java @@ -29,7 +29,7 @@ public class DayOfWeekFunction extends BaseFEELFunction { public static final DayOfWeekFunction INSTANCE = new DayOfWeekFunction(); - DayOfWeekFunction() { + private DayOfWeekFunction() { super("day of week"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DayOfYearFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DayOfYearFunction.java index 9a218dcbefd..5354d2efc1b 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DayOfYearFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DayOfYearFunction.java @@ -29,7 +29,7 @@ public class DayOfYearFunction extends BaseFEELFunction { public static final DayOfYearFunction INSTANCE = new DayOfYearFunction(); - DayOfYearFunction() { + private DayOfYearFunction() { super("day of year"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecimalFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecimalFunction.java index b62266cda32..e1dce2f1cfc 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecimalFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecimalFunction.java @@ -23,14 +23,13 @@ import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; public class DecimalFunction extends BaseFEELFunction { public static final DecimalFunction INSTANCE = new DecimalFunction(); - public DecimalFunction() { + private DecimalFunction() { super( "decimal" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java index 5643ee5922d..80437477ada 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java @@ -50,7 +50,7 @@ public class DecisionTableFunction private static final Logger LOG = LoggerFactory.getLogger( DecisionTableFunction.class ); - public DecisionTableFunction() { + private DecisionTableFunction() { super( "decision table" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunction.java index 3de0a290ac9..65a43ab3bc8 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunction.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -29,7 +30,7 @@ public class DistinctValuesFunction public static final DistinctValuesFunction INSTANCE = new DistinctValuesFunction(); - public DistinctValuesFunction() { + private DistinctValuesFunction() { super( "distinct values" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DurationFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DurationFunction.java index acf5d8ab587..b6ddaccd0a3 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DurationFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DurationFunction.java @@ -33,7 +33,7 @@ public class DurationFunction public static final DurationFunction INSTANCE = new DurationFunction(); - public DurationFunction() { + private DurationFunction() { super(FEELConversionFunctionNames.DURATION); } @@ -42,10 +42,6 @@ public FEELFnResult invoke(@ParameterName( "from" ) String val) return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "cannot be null")); } - if ( val.indexOf("-") > 0) { - return FEELFnResult.ofError( new InvalidParametersEvent(Severity.ERROR, "from", "negative values for units are not allowed.") ); - } - try { // try to parse as days/hours/minute/seconds return FEELFnResult.ofResult( Duration.parse( val ) ); diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EndsWithFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EndsWithFunction.java index bbf0b64d037..04b4e4bf6e2 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EndsWithFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EndsWithFunction.java @@ -26,7 +26,7 @@ public class EndsWithFunction public static final EndsWithFunction INSTANCE = new EndsWithFunction(); - public EndsWithFunction() { + private EndsWithFunction() { super( "ends with" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EvenFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EvenFunction.java index 259455ebe0e..5bf86b2ed21 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EvenFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EvenFunction.java @@ -18,18 +18,18 @@ */ package org.kie.dmn.feel.runtime.functions; +import java.math.BigDecimal; + import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import java.math.BigDecimal; - public class EvenFunction extends BaseFEELFunction { public static final EvenFunction INSTANCE = new EvenFunction(); private static final BigDecimal TWO = BigDecimal.valueOf(2); - EvenFunction() { + private EvenFunction() { super("even"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ExpFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ExpFunction.java index 4b17ef39a27..9fc25f9b8ba 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ExpFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ExpFunction.java @@ -29,7 +29,7 @@ public class ExpFunction extends BaseFEELFunction { public static final ExpFunction INSTANCE = new ExpFunction(); - ExpFunction() { + private ExpFunction() { super("exp"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FlattenFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FlattenFunction.java index 9194eb9da4e..314b5829b0c 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FlattenFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FlattenFunction.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -29,7 +30,7 @@ public class FlattenFunction public static final FlattenFunction INSTANCE = new FlattenFunction(); - public FlattenFunction() { + private FlattenFunction() { super( "flatten" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FloorFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FloorFunction.java index f2b26d40ce6..9e05a16a739 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FloorFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FloorFunction.java @@ -29,7 +29,7 @@ public class FloorFunction public static final FloorFunction INSTANCE = new FloorFunction(); - public FloorFunction() { + private FloorFunction() { super( "floor" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetEntriesFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetEntriesFunction.java index aba3972368e..69c2d4d7f45 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetEntriesFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetEntriesFunction.java @@ -25,13 +25,12 @@ import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.extended.ContextPutFunction; public class GetEntriesFunction extends BaseFEELFunction { public static final GetEntriesFunction INSTANCE = new GetEntriesFunction(); - public GetEntriesFunction() { + private GetEntriesFunction() { super("get entries"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetValueFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetValueFunction.java index 1dee390bcdc..89fc3a3e09c 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetValueFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetValueFunction.java @@ -29,7 +29,7 @@ public class GetValueFunction extends BaseFEELFunction { public static final GetValueFunction INSTANCE = new GetValueFunction(); - public GetValueFunction() { + private GetValueFunction() { super("get value"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IndexOfFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IndexOfFunction.java index 529901d8b00..7bca208b845 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IndexOfFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IndexOfFunction.java @@ -21,6 +21,7 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -29,7 +30,7 @@ public class IndexOfFunction public static final IndexOfFunction INSTANCE = new IndexOfFunction(); - public IndexOfFunction() { + private IndexOfFunction() { super( "index of" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunction.java index ba2a587958d..78e7c151ad0 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunction.java @@ -21,6 +21,7 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -29,7 +30,7 @@ public class InsertBeforeFunction public static final InsertBeforeFunction INSTANCE = new InsertBeforeFunction(); - public InsertBeforeFunction() { + private InsertBeforeFunction() { super( "insert before" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IsFunction.java index b45d128ae43..36a225d3567 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IsFunction.java @@ -23,12 +23,11 @@ import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.feel.util.BooleanEvalHelper; -import org.kie.dmn.feel.util.EvalHelper; public class IsFunction extends BaseFEELFunction { public static final IsFunction INSTANCE = new IsFunction(); - IsFunction() { + private IsFunction() { super("is"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ListContainsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ListContainsFunction.java index d4e92df21ee..c14853f0a96 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ListContainsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ListContainsFunction.java @@ -31,7 +31,7 @@ public class ListContainsFunction public static final ListContainsFunction INSTANCE = new ListContainsFunction(); - public ListContainsFunction() { + private ListContainsFunction() { super( "list contains" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/LogFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/LogFunction.java index 7c98cc99542..6d8925c2ef1 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/LogFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/LogFunction.java @@ -29,7 +29,7 @@ public class LogFunction extends BaseFEELFunction { public static final LogFunction INSTANCE = new LogFunction(); - LogFunction() { + private LogFunction() { super("log"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MatchesFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MatchesFunction.java index e13beaa0fc3..f6b1806ca20 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MatchesFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MatchesFunction.java @@ -18,19 +18,19 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; - import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; +import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; + public class MatchesFunction extends BaseFEELFunction { public static final MatchesFunction INSTANCE = new MatchesFunction(); - public MatchesFunction() { + private MatchesFunction() { super( "matches" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MaxFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MaxFunction.java index 2310dfc4652..bb4a5f9665d 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MaxFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MaxFunction.java @@ -31,7 +31,7 @@ public class MaxFunction public static final MaxFunction INSTANCE = new MaxFunction(); - public MaxFunction() { + private MaxFunction() { super( "max" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MeanFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MeanFunction.java index c53dc339952..0d940380ba7 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MeanFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MeanFunction.java @@ -36,7 +36,7 @@ public class MeanFunction private SumFunction sum = SumFunction.INSTANCE; - public MeanFunction() { + private MeanFunction() { super( "mean" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MedianFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MedianFunction.java index e2a6a6c7092..1340e3a42d8 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MedianFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MedianFunction.java @@ -31,7 +31,7 @@ public class MedianFunction extends BaseFEELFunction { public static final MedianFunction INSTANCE = new MedianFunction(); - MedianFunction() { + private MedianFunction() { super("median"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MinFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MinFunction.java index 81a44c0e96f..c7cc8509e97 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MinFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MinFunction.java @@ -31,7 +31,7 @@ public class MinFunction public static final MinFunction INSTANCE = new MinFunction(); - public MinFunction() { + private MinFunction() { super( "min" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ModeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ModeFunction.java index 09224dcc621..e5807c9ff06 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ModeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ModeFunction.java @@ -35,7 +35,7 @@ public class ModeFunction extends BaseFEELFunction { public static final ModeFunction INSTANCE = new ModeFunction(); - ModeFunction() { + private ModeFunction() { super("mode"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ModuloFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ModuloFunction.java index ad0aa35b170..d9f78893cb9 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ModuloFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ModuloFunction.java @@ -28,7 +28,7 @@ public class ModuloFunction extends BaseFEELFunction { public static final ModuloFunction INSTANCE = new ModuloFunction(); - ModuloFunction() { + private ModuloFunction() { super( "modulo" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MonthOfYearFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MonthOfYearFunction.java index 8aa7c197fc3..76a231c55d1 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MonthOfYearFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MonthOfYearFunction.java @@ -29,7 +29,7 @@ public class MonthOfYearFunction extends BaseFEELFunction { public static final MonthOfYearFunction INSTANCE = new MonthOfYearFunction(); - MonthOfYearFunction() { + private MonthOfYearFunction() { super("month of year"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NotFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NotFunction.java index 287c63331e3..c099876dbf5 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NotFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NotFunction.java @@ -31,7 +31,7 @@ public class NotFunction public static final NotFunction INSTANCE = new NotFunction(); - public NotFunction() { + private NotFunction() { super( "not" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/NowFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NowFunction.java similarity index 84% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/NowFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NowFunction.java index c9a2bd61a9d..73c5a1ce455 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/NowFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NowFunction.java @@ -16,18 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.time.ZonedDateTime; import java.time.temporal.TemporalAccessor; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; - public class NowFunction extends BaseFEELFunction { - public NowFunction() { + public static final NowFunction INSTANCE = new NowFunction(); + + private NowFunction() { super( "now" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NumberFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NumberFunction.java index 822b592ba7c..54759f5f2d9 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NumberFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NumberFunction.java @@ -29,7 +29,7 @@ public class NumberFunction public static final NumberFunction INSTANCE = new NumberFunction(); - public NumberFunction() { + private NumberFunction() { super(FEELConversionFunctionNames.NUMBER); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/OddFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/OddFunction.java index e4eec63f036..c32176d594a 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/OddFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/OddFunction.java @@ -18,18 +18,18 @@ */ package org.kie.dmn.feel.runtime.functions; +import java.math.BigDecimal; + import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import java.math.BigDecimal; - public class OddFunction extends BaseFEELFunction { public static final OddFunction INSTANCE = new OddFunction(); private static final BigDecimal TWO = BigDecimal.valueOf(2); - OddFunction() { + private OddFunction() { super("odd"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ProductFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ProductFunction.java index 689dfafe3af..11462667c87 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ProductFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ProductFunction.java @@ -30,7 +30,7 @@ public class ProductFunction extends BaseFEELFunction { public static final ProductFunction INSTANCE = new ProductFunction(); - ProductFunction() { + private ProductFunction() { super( "product" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RangeFunction.java similarity index 87% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RangeFunction.java index 1eac4c6dfe6..9dab904aca7 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RangeFunction.java @@ -16,13 +16,32 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; + +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.ZonedDateTime; +import java.time.chrono.ChronoPeriod; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.function.Predicate; import org.antlr.v4.runtime.tree.ParseTree; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.lang.FEELDialect; -import org.kie.dmn.feel.lang.ast.*; +import org.kie.dmn.feel.lang.ast.AtLiteralNode; +import org.kie.dmn.feel.lang.ast.BaseNode; +import org.kie.dmn.feel.lang.ast.FunctionInvocationNode; +import org.kie.dmn.feel.lang.ast.NullNode; +import org.kie.dmn.feel.lang.ast.NumberNode; +import org.kie.dmn.feel.lang.ast.StringNode; import org.kie.dmn.feel.lang.impl.EvaluationContextImpl; import org.kie.dmn.feel.lang.impl.FEELEventListenersManager; import org.kie.dmn.feel.parser.feel11.ASTBuilderVisitor; @@ -31,24 +50,14 @@ import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; import org.kie.dmn.feel.runtime.impl.RangeImpl; -import java.time.*; -import java.time.chrono.ChronoPeriod; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.function.Predicate; - public class RangeFunction extends BaseFEELFunction { public static final RangeFunction INSTANCE = new RangeFunction(); - // Defaulting FEELDialect to FEEL - private static final EvaluationContext STUBBED = new EvaluationContextImpl(Thread.currentThread().getContextClassLoader(), new FEELEventListenersManager(), 0, FEELDialect.FEEL); + + private static EvaluationContext STUBBED; + private static final List> ALLOWED_NODES = Arrays.asList(baseNode -> baseNode instanceof NullNode, baseNode -> baseNode instanceof NumberNode, @@ -69,7 +78,7 @@ public class RangeFunction extends BaseFEELFunction { object -> object instanceof LocalTime); - public RangeFunction() { + private RangeFunction() { super("range"); } @@ -111,12 +120,12 @@ public FEELFnResult invoke(@ParameterName("from") String from) { if (!nodeIsAllowed(rightNode)) { return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "right endpoint is not a recognised valid literal")); } - Object left = leftNode.evaluate(STUBBED); + Object left = leftNode.evaluate(getStubbed()); if (!nodeValueIsAllowed(left)) { return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "left endpoint is not a valid value " + left.getClass())); } - Object right = rightNode.evaluate(STUBBED); + Object right = rightNode.evaluate(getStubbed()); if (!nodeValueIsAllowed(right)) { return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "right endpoint is not a valid value " + right.getClass())); } @@ -169,4 +178,13 @@ protected BaseNode parseNotEmptyInput(String input) { return expr; } + private EvaluationContext getStubbed() { + if (STUBBED == null) { + // Defaulting FEELDialect to FEEL + STUBBED = new EvaluationContextImpl(Thread.currentThread().getContextClassLoader(), + new FEELEventListenersManager(), 0, FEELDialect.FEEL); + } + return STUBBED; + } + } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RemoveFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RemoveFunction.java index f4ee82a787e..9a7734a60a6 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RemoveFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RemoveFunction.java @@ -21,6 +21,7 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -29,7 +30,7 @@ public class RemoveFunction public static final RemoveFunction INSTANCE = new RemoveFunction(); - public RemoveFunction() { + private RemoveFunction() { super( "remove" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReplaceFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReplaceFunction.java index 11a041d4ae4..723efcbdd36 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReplaceFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReplaceFunction.java @@ -26,7 +26,7 @@ public class ReplaceFunction public static final ReplaceFunction INSTANCE = new ReplaceFunction(); - public ReplaceFunction() { + private ReplaceFunction() { super( "replace" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReverseFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReverseFunction.java index 6b588868e78..233f7c70938 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReverseFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReverseFunction.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -29,7 +30,7 @@ public class ReverseFunction public static final ReverseFunction INSTANCE = new ReverseFunction(); - public ReverseFunction() { + private ReverseFunction() { super( "reverse" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundDownFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundDownFunction.java similarity index 87% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundDownFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundDownFunction.java index 0a67a7d31f7..eb645198613 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundDownFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundDownFunction.java @@ -16,26 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; import java.math.RoundingMode; import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; -/** - * provisional access for DMN14-126 - */ public class RoundDownFunction extends BaseFEELFunction { public static final RoundDownFunction INSTANCE = new RoundDownFunction(); - public RoundDownFunction() { + private RoundDownFunction() { super( "round down" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfDownFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundHalfDownFunction.java similarity index 87% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfDownFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundHalfDownFunction.java index 5d5648cc55d..08829325c58 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfDownFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundHalfDownFunction.java @@ -16,26 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; import java.math.RoundingMode; import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; -/** - * provisional access for DMN14-126 - */ public class RoundHalfDownFunction extends BaseFEELFunction { public static final RoundHalfDownFunction INSTANCE = new RoundHalfDownFunction(); - public RoundHalfDownFunction() { + private RoundHalfDownFunction() { super( "round half down" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfUpFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundHalfUpFunction.java similarity index 87% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfUpFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundHalfUpFunction.java index 990f19c5dd2..da9b000e4e9 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfUpFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundHalfUpFunction.java @@ -16,26 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; import java.math.RoundingMode; import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; -/** - * provisional access for DMN14-126 - */ public class RoundHalfUpFunction extends BaseFEELFunction { public static final RoundHalfUpFunction INSTANCE = new RoundHalfUpFunction(); - public RoundHalfUpFunction() { + private RoundHalfUpFunction() { super( "round half up" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundUpFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundUpFunction.java similarity index 87% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundUpFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundUpFunction.java index e17c90d57df..d840526bbed 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/RoundUpFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RoundUpFunction.java @@ -16,26 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; import java.math.RoundingMode; import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; -/** - * provisional access for DMN14-126 - */ public class RoundUpFunction extends BaseFEELFunction { public static final RoundUpFunction INSTANCE = new RoundUpFunction(); - public RoundUpFunction() { + private RoundUpFunction() { super( "round up" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SortFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SortFunction.java index 8d091ec684b..48450eabcb1 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SortFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SortFunction.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.runtime.FEELFunction; @@ -31,7 +32,7 @@ public class SortFunction public static final SortFunction INSTANCE = new SortFunction(); - public SortFunction() { + private SortFunction() { super( "sort" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SplitFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SplitFunction.java index ba633d17eee..d7c31332ffa 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SplitFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SplitFunction.java @@ -29,7 +29,7 @@ public class SplitFunction extends BaseFEELFunction { public static final SplitFunction INSTANCE = new SplitFunction(); - SplitFunction() { + private SplitFunction() { super( "split" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SqrtFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SqrtFunction.java index 90e0521157e..e2ec2d7a597 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SqrtFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SqrtFunction.java @@ -30,7 +30,7 @@ public class SqrtFunction extends BaseFEELFunction { public static final SqrtFunction INSTANCE = new SqrtFunction(); - SqrtFunction() { + private SqrtFunction() { super("sqrt"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StartsWithFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StartsWithFunction.java index 6fac9e2708c..c5029643fb0 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StartsWithFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StartsWithFunction.java @@ -26,7 +26,7 @@ public class StartsWithFunction public static final StartsWithFunction INSTANCE = new StartsWithFunction(); - public StartsWithFunction() { + private StartsWithFunction() { super( "starts with" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StddevFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StddevFunction.java index 88a3484e9a6..de7451bb13f 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StddevFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StddevFunction.java @@ -25,7 +25,6 @@ import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.util.EvalHelper; import org.kie.dmn.feel.util.NumberEvalHelper; // based on the examples of calculations, stddev is supposed to return sample standard deviation, not population standard deviation @@ -33,7 +32,7 @@ public class StddevFunction extends BaseFEELFunction { public static final StddevFunction INSTANCE = new StddevFunction(); - StddevFunction() { + private StddevFunction() { super("stddev"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringFunction.java index a5b5629360b..a95dbbb80e9 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringFunction.java @@ -27,7 +27,7 @@ public class StringFunction public static final StringFunction INSTANCE = new StringFunction(); - public StringFunction() { + private StringFunction() { super(FEELConversionFunctionNames.STRING); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/StringJoinFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringJoinFunction.java similarity index 90% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/StringJoinFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringJoinFunction.java index 3ee399fc18e..532da277c54 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/StringJoinFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringJoinFunction.java @@ -16,22 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.util.List; import java.util.StringJoiner; import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; public class StringJoinFunction extends BaseFEELFunction { public static final StringJoinFunction INSTANCE = new StringJoinFunction(); - public StringJoinFunction() { + private StringJoinFunction() { super("string join"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLengthFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLengthFunction.java index e1c673102a7..630a2bfd150 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLengthFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLengthFunction.java @@ -29,7 +29,7 @@ public class StringLengthFunction public static final StringLengthFunction INSTANCE = new StringLengthFunction(); - public StringLengthFunction() { + private StringLengthFunction() { super( "string length" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunction.java index c3ee83c4994..bc238d6a035 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunction.java @@ -26,7 +26,7 @@ public class StringLowerCaseFunction public static final StringLowerCaseFunction INSTANCE = new StringLowerCaseFunction(); - public StringLowerCaseFunction() { + private StringLowerCaseFunction() { super( "lower case" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunction.java index 4bffb14476d..481301fd4d7 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunction.java @@ -26,7 +26,7 @@ public class StringUpperCaseFunction public static final StringUpperCaseFunction INSTANCE = new StringUpperCaseFunction(); - public StringUpperCaseFunction() { + private StringUpperCaseFunction() { super( "upper case" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SublistFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SublistFunction.java index 261b75e942b..068b2445da5 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SublistFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SublistFunction.java @@ -20,6 +20,7 @@ import java.math.BigDecimal; import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -28,7 +29,7 @@ public class SublistFunction public static final SublistFunction INSTANCE = new SublistFunction(); - public SublistFunction() { + private SublistFunction() { super( "sublist" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunction.java index c0e036d9df0..d7c060f6fe1 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunction.java @@ -26,7 +26,7 @@ public class SubstringAfterFunction public static final SubstringAfterFunction INSTANCE = new SubstringAfterFunction(); - public SubstringAfterFunction() { + private SubstringAfterFunction() { super( "substring after" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunction.java index 689bab3ca60..32c8a3082e6 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunction.java @@ -26,7 +26,7 @@ public class SubstringBeforeFunction public static final SubstringBeforeFunction INSTANCE = new SubstringBeforeFunction(); - public SubstringBeforeFunction() { + private SubstringBeforeFunction() { super( "substring before" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringFunction.java index cd5f1939aeb..87d01b2ce5b 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringFunction.java @@ -28,7 +28,7 @@ public class SubstringFunction public static final SubstringFunction INSTANCE = new SubstringFunction(); - public SubstringFunction() { + private SubstringFunction() { super( "substring" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SumFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SumFunction.java index aa2e30013c7..86d3a0310c2 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SumFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SumFunction.java @@ -24,7 +24,6 @@ import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.util.EvalHelper; import org.kie.dmn.feel.util.NumberEvalHelper; public class SumFunction @@ -32,7 +31,7 @@ public class SumFunction public static final SumFunction INSTANCE = new SumFunction(); - public SumFunction() { + private SumFunction() { super( "sum" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/TimeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/TimeFunction.java index 7bcd6e76d50..8150480613b 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/TimeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/TimeFunction.java @@ -63,7 +63,14 @@ public class TimeFunction .withResolverStyle(ResolverStyle.STRICT); } - public TimeFunction() { + public static boolean timeStringWithSeconds(String val) { + return timePattern.matcher(val).find(); + } + + private static final BigDecimal NANO_MULT = BigDecimal.valueOf( 1000000000 ); + + + protected TimeFunction() { super(FEELConversionFunctionNames.TIME); } @@ -71,7 +78,6 @@ public FEELFnResult invoke(@ParameterName("from") String val) if ( val == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "cannot be null")); } - try { TemporalAccessor parsed = FEEL_TIME.parse(val); @@ -90,19 +96,12 @@ public FEELFnResult invoke(@ParameterName("from") String val) ZoneTime zoneTime = ZoneTime.of(asLocalTime, zoneId, hasSeconds); return FEELFnResult.ofResult(zoneTime); } - return FEELFnResult.ofResult(parsed); } catch (DateTimeException e) { - return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", e)); + return manageDateTimeException(e, val); } } - public static boolean timeStringWithSeconds(String val) { - return timePattern.matcher(val).find(); - } - - private static final BigDecimal NANO_MULT = BigDecimal.valueOf( 1000000000 ); - public FEELFnResult invoke( @ParameterName("hour") Number hour, @ParameterName("minute") Number minute, @ParameterName("second") Number seconds) { @@ -171,4 +170,8 @@ public FEELFnResult invoke(@ParameterName("from") TemporalAcce } } + protected FEELFnResult manageDateTimeException(DateTimeException e, String val) { + return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", e)); + } + } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/TodayFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/TodayFunction.java similarity index 84% rename from kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/TodayFunction.java rename to kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/TodayFunction.java index d392ec6803e..d0ff403ef64 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/TodayFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/TodayFunction.java @@ -16,18 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.time.LocalDate; import java.time.temporal.TemporalAccessor; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; - public class TodayFunction extends BaseFEELFunction { - public TodayFunction() { + public static final TodayFunction INSTANCE = new TodayFunction(); + + private TodayFunction() { super( "today" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/UnionFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/UnionFunction.java index 926627a26ed..81926dd3a66 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/UnionFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/UnionFunction.java @@ -23,6 +23,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -31,7 +32,7 @@ public class UnionFunction public static final UnionFunction INSTANCE = new UnionFunction(); - public UnionFunction() { + private UnionFunction() { super( "union" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/WeekOfYearFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/WeekOfYearFunction.java index a01aeeae339..eb272d0e183 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/WeekOfYearFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/WeekOfYearFunction.java @@ -24,13 +24,12 @@ import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.util.EvalHelper; import org.kie.dmn.feel.util.NumberEvalHelper; public class WeekOfYearFunction extends BaseFEELFunction { public static final WeekOfYearFunction INSTANCE = new WeekOfYearFunction(); - WeekOfYearFunction() { + private WeekOfYearFunction() { super("week of year"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunction.java index fad88161e98..4e53a238937 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunction.java @@ -35,7 +35,7 @@ public class YearsAndMonthsFunction public static final YearsAndMonthsFunction INSTANCE = new YearsAndMonthsFunction(); - public YearsAndMonthsFunction() { + private YearsAndMonthsFunction() { super(FEELConversionFunctionNames.YEARS_AND_MONTHS_DURATION); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/CeilingFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/CeilingFunction.java deleted file mode 100644 index a406a26bc1e..00000000000 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/CeilingFunction.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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.runtime.functions.extended; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; - -/** - * provisional access for DMN14-126 - */ -public class CeilingFunction - extends BaseFEELFunction { - - public static final CeilingFunction INSTANCE = new CeilingFunction(); - - public CeilingFunction() { - super( "ceiling" ); - } - - public FEELFnResult invoke(@ParameterName( "n" ) BigDecimal n) { - return invoke(n, BigDecimal.ZERO); - } - - public FEELFnResult invoke(@ParameterName( "n" ) BigDecimal n, @ParameterName( "scale" ) BigDecimal scale) { - if ( n == null ) { - return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "n", "cannot be null")); - } - if ( scale == null ) { - return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null")); - } - return FEELFnResult.ofResult( n.setScale( scale.intValue(), RoundingMode.CEILING ) ); - } -} diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/CodeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/CodeFunction.java index d353251de84..a844b5e823c 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/CodeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/CodeFunction.java @@ -26,7 +26,9 @@ public class CodeFunction extends BaseFEELFunction { - public CodeFunction() { + public static final CodeFunction INSTANCE = new CodeFunction(); + + private CodeFunction() { super( "code" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/DateFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/DateFunction.java index e40fd3a77b4..addf07c0166 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/DateFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/DateFunction.java @@ -19,94 +19,48 @@ package org.kie.dmn.feel.runtime.functions.extended; import java.time.DateTimeException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.time.format.ResolverStyle; -import java.time.format.SignStyle; import java.time.temporal.TemporalAccessor; -import java.util.regex.Pattern; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; import org.kie.dmn.feel.runtime.functions.BuiltInFunctions; import org.kie.dmn.feel.runtime.functions.DateAndTimeFunction; -import org.kie.dmn.feel.runtime.functions.FEELConversionFunctionNames; import org.kie.dmn.feel.runtime.functions.FEELFnResult; import org.kie.dmn.feel.runtime.functions.ParameterName; -import static java.time.temporal.ChronoField.DAY_OF_MONTH; -import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static java.time.temporal.ChronoField.YEAR; - -public class DateFunction extends BaseFEELFunction { +/** + * This class overrides parent methods due to BaseFEELFunction#getCandidateMethod implementation + */ +public class DateFunction extends org.kie.dmn.feel.runtime.functions.DateFunction { public static final DateFunction INSTANCE = new DateFunction(); - private static final Pattern BEGIN_YEAR = Pattern.compile("^-?(([1-9]\\d\\d\\d+)|(0\\d\\d\\d))-"); // FEEL spec, "specified by XML Schema Part 2 Datatypes", hence: yearFrag ::= '-'? (([1-9] digit digit digit+)) | ('0' digit digit digit)) - private static final DateTimeFormatter FEEL_DATE; - - static { - FEEL_DATE = new DateTimeFormatterBuilder().appendValue(YEAR, 4, 9, SignStyle.NORMAL) - .appendLiteral('-') - .appendValue(MONTH_OF_YEAR, 2) - .appendLiteral('-') - .appendValue(DAY_OF_MONTH, 2) - .toFormatter() - .withResolverStyle(ResolverStyle.STRICT); - } - - DateFunction() { - super(FEELConversionFunctionNames.DATE); + private DateFunction() { } + @Override public FEELFnResult invoke(@ParameterName("from") String val) { - if (val == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "cannot be null")); - } - if (!BEGIN_YEAR.matcher(val).find()) { // please notice the regex strictly requires the beginning, so we can use find. - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "year not compliant with XML Schema Part 2 Datatypes")); - } - - try { - return FEELFnResult.ofResult(LocalDate.from(FEEL_DATE.parse(val))); - } catch (DateTimeException e) { - // try to parse it as a date time and extract the date component - // NOTE: this is an extension to the standard - return BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(val) - .cata(overrideLeft -> FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "date-parsing exception", e)), - this::invoke - ); - } + return super.invoke(val); } - public FEELFnResult invoke(@ParameterName("year") Number year, @ParameterName("month") Number month, @ParameterName("day") Number day) { - if (year == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "year", "cannot be null")); - } - if (month == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "month", "cannot be null")); - } - if (day == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "day", "cannot be null")); - } - - try { - return FEELFnResult.ofResult(LocalDate.of(year.intValue(), month.intValue(), day.intValue())); - } catch (DateTimeException e) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "input parameters date-parsing exception", e)); - } + @Override + public FEELFnResult invoke(@ParameterName( "year" ) Number year, @ParameterName( "month" ) Number month, @ParameterName( "day" ) Number day) { + return super.invoke(year, month, day); } - public FEELFnResult invoke(@ParameterName("from") TemporalAccessor date) { - if (date == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "cannot be null")); - } + @Override + public FEELFnResult invoke(@ParameterName( "from" ) TemporalAccessor date) { + return super.invoke(date); + } - try { - return FEELFnResult.ofResult(LocalDate.from(date)); - } catch (DateTimeException e) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "date-parsing exception", e)); - } + @Override + protected FEELFnResult manageDateTimeException(DateTimeException e, String val) { + // try to parse it as a date time and extract the date component + // NOTE: this is an extension to the standard + return BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(val) + .cata(overrideLeft -> FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from" + , "date-parsing exception", e)), + this::invoke + ); } + } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/DurationFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/DurationFunction.java deleted file mode 100644 index 869efea0035..00000000000 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/DurationFunction.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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.runtime.functions.extended; - -import java.time.Duration; -import java.time.format.DateTimeParseException; -import java.time.temporal.TemporalAmount; -import java.util.Arrays; -import java.util.List; - -import org.kie.dmn.api.feel.runtime.events.FEELEvent; -import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELConversionFunctionNames; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; - -public class DurationFunction extends BaseFEELFunction { - public static final DurationFunction INSTANCE = new DurationFunction(); - - DurationFunction() { - super(FEELConversionFunctionNames.DURATION); - } - - public FEELFnResult invoke(@ParameterName( "from" ) String val) { - if ( val == null ) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "cannot be null")); - } - - try { - // try to parse as days/hours/minute/seconds - return FEELFnResult.ofResult( Duration.parse( val ) ); - } catch( DateTimeParseException e ) { - // if it failed, try to parse as years/months - try { - return FEELFnResult.ofResult(ComparablePeriod.parse(val).normalized()); - } catch( DateTimeParseException e2 ) { - // failed to parse, so return null according to the spec - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "date-parsing exception", - new RuntimeException(new Throwable() { public final List causes = Arrays.asList( new Throwable[]{e, e2} ); } ))); - } - } - - } - - public FEELFnResult invoke(@ParameterName( "from" ) TemporalAmount val) { - if ( val == null ) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "cannot be null")); - } - return FEELFnResult.ofResult( val ); - } - -} diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/FloorFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/FloorFunction.java deleted file mode 100644 index 3fefcca6788..00000000000 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/FloorFunction.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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.runtime.functions.extended; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.ParameterName; - -/** - * provisional access for DMN14-126 - */ -public class FloorFunction - extends BaseFEELFunction { - - public static final FloorFunction INSTANCE = new FloorFunction(); - - public FloorFunction() { - super( "floor" ); - } - - public FEELFnResult invoke(@ParameterName( "n" ) BigDecimal n) { - return invoke(n, BigDecimal.ZERO); - } - - public FEELFnResult invoke(@ParameterName( "n" ) BigDecimal n, @ParameterName( "scale" ) BigDecimal scale) { - if ( n == null ) { - return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "n", "cannot be null")); - } - if ( scale == null ) { - return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null")); - } - return FEELFnResult.ofResult( n.setScale( scale.intValue(), RoundingMode.FLOOR ) ); - } -} diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/InvokeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/InvokeFunction.java index f6c005ae5c7..3a1ac7cdbd2 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/InvokeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/InvokeFunction.java @@ -39,7 +39,9 @@ @Deprecated public class InvokeFunction extends BaseFEELFunction { - public InvokeFunction() { + public static final InvokeFunction INSTANCE = new InvokeFunction(); + + private InvokeFunction() { super("invoke"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/KieExtendedDMNFunctions.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/KieExtendedDMNFunctions.java index e6ab02e2993..6a4d89ef648 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/KieExtendedDMNFunctions.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/KieExtendedDMNFunctions.java @@ -40,23 +40,10 @@ public class KieExtendedDMNFunctions { protected static final FEELFunction[] FUNCTIONS = new FEELFunction[]{ TimeFunction.INSTANCE, DateFunction.INSTANCE, - DurationFunction.INSTANCE, // additional functions not part of the spec version 1.1 - new NowFunction(), - new TodayFunction(), - new CodeFunction(), - new InvokeFunction(), - - ContextPutFunction.INSTANCE, - ContextMergeFunction.INSTANCE, - ContextFunction.INSTANCE, - FloorFunction.INSTANCE, - CeilingFunction.INSTANCE, - RoundUpFunction.INSTANCE, - RoundDownFunction.INSTANCE, - RoundHalfUpFunction.INSTANCE, - RoundHalfDownFunction.INSTANCE, + CodeFunction.INSTANCE, + InvokeFunction.INSTANCE, // CQL based, two value logic functions NNAnyFunction.INSTANCE, @@ -70,9 +57,6 @@ public class KieExtendedDMNFunctions { NNStddevFunction.INSTANCE, NNSumFunction.INSTANCE, - StringJoinFunction.INSTANCE, - RangeFunction.INSTANCE, - }; public static FEELFunction[] getFunctions() { diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/TimeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/TimeFunction.java index 744474dd615..3c7aa4593e6 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/TimeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/extended/TimeFunction.java @@ -18,158 +18,58 @@ */ package org.kie.dmn.feel.runtime.functions.extended; -import java.math.BigDecimal; -import java.math.RoundingMode; import java.time.DateTimeException; import java.time.Duration; -import java.time.LocalTime; -import java.time.OffsetTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.time.format.ResolverStyle; -import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQueries; import org.kie.dmn.api.feel.runtime.events.FEELEvent; -import org.kie.dmn.feel.runtime.custom.ZoneTime; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; import org.kie.dmn.feel.runtime.functions.BuiltInFunctions; import org.kie.dmn.feel.runtime.functions.DateAndTimeFunction; -import org.kie.dmn.feel.runtime.functions.FEELConversionFunctionNames; import org.kie.dmn.feel.runtime.functions.FEELFnResult; import org.kie.dmn.feel.runtime.functions.ParameterName; -import static org.kie.dmn.feel.runtime.functions.TimeFunction.timeStringWithSeconds; - -public class TimeFunction extends BaseFEELFunction { +/** + * This class overrides parent methods due to BaseFEELFunction#getCandidateMethod implementation + */ +public class TimeFunction extends org.kie.dmn.feel.runtime.functions.TimeFunction { public static final TimeFunction INSTANCE = new TimeFunction(); - private static final DateTimeFormatter FEEL_TIME; - - static { - FEEL_TIME = new DateTimeFormatterBuilder().parseCaseInsensitive() - .append(DateTimeFormatter.ISO_LOCAL_TIME) - .optionalStart() - .appendLiteral("@") - .appendZoneRegionId() - .optionalEnd() - .optionalStart() - .appendOffsetId() - .optionalEnd() - .toFormatter() - .withResolverStyle(ResolverStyle.STRICT); - } - - TimeFunction() { - super(FEELConversionFunctionNames.TIME); + private TimeFunction() { } + @Override public FEELFnResult invoke(@ParameterName("from") String val) { - if (val == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "cannot be null")); - } - - try { - TemporalAccessor parsed = FEEL_TIME.parse(val); - - if (parsed.query(TemporalQueries.offset()) != null) { - // it is an offset-zoned time, so I can know for certain an OffsetTime - OffsetTime asOffSetTime = parsed.query(OffsetTime::from); - return FEELFnResult.ofResult(asOffSetTime); - } else if (parsed.query(TemporalQueries.zone()) == null) { - // if it does not contain any zone information at all, then I know for certain is a local time. - LocalTime asLocalTime = parsed.query(LocalTime::from); - return FEELFnResult.ofResult(asLocalTime); - } else if (parsed.query(TemporalQueries.zone()) != null) { - boolean hasZeroSeconds = timeStringWithSeconds(val); - LocalTime asLocalTime = parsed.query(LocalTime::from); - ZoneId zoneId = parsed.query(TemporalQueries.zone()); - ZoneTime zoneTime = ZoneTime.of(asLocalTime, zoneId, hasZeroSeconds); - return FEELFnResult.ofResult(zoneTime); - } - - return FEELFnResult.ofResult(parsed); - } catch (DateTimeException e) { - // try to parse it as a date time and extract the date component - // NOTE: this is an extension to the standard - return BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(val) - .cata(overrideLeft -> FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "time-parsing exception", e)), - this::invoke - ); - } + return super.invoke(val); } - private static final BigDecimal NANO_MULT = BigDecimal.valueOf(1000000000); - + @Override public FEELFnResult invoke( @ParameterName("hour") Number hour, @ParameterName("minute") Number minute, @ParameterName("second") Number seconds) { - return invoke(hour, minute, seconds, null); + return super.invoke(hour, minute, seconds); } + @Override public FEELFnResult invoke( @ParameterName("hour") Number hour, @ParameterName("minute") Number minute, @ParameterName("second") Number seconds, @ParameterName("offset") Duration offset) { - if (hour == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "hour", "cannot be null")); - } - if (minute == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "minute", "cannot be null")); - } - if (seconds == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "seconds", "cannot be null")); - } - - try { - int nanosecs = 0; - if (seconds instanceof BigDecimal) { - BigDecimal secs = (BigDecimal) seconds; - nanosecs = secs.subtract(secs.setScale(0, RoundingMode.DOWN)).multiply(NANO_MULT).intValue(); - } - - if (offset == null) { - return FEELFnResult.ofResult(LocalTime.of(hour.intValue(), minute.intValue(), seconds.intValue(), - nanosecs)); - } else { - return FEELFnResult.ofResult(OffsetTime.of(hour.intValue(), minute.intValue(), seconds.intValue(), - nanosecs, - ZoneOffset.ofTotalSeconds((int) offset.getSeconds()))); - } - } catch (DateTimeException e) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "time-parsing exception", e)); - } + return super.invoke(hour, minute, seconds, offset); } + @Override public FEELFnResult invoke(@ParameterName("from") TemporalAccessor date) { - if (date == null) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "cannot be null")); - } + return super.invoke(date); + } - try { - // If the temporal accessor type doesn't support time, try to parse it as a date with UTC midnight. - if (!date.isSupported(ChronoField.HOUR_OF_DAY)) { - return BuiltInFunctions.getFunction( DateAndTimeFunction.class ).invoke( date, OffsetTime.of(0, 0, 0, 0, ZoneOffset.UTC) ) - .cata( overrideLeft -> FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "time-parsing exception")), - this::invoke - ); - } else if( date.query( TemporalQueries.offset() ) == null ) { - return FEELFnResult.ofResult(LocalTime.from(date)); - } else { - ZoneId zone = date.query(TemporalQueries.zoneId()); - if (!(zone instanceof ZoneOffset)) { - // TZ is a ZoneRegion, so do NOT normalize (although the result will be unreversible, but will keep what was supplied originally). - // Unfortunately java.time.Parsed is a package-private class, hence will need to re-parse in order to have it instantiated. - return invoke(date.query(TemporalQueries.localTime()) + "@" + zone); - } else { - return FEELFnResult.ofResult(OffsetTime.from(date)); - } - } - } catch (DateTimeException e) { - return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "time-parsing exception", e)); - } + @Override + protected FEELFnResult manageDateTimeException(DateTimeException e, String val) { + // try to parse it as a date time and extract the date component + // NOTE: this is an extension to the standard + return BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(val) + .cata(overrideLeft -> FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from" + , "time-parsing exception", e)), + this::invoke + ); } } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/AfterFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/AfterFunction.java index 007250f1687..fafe3a4a939 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/AfterFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/AfterFunction.java @@ -31,7 +31,7 @@ public class AfterFunction public static final AfterFunction INSTANCE = new AfterFunction(); - public AfterFunction() { + private AfterFunction() { super( "after" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/BeforeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/BeforeFunction.java index 4ae46d43ad1..f6b22e421ce 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/BeforeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/BeforeFunction.java @@ -30,7 +30,7 @@ public class BeforeFunction public static final BeforeFunction INSTANCE = new BeforeFunction(); - public BeforeFunction() { + private BeforeFunction() { super( "before" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/CoincidesFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/CoincidesFunction.java index 9247aa69fec..6f15d0a87fe 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/CoincidesFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/CoincidesFunction.java @@ -30,7 +30,7 @@ public class CoincidesFunction public static final CoincidesFunction INSTANCE = new CoincidesFunction(); - public CoincidesFunction() { + private CoincidesFunction() { super( "coincides" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/DuringFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/DuringFunction.java index 9adf8a3a936..14ca0aef43b 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/DuringFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/DuringFunction.java @@ -31,7 +31,7 @@ public class DuringFunction public static final DuringFunction INSTANCE = new DuringFunction(); - public DuringFunction() { + private DuringFunction() { super( "during" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/FinishedByFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/FinishedByFunction.java index c64b697a9d4..b17066eaed5 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/FinishedByFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/FinishedByFunction.java @@ -31,7 +31,7 @@ public class FinishedByFunction public static final FinishedByFunction INSTANCE = new FinishedByFunction(); - public FinishedByFunction() { + private FinishedByFunction() { super( "finished by" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/FinishesFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/FinishesFunction.java index bc03b1ef1ba..ab6fd59f7ab 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/FinishesFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/FinishesFunction.java @@ -31,7 +31,7 @@ public class FinishesFunction public static final FinishesFunction INSTANCE = new FinishesFunction(); - public FinishesFunction() { + private FinishesFunction() { super( "finishes" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/IncludesFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/IncludesFunction.java index 1445053d516..8ef61b23ecc 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/IncludesFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/IncludesFunction.java @@ -31,7 +31,7 @@ public class IncludesFunction public static final IncludesFunction INSTANCE = new IncludesFunction(); - public IncludesFunction() { + private IncludesFunction() { super( "includes" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/MeetsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/MeetsFunction.java index 7c33d183022..747eef9ee06 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/MeetsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/MeetsFunction.java @@ -29,7 +29,7 @@ public class MeetsFunction extends BaseFEELFunction { public static final MeetsFunction INSTANCE = new MeetsFunction(); - public MeetsFunction() { + private MeetsFunction() { super( "meets" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/MetByFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/MetByFunction.java index 125867ebc3e..4f2ea578b72 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/MetByFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/MetByFunction.java @@ -29,7 +29,7 @@ public class MetByFunction extends BaseFEELFunction { public static final MetByFunction INSTANCE = new MetByFunction(); - public MetByFunction() { + private MetByFunction() { super("met by"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsAfterFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsAfterFunction.java index 7924bd1c026..af10abd3007 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsAfterFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsAfterFunction.java @@ -28,7 +28,7 @@ public class OverlapsAfterFunction public static final OverlapsAfterFunction INSTANCE = new OverlapsAfterFunction(); - public OverlapsAfterFunction() { + private OverlapsAfterFunction() { super("overlaps after"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsBeforeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsBeforeFunction.java index c20a7643646..16ebbb89836 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsBeforeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsBeforeFunction.java @@ -31,7 +31,7 @@ public class OverlapsBeforeFunction public static final OverlapsBeforeFunction INSTANCE = new OverlapsBeforeFunction(); - public OverlapsBeforeFunction() { + private OverlapsBeforeFunction() { super("overlaps before"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsFunction.java index 49afd62753e..51208ef9df6 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsFunction.java @@ -30,7 +30,7 @@ public class OverlapsFunction extends BaseFEELFunction { public static final OverlapsFunction INSTANCE = new OverlapsFunction(); - public OverlapsFunction() { + private OverlapsFunction() { super("overlaps"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/StartedByFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/StartedByFunction.java index 54aaa2ac7b2..611d4f2c35b 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/StartedByFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/StartedByFunction.java @@ -31,7 +31,7 @@ public class StartedByFunction public static final StartedByFunction INSTANCE = new StartedByFunction(); - public StartedByFunction() { + private StartedByFunction() { super( "started by" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/StartsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/StartsFunction.java index 900bfb4852a..1026798486e 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/StartsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/interval/StartsFunction.java @@ -31,7 +31,7 @@ public class StartsFunction public static final StartsFunction INSTANCE = new StartsFunction(); - public StartsFunction() { + private StartsFunction() { super( "starts" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunction.java index 40384f66b30..203b48287e7 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunction.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,15 +18,15 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; +import java.util.Arrays; +import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; import org.kie.dmn.feel.runtime.functions.FEELFnResult; import org.kie.dmn.feel.runtime.functions.ParameterName; -import java.util.Arrays; -import java.util.List; - /** * An implementation of the all() function that ignores nulls */ @@ -35,39 +35,40 @@ public class NNAllFunction public static final NNAllFunction INSTANCE = new NNAllFunction(); - public NNAllFunction() { - super( "nn all" ); + private NNAllFunction() { + super("nn all"); } - public FEELFnResult invoke(@ParameterName( "list" ) List list) { - if ( list == null ) { - return FEELFnResult.ofResult( true ); + public FEELFnResult invoke(@ParameterName("list") List list) { + if (list == null) { + return FEELFnResult.ofResult(true); } boolean result = true; - for ( final Object element : list ) { + for (final Object element : list) { if (element != null && !(element instanceof Boolean)) { - return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "an element in the list is not a Boolean")); + return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "an element in the list is not" + + " a Boolean")); } else { if (element != null) { result &= (Boolean) element; } } } - return FEELFnResult.ofResult( result ); + return FEELFnResult.ofResult(result); } - public FEELFnResult invoke(@ParameterName( "list" ) Boolean single) { - if( single == null ) { - return FEELFnResult.ofResult( true ); + public FEELFnResult invoke(@ParameterName("list") Boolean single) { + if (single == null) { + return FEELFnResult.ofResult(true); } - return FEELFnResult.ofResult( Boolean.TRUE.equals( single ) ); + return FEELFnResult.ofResult(Boolean.TRUE.equals(single)); } - public FEELFnResult invoke(@ParameterName( "b" ) Object[] list) { - if ( list == null ) { - return FEELFnResult.ofResult( true ); + public FEELFnResult invoke(@ParameterName("b") Object[] list) { + if (list == null) { + return FEELFnResult.ofResult(true); } - - return invoke( Arrays.asList( list ) ); + + return invoke(Arrays.asList(list)); } } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunction.java index fd826ddbabd..f149cc0f201 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunction.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,15 +18,15 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; +import java.util.Arrays; +import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; import org.kie.dmn.feel.runtime.functions.FEELFnResult; import org.kie.dmn.feel.runtime.functions.ParameterName; -import java.util.Arrays; -import java.util.List; - /** * An implementation of the any() function that ignores nulls */ @@ -35,39 +35,40 @@ public class NNAnyFunction public static final NNAnyFunction INSTANCE = new NNAnyFunction(); - public NNAnyFunction() { - super( "nn any" ); + private NNAnyFunction() { + super("nn any"); } - public FEELFnResult invoke(@ParameterName( "list" ) List list) { - if ( list == null ) { - return FEELFnResult.ofResult( false ); + public FEELFnResult invoke(@ParameterName("list") List list) { + if (list == null) { + return FEELFnResult.ofResult(false); } boolean result = false; - for ( final Object element : list ) { + for (final Object element : list) { if (element != null && !(element instanceof Boolean)) { - return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "an element in the list is not a Boolean")); + return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "an element in the list is not" + + " a Boolean")); } else { if (element != null) { result |= (Boolean) element; } } } - return FEELFnResult.ofResult( result ); + return FEELFnResult.ofResult(result); } - public FEELFnResult invoke(@ParameterName( "list" ) Boolean single) { - if( single == null ) { + public FEELFnResult invoke(@ParameterName("list") Boolean single) { + if (single == null) { single = Boolean.FALSE; } - return FEELFnResult.ofResult( single ); + return FEELFnResult.ofResult(single); } - public FEELFnResult invoke(@ParameterName( "b" ) Object[] list) { - if ( list == null ) { - return FEELFnResult.ofResult( false ); + public FEELFnResult invoke(@ParameterName("b") Object[] list) { + if (list == null) { + return FEELFnResult.ofResult(false); } - - return invoke( Arrays.asList( list ) ); + + return invoke(Arrays.asList(list)); } } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNCountFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNCountFunction.java index 14ee16efd35..cfbd32f31ac 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNCountFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNCountFunction.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,47 +18,47 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; +import java.math.BigDecimal; +import java.util.List; + import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; import org.kie.dmn.feel.runtime.functions.FEELFnResult; import org.kie.dmn.feel.runtime.functions.ParameterName; -import java.math.BigDecimal; -import java.util.List; - public class NNCountFunction extends BaseFEELFunction { public static final NNCountFunction INSTANCE = new NNCountFunction(); - public NNCountFunction() { - super( "nn count" ); + private NNCountFunction() { + super("nn count"); } - public FEELFnResult invoke(@ParameterName( "list" ) List list) { - if ( list == null ) { + public FEELFnResult invoke(@ParameterName("list") List list) { + if (list == null) { return FEELFnResult.ofResult(BigDecimal.ZERO); } // using raw loop instead of streams for performance int count = 0; - for( int i = 0; i < list.size(); i++ ) { - if( list.get( i ) != null ) { + for (int i = 0; i < list.size(); i++) { + if (list.get(i) != null) { count++; } } - return FEELFnResult.ofResult( BigDecimal.valueOf( count ) ); + return FEELFnResult.ofResult(BigDecimal.valueOf(count)); } - public FEELFnResult invoke(@ParameterName( "c" ) Object[] list) { - if ( list == null ) { + public FEELFnResult invoke(@ParameterName("c") Object[] list) { + if (list == null) { return FEELFnResult.ofResult(BigDecimal.ZERO); } // using raw loop instead of streams for performance int count = 0; - for( int i = 0; i < list.length; i++ ) { - if( list[ i ] != null ) { + for (int i = 0; i < list.length; i++) { + if (list[i] != null) { count++; } } - return FEELFnResult.ofResult( BigDecimal.valueOf( count ) ); + return FEELFnResult.ofResult(BigDecimal.valueOf(count)); } } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMaxFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMaxFunction.java index 57af28511df..788e22954b7 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMaxFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMaxFunction.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,53 +18,53 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; +import java.util.Arrays; +import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; import org.kie.dmn.feel.runtime.functions.FEELFnResult; import org.kie.dmn.feel.runtime.functions.ParameterName; -import java.util.Arrays; -import java.util.List; - public class NNMaxFunction extends BaseFEELFunction { public static final NNMaxFunction INSTANCE = new NNMaxFunction(); - public NNMaxFunction() { - super( "nn max" ); + private NNMaxFunction() { + super("nn max"); } public FEELFnResult invoke(@ParameterName("list") List list) { - if ( list == null || list.isEmpty() ) { - return FEELFnResult.ofResult( null ); + if (list == null || list.isEmpty()) { + return FEELFnResult.ofResult(null); } else { try { Comparable max = null; - for( int i = 0; i < list.size(); i++ ) { - Comparable candidate = (Comparable) list.get( i ); - if( candidate == null ) { + for (int i = 0; i < list.size(); i++) { + Comparable candidate = (Comparable) list.get(i); + if (candidate == null) { continue; - } else if( max == null ) { + } else if (max == null) { max = candidate; - } else if( max.compareTo( candidate ) < 0 ) { + } else if (max.compareTo(candidate) < 0) { max = candidate; } } - return FEELFnResult.ofResult( max ); + return FEELFnResult.ofResult(max); } catch (ClassCastException e) { - return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "contains items that are not comparable")); + return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "contains items that " + + "are not comparable")); } } } public FEELFnResult invoke(@ParameterName("c") Object[] list) { - if ( list == null || list.length == 0 ) { - return FEELFnResult.ofResult( null ); + if (list == null || list.length == 0) { + return FEELFnResult.ofResult(null); } - - return invoke( Arrays.asList( list ) ); - } + return invoke(Arrays.asList(list)); + } } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMeanFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMeanFunction.java index e84c767c8c8..d0cee07fcfa 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMeanFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMeanFunction.java @@ -35,7 +35,7 @@ public class NNMeanFunction public static final NNMeanFunction INSTANCE = new NNMeanFunction(); - public NNMeanFunction() { + private NNMeanFunction() { super( "nn mean" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMedianFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMedianFunction.java index c6af85b7ab9..f3ddbbbeff8 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMedianFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMedianFunction.java @@ -37,7 +37,7 @@ public class NNMedianFunction public static final NNMedianFunction INSTANCE = new NNMedianFunction(); - NNMedianFunction() { + private NNMedianFunction() { super("nn median"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMinFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMinFunction.java index e50ced74450..3f54cb86742 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMinFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNMinFunction.java @@ -18,21 +18,21 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; +import java.util.Arrays; +import java.util.List; + import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.BaseFEELFunction; import org.kie.dmn.feel.runtime.functions.FEELFnResult; import org.kie.dmn.feel.runtime.functions.ParameterName; -import java.util.Arrays; -import java.util.List; - public class NNMinFunction extends BaseFEELFunction { public static final NNMinFunction INSTANCE = new NNMinFunction(); - public NNMinFunction() { + private NNMinFunction() { super( "nn min" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNModeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNModeFunction.java index f4e30e5c8e2..4bca232125d 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNModeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNModeFunction.java @@ -36,7 +36,7 @@ public class NNModeFunction extends BaseFEELFunction { public static final NNModeFunction INSTANCE = new NNModeFunction(); - NNModeFunction() { + private NNModeFunction() { super("nn mode"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNStddevFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNStddevFunction.java index c07410ec4fa..36178e0ee45 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNStddevFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNStddevFunction.java @@ -37,7 +37,7 @@ public class NNStddevFunction extends BaseFEELFunction { public static final NNStddevFunction INSTANCE = new NNStddevFunction(); - NNStddevFunction() { + private NNStddevFunction() { super("nn stddev"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNSumFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNSumFunction.java index 0ed8d289c75..e4dfa336a58 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNSumFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNSumFunction.java @@ -34,7 +34,7 @@ public class NNSumFunction public static final NNSumFunction INSTANCE = new NNSumFunction(); - public NNSumFunction() { + private NNSumFunction() { super( "nn sum" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/BooleanEvalHelper.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/BooleanEvalHelper.java index f6049372c7f..39f9707923d 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/BooleanEvalHelper.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/BooleanEvalHelper.java @@ -30,8 +30,6 @@ import java.util.Optional; import java.util.function.BiPredicate; -import org.kie.dmn.feel.lang.EvaluationContext; -import org.kie.dmn.feel.lang.FEELDialect; import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.Range; diff --git a/kie-dmn/kie-dmn-feel/src/main/resources/META-INF/native-image/org.kie/kie-dmn-feel/reflect-config.json b/kie-dmn/kie-dmn-feel/src/main/resources/META-INF/native-image/org.kie/kie-dmn-feel/reflect-config.json index c6b830b456f..a80edd19086 100644 --- a/kie-dmn/kie-dmn-feel/src/main/resources/META-INF/native-image/org.kie/kie-dmn-feel/reflect-config.json +++ b/kie-dmn/kie-dmn-feel/src/main/resources/META-INF/native-image/org.kie/kie-dmn-feel/reflect-config.json @@ -1,992 +1,992 @@ [ - { - "name": "org.kie.dmn.feel.codegen.feel11.CompiledCustomFEELFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.AbsFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.AbstractCustomFEELFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.AllFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.AnyFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.AppendFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.BaseFEELFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.CeilingFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ConcatenateFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ContainsFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.CountFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.CustomFEELFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.DTInvokerFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.DateAndTimeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.DateFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.DayOfWeekFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.DayOfYearFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.DecimalFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.DecisionTableFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.DistinctValuesFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.DurationFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.EndsWithFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.EvenFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ExpFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.FlattenFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.FloorFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.GetEntriesFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.GetValueFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.IndexOfFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.InsertBeforeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.IsFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.JavaFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ListContainsFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ListReplaceFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.LogFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.MatchesFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.MaxFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.MeanFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.MedianFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.MinFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ModeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ModuloFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.MonthOfYearFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.NotFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.NumberFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.OddFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ProductFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.RemoveFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ReplaceFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.ReverseFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.SortFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.SplitFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.SqrtFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.StartsWithFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.StddevFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.StringFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.StringLengthFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.StringLowerCaseFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.StringUpperCaseFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.SublistFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.SubstringAfterFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.SubstringBeforeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.SubstringFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.SumFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.TimeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.UnionFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.WeekOfYearFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.YearsAndMonthsFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.CeilingFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.CodeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.ContextFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.ContextMergeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.ContextPutFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.DateFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.DurationFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.FloorFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.InvokeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.NowFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.RangeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.RoundDownFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.RoundHalfDownFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.RoundHalfUpFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.RoundUpFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.StringJoinFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.TimeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.extended.TodayFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.AfterFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.BeforeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.CoincidesFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.DuringFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.FinishedByFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.FinishesFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.IncludesFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.MeetsFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.MetByFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.OverlapsAfterFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.OverlapsBeforeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.OverlapsFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.StartedByFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.interval.StartsFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNAllFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNAnyFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNCountFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNMaxFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNMeanFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNMedianFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNMinFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNModeFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNStddevFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - }, - { - "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNSumFunction", - "allDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredClasses": true, - "allPublicClasses": true - } + { + "name": "org.kie.dmn.feel.codegen.feel11.CompiledCustomFEELFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.AbsFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.AbstractCustomFEELFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.AllFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.AnyFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.AppendFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.BaseFEELFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.CeilingFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ConcatenateFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ContainsFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.CountFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.CustomFEELFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DTInvokerFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DateAndTimeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DateFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DayOfWeekFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DayOfYearFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DecimalFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DecisionTableFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DistinctValuesFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DurationFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.EndsWithFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.EvenFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ExpFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.FlattenFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.FloorFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.GetEntriesFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.GetValueFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.IndexOfFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.InsertBeforeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.IsFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.JavaFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ListContainsFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ListReplaceFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.LogFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.MatchesFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.MaxFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.MeanFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.MedianFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.MinFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ModeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ModuloFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.MonthOfYearFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.NotFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.NumberFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.OddFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ProductFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.RemoveFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ReplaceFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ReverseFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.SortFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.SplitFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.SqrtFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.StartsWithFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.StddevFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.StringFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.StringLengthFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.StringLowerCaseFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.StringUpperCaseFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.SublistFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.SubstringAfterFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.SubstringBeforeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.SubstringFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.SumFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.TimeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.UnionFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.WeekOfYearFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.YearsAndMonthsFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.CeilingFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ContextFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ContextMergeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.ContextPutFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.DurationFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.FloorFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.NowFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.RangeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.RoundDownFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.RoundHalfDownFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.RoundHalfUpFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.RoundUpFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.StringJoinFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.TodayFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.extended.CodeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.extended.DateFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.extended.InvokeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.extended.TimeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.AfterFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.BeforeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.CoincidesFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.DuringFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.FinishedByFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.FinishesFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.IncludesFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.MeetsFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.MetByFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.OverlapsAfterFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.OverlapsBeforeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.OverlapsFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.StartedByFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.interval.StartsFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNAllFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNAnyFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNCountFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNMaxFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNMeanFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNMedianFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNMinFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNModeFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNStddevFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.feel.runtime.functions.twovaluelogic.NNSumFunction", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + } ] diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AllFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AllFunctionTest.java index 721d7ac405e..06e35405ee0 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AllFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AllFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,18 +22,12 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class AllFunctionTest { - private AllFunction allFunction; - - @BeforeEach - void setUp() { - allFunction = new AllFunction(); - } + private static final AllFunction allFunction = AllFunction.INSTANCE; @Test void invokeBooleanParamNull() { @@ -78,9 +72,12 @@ void invokeArrayParamReturnNull() { @Test void invokeArrayParamTypeHeterogenousArray() { - FunctionTestUtil.assertResultError(allFunction.invoke(new Object[]{Boolean.TRUE, 1}), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(allFunction.invoke(new Object[]{Boolean.FALSE, 1}), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(allFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(allFunction.invoke(new Object[]{Boolean.TRUE, 1}), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(allFunction.invoke(new Object[]{Boolean.FALSE, 1}), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(allFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), + InvalidParametersEvent.class); } @Test @@ -111,8 +108,11 @@ void invokeListParamReturnNull() { @Test void invokeListParamTypeHeterogenousArray() { - FunctionTestUtil.assertResultError(allFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(allFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(allFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(allFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(allFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(allFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), + InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AnyFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AnyFunctionTest.java index 216b5c7fa83..aa322fb38f0 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AnyFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AnyFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,18 +22,12 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class AnyFunctionTest { - private AnyFunction anyFunction; - - @BeforeEach - void setUp() { - anyFunction = new AnyFunction(); - } + private static final AnyFunction anyFunction = AnyFunction.INSTANCE; @Test void invokeBooleanParamNull() { @@ -80,9 +74,12 @@ void invokeArrayParamReturnNull() { @Test void invokeArrayParamTypeHeterogenousArray() { - FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.FALSE, 1}), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.TRUE, 1}), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.FALSE, 1}), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.TRUE, 1}), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), + InvalidParametersEvent.class); } @Test @@ -115,8 +112,11 @@ void invokeListParamReturnNull() { @Test void invokeListParamTypeHeterogenousArray() { - FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), + InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AppendFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AppendFunctionTest.java index 2a94891f4fa..5298f0be4bc 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AppendFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AppendFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,41 +22,42 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class AppendFunctionTest { - private AppendFunction appendFunction; - - @BeforeEach - void setUp() { - appendFunction = new AppendFunction(); - } + private static final AppendFunction appendFunction = AppendFunction.INSTANCE; @Test void invokeInvalidParams() { FunctionTestUtil.assertResultError(appendFunction.invoke((List) null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(appendFunction.invoke((List) null, new Object[]{}), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(appendFunction.invoke(Collections.emptyList(), null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(appendFunction.invoke((List) null, new Object[]{}), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(appendFunction.invoke(Collections.emptyList(), null), + InvalidParametersEvent.class); } @Test void invokeEmptyParams() { - FunctionTestUtil.assertResultList(appendFunction.invoke(Collections.emptyList(), new Object[]{}), Collections.emptyList()); + FunctionTestUtil.assertResultList(appendFunction.invoke(Collections.emptyList(), new Object[]{}), + Collections.emptyList()); } @Test void invokeAppendNothing() { FunctionTestUtil.assertResultList(appendFunction.invoke(List.of("test"), new Object[]{}), List.of("test")); - FunctionTestUtil.assertResultList(appendFunction.invoke(Arrays.asList("test", "test2"), new Object[]{}), Arrays.asList("test", "test2")); + FunctionTestUtil.assertResultList(appendFunction.invoke(Arrays.asList("test", "test2"), new Object[]{}), + Arrays.asList("test", "test2")); } @Test void invokeAppendSomething() { - FunctionTestUtil.assertResultList(appendFunction.invoke(Collections.emptyList(), new Object[]{"test"}), List.of("test")); - FunctionTestUtil.assertResultList(appendFunction.invoke(List.of("test"), new Object[]{"test2"}), Arrays.asList("test", "test2")); - FunctionTestUtil.assertResultList(appendFunction.invoke(List.of("test"), new Object[]{"test2", "test3"}), Arrays.asList("test", "test2", "test3")); + FunctionTestUtil.assertResultList(appendFunction.invoke(Collections.emptyList(), new Object[]{"test"}), + List.of("test")); + FunctionTestUtil.assertResultList(appendFunction.invoke(List.of("test"), new Object[]{"test2"}), + Arrays.asList("test", "test2")); + FunctionTestUtil.assertResultList(appendFunction.invoke(List.of("test"), new Object[]{"test2", "test3"}), + Arrays.asList("test", "test2", "test3")); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CeilingFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CeilingFunctionTest.java index 386b053ddda..b7eaea5785e 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CeilingFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CeilingFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -20,25 +20,21 @@ import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class CeilingFunctionTest { - private CeilingFunction ceilingFunction; - - @BeforeEach - void setUp() { - ceilingFunction = new CeilingFunction(); - } + private static final CeilingFunction ceilingFunction = CeilingFunction.INSTANCE; @Test void invokeNull() { FunctionTestUtil.assertResultError(ceilingFunction.invoke(null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(ceilingFunction.invoke((BigDecimal) null, null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(ceilingFunction.invoke((BigDecimal) null, null), + InvalidParametersEvent.class); FunctionTestUtil.assertResultError(ceilingFunction.invoke(BigDecimal.ONE, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(ceilingFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); } + FunctionTestUtil.assertResultError(ceilingFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); + } @Test void invokeZero() { @@ -47,17 +43,21 @@ void invokeZero() { @Test void invokePositive() { - FunctionTestUtil.assertResultBigDecimal(ceilingFunction.invoke(BigDecimal.valueOf(10.2)), BigDecimal.valueOf(11)); + FunctionTestUtil.assertResultBigDecimal(ceilingFunction.invoke(BigDecimal.valueOf(10.2)), + BigDecimal.valueOf(11)); } @Test void invokeNegative() { - FunctionTestUtil.assertResultBigDecimal(ceilingFunction.invoke(BigDecimal.valueOf(-10.2)), BigDecimal.valueOf(-10)); + FunctionTestUtil.assertResultBigDecimal(ceilingFunction.invoke(BigDecimal.valueOf(-10.2)), + BigDecimal.valueOf(-10)); } @Test void invokeOutRangeScale() { - FunctionTestUtil.assertResultError(ceilingFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(6177)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(ceilingFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(-6122)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(ceilingFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(6177)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(ceilingFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(-6122)) + , InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CodeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CodeFunctionTest.java index acafaed37eb..0bdbd97ba21 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CodeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CodeFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -33,7 +33,6 @@ import java.util.List; import java.util.Map; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.functions.extended.CodeFunction; @@ -41,12 +40,7 @@ class CodeFunctionTest { - private CodeFunction codeFunction; - - @BeforeEach - void setUp() { - codeFunction = new CodeFunction(); - } + private static final CodeFunction codeFunction = CodeFunction.INSTANCE; @Test void invokeNull() { @@ -72,31 +66,36 @@ void invokeLocalDate() { @Test void invokeLocalTime() { final LocalTime localTime = LocalTime.now(); - FunctionTestUtil.assertResult(codeFunction.invoke(localTime), "time( \"" + TimeFunction.FEEL_TIME.format(localTime) + "\" )"); + FunctionTestUtil.assertResult(codeFunction.invoke(localTime), + "time( \"" + TimeFunction.FEEL_TIME.format(localTime) + "\" )"); } @Test void invokeOffsetTime() { final OffsetTime offsetTime = OffsetTime.now(); - FunctionTestUtil.assertResult(codeFunction.invoke(offsetTime), "time( \"" + TimeFunction.FEEL_TIME.format(offsetTime) + "\" )"); + FunctionTestUtil.assertResult(codeFunction.invoke(offsetTime), + "time( \"" + TimeFunction.FEEL_TIME.format(offsetTime) + "\" )"); } @Test void invokeLocalDateTime() { final LocalDateTime localDateTime = LocalDateTime.now(); - FunctionTestUtil.assertResult(codeFunction.invoke(localDateTime), "date and time( \"" + DateAndTimeFunction.FEEL_DATE_TIME.format(localDateTime) + "\" )"); + FunctionTestUtil.assertResult(codeFunction.invoke(localDateTime), + "date and time( \"" + DateAndTimeFunction.FEEL_DATE_TIME.format(localDateTime) + "\" )"); } @Test void invokeOffsetDateTime() { final OffsetDateTime offsetDateTime = OffsetDateTime.now(); - FunctionTestUtil.assertResult(codeFunction.invoke(offsetDateTime), "date and time( \"" + DateAndTimeFunction.FEEL_DATE_TIME.format(offsetDateTime) + "\" )"); + FunctionTestUtil.assertResult(codeFunction.invoke(offsetDateTime), + "date and time( \"" + DateAndTimeFunction.FEEL_DATE_TIME.format(offsetDateTime) + "\" )"); } @Test void invokeZonedDateTime() { final ZonedDateTime zonedDateTime = ZonedDateTime.now(); - FunctionTestUtil.assertResult(codeFunction.invoke(zonedDateTime), "date and time( \"" + DateAndTimeFunction.REGION_DATETIME_FORMATTER.format(zonedDateTime) + "\" )"); + FunctionTestUtil.assertResult(codeFunction.invoke(zonedDateTime), + "date and time( \"" + DateAndTimeFunction.REGION_DATETIME_FORMATTER.format(zonedDateTime) + "\" )"); } @Test @@ -140,8 +139,10 @@ void invokeDurationNanosMillis() { FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofNanos(10000)), "duration( \"PT0.00001S\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofNanos(10025)), "duration( \"PT0.000010025S\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofMillis(1500)), "duration( \"PT1.5S\" )"); - FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofMillis(90061025)), "duration( \"P1DT1H1M1.025S\" )"); - FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofMillis(-90061025)), "duration( \"-P1DT1H1M1.025S\" )"); + FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofMillis(90061025)), "duration( \"P1DT1H1M1.025S\"" + + " )"); + FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofMillis(-90061025)), "duration( \"-P1DT1H1M1" + + ".025S\" )"); } @Test @@ -218,6 +219,7 @@ void invokeContextNonEmpty() { contextMap.put("key1", "value1"); contextMap.put("key2", childContextMap); - FunctionTestUtil.assertResult(codeFunction.invoke(contextMap), "{ key1 : \"value1\", key2 : { childKey1 : \"childValue1\" } }"); + FunctionTestUtil.assertResult(codeFunction.invoke(contextMap), "{ key1 : \"value1\", key2 : { childKey1 : " + + "\"childValue1\" } }"); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ComposingDifferentFunctionsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ComposingDifferentFunctionsTest.java index 9da075adf9d..4914f64143d 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ComposingDifferentFunctionsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ComposingDifferentFunctionsTest.java @@ -27,25 +27,16 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; class ComposingDifferentFunctionsTest { - private DateAndTimeFunction dateTimeFunction; - private DateFunction dateFunction; - private TimeFunction timeFunction; - private StringFunction stringFunction; - - @BeforeEach - void setUp() { - dateTimeFunction = new DateAndTimeFunction(); - dateFunction = new DateFunction(); - timeFunction = new TimeFunction(); - stringFunction = new StringFunction(); - } + private static final DateAndTimeFunction dateTimeFunction = DateAndTimeFunction.INSTANCE; + private static final DateFunction dateFunction = DateFunction.INSTANCE; + private static final TimeFunction timeFunction = TimeFunction.INSTANCE; + private static final StringFunction stringFunction = StringFunction.INSTANCE; @Test void composite1() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunctionTest.java index 9687ba46580..e7b9e39d74f 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,18 +22,12 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class ConcatenateFunctionTest { - private ConcatenateFunction concatenateFunction; - - @BeforeEach - void setUp() { - concatenateFunction = new ConcatenateFunction(); - } + private static final ConcatenateFunction concatenateFunction = ConcatenateFunction.INSTANCE; @Test void invokeNull() { @@ -47,18 +41,21 @@ void invokeEmptyArray() { @Test void invokeArrayWithNull() { - FunctionTestUtil.assertResultError(concatenateFunction.invoke(new Object[]{null}), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(concatenateFunction.invoke(new Object[]{1, null}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(concatenateFunction.invoke(new Object[]{null}), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(concatenateFunction.invoke(new Object[]{1, null}), + InvalidParametersEvent.class); } @Test void invokeArrayWithList() { - FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{"test", 2, Arrays.asList(2, 3)}), Arrays.asList("test", 2, 2, 3)); + FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{"test", 2, Arrays.asList(2, 3)}), + Arrays.asList("test", 2, 2, 3)); } @Test void invokeArrayWithoutList() { - FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{"test", 2, BigDecimal.valueOf(25.3)}), Arrays.asList("test", 2, BigDecimal.valueOf(25.3))); + FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{"test", 2, + BigDecimal.valueOf(25.3)}), Arrays.asList("test", 2, BigDecimal.valueOf(25.3))); } - } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContainsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContainsFunctionTest.java index 23c0e182475..31349953d4a 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContainsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContainsFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,18 +18,12 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class ContainsFunctionTest { - private ContainsFunction containsFunction; - - @BeforeEach - void setUp() { - containsFunction = new ContainsFunction(); - } + private static final ContainsFunction containsFunction = ContainsFunction.INSTANCE; @Test void invokeParamsNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/ContextFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContextFunctionTest.java similarity index 82% rename from kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/ContextFunctionTest.java rename to kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContextFunctionTest.java index e4909074e77..7078e33b65c 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/ContextFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContextFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -16,26 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; +package org.kie.dmn.feel.runtime.functions; import java.util.List; import java.util.Map; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; + class ContextFunctionTest { - private ContextFunction contextFunction; - private record ContextEntry(String key, Object value) {} + private static final ContextFunction contextFunction = ContextFunction.INSTANCE; - @BeforeEach - void setUp() { - contextFunction = new ContextFunction(); - } @Test void invokeListNull() { @@ -47,7 +39,7 @@ void invokeContainsNoKeyAndValue() { FunctionTestUtil.assertResultError(contextFunction.invoke(List.of( Map.of("test", "name", "value", "John Doe"), Map.of("key", "name", "test", "John Doe"))), InvalidParametersEvent.class); -} + } @Test void invokeDuplicateKey() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CountFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CountFunctionTest.java index b743b549e42..aa9591e5b6f 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CountFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CountFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,18 +23,12 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class CountFunctionTest { - private CountFunction countFunction; - - @BeforeEach - void setUp() { - countFunction = new CountFunction(); - } + private static final CountFunction countFunction = CountFunction.INSTANCE; @Test void invokeParamListNull() { @@ -65,5 +59,4 @@ void invokeParamArrayEmpty() { void invokeParamArrayNonEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(new Object[]{1, 2, "test"}), BigDecimal.valueOf(3)); } - } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java index f44aa68c5e0..ac8cd20a950 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -27,18 +27,12 @@ import java.time.ZonedDateTime; import java.time.temporal.Temporal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class DateTimeFunctionTest { - private DateAndTimeFunction dateTimeFunction; - - @BeforeEach - void setUp() { - dateTimeFunction = new DateAndTimeFunction(); - } + private static final DateAndTimeFunction dateTimeFunction = DateAndTimeFunction.INSTANCE; @Test void invokeParamStringNull() { @@ -54,22 +48,33 @@ void invokeParamStringNotDateOrTime() { @Test void invokeParamStringDateTime() { - FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-09-07T10:20:30"), LocalDateTime.of(2017, 9, 7, 10, 20, 30)); - FunctionTestUtil.assertResult(dateTimeFunction.invoke("99999-12-31T11:22:33"), LocalDateTime.of(99999, 12, 31, 11, 22, 33)); + FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-09-07T10:20:30"), LocalDateTime.of(2017, 9, 7, 10 + , 20, 30)); + FunctionTestUtil.assertResult(dateTimeFunction.invoke("99999-12-31T11:22:33"), LocalDateTime.of(99999, 12, 31 + , 11, 22, 33)); } @Test void invokeParamStringDateTimeZoned() { - FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30@Europe/Paris"), ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 0, ZoneId.of("Europe/Paris"))); - FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.987@Europe/Paris"), ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 987_000_000, ZoneId.of("Europe/Paris"))); - FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.123456789@Europe/Paris"), ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 123_456_789, ZoneId.of("Europe/Paris"))); - FunctionTestUtil.assertResult(dateTimeFunction.invoke("999999999-12-31T23:59:59.999999999@Europe/Paris"), ZonedDateTime.of(999999999, 12, 31, 23, 59, 59, 999_999_999, ZoneId.of("Europe/Paris"))); + FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30@Europe/Paris"), + ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 0, ZoneId.of("Europe/Paris"))); + FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.987@Europe/Paris"), + ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 987_000_000, ZoneId.of("Europe/Paris" + ))); + FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.123456789@Europe/Paris"), + ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 123_456_789, ZoneId.of("Europe/Paris" + ))); + FunctionTestUtil.assertResult(dateTimeFunction.invoke("999999999-12-31T23:59:59.999999999@Europe/Paris"), + ZonedDateTime.of(999999999, 12, 31, 23, 59, 59, 999_999_999, ZoneId.of("Europe/Paris"))); } @Test void invokeParamStringDateOffset() { - FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-12-31T23:59:59.999999999+02:00"), ZonedDateTime.of(2017, 12, 31, 23, 59, 59, 999_999_999, ZoneOffset.of("+02:00"))); - FunctionTestUtil.assertResult(dateTimeFunction.invoke("-999999999-12-31T23:59:59.999999999+02:00"), ZonedDateTime.of(-999999999, 12, 31, 23, 59, 59, 999_999_999, ZoneOffset.of("+02:00"))); + FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-12-31T23:59:59.999999999+02:00"), + ZonedDateTime.of(2017, 12, 31, 23, 59, 59, 999_999_999, ZoneOffset.of("+02:00"))); + FunctionTestUtil.assertResult(dateTimeFunction.invoke("-999999999-12-31T23:59:59.999999999+02:00"), + ZonedDateTime.of(-999999999, 12, 31, 23, 59, 59, 999_999_999, ZoneOffset.of( + "+02:00"))); } @Test @@ -79,14 +84,19 @@ void invokeParamStringDate() { @Test void invokeParamTemporalNulls() { - FunctionTestUtil.assertResultError(dateTimeFunction.invoke((Temporal) null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(dateTimeFunction.invoke(null, LocalTime.of(10, 6, 20)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(dateTimeFunction.invoke(LocalDate.of(2017, 6, 12), null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(dateTimeFunction.invoke((Temporal) null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(dateTimeFunction.invoke(null, LocalTime.of(10, 6, 20)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(dateTimeFunction.invoke(LocalDate.of(2017, 6, 12), null), + InvalidParametersEvent.class); } @Test void invokeParamTemporalWrongTemporal() { - // reminder: 1st parameter accordingly to FEEL Spec Table 58 "date is a date or date time [...] creates a date time from the given date (ignoring any time component)" [that means ignoring any TZ from `date` parameter, too] + // reminder: 1st parameter accordingly to FEEL Spec Table 58 "date is a date or date time [...] creates a + // date time from the given date (ignoring any time component)" [that means ignoring any TZ from `date` + // parameter, too] FunctionTestUtil.assertResultError( dateTimeFunction.invoke( LocalDate.of(2017, 6, 12), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DecimalFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DecimalFunctionTest.java index 8e335cf1d1d..d56b213393a 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DecimalFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DecimalFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -20,54 +20,56 @@ import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class DecimalFunctionTest { - private DecimalFunction decimalFunction; - - @BeforeEach - void setUp() { - decimalFunction = new DecimalFunction(); - } + private static final DecimalFunction decimalFunction = DecimalFunction.INSTANCE; @Test void invokeNull() { - FunctionTestUtil.assertResultError(decimalFunction.invoke((BigDecimal) null, null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(decimalFunction.invoke((BigDecimal) null, null), + InvalidParametersEvent.class); FunctionTestUtil.assertResultError(decimalFunction.invoke(BigDecimal.ONE, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(decimalFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); } @Test void invokeRoundingUp() { - FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), BigDecimal.valueOf(10.3)); + FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), + BigDecimal.valueOf(10.3)); } @Test void invokeRoundingDown() { - FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), BigDecimal.valueOf(10.2)); + FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), + BigDecimal.valueOf(10.2)); } @Test void invokeRoundingEven() { - FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), BigDecimal.valueOf(10.2)); + FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), + BigDecimal.valueOf(10.2)); } @Test void invokeRoundingOdd() { - FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), BigDecimal.valueOf(10.4)); + FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), + BigDecimal.valueOf(10.4)); } @Test void invokeLargerScale() { - FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.123456789), BigDecimal.valueOf(6)), BigDecimal.valueOf(10.123457)); + FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.123456789), BigDecimal.valueOf(6)) + , BigDecimal.valueOf(10.123457)); } @Test void invokeOutRangeScale() { - FunctionTestUtil.assertResultError(decimalFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(6177)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(decimalFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(-6122)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(decimalFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(6177)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(decimalFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(-6122)) + , InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunctionTest.java index 5b3af9101c5..f23c0295244 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,18 +23,12 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class DistinctValuesFunctionTest { - private DistinctValuesFunction distinctValuesFunction; - - @BeforeEach - void setUp() { - distinctValuesFunction = new DistinctValuesFunction(); - } + private static final DistinctValuesFunction distinctValuesFunction = DistinctValuesFunction.INSTANCE; @Test void invokeNull() { @@ -57,7 +51,8 @@ void invokeParamArray() { @Test void invokeEmptyList() { - FunctionTestUtil.assertResultList(distinctValuesFunction.invoke(Collections.emptyList()), Collections.emptyList()); + FunctionTestUtil.assertResultList(distinctValuesFunction.invoke(Collections.emptyList()), + Collections.emptyList()); } @Test diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DurationFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DurationFunctionTest.java index b2472333139..83c57f664f1 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DurationFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DurationFunctionTest.java @@ -22,19 +22,13 @@ import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAmount; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class DurationFunctionTest { - private DurationFunction durationFunction; - - @BeforeEach - void setUp() { - durationFunction = new DurationFunction(); - } + private static final DurationFunction durationFunction = DurationFunction.INSTANCE; @Test void invokeParamStringNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/EndsWithFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/EndsWithFunctionTest.java index a5146d0a54d..a3df90c4b37 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/EndsWithFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/EndsWithFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,18 +18,12 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class EndsWithFunctionTest { - private EndsWithFunction endsWithFunction; - - @BeforeEach - void setUp() { - endsWithFunction = new EndsWithFunction(); - } + private static final EndsWithFunction endsWithFunction = EndsWithFunction.INSTANCE; @Test void invokeParamsNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FlattenFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FlattenFunctionTest.java index 3b9056e65e9..86b5bc900c1 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FlattenFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FlattenFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,18 +22,12 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class FlattenFunctionTest { - private FlattenFunction flattenFunction; - - @BeforeEach - void setUp() { - flattenFunction = new FlattenFunction(); - } + private static final FlattenFunction flattenFunction = FlattenFunction.INSTANCE; @Test void invokeNull() { @@ -42,23 +36,27 @@ void invokeNull() { @Test void invokeParamNotCollection() { - FunctionTestUtil.assertResult(flattenFunction.invoke(BigDecimal.valueOf(10.2)), Collections.singletonList(BigDecimal.valueOf(10.2))); + FunctionTestUtil.assertResult(flattenFunction.invoke(BigDecimal.valueOf(10.2)), + Collections.singletonList(BigDecimal.valueOf(10.2))); FunctionTestUtil.assertResult(flattenFunction.invoke("test"), Collections.singletonList("test")); } @Test void invokeParamCollection() { FunctionTestUtil.assertResult(flattenFunction.invoke(Arrays.asList("test", 1, 2)), Arrays.asList("test", 1, 2)); - FunctionTestUtil.assertResult(flattenFunction.invoke(Arrays.asList("test", 1, 2, Arrays.asList(3, 4))), Arrays.asList("test", 1, 2, 3, 4)); - FunctionTestUtil.assertResult(flattenFunction.invoke(Arrays.asList("test", 1, 2, Arrays.asList(1, 2))), Arrays.asList("test", 1, 2, 1, 2)); + FunctionTestUtil.assertResult(flattenFunction.invoke(Arrays.asList("test", 1, 2, Arrays.asList(3, 4))), + Arrays.asList("test", 1, 2, 3, 4)); + FunctionTestUtil.assertResult(flattenFunction.invoke(Arrays.asList("test", 1, 2, Arrays.asList(1, 2))), + Arrays.asList("test", 1, 2, 1, 2)); FunctionTestUtil.assertResult( flattenFunction.invoke( Arrays.asList("test", 1, Arrays.asList(BigDecimal.ZERO, 3), 2, Arrays.asList(1, 2))), - Arrays.asList("test", 1, BigDecimal.ZERO, 3, 2, 1, 2)); + Arrays.asList("test", 1, BigDecimal.ZERO, 3, 2, 1, 2)); FunctionTestUtil.assertResult( flattenFunction.invoke( - Arrays.asList("test", 1, Arrays.asList(Arrays.asList(10, 15), BigDecimal.ZERO, 3), 2, Arrays.asList(1, 2))), + Arrays.asList("test", 1, Arrays.asList(Arrays.asList(10, 15), BigDecimal.ZERO, 3), 2, + Arrays.asList(1, 2))), Arrays.asList("test", 1, 10, 15, BigDecimal.ZERO, 3, 2, 1, 2)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FloorFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FloorFunctionTest.java index bf84075681a..739dc196e38 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FloorFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FloorFunctionTest.java @@ -20,18 +20,12 @@ import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class FloorFunctionTest { - private FloorFunction floorFunction; - - @BeforeEach - void setUp() { - floorFunction = new FloorFunction(); - } + private static final FloorFunction floorFunction = FloorFunction.INSTANCE; @Test void invokeNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/IndexOfFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/IndexOfFunctionTest.java index 3e5a9e00089..9317907bf9b 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/IndexOfFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/IndexOfFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,18 +23,12 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class IndexOfFunctionTest { - private IndexOfFunction indexOfFunction; - - @BeforeEach - void setUp() { - indexOfFunction = new IndexOfFunction(); - } + private static final IndexOfFunction indexOfFunction = IndexOfFunction.INSTANCE; @Test void invokeListNull() { @@ -44,8 +38,10 @@ void invokeListNull() { @Test void invokeMatchNull() { - FunctionTestUtil.assertResultList(indexOfFunction.invoke(Collections.emptyList(), null), Collections.emptyList()); - FunctionTestUtil.assertResultList(indexOfFunction.invoke(Collections.singletonList("test"), null), Collections.emptyList()); + FunctionTestUtil.assertResultList(indexOfFunction.invoke(Collections.emptyList(), null), + Collections.emptyList()); + FunctionTestUtil.assertResultList(indexOfFunction.invoke(Collections.singletonList("test"), null), + Collections.emptyList()); FunctionTestUtil.assertResultList( indexOfFunction.invoke(Arrays.asList("test", null), null), Collections.singletonList(BigDecimal.valueOf(2))); @@ -62,7 +58,8 @@ void invokeMatchNull() { @Test void invokeBigDecimal() { - FunctionTestUtil.assertResult(indexOfFunction.invoke(Arrays.asList("test", null, 12), BigDecimal.valueOf(12)), Collections.emptyList()); + FunctionTestUtil.assertResult(indexOfFunction.invoke(Arrays.asList("test", null, 12), BigDecimal.valueOf(12)) + , Collections.emptyList()); FunctionTestUtil.assertResult( indexOfFunction.invoke(Arrays.asList("test", null, BigDecimal.valueOf(12)), BigDecimal.valueOf(12)), Collections.singletonList(BigDecimal.valueOf(3))); @@ -80,12 +77,13 @@ void invokeBigDecimal() { @Test void invokeMatchNotNull() { - FunctionTestUtil.assertResult(indexOfFunction.invoke(Arrays.asList("test", null, 12), "testttt"), Collections.emptyList()); + FunctionTestUtil.assertResult(indexOfFunction.invoke(Arrays.asList("test", null, 12), "testttt"), + Collections.emptyList()); FunctionTestUtil.assertResult( indexOfFunction.invoke(Arrays.asList("test", null, BigDecimal.valueOf(12)), "test"), Collections.singletonList(BigDecimal.valueOf(1))); FunctionTestUtil.assertResult( - indexOfFunction.invoke(Arrays.asList("test", null, "test"),"test"), + indexOfFunction.invoke(Arrays.asList("test", null, "test"), "test"), Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(3))); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunctionTest.java index a8ef326d606..380b57ffe60 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,70 +22,80 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class InsertBeforeFunctionTest { - private InsertBeforeFunction insertBeforeFunction; - - @BeforeEach - void setUp() { - insertBeforeFunction = new InsertBeforeFunction(); - } + private static final InsertBeforeFunction insertBeforeFunction = InsertBeforeFunction.INSTANCE; @Test void invokeListNull() { - FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(null, BigDecimal.ZERO, new Object()), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(null, BigDecimal.ZERO, new Object()), + InvalidParametersEvent.class); } @Test void invokePositionNull() { - FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), null, new Object()), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), null, new Object()), + InvalidParametersEvent.class); } @Test void invokeListPositionNull() { - FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(null, null, new Object()), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(null, null, new Object()), + InvalidParametersEvent.class); } @Test void invokePositionZero() { - FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.ZERO, new Object()), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.ZERO, + new Object()), InvalidParametersEvent.class); } @Test void invokePositionOutsideListBounds() { - FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.ONE, new Object()), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.valueOf(-1), new Object()), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.ONE, + new Object()), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), + BigDecimal.valueOf(-1), new Object()), + InvalidParametersEvent.class); } @Test void invokeInsertIntoEmptyList() { - // According to spec, inserting into empty list shouldn't be possible. For inserting into empty list, user should use append() function. - FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.ONE, null), InvalidParametersEvent.class); + // According to spec, inserting into empty list shouldn't be possible. For inserting into empty list, user + // should use append() function. + FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.ONE, null) + , InvalidParametersEvent.class); } @Test void invokePositionPositive() { - FunctionTestUtil.assertResult(insertBeforeFunction.invoke(Collections.singletonList("test"), BigDecimal.ONE, null), Arrays.asList(null, "test")); + FunctionTestUtil.assertResult(insertBeforeFunction.invoke(Collections.singletonList("test"), BigDecimal.ONE, + null), Arrays.asList(null, "test")); FunctionTestUtil.assertResult( - insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(2), "testtt"), + insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(2), + "testtt"), Arrays.asList("test", "testtt", null, BigDecimal.ZERO)); FunctionTestUtil.assertResult( - insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(3), "testtt"), + insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(3), + "testtt"), Arrays.asList("test", null, "testtt", BigDecimal.ZERO)); } @Test void invokePositionNegative() { - FunctionTestUtil.assertResult(insertBeforeFunction.invoke(Collections.singletonList("test"), BigDecimal.valueOf(-1), null), Arrays.asList(null, "test")); + FunctionTestUtil.assertResult(insertBeforeFunction.invoke(Collections.singletonList("test"), + BigDecimal.valueOf(-1), null), Arrays.asList(null, + "test")); FunctionTestUtil.assertResult( - insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(-2), "testtt"), + insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(-2), + "testtt"), Arrays.asList("test", "testtt", null, BigDecimal.ZERO)); FunctionTestUtil.assertResult( - insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(-3), "testtt"), + insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(-3), + "testtt"), Arrays.asList("testtt", "test", null, BigDecimal.ZERO)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListContainsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListContainsFunctionTest.java index 318bac32367..ac96e85d3f1 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListContainsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListContainsFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,23 +23,19 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class ListContainsFunctionTest { - private ListContainsFunction listContainsFunction; - - @BeforeEach - void setUp() { - listContainsFunction = new ListContainsFunction(); - } + private static final ListContainsFunction listContainsFunction = ListContainsFunction.INSTANCE; @Test void invokeListNull() { - FunctionTestUtil.assertResultError(listContainsFunction.invoke((List) null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(listContainsFunction.invoke(null, new Object()), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(listContainsFunction.invoke((List) null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(listContainsFunction.invoke(null, new Object()), + InvalidParametersEvent.class); } @Test @@ -67,6 +63,7 @@ void invokeContains() { void invokeNotContains() { FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), "testtt"), false); FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), 3), false); - FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), BigDecimal.valueOf(3)), false); + FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), BigDecimal.valueOf(3)) + , false); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MatchesFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MatchesFunctionTest.java index cdbbd3c6e24..0f105f622d9 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MatchesFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MatchesFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,18 +18,12 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class MatchesFunctionTest { - private MatchesFunction matchesFunction; - - @BeforeEach - void setUp() { - matchesFunction = new MatchesFunction(); - } + private final static MatchesFunction matchesFunction = MatchesFunction.INSTANCE; @Test void invokeNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MaxFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MaxFunctionTest.java index 561074eb9c5..ddc5e1f81b9 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MaxFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MaxFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -27,19 +27,13 @@ import java.util.List; import java.util.function.Predicate; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class MaxFunctionTest { - private MaxFunction maxFunction; - - @BeforeEach - void setUp() { - maxFunction = new MaxFunction(); - } + private static final MaxFunction maxFunction = MaxFunction.INSTANCE; @Test void invokeNullList() { @@ -53,7 +47,8 @@ void invokeEmptyList() { @Test void invokeListWithHeterogenousTypes() { - FunctionTestUtil.assertResultError(maxFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(maxFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), + InvalidParametersEvent.class); } @Test @@ -79,12 +74,18 @@ void invokeListOfChronoPeriods() { final ChronoPeriod p2Period = Period.parse("P1M"); final ChronoPeriod p2Comparable = ComparablePeriod.parse("P1M"); Predicate assertion = i -> i.get(ChronoUnit.YEARS) == 1 && i.get(ChronoUnit.MONTHS) == 0; - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Collections.singletonList(p1Period)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Collections.singletonList(p1Comparable)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Arrays.asList(p1Period, p2Period)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Arrays.asList(p1Comparable, p2Period)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Arrays.asList(p1Period, p2Comparable)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Arrays.asList(p1Comparable, p2Comparable)), ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Collections.singletonList(p1Period)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Collections.singletonList(p1Comparable)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Arrays.asList(p1Period, p2Period)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Arrays.asList(p1Comparable, p2Period)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Arrays.asList(p1Period, p2Comparable)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(Arrays.asList(p1Comparable, p2Comparable)), + ChronoPeriod.class, assertion); } @Test @@ -99,7 +100,8 @@ void invokeEmptyArray() { @Test void invokeArrayWithHeterogenousTypes() { - FunctionTestUtil.assertResultError(maxFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(maxFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), + InvalidParametersEvent.class); } @Test @@ -125,11 +127,17 @@ void invokeArrayOfChronoPeriods() { final ChronoPeriod p2Period = Period.parse("P1M"); final ChronoPeriod p2Comparable = ComparablePeriod.parse("P1M"); Predicate assertion = i -> i.get(ChronoUnit.YEARS) == 1 && i.get(ChronoUnit.MONTHS) == 0; - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Period}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Comparable}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Period, p2Period}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Comparable, p2Period}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Period, p2Comparable}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Comparable, p2Comparable}), ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Period}), ChronoPeriod.class, + assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Comparable}), ChronoPeriod.class, + assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Period, p2Period}), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Comparable, p2Period}), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Period, p2Comparable}), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(maxFunction.invoke(new Object[]{p1Comparable, p2Comparable}), + ChronoPeriod.class, assertion); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MeanFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MeanFunctionTest.java index 9a6892a6648..368fe628d86 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MeanFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MeanFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,18 +23,12 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class MeanFunctionTest { - private MeanFunction meanFunction; - - @BeforeEach - void setUp() { - meanFunction = new MeanFunction(); - } + private static final MeanFunction meanFunction = MeanFunction.INSTANCE; @Test void invokeNumberNull() { @@ -98,7 +92,8 @@ void invokeListWithIntegers() { @Test void invokeListWithDoubles() { FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.0d, 20.0d, 30.0d)), BigDecimal.valueOf(20)); - FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.2d, 20.2d, 30.2d)), BigDecimal.valueOf(20.2)); + FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.2d, 20.2d, 30.2d)), + BigDecimal.valueOf(20.2)); } @Test diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MinFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MinFunctionTest.java index d41c0e2ccfa..59b1a8634b6 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MinFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MinFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -27,19 +27,13 @@ import java.util.List; import java.util.function.Predicate; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class MinFunctionTest { - private MinFunction minFunction; - - @BeforeEach - void setUp() { - minFunction = new MinFunction(); - } + private static final MinFunction minFunction = MinFunction.INSTANCE; @Test void invokeNullList() { @@ -53,7 +47,8 @@ void invokeEmptyList() { @Test void invokeListWithHeterogenousTypes() { - FunctionTestUtil.assertResultError(minFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(minFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), + InvalidParametersEvent.class); } @Test @@ -79,12 +74,18 @@ void invokeListOfChronoPeriods() { final ChronoPeriod p2Period = Period.parse("P1M"); final ChronoPeriod p2Comparable = ComparablePeriod.parse("P1M"); Predicate assertion = i -> i.get(ChronoUnit.YEARS) == 0 && i.get(ChronoUnit.MONTHS) == 1; - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Collections.singletonList(p2Period)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Collections.singletonList(p2Comparable)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Arrays.asList(p1Period, p2Period)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Arrays.asList(p1Comparable, p2Period)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Arrays.asList(p1Period, p2Comparable)), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Arrays.asList(p1Comparable, p2Comparable)), ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Collections.singletonList(p2Period)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Collections.singletonList(p2Comparable)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Arrays.asList(p1Period, p2Period)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Arrays.asList(p1Comparable, p2Period)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Arrays.asList(p1Period, p2Comparable)), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(Arrays.asList(p1Comparable, p2Comparable)), + ChronoPeriod.class, assertion); } @Test @@ -99,7 +100,8 @@ void invokeEmptyArray() { @Test void invokeArrayWithHeterogenousTypes() { - FunctionTestUtil.assertResultError(minFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(minFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), + InvalidParametersEvent.class); } @Test @@ -125,11 +127,17 @@ void invokeArrayOfChronoPeriods() { final ChronoPeriod p2Period = Period.parse("P1M"); final ChronoPeriod p2Comparable = ComparablePeriod.parse("P1M"); Predicate assertion = i -> i.get(ChronoUnit.YEARS) == 0 && i.get(ChronoUnit.MONTHS) == 1; - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p2Period}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p2Comparable}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p1Period, p2Period}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p1Comparable, p2Period}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p1Period, p2Comparable}), ChronoPeriod.class, assertion); - FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p1Comparable, p2Comparable}), ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p2Period}), ChronoPeriod.class, + assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p2Comparable}), ChronoPeriod.class, + assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p1Period, p2Period}), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p1Comparable, p2Period}), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p1Period, p2Comparable}), + ChronoPeriod.class, assertion); + FunctionTestUtil.assertPredicateOnResult(minFunction.invoke(new Object[]{p1Comparable, p2Comparable}), + ChronoPeriod.class, assertion); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MonthOfYearTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MonthOfYearTest.java index a837fce749a..c77e169f3e4 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MonthOfYearTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MonthOfYearTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -24,25 +24,21 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class MonthOfYearTest { - private MonthOfYearFunction fut; - - @BeforeEach - void setUp() { - fut = MonthOfYearFunction.INSTANCE; - } + private static final MonthOfYearFunction fut = MonthOfYearFunction.INSTANCE; @Test void monthOfYearFunctionTemporalAccessor() { FunctionTestUtil.assertResult(fut.invoke(LocalDate.of(2019, 9, 17)), "September"); FunctionTestUtil.assertResult(fut.invoke(LocalDateTime.of(2019, 9, 17, 0, 0, 0)), "September"); - FunctionTestUtil.assertResult(fut.invoke(OffsetDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), "September"); - FunctionTestUtil.assertResult(fut.invoke(ZonedDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), "September"); + FunctionTestUtil.assertResult(fut.invoke(OffsetDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), + "September"); + FunctionTestUtil.assertResult(fut.invoke(ZonedDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), + "September"); FunctionTestUtil.assertResultError(fut.invoke(null), InvalidParametersEvent.class); } } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NotFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NotFunctionTest.java index 1d5aef5cca4..c79073df62c 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NotFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NotFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -20,18 +20,12 @@ import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class NotFunctionTest { - private NotFunction notFunction; - - @BeforeEach - void setUp() { - notFunction = new NotFunction(); - } + private static final NotFunction notFunction = NotFunction.INSTANCE; @Test void invokeNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NowFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NowFunctionTest.java index adaf8d74819..7bc19492a3c 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NowFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NowFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -21,24 +21,18 @@ import java.time.ZonedDateTime; import java.time.temporal.TemporalAccessor; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.kie.dmn.feel.runtime.functions.extended.NowFunction; import static org.assertj.core.api.Assertions.assertThat; class NowFunctionTest { - private NowFunction nowFunction; - - @BeforeEach - void setUp() { - nowFunction = new NowFunction(); - } + private static final NowFunction nowFunction = NowFunction.INSTANCE; @Test void invoke() { - // The current time that we need to compare will almost never be the same as another one we get for comparison purposes, + // The current time that we need to compare will almost never be the same as another one we get for + // comparison purposes, // because there is some execution between them, so the comparison assertion doesn't make sense. // Note: We cannot guarantee any part of the date to be the same. E.g. in case when the test is executed // at the exact moment when the year is flipped to the next one, we cannot guarantee the year will be the same. @@ -49,5 +43,4 @@ void invoke() { assertThat(result).isNotNull(); assertThat(result).isInstanceOfAny(ZonedDateTime.class); } - } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NumberFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NumberFunctionTest.java index 16c322489e3..0e2ef01e32b 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NumberFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NumberFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -20,18 +20,12 @@ import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class NumberFunctionTest { - private NumberFunction numberFunction; - - @BeforeEach - void setUp() { - numberFunction = new NumberFunction(); - } + private static final NumberFunction numberFunction = NumberFunction.INSTANCE; @Test void invokeNull() { @@ -87,8 +81,10 @@ void invokeNumberWithDecimalCharDot() { @Test void invokeNumberWithGroupAndDecimalChar() { FunctionTestUtil.assertResult(numberFunction.invoke("9 876.124", " ", "."), BigDecimal.valueOf(9876.124)); - FunctionTestUtil.assertResult(numberFunction.invoke("9 876 000.124", " ", "."), BigDecimal.valueOf(9876000.124)); - FunctionTestUtil.assertResult(numberFunction.invoke("9.876.000,124", ".", ","), BigDecimal.valueOf(9876000.124)); + FunctionTestUtil.assertResult(numberFunction.invoke("9 876 000.124", " ", "."), + BigDecimal.valueOf(9876000.124)); + FunctionTestUtil.assertResult(numberFunction.invoke("9.876.000,124", ".", ","), + BigDecimal.valueOf(9876000.124)); } @Test diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RangeFunctionTest.java similarity index 66% rename from kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunctionTest.java rename to kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RangeFunctionTest.java index 3fea8c48bdb..08a77bde8ed 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RangeFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; import java.time.Duration; @@ -29,7 +29,6 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.ast.AtLiteralNode; import org.kie.dmn.feel.lang.ast.BaseNode; @@ -41,34 +40,29 @@ import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FEELFnResult; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; import static org.assertj.core.api.Assertions.assertThat; class RangeFunctionTest { - private RangeFunction rangeFunction; - - @BeforeEach - void setUp() { - rangeFunction = new RangeFunction(); - } + private static final RangeFunction rangeFunction = RangeFunction.INSTANCE; @Test void invokeNull() { List from = Arrays.asList(null, " ", "", "[..]"); - from.forEach(it -> FunctionTestUtil.assertResultError(rangeFunction.invoke(it), InvalidParametersEvent.class, it)); + from.forEach(it -> FunctionTestUtil.assertResultError(rangeFunction.invoke(it), InvalidParametersEvent.class, + it)); } @Test void invokeDifferentTypes() { List from = Arrays.asList("[1..\"cheese\"]", - "[1..date(\"1978-09-12\")]", - "[1..date(\"1978-09-12\")]", - "[1..\"upper case(\"aBc4\")\"]"); - from.forEach(it -> FunctionTestUtil.assertResultError(rangeFunction.invoke(it), InvalidParametersEvent.class, it)); + "[1..date(\"1978-09-12\")]", + "[1..date(\"1978-09-12\")]", + "[1..\"upper case(\"aBc4\")\"]"); + from.forEach(it -> FunctionTestUtil.assertResultError(rangeFunction.invoke(it), InvalidParametersEvent.class, + it)); } @Test @@ -81,169 +75,189 @@ void invokeInvalidTypes() { void invoke_LeftNull() { String from = "(..2)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, null, BigDecimal.valueOf(2), Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, null, BigDecimal.valueOf(2), + Range.RangeBoundary.OPEN), + from); from = "(..\"z\")"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, null, "z", Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, null, "z", Range.RangeBoundary.OPEN), + from); from = "(..\"yz\")"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, null, "yz", Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, null, "yz", Range.RangeBoundary.OPEN), + from); from = "(..date(\"1978-10-13\"))"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, null, LocalDate.of(1978, 10, 13), Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, null, LocalDate.of(1978, 10, 13), + Range.RangeBoundary.OPEN), + from); from = "(..duration(\"P3DT20H14M\"))"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, null, Duration.parse("P3DT20H14M"), Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, null, Duration.parse("P3DT20H14M"), + Range.RangeBoundary.OPEN), + from); from = "(..duration(\"P2Y6M\"))"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, - null, - new ComparablePeriod(Period.parse("P2Y6M")), - Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, + null, + new ComparablePeriod(Period.parse("P2Y6M")), + Range.RangeBoundary.OPEN), + from); } @Test void invoke_RightNull() { String from = "(1..)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, null, Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, null, + Range.RangeBoundary.OPEN), + from); from = "(\"a\"..)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, "a", null, Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, "a", null, Range.RangeBoundary.OPEN), + from); from = "(\"ab\"..)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, "ab", null, Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, "ab", null, Range.RangeBoundary.OPEN), + from); from = "(date(\"1978-09-12\")..)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, LocalDate.of(1978, 9, 12), null, Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, LocalDate.of(1978, 9, 12), null, + Range.RangeBoundary.OPEN), + from); from = "(duration(\"P2DT20H14M\")..)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, Duration.parse("P2DT20H14M"), null, Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, Duration.parse("P2DT20H14M"), null, + Range.RangeBoundary.OPEN), + from); from = "(duration(\"P1Y6M\")..)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, - new ComparablePeriod(Period.parse("P1Y6M")), - null, - Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, + new ComparablePeriod(Period.parse("P1Y6M")), + null, + Range.RangeBoundary.OPEN), + from); } @Test void invoke_OpenOpenBoundaries() { String from = "(1..2)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, BigDecimal.valueOf(2), + Range.RangeBoundary.OPEN), + from); from = "(\"a\"..\"z\")"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, "a", "z", Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, "a", "z", Range.RangeBoundary.OPEN), + from); from = "(\"ab\"..\"yz\")"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, "ab", "yz", Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, "ab", "yz", Range.RangeBoundary.OPEN), + from); from = "(date(\"1978-09-12\")..date(\"1978-10-13\"))"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, LocalDate.of(1978, 9, 12), LocalDate.of(1978, 10, 13), Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, LocalDate.of(1978, 9, 12), + LocalDate.of(1978, 10, 13), Range.RangeBoundary.OPEN), + from); from = "(duration(\"P2DT20H14M\")..duration(\"P3DT20H14M\"))"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, Duration.parse("P2DT20H14M"), Duration.parse("P3DT20H14M"), Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, Duration.parse("P2DT20H14M"), + Duration.parse("P3DT20H14M"), Range.RangeBoundary.OPEN), + from); from = "(duration(\"P1Y6M\")..duration(\"P2Y6M\"))"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, - new ComparablePeriod(Period.parse("P1Y6M")), - new ComparablePeriod(Period.parse("P2Y6M")), - Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.OPEN, + new ComparablePeriod(Period.parse("P1Y6M")), + new ComparablePeriod(Period.parse("P2Y6M")), + Range.RangeBoundary.OPEN), + from); } @Test void invoke_OpenClosedBoundaries() { String from = "(1..2]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, BigDecimal.valueOf(2), + Range.RangeBoundary.CLOSED), + from); from = "(\"a\"..\"z\"]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, "a", "z", Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.OPEN, "a", "z", Range.RangeBoundary.CLOSED), + from); from = "(date(\"1978-09-12\")..date(\"1978-10-13\")]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, LocalDate.of(1978, 9, 12), LocalDate.of(1978, 10, 13), Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.OPEN, LocalDate.of(1978, 9, 12), + LocalDate.of(1978, 10, 13), Range.RangeBoundary.CLOSED), + from); from = "(duration(\"P2DT20H14M\")..duration(\"P3DT20H14M\")]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.OPEN, Duration.parse("P2DT20H14M"), Duration.parse("P3DT20H14M"), Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.OPEN, Duration.parse("P2DT20H14M"), + Duration.parse("P3DT20H14M"), Range.RangeBoundary.CLOSED), + from); } @Test void invoke_ClosedOpenBoundaries() { String from = "[1..2)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2) + , Range.RangeBoundary.OPEN), + from); from = "[\"a\"..\"z\")"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.CLOSED, "a", "z", Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, "a", "z", Range.RangeBoundary.OPEN), + from); from = "[date(\"1978-09-12\")..date(\"1978-10-13\"))"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.CLOSED, LocalDate.of(1978, 9, 12), LocalDate.of(1978, 10, 13), Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, LocalDate.of(1978, 9, 12), + LocalDate.of(1978, 10, 13), Range.RangeBoundary.OPEN), + from); from = "[duration(\"P2DT20H14M\")..duration(\"P3DT20H14M\"))"; FunctionTestUtil.assertResult(rangeFunction.invoke("[duration(\"P2DT20H14M\")..duration(\"P3DT20H14M\"))"), - new RangeImpl(Range.RangeBoundary.CLOSED, Duration.parse("P2DT20H14M"), Duration.parse("P3DT20H14M"), Range.RangeBoundary.OPEN), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, Duration.parse("P2DT20H14M"), + Duration.parse("P3DT20H14M"), Range.RangeBoundary.OPEN), + from); } @Test void invoke_ClosedClosedBoundaries() { String from = "[1..2)"; FunctionTestUtil.assertResult(rangeFunction.invoke("[1..2]"), - new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2) + , Range.RangeBoundary.CLOSED), + from); from = "[2..1]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.valueOf(2), BigDecimal.ONE, Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.valueOf(2), BigDecimal.ONE + , Range.RangeBoundary.CLOSED), + from); from = "[\"a\"..\"z\"]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.CLOSED, "a", "z", Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, "a", "z", Range.RangeBoundary.CLOSED), + from); from = "[date(\"1978-09-12\")..date(\"1978-10-13\")]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.CLOSED, LocalDate.of(1978, 9, 12), LocalDate.of(1978, 10, 13), Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, LocalDate.of(1978, 9, 12), + LocalDate.of(1978, 10, 13), Range.RangeBoundary.CLOSED), + from); from = "[duration(\"P2DT20H14M\")..duration(\"P3DT20H14M\")]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.CLOSED, Duration.parse("P2DT20H14M"), Duration.parse("P3DT20H14M"), Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, Duration.parse("P2DT20H14M"), + Duration.parse("P3DT20H14M"), Range.RangeBoundary.CLOSED), + from); } @Test void invoke_WithOneFunctionNode() { String from = "[number(\"1\", \",\", \".\")\"..2]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2) + , Range.RangeBoundary.CLOSED), + from); from = "[\"a\"..lower case(\"Z\")]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), - new RangeImpl(Range.RangeBoundary.CLOSED, "a", "z", Range.RangeBoundary.CLOSED), - from); + new RangeImpl(Range.RangeBoundary.CLOSED, "a", "z", Range.RangeBoundary.CLOSED), + from); } @Test @@ -387,7 +401,6 @@ void getNullNode() { assertThat(rangeFunction.getNullNode()).isInstanceOf(NullNode.class); } - private NumberNode getNumberNode() { return (NumberNode) rangeFunction.parse("1"); } @@ -408,7 +421,8 @@ private FunctionInvocationNode getFunctionInvocationNodeA() { return (FunctionInvocationNode) rangeFunction.parse("duration(\"P2DT20H14M\")"); } - // 10.3.2.7 Endpoints can be either a literal or a qualified name of the following types: number, string, date, time, date and + // 10.3.2.7 Endpoints can be either a literal or a qualified name of the following types: number, string, date, + // time, date and //time, or duration. private static Object[][] validFunctionInvocationNodeData() { // Subset of FEELFunctionsTest.data @@ -498,7 +512,8 @@ private static Object[][] validFunctionInvocationNodeData() { }; } - // 10.3.2.7 Endpoints can be either a literal or a qualified name of the following types: number, string, date, time, date and + // 10.3.2.7 Endpoints can be either a literal or a qualified name of the following types: number, string, date, + // time, date and //time, or duration. private static Object[][] invalidFunctionInvocationNodeData() { // Subset of FEELFunctionsTest.data @@ -522,43 +537,68 @@ private static Object[][] invalidFunctionInvocationNodeData() { {"list contains([1, 2, 3], 5)", Boolean.FALSE}, {"sublist( [1, 2, 3, 4, 5 ], 3, 2 )", Arrays.asList(BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, {"sublist( [1, 2, 3, 4, 5 ], -2, 1 )", Collections.singletonList(BigDecimal.valueOf(4))}, - {"sublist( [1, 2, 3, 4, 5 ], -5, 3 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3))}, - {"sublist( [1, 2, 3, 4, 5 ], 1, 3 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3))}, - {"append( [1, 2], 3, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, + {"sublist( [1, 2, 3, 4, 5 ], -5, 3 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(3))}, + {"sublist( [1, 2, 3, 4, 5 ], 1, 3 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(3))}, + {"append( [1, 2], 3, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, {"append( [], 3, 4 )", Arrays.asList(BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, {"append( [1, 2] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2))}, - {"append( [1, 2], null, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), null, BigDecimal.valueOf(4))}, - {"append( 0, 1, 2 )", Arrays.asList(BigDecimal.valueOf(0), BigDecimal.valueOf(1), BigDecimal.valueOf(2))}, - {"concatenate( [1, 2], [3] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3))}, - {"concatenate( [1, 2], 3, [4] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, - {"insert before( [1, 2, 3], 1, 4 )", Arrays.asList(BigDecimal.valueOf(4), BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3))}, - {"insert before( [1, 2, 3], 3, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(4), BigDecimal.valueOf(3))}, - {"insert before( [1, 2, 3], 3, null )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), null, BigDecimal.valueOf(3))}, - {"insert before( [1, 2, 3], -3, 4 )", Arrays.asList(BigDecimal.valueOf(4), BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3))}, - {"insert before( [1, 2, 3], -1, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(4), BigDecimal.valueOf(3))}, + {"append( [1, 2], null, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), null, + BigDecimal.valueOf(4))}, + {"append( 0, 1, 2 )", Arrays.asList(BigDecimal.valueOf(0), BigDecimal.valueOf(1), + BigDecimal.valueOf(2))}, + {"concatenate( [1, 2], [3] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(3))}, + {"concatenate( [1, 2], 3, [4] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, + {"insert before( [1, 2, 3], 1, 4 )", Arrays.asList(BigDecimal.valueOf(4), BigDecimal.valueOf(1), + BigDecimal.valueOf(2), BigDecimal.valueOf(3))}, + {"insert before( [1, 2, 3], 3, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(4), BigDecimal.valueOf(3))}, + {"insert before( [1, 2, 3], 3, null )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + null, BigDecimal.valueOf(3))}, + {"insert before( [1, 2, 3], -3, 4 )", Arrays.asList(BigDecimal.valueOf(4), BigDecimal.valueOf(1), + BigDecimal.valueOf(2), BigDecimal.valueOf(3))}, + {"insert before( [1, 2, 3], -1, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(4), BigDecimal.valueOf(3))}, {"remove( [1, 2, 3], 1 )", Arrays.asList(BigDecimal.valueOf(2), BigDecimal.valueOf(3))}, {"remove( [1, 2, 3], 3 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2))}, {"remove( [1, 2, 3], -1 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2))}, {"remove( [1, 2, 3], -3 )", Arrays.asList(BigDecimal.valueOf(2), BigDecimal.valueOf(3))}, - {"reverse( [1, 2, 3] )", Arrays.asList(BigDecimal.valueOf(3), BigDecimal.valueOf(2), BigDecimal.valueOf(1))}, + {"reverse( [1, 2, 3] )", Arrays.asList(BigDecimal.valueOf(3), BigDecimal.valueOf(2), + BigDecimal.valueOf(1))}, {"index of( [1, 2, 3, 2], 2 )", Arrays.asList(BigDecimal.valueOf(2), BigDecimal.valueOf(4))}, {"index of( [1, 2, null, null], null )", Arrays.asList(BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, {"index of( [1, 2, null, null], 1 )", Collections.singletonList(BigDecimal.valueOf(1))}, - {"union( [1, 2, 1], [2, 3], 2, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, - {"union( [1, 2, null], 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), null, BigDecimal.valueOf(4))}, + {"union( [1, 2, 1], [2, 3], 2, 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, + {"union( [1, 2, null], 4 )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), null, + BigDecimal.valueOf(4))}, {"union( null, 4 )", Arrays.asList(null, BigDecimal.valueOf(4))}, - {"distinct values( [1, 2, 3, 2, 4] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, - {"distinct values( [1, 2, null, 2, 4] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), null, BigDecimal.valueOf(4))}, + {"distinct values( [1, 2, 3, 2, 4] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(3), BigDecimal.valueOf(4))}, + {"distinct values( [1, 2, null, 2, 4] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + null, BigDecimal.valueOf(4))}, {"distinct values( 1 )", Collections.singletonList(BigDecimal.valueOf(1))}, - {"sort( [3, 1, 4, 5, 2], function(x,y) x < y )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3), - BigDecimal.valueOf(4), BigDecimal.valueOf(5))}, - {"sort( [3, 1, 4, 5, 2] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3), - BigDecimal.valueOf(4), BigDecimal.valueOf(5))}, - {"sort( list : [3, 1, 4, 5, 2] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3), - BigDecimal.valueOf(4), BigDecimal.valueOf(5))}, - {"sort( [\"c\", \"e\", \"d\", \"a\", \"b\"], function(x,y) x < y )", Arrays.asList("a", "b", "c", "d", "e")}, - {"sort( list : [\"c\", \"e\", \"d\", \"a\", \"b\"], precedes : function(x,y) x < y )", Arrays.asList("a", "b", "c", "d", "e")}, - {"sort( precedes : function(x,y) x < y, list : [\"c\", \"e\", \"d\", \"a\", \"b\"] )", Arrays.asList("a", "b", "c", "d", "e")}, + {"sort( [3, 1, 4, 5, 2], function(x,y) x < y )", Arrays.asList(BigDecimal.valueOf(1), + BigDecimal.valueOf(2), + BigDecimal.valueOf(3), + BigDecimal.valueOf(4), + BigDecimal.valueOf(5))}, + {"sort( [3, 1, 4, 5, 2] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(3), + BigDecimal.valueOf(4), BigDecimal.valueOf(5))}, + {"sort( list : [3, 1, 4, 5, 2] )", Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), + BigDecimal.valueOf(3), + BigDecimal.valueOf(4), BigDecimal.valueOf(5))}, + {"sort( [\"c\", \"e\", \"d\", \"a\", \"b\"], function(x,y) x < y )", Arrays.asList("a", "b", "c", "d" + , "e")}, + {"sort( list : [\"c\", \"e\", \"d\", \"a\", \"b\"], precedes : function(x,y) x < y )", Arrays.asList( + "a", "b", "c", "d", "e")}, + {"sort( precedes : function(x,y) x < y, list : [\"c\", \"e\", \"d\", \"a\", \"b\"] )", Arrays.asList( + "a", "b", "c", "d", "e")}, {"all( true )", true}, {"all( false )", false}, {"all( [true] )", true}, @@ -581,6 +621,4 @@ private static Object[][] invalidFunctionInvocationNodeData() { {"any( [] )", false}, }; } - - } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RemoveFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RemoveFunctionTest.java index a4f1b0def08..aade71092b6 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RemoveFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RemoveFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,42 +23,45 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class RemoveFunctionTest { - private RemoveFunction removeFunction; - - @BeforeEach - void setUp() { - removeFunction = new RemoveFunction(); - } + private static final RemoveFunction removeFunction = RemoveFunction.INSTANCE; @Test void invokeNull() { FunctionTestUtil.assertResultError(removeFunction.invoke((List) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(removeFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.emptyList(), null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.emptyList(), null), + InvalidParametersEvent.class); } @Test void invokePositionZero() { - FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.ZERO), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.ZERO), + InvalidParametersEvent.class); } @Test void invokePositionOutOfListBounds() { - FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(2)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(154)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(-2)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(-154)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(2)) + , InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), + BigDecimal.valueOf(154)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), + BigDecimal.valueOf(-2)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), + BigDecimal.valueOf(-154)), + InvalidParametersEvent.class); } @Test void invokePositionPositive() { - FunctionTestUtil.assertResultList(removeFunction.invoke(Collections.singletonList(1), BigDecimal.ONE), Collections.emptyList()); + FunctionTestUtil.assertResultList(removeFunction.invoke(Collections.singletonList(1), BigDecimal.ONE), + Collections.emptyList()); FunctionTestUtil.assertResultList( removeFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(14)), BigDecimal.ONE), Arrays.asList("test", BigDecimal.valueOf(14))); @@ -72,7 +75,8 @@ void invokePositionPositive() { @Test void invokePositionNegative() { - FunctionTestUtil.assertResultList(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(-1)), Collections.emptyList()); + FunctionTestUtil.assertResultList(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(-1)) + , Collections.emptyList()); FunctionTestUtil.assertResultList( removeFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(14)), BigDecimal.valueOf(-1)), Arrays.asList(1, "test")); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReplaceFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReplaceFunctionTest.java index 125914338de..8864beaa143 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReplaceFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReplaceFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,24 +18,20 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class ReplaceFunctionTest { - private ReplaceFunction replaceFunction; - - @BeforeEach - void setUp() { - replaceFunction = new ReplaceFunction(); - } + private static final ReplaceFunction replaceFunction = ReplaceFunction.INSTANCE; @Test void invokeNull() { FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", "test", null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", "test", null), + InvalidParametersEvent.class); FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", "ttt"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, "ttt"), InvalidParametersEvent.class); @@ -43,19 +39,30 @@ void invokeNull() { @Test void invokeNullWithFlags() { - FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", null, null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", "test", null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", "ttt", null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, "ttt", null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", null, null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", "test", null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", "ttt", null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, "ttt", null), + InvalidParametersEvent.class); FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, null, "s"), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", null, null, "s"), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", "test", null, "s"), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", null, "s"), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", "ttt", "s"), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, "ttt", "s"), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", null, null, "s"), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", "test", null, "s"), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", null, "s"), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke(null, "test", "ttt", "s"), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, "ttt", "s"), + InvalidParametersEvent.class); } @Test diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReverseFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReverseFunctionTest.java index b40e64c186d..13b2e3b28fc 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReverseFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReverseFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,18 +22,12 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class ReverseFunctionTest { - private ReverseFunction reverseFunction; - - @BeforeEach - void setUp() { - reverseFunction = new ReverseFunction(); - } + private static final ReverseFunction reverseFunction = ReverseFunction.INSTANCE; @Test void invokeNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundDownFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundDownFunctionTest.java similarity index 62% rename from kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundDownFunctionTest.java rename to kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundDownFunctionTest.java index 37e4742f759..5b58c9fdf4d 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundDownFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundDownFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -16,64 +16,69 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; + +import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - -import java.math.BigDecimal; class RoundDownFunctionTest { - private RoundDownFunction roundDownFunction; - - @BeforeEach - void setUp() { - roundDownFunction = new RoundDownFunction(); - } + private static final RoundDownFunction roundDownFunction = RoundDownFunction.INSTANCE; @Test void invokeNull() { FunctionTestUtil.assertResultError(roundDownFunction.invoke(null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundDownFunction.invoke((BigDecimal) null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundDownFunction.invoke(BigDecimal.ONE, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundDownFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundDownFunction.invoke((BigDecimal) null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundDownFunction.invoke(BigDecimal.ONE, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundDownFunction.invoke(null, BigDecimal.ONE), + InvalidParametersEvent.class); } @Test void invokeRoundingUp() { FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.27)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), BigDecimal.valueOf(10.2)); + FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), + BigDecimal.valueOf(10.2)); } @Test void invokeRoundingDown() { FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.24)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), BigDecimal.valueOf(10.2)); + FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), + BigDecimal.valueOf(10.2)); } @Test void invokeRoundingEven() { FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.25)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), BigDecimal.valueOf(10.2)); + FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), + BigDecimal.valueOf(10.2)); } @Test void invokeRoundingOdd() { FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.35)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), BigDecimal.valueOf(10.3)); + FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), + BigDecimal.valueOf(10.3)); } @Test void invokeLargerScale() { - FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.123456789), BigDecimal.valueOf(6)), BigDecimal.valueOf(10.123456)); + FunctionTestUtil.assertResult(roundDownFunction.invoke(BigDecimal.valueOf(10.123456789), + BigDecimal.valueOf(6)), BigDecimal.valueOf(10.123456)); } @Test void invokeOutRangeScale() { - FunctionTestUtil.assertResultError(roundDownFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(6177)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundDownFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(-6122)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundDownFunction.invoke(BigDecimal.valueOf(1.5), + BigDecimal.valueOf(6177)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundDownFunction.invoke(BigDecimal.valueOf(1.5), + BigDecimal.valueOf(-6122)), + InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfDownFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundHalfDownFunctionTest.java similarity index 61% rename from kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfDownFunctionTest.java rename to kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundHalfDownFunctionTest.java index d91b548c14b..79d498b1239 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfDownFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundHalfDownFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -16,64 +16,70 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; + +import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - -import java.math.BigDecimal; class RoundHalfDownFunctionTest { - private RoundHalfDownFunction roundHalfDownFunction; - - @BeforeEach - void setUp() { - roundHalfDownFunction = new RoundHalfDownFunction(); - } + private static final RoundHalfDownFunction roundHalfDownFunction = RoundHalfDownFunction.INSTANCE; @Test void invokeNull() { FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke(null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke((BigDecimal) null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke(BigDecimal.ONE, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke((BigDecimal) null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke(BigDecimal.ONE, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke(null, BigDecimal.ONE), + InvalidParametersEvent.class); } @Test void invokeRoundingUp() { FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.27)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), BigDecimal.valueOf(10.3)); + FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), + BigDecimal.valueOf(10.3)); } @Test void invokeRoundingDown() { FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.24)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), BigDecimal.valueOf(10.2)); + FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), + BigDecimal.valueOf(10.2)); } @Test void invokeRoundingEven() { FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.25)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), BigDecimal.valueOf(10.2)); + FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), + BigDecimal.valueOf(10.2)); } @Test void invokeRoundingOdd() { FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.35)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), BigDecimal.valueOf(10.3)); + FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), + BigDecimal.valueOf(10.3)); } @Test void invokeLargerScale() { - FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.123456789), BigDecimal.valueOf(6)), BigDecimal.valueOf(10.123457)); + FunctionTestUtil.assertResult(roundHalfDownFunction.invoke(BigDecimal.valueOf(10.123456789), + BigDecimal.valueOf(6)), + BigDecimal.valueOf(10.123457)); } @Test void invokeOutRangeScale() { - FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(6177)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(-6122)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke(BigDecimal.valueOf(1.5), + BigDecimal.valueOf(6177)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfDownFunction.invoke(BigDecimal.valueOf(1.5), + BigDecimal.valueOf(-6122)), + InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfUpFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundHalfUpFunctionTest.java similarity index 62% rename from kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfUpFunctionTest.java rename to kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundHalfUpFunctionTest.java index a5afd7a5013..b37deb7d6f9 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundHalfUpFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundHalfUpFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -16,64 +16,69 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; + +import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - -import java.math.BigDecimal; class RoundHalfUpFunctionTest { - private RoundHalfUpFunction roundHalfUpFunction; - - @BeforeEach - void setUp() { - roundHalfUpFunction = new RoundHalfUpFunction(); - } + private static final RoundHalfUpFunction roundHalfUpFunction = RoundHalfUpFunction.INSTANCE; @Test void invokeNull() { FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke(null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke((BigDecimal) null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke(BigDecimal.ONE, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke((BigDecimal) null, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke(BigDecimal.ONE, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke(null, BigDecimal.ONE), + InvalidParametersEvent.class); } @Test void invokeRoundingUp() { FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.27)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), BigDecimal.valueOf(10.3)); + FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), + BigDecimal.valueOf(10.3)); } @Test void invokeRoundingDown() { FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.24)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), BigDecimal.valueOf(10.2)); + FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), + BigDecimal.valueOf(10.2)); } @Test void invokeRoundingEven() { FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.25)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), BigDecimal.valueOf(10.3)); + FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), + BigDecimal.valueOf(10.3)); } @Test void invokeRoundingOdd() { FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.35)), BigDecimal.valueOf(10)); - FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), BigDecimal.valueOf(10.4)); + FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), + BigDecimal.valueOf(10.4)); } @Test void invokeLargerScale() { - FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.123456789), BigDecimal.valueOf(6)), BigDecimal.valueOf(10.123457)); + FunctionTestUtil.assertResult(roundHalfUpFunction.invoke(BigDecimal.valueOf(10.123456789), + BigDecimal.valueOf(6)), BigDecimal.valueOf(10.123457)); } @Test void invokeOutRangeScale() { - FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(6177)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(-6122)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke(BigDecimal.valueOf(1.5), + BigDecimal.valueOf(6177)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundHalfUpFunction.invoke(BigDecimal.valueOf(1.5), + BigDecimal.valueOf(-6122)), + InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundUpFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundUpFunctionTest.java similarity index 70% rename from kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundUpFunctionTest.java rename to kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundUpFunctionTest.java index 2175fe8f5c7..5827e777c8c 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RoundUpFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RoundUpFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -16,28 +16,22 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.dmn.feel.runtime.functions.extended; +package org.kie.dmn.feel.runtime.functions; + +import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - -import java.math.BigDecimal; class RoundUpFunctionTest { - private RoundUpFunction roundUpFunction; - - @BeforeEach - void setUp() { - roundUpFunction = new RoundUpFunction(); - } + private static final RoundUpFunction roundUpFunction = RoundUpFunction.INSTANCE; @Test void invokeNull() { FunctionTestUtil.assertResultError(roundUpFunction.invoke(null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundUpFunction.invoke((BigDecimal) null, null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundUpFunction.invoke((BigDecimal) null, null), + InvalidParametersEvent.class); FunctionTestUtil.assertResultError(roundUpFunction.invoke(BigDecimal.ONE, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(roundUpFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); } @@ -45,35 +39,42 @@ void invokeNull() { @Test void invokeRoundingUp() { FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.27)), BigDecimal.valueOf(11)); - FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), BigDecimal.valueOf(10.3)); + FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), + BigDecimal.valueOf(10.3)); } @Test void invokeRoundingDown() { FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.24)), BigDecimal.valueOf(11)); - FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), BigDecimal.valueOf(10.3)); + FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), + BigDecimal.valueOf(10.3)); } @Test void invokeRoundingEven() { FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.25)), BigDecimal.valueOf(11)); - FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), BigDecimal.valueOf(10.3)); + FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), + BigDecimal.valueOf(10.3)); } @Test void invokeRoundingOdd() { FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.35)), BigDecimal.valueOf(11)); - FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), BigDecimal.valueOf(10.4)); + FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), + BigDecimal.valueOf(10.4)); } @Test void invokeLargerScale() { - FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.123456789), BigDecimal.valueOf(6)), BigDecimal.valueOf(10.123457)); + FunctionTestUtil.assertResult(roundUpFunction.invoke(BigDecimal.valueOf(10.123456789), BigDecimal.valueOf(6)) + , BigDecimal.valueOf(10.123457)); } @Test void invokeOutRangeScale() { - FunctionTestUtil.assertResultError(roundUpFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(6177)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(roundUpFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(-6122)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundUpFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(6177)), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(roundUpFunction.invoke(BigDecimal.valueOf(1.5), BigDecimal.valueOf(-6122)) + , InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SortFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SortFunctionTest.java index ea35bba6cb1..ffbb96ea34f 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SortFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SortFunctionTest.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.lang.Symbol; @@ -32,12 +31,7 @@ class SortFunctionTest { - private SortFunction sortFunction; - - @BeforeEach - void setUp() { - sortFunction = new SortFunction(); - } + private static final SortFunction sortFunction = SortFunction.INSTANCE; @Test void invokeListParamNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StartsWithFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StartsWithFunctionTest.java index c4ff1ea5db2..e4dcd3d63b6 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StartsWithFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StartsWithFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,22 +18,17 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class StartsWithFunctionTest { - private StartsWithFunction startsWithFunction; - - @BeforeEach - void setUp() { - startsWithFunction = new StartsWithFunction(); - } + private static final StartsWithFunction startsWithFunction = StartsWithFunction.INSTANCE; @Test void invokeNull() { - FunctionTestUtil.assertResultError(startsWithFunction.invoke((String) null, null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(startsWithFunction.invoke((String) null, null), + InvalidParametersEvent.class); FunctionTestUtil.assertResultError(startsWithFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(startsWithFunction.invoke("test", null), InvalidParametersEvent.class); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringFunctionTest.java index 8f36668a7c5..091c00f43d7 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -33,7 +33,6 @@ import java.util.List; import java.util.Map; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -41,12 +40,7 @@ class StringFunctionTest { - private StringFunction stringFunction; - - @BeforeEach - void setUp() { - stringFunction = new StringFunction(); - } + private static final StringFunction stringFunction = StringFunction.INSTANCE; @Test void invokeNull() { @@ -56,7 +50,8 @@ void invokeNull() { @Test void invokeMaskNull() { FunctionTestUtil.assertResultError(stringFunction.invoke((String) null, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(stringFunction.invoke((String) null, new Object[]{}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(stringFunction.invoke((String) null, new Object[]{}), + InvalidParametersEvent.class); } @Test @@ -90,19 +85,22 @@ void invokeOffsetTime() { @Test void invokeLocalDateTime() { final LocalDateTime localDateTime = LocalDateTime.now(); - FunctionTestUtil.assertResult(stringFunction.invoke(localDateTime), DateAndTimeFunction.FEEL_DATE_TIME.format(localDateTime)); + FunctionTestUtil.assertResult(stringFunction.invoke(localDateTime), + DateAndTimeFunction.FEEL_DATE_TIME.format(localDateTime)); } @Test void invokeOffsetDateTime() { final OffsetDateTime offsetDateTime = OffsetDateTime.now(); - FunctionTestUtil.assertResult(stringFunction.invoke(offsetDateTime), DateAndTimeFunction.FEEL_DATE_TIME.format(offsetDateTime)); + FunctionTestUtil.assertResult(stringFunction.invoke(offsetDateTime), + DateAndTimeFunction.FEEL_DATE_TIME.format(offsetDateTime)); } @Test void invokeZonedDateTime() { final ZonedDateTime zonedDateTime = ZonedDateTime.now(); - FunctionTestUtil.assertResult(stringFunction.invoke(zonedDateTime), DateAndTimeFunction.REGION_DATETIME_FORMATTER.format(zonedDateTime)); + FunctionTestUtil.assertResult(stringFunction.invoke(zonedDateTime), + DateAndTimeFunction.REGION_DATETIME_FORMATTER.format(zonedDateTime)); } @Test @@ -224,11 +222,13 @@ void invokeContextNonEmpty() { contextMap.put("key1", "value1"); contextMap.put("key2", childContextMap); - FunctionTestUtil.assertResult(stringFunction.invoke(contextMap), "{ key1 : value1, key2 : { childKey1 : childValue1 } }"); + FunctionTestUtil.assertResult(stringFunction.invoke(contextMap), "{ key1 : value1, key2 : { childKey1 : " + + "childValue1 } }"); } @Test void invokeMaskedFormat() { - FunctionTestUtil.assertResult(stringFunction.invoke("%s is here!", new Object[]{"Gorgonzola"}), "Gorgonzola is here!"); + FunctionTestUtil.assertResult(stringFunction.invoke("%s is here!", new Object[]{"Gorgonzola"}), "Gorgonzola " + + "is here!"); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLengthFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLengthFunctionTest.java index 94eceadca52..ea52ff04fb3 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLengthFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLengthFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -20,18 +20,12 @@ import java.math.BigDecimal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class StringLengthFunctionTest { - private StringLengthFunction stringLengthFunction; - - @BeforeEach - void setUp() { - stringLengthFunction = new StringLengthFunction(); - } + private static final StringLengthFunction stringLengthFunction = StringLengthFunction.INSTANCE; @Test void invokeNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunctionTest.java index 7171cffa716..6126be7009e 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,18 +18,12 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class StringLowerCaseFunctionTest { - private StringLowerCaseFunction stringLowerCaseFunction; - - @BeforeEach - void setUp() { - stringLowerCaseFunction = new StringLowerCaseFunction(); - } + private static final StringLowerCaseFunction stringLowerCaseFunction = StringLowerCaseFunction.INSTANCE; @Test void invokeNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunctionTest.java index 8770234a7b4..846f2c05c26 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,18 +18,12 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class StringUpperCaseFunctionTest { - private StringUpperCaseFunction stringUpperCaseFunction; - - @BeforeEach - void setUp() { - stringUpperCaseFunction = new StringUpperCaseFunction(); - } + private static final StringUpperCaseFunction stringUpperCaseFunction = StringUpperCaseFunction.INSTANCE; @Test void invokeNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SublistFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SublistFunctionTest.java index ac0f4cfdfc3..d2fd47b27ce 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SublistFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SublistFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,59 +23,67 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class SublistFunctionTest { - private SublistFunction sublistFunction; - - @BeforeEach - void setUp() { - sublistFunction = new SublistFunction(); - } + private static final SublistFunction sublistFunction = SublistFunction.INSTANCE; @Test void invokeNull() { FunctionTestUtil.assertResultError(sublistFunction.invoke((List) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(sublistFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(sublistFunction.invoke(Collections.emptyList(), null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sublistFunction.invoke(Collections.emptyList(), null), + InvalidParametersEvent.class); } @Test void invokeStartZero() { - FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.ZERO), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.ZERO), + InvalidParametersEvent.class); } @Test void invokeStartOutOfListBounds() { - FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.TEN), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.valueOf(-10)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.TEN), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.valueOf(-10)), + InvalidParametersEvent.class); } @Test void invokeLengthNegative() { - FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.valueOf(1), BigDecimal.valueOf(-3)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.valueOf(1), + BigDecimal.valueOf(-3)), + InvalidParametersEvent.class); } @Test void invokeLengthOutOfListBounds() { - FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.ONE, BigDecimal.valueOf(3)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.valueOf(-1), BigDecimal.valueOf(3)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.ONE, + BigDecimal.valueOf(3)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.valueOf(-1), + BigDecimal.valueOf(3)), InvalidParametersEvent.class); } @Test void invokeStartPositive() { - FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, 2, 3), BigDecimal.valueOf(2)), Arrays.asList(2, 3)); - FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(2)), Arrays.asList("test", 3)); - FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(2), BigDecimal.ONE), Collections.singletonList("test")); + FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, 2, 3), BigDecimal.valueOf(2)), + Arrays.asList(2, 3)); + FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(2)), + Arrays.asList("test", 3)); + FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(2), + BigDecimal.ONE), Collections.singletonList("test")); } @Test void invokeStartNegative() { - FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, 2, 3), BigDecimal.valueOf(-2)), Arrays.asList(2, 3)); - FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(-2)), Arrays.asList("test", 3)); - FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(-2), BigDecimal.ONE), Collections.singletonList("test")); + FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, 2, 3), BigDecimal.valueOf(-2)), + Arrays.asList(2, 3)); + FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(-2)), + Arrays.asList("test", 3)); + FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(-2), + BigDecimal.ONE), Collections.singletonList("test")); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunctionTest.java index 8aae3b448d1..b152ac5ae54 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,22 +18,17 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class SubstringAfterFunctionTest { - private SubstringAfterFunction substringAfterFunction; - - @BeforeEach - void setUp() { - substringAfterFunction = new SubstringAfterFunction(); - } + private static final SubstringAfterFunction substringAfterFunction = SubstringAfterFunction.INSTANCE; @Test void invokeNull() { - FunctionTestUtil.assertResultError(substringAfterFunction.invoke((String) null, null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(substringAfterFunction.invoke((String) null, null), + InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringAfterFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringAfterFunction.invoke("test", null), InvalidParametersEvent.class); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunctionTest.java index 8b4b9fb1ec7..c88e5933727 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,22 +18,17 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class SubstringBeforeFunctionTest { - private SubstringBeforeFunction substringBeforeFunction; - - @BeforeEach - void setUp() { - substringBeforeFunction = new SubstringBeforeFunction(); - } + private static final SubstringBeforeFunction substringBeforeFunction = SubstringBeforeFunction.INSTANCE; @Test void invokeNull() { - FunctionTestUtil.assertResultError(substringBeforeFunction.invoke((String) null, null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(substringBeforeFunction.invoke((String) null, null), + InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringBeforeFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringBeforeFunction.invoke("test", null), InvalidParametersEvent.class); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringFunctionTest.java index c9f31216961..d32c8078591 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -18,18 +18,12 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class SubstringFunctionTest { - private SubstringFunction substringFunction; - - @BeforeEach - void setUp() { - substringFunction = new SubstringFunction(); - } + private static final SubstringFunction substringFunction = SubstringFunction.INSTANCE; @Test void invokeNull2ParamsMethod() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SumFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SumFunctionTest.java index e701404a614..7602158e5d2 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SumFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SumFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,18 +22,12 @@ import java.util.Arrays; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class SumFunctionTest { - private SumFunction sumFunction; - - @BeforeEach - void setUp() { - sumFunction = new SumFunction(); - } + private static final SumFunction sumFunction = SumFunction.INSTANCE; @Test void invokeNumberParamNull() { @@ -60,17 +54,20 @@ void invokeListParam() { @Test void invokeListParamContainsUnsupportedNumber() { - FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, 2, Double.NaN)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, 2, Double.NaN)), + InvalidParametersEvent.class); } @Test void invokeListParamContainsUnsupportedType() { - FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, "test", 2)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, "test", 2)), + InvalidParametersEvent.class); } @Test void invokeListParamSupportedTypes() { - FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, (long) 5, BigDecimal.TEN)), BigDecimal.valueOf(30.1)); + FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, (long) 5, BigDecimal.TEN)), + BigDecimal.valueOf(30.1)); } @Test @@ -80,16 +77,19 @@ void invokeArrayParam() { @Test void invokeArrayParamContainsUnsupportedNumber() { - FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, 2, Double.NaN}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, 2, Double.NaN}), + InvalidParametersEvent.class); } @Test void invokeArrayParamContainsUnsupportedType() { - FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, "test", 2}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, "test", 2}), + InvalidParametersEvent.class); } @Test void invokeArrayParamSupportedTypes() { - FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, 12.1, (long) 5, BigDecimal.TEN}), BigDecimal.valueOf(30.1)); + FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, 12.1, (long) 5, BigDecimal.TEN}), + BigDecimal.valueOf(30.1)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TimeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TimeFunctionTest.java index 6e12e099172..63ba79e11bf 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TimeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TimeFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -30,7 +30,6 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -40,12 +39,7 @@ class TimeFunctionTest { - private TimeFunction timeFunction; - - @BeforeEach - void setUp() { - timeFunction = new TimeFunction(); - } + private static final TimeFunction timeFunction = TimeFunction.INSTANCE; @Test void invokeStringParamNull() { @@ -64,13 +58,15 @@ void invokeStringParamTimeWrongFormat() { @Test void invokeStringParamNoOffset() { - FunctionTestUtil.assertResult(timeFunction.invoke("10:15:06"), LocalTime.of(10,15,6)); + FunctionTestUtil.assertResult(timeFunction.invoke("10:15:06"), LocalTime.of(10, 15, 6)); } @Test void invokeStringParamWithOffset() { - FunctionTestUtil.assertResult(timeFunction.invoke("10:15:06+01:00"), OffsetTime.of(10,15,6, 0, ZoneOffset.ofHours(1))); - FunctionTestUtil.assertResult(timeFunction.invoke("10:15:06-01:00"), OffsetTime.of(10,15,6, 0, ZoneOffset.ofHours(-1))); + FunctionTestUtil.assertResult(timeFunction.invoke("10:15:06+01:00"), OffsetTime.of(10, 15, 6, 0, + ZoneOffset.ofHours(1))); + FunctionTestUtil.assertResult(timeFunction.invoke("10:15:06-01:00"), OffsetTime.of(10, 15, 6, 0, + ZoneOffset.ofHours(-1))); } @Test @@ -89,7 +85,8 @@ void parseWithZoneIANA() { @Test void invokeWrongIANAformat() { - FunctionTestUtil.assertResultError(timeFunction.invoke("13:20:00+02:00@Europe/Paris"), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(timeFunction.invoke("13:20:00+02:00@Europe/Paris"), + InvalidParametersEvent.class); } @Test @@ -104,7 +101,8 @@ void invokeTemporalAccessorParamUnsupportedAccessor() { @Test void invokeTemporalAccessorParamDate() { - FunctionTestUtil.assertResult(timeFunction.invoke(LocalDate.of(2017, 6, 12)), OffsetTime.of(0, 0, 0, 0, ZoneOffset.UTC)); + FunctionTestUtil.assertResult(timeFunction.invoke(LocalDate.of(2017, 6, 12)), OffsetTime.of(0, 0, 0, 0, + ZoneOffset.UTC)); } @Test @@ -114,7 +112,8 @@ void invokeTemporalAccessorParamTime() { @Test void invokeTemporalAccessorParamDateTime() { - FunctionTestUtil.assertResult(timeFunction.invoke(LocalDateTime.of(2017, 6, 12, 11, 43)), LocalTime.of(11, 43, 0)); + FunctionTestUtil.assertResult(timeFunction.invoke(LocalDateTime.of(2017, 6, 12, 11, 43)), LocalTime.of(11, 43 + , 0)); } @Test @@ -130,12 +129,18 @@ void invokeTimeUnitsParamsNull() { @Test void invokeTimeUnitsParamsUnsupportedNumber() { - FunctionTestUtil.assertResultError(timeFunction.invoke(Double.POSITIVE_INFINITY, 1, 1, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(timeFunction.invoke(Double.NEGATIVE_INFINITY, 1, 1, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(timeFunction.invoke(1, Double.POSITIVE_INFINITY, 1, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(timeFunction.invoke(1, Double.NEGATIVE_INFINITY, 1, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(timeFunction.invoke(1, 1, Double.POSITIVE_INFINITY, null), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(timeFunction.invoke(1, 1, Double.NEGATIVE_INFINITY, null), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(timeFunction.invoke(Double.POSITIVE_INFINITY, 1, 1, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(timeFunction.invoke(Double.NEGATIVE_INFINITY, 1, 1, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(timeFunction.invoke(1, Double.POSITIVE_INFINITY, 1, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(timeFunction.invoke(1, Double.NEGATIVE_INFINITY, 1, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(timeFunction.invoke(1, 1, Double.POSITIVE_INFINITY, null), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(timeFunction.invoke(1, 1, Double.NEGATIVE_INFINITY, null), + InvalidParametersEvent.class); } @Test @@ -152,13 +157,19 @@ void invokeTimeUnitsParamsNoOffset() { @Test void invokeTimeUnitsParamsNoOffsetWithNanoseconds() { - FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, BigDecimal.valueOf(15.154), null), LocalTime.of(10, 43, 15, 154000000)); + FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, BigDecimal.valueOf(15.154), null), LocalTime.of(10, + 43, + 15, + 154000000)); } @Test void invokeTimeUnitsParamsWithOffset() { - FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, 15, Duration.ofHours(1)), OffsetTime.of(10, 43, 15, 0, ZoneOffset.ofHours(1))); - FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, 15, Duration.ofHours(-1)), OffsetTime.of(10, 43, 15, 0, ZoneOffset.ofHours(-1))); + FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, 15, Duration.ofHours(1)), OffsetTime.of(10, 43, 15, + 0, + ZoneOffset.ofHours(1))); + FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, 15, Duration.ofHours(-1)), OffsetTime.of(10, 43, 15 + , 0, ZoneOffset.ofHours(-1))); } @Test diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TodayFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TodayFunctionTest.java index 161c4b98d60..6db80988b06 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TodayFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TodayFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -20,22 +20,14 @@ import java.time.LocalDate; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.kie.dmn.feel.runtime.functions.extended.TodayFunction; class TodayFunctionTest { - private TodayFunction todayFunction; - - @BeforeEach - void setUp() { - todayFunction = new TodayFunction(); - } + private static final TodayFunction todayFunction = TodayFunction.INSTANCE; @Test void invoke() { FunctionTestUtil.assertResult(todayFunction.invoke(), LocalDate.now()); } - } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/UnionFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/UnionFunctionTest.java index cc99800a7a7..eb9180f8497 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/UnionFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/UnionFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,18 +22,12 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class UnionFunctionTest { - private UnionFunction unionFunction; - - @BeforeEach - void setUp() { - unionFunction = new UnionFunction(); - } + private static final UnionFunction unionFunction = UnionFunction.INSTANCE; @Test void invokeNull() { @@ -52,13 +46,15 @@ void invokeSingleObject() { @Test void invokeSingleObjectInAList() { - FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{Collections.singletonList(10)}), Collections.singletonList(10)); + FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{Collections.singletonList(10)}), + Collections.singletonList(10)); } @Test void invokeSingleObjectInAnArray() { final int[] testArray = new int[]{10}; - FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{testArray}), Collections.singletonList(testArray)); + FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{testArray}), + Collections.singletonList(testArray)); } @Test @@ -68,7 +64,8 @@ void invokeListIsNull() { @Test void invokeListContainsNull() { - FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{Arrays.asList(null, 10, null)}), Arrays.asList(null, 10)); + FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{Arrays.asList(null, 10, null)}), + Arrays.asList(null, 10)); } @Test @@ -79,7 +76,8 @@ void invokeListsNoDuplicates() { @Test void invokeListsSomeDuplicates() { - final Object[] params = new Object[]{Arrays.asList(10, 8, 3), Arrays.asList(1, 10, 2), Arrays.asList(10, 3, 2, 5)}; + final Object[] params = new Object[]{Arrays.asList(10, 8, 3), Arrays.asList(1, 10, 2), Arrays.asList(10, 3, 2 + , 5)}; FunctionTestUtil.assertResultList(unionFunction.invoke(params), Arrays.asList(10, 8, 3, 1, 2, 5)); } @@ -91,12 +89,14 @@ void invokeListsAllDuplicates() { @Test void invokeListAndSingleObject() { - FunctionTestUtil.assertResultList(unionFunction.invoke(new Object[]{Arrays.asList(10, 4, 5), 1}), Arrays.asList(10, 4, 5, 1)); + FunctionTestUtil.assertResultList(unionFunction.invoke(new Object[]{Arrays.asList(10, 4, 5), 1}), + Arrays.asList(10, 4, 5, 1)); } @Test void invokeListAndSingleObjectWithDuplicates() { - FunctionTestUtil.assertResultList(unionFunction.invoke(new Object[]{5, Arrays.asList(10, 4, 5), 10}), Arrays.asList(5, 10, 4)); + FunctionTestUtil.assertResultList(unionFunction.invoke(new Object[]{5, Arrays.asList(10, 4, 5), 10}), + Arrays.asList(5, 10, 4)); } @Test diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/WeekOfYearTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/WeekOfYearTest.java index d6ca2314cfe..af142a53434 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/WeekOfYearTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/WeekOfYearTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -24,7 +24,6 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -32,19 +31,16 @@ class WeekOfYearTest { - private WeekOfYearFunction fut; - - @BeforeEach - void setUp() { - fut = WeekOfYearFunction.INSTANCE; - } + private static final WeekOfYearFunction fut = WeekOfYearFunction.INSTANCE; @Test void weekOfYearFunctionTemporalAccessor() { FunctionTestUtil.assertResult(fut.invoke(LocalDate.of(2019, 9, 17)), valueOf(38)); FunctionTestUtil.assertResult(fut.invoke(LocalDateTime.of(2019, 9, 17, 0, 0, 0)), valueOf(38)); - FunctionTestUtil.assertResult(fut.invoke(OffsetDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), valueOf(38)); - FunctionTestUtil.assertResult(fut.invoke(ZonedDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), valueOf(38)); + FunctionTestUtil.assertResult(fut.invoke(OffsetDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), + valueOf(38)); + FunctionTestUtil.assertResult(fut.invoke(ZonedDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), + valueOf(38)); FunctionTestUtil.assertResultError(fut.invoke(null), InvalidParametersEvent.class); } } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunctionTest.java index 57c36ee134f..f262c512223 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -25,19 +25,13 @@ import java.time.YearMonth; import java.time.temporal.Temporal; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; class YearsAndMonthsFunctionTest { - private YearsAndMonthsFunction yamFunction; - - @BeforeEach - void setUp() { - yamFunction = new YearsAndMonthsFunction(); - } + private static final YearsAndMonthsFunction yamFunction = YearsAndMonthsFunction.INSTANCE; @Test void invokeNull() { @@ -48,8 +42,10 @@ void invokeNull() { @Test void invokeUnsupportedTemporal() { - FunctionTestUtil.assertResultError(yamFunction.invoke(Instant.EPOCH, Instant.EPOCH), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(yamFunction.invoke(LocalDate.of(2017, 1, 1), Instant.EPOCH), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(yamFunction.invoke(Instant.EPOCH, Instant.EPOCH), + InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(yamFunction.invoke(LocalDate.of(2017, 1, 1), Instant.EPOCH), + InvalidParametersEvent.class); } @Test diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/CountFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/CountFunctionTest.java index 344ff641169..2ac7c800ef3 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/CountFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/CountFunctionTest.java @@ -23,18 +23,12 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; class CountFunctionTest { - private NNCountFunction countFunction; - - @BeforeEach - void setUp() { - countFunction = new NNCountFunction(); - } + private static final NNCountFunction countFunction = NNCountFunction.INSTANCE; @Test void invokeParamListNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MaxFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MaxFunctionTest.java index 499b7b5e339..e8cd0308495 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MaxFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MaxFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,19 +23,13 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; class MaxFunctionTest { - private NNMaxFunction maxFunction; - - @BeforeEach - void setUp() { - maxFunction = new NNMaxFunction(); - } + private static final NNMaxFunction maxFunction = NNMaxFunction.INSTANCE; @Test void invokeNullList() { @@ -49,7 +43,8 @@ void invokeEmptyList() { @Test void invokeListWithHeterogenousTypes() { - FunctionTestUtil.assertResultError(maxFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(maxFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), + InvalidParametersEvent.class); } @Test @@ -80,7 +75,8 @@ void invokeEmptyArray() { @Test void invokeArrayWithHeterogenousTypes() { - FunctionTestUtil.assertResultError(maxFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(maxFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), + InvalidParametersEvent.class); } @Test diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MeanFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MeanFunctionTest.java index 6170103b523..c202f581cc8 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MeanFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MeanFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,19 +23,13 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; class MeanFunctionTest { - private NNMeanFunction meanFunction; - - @BeforeEach - void setUp() { - meanFunction = new NNMeanFunction(); - } + private static final NNMeanFunction meanFunction = NNMeanFunction.INSTANCE; @Test void invokeNumberNull() { @@ -91,7 +85,8 @@ void invokeListTypeHeterogenous() { @Test void invokeListParamSupportedTypesWithNull() { - FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(20, 30, null, (long) 40, null, BigDecimal.TEN)), BigDecimal.valueOf(25)); + FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(20, 30, null, (long) 40, null, + BigDecimal.TEN)), BigDecimal.valueOf(25)); } @Test @@ -104,7 +99,8 @@ void invokeListWithIntegers() { @Test void invokeListWithDoubles() { FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.0d, 20.0d, 30.0d)), BigDecimal.valueOf(20)); - FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.2d, 20.2d, 30.2d)), BigDecimal.valueOf(20.2)); + FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.2d, 20.2d, 30.2d)), + BigDecimal.valueOf(20.2)); } @Test @@ -139,5 +135,4 @@ void invokeArrayWithDoubles() { void invokeArrayParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{20, 30, null, (long) 40, null, BigDecimal.TEN}), BigDecimal.valueOf(25)); } - } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MinFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MinFunctionTest.java index cace72fa8e9..3c15bff2208 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MinFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MinFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -23,19 +23,13 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; class MinFunctionTest { - private NNMinFunction minFunction; - - @BeforeEach - void setUp() { - minFunction = new NNMinFunction(); - } + private static final NNMinFunction minFunction = NNMinFunction.INSTANCE; @Test void invokeNullList() { @@ -49,7 +43,8 @@ void invokeEmptyList() { @Test void invokeListWithHeterogenousTypes() { - FunctionTestUtil.assertResultError(minFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(minFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), + InvalidParametersEvent.class); } @Test @@ -57,7 +52,7 @@ void invokeListOfIntegers() { FunctionTestUtil.assertResult(minFunction.invoke(Collections.singletonList(1)), 1); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList(null, 1, 2, 3)), 1); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList(2, null, 1, 3)), 1); - FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList(2, 3, 1, null )), 1); + FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList(2, 3, 1, null)), 1); } @Test @@ -80,7 +75,8 @@ void invokeEmptyArray() { @Test void invokeArrayWithHeterogenousTypes() { - FunctionTestUtil.assertResultError(minFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(minFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), + InvalidParametersEvent.class); } @Test diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunctionTest.java index 68919aee554..4bbb690a6b1 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunctionTest.java @@ -22,98 +22,93 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; class NNAllFunctionTest { - private NNAllFunction NNAllFunction; + private static final NNAllFunction nnAllFunction = NNAllFunction.INSTANCE; - @BeforeEach - void setUp() { - NNAllFunction = new NNAllFunction(); - } @Test void invokeBooleanParamNull() { - FunctionTestUtil.assertResult(NNAllFunction.invoke((Boolean) null), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke((Boolean) null), true); } @Test void invokeBooleanParamTrue() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(true), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke(true), true); } @Test void invokeBooleanParamFalse() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(false), false); + FunctionTestUtil.assertResult(nnAllFunction.invoke(false), false); } @Test void invokeArrayParamNull() { - FunctionTestUtil.assertResult(NNAllFunction.invoke((Object[]) null), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke((Object[]) null), true); } @Test void invokeArrayParamEmptyArray() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{}), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke(new Object[]{}), true); } @Test void invokeArrayParamReturnTrue() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{Boolean.TRUE, Boolean.TRUE}), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke(new Object[]{Boolean.TRUE, Boolean.TRUE}), true); } @Test void invokeArrayParamReturnFalse() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{Boolean.TRUE, Boolean.FALSE}), false); - FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{Boolean.TRUE, null, Boolean.FALSE}), false); + FunctionTestUtil.assertResult(nnAllFunction.invoke(new Object[]{Boolean.TRUE, Boolean.FALSE}), false); + FunctionTestUtil.assertResult(nnAllFunction.invoke(new Object[]{Boolean.TRUE, null, Boolean.FALSE}), false); } @Test void invokeArrayParamReturnNull() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{Boolean.TRUE, null, Boolean.TRUE}), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke(new Object[]{Boolean.TRUE, null, Boolean.TRUE}), true); } @Test void invokeArrayParamTypeHeterogenousArray() { - FunctionTestUtil.assertResultError(NNAllFunction.invoke(new Object[]{Boolean.TRUE, 1}), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(NNAllFunction.invoke(new Object[]{Boolean.FALSE, 1}), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(NNAllFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(nnAllFunction.invoke(new Object[]{Boolean.TRUE, 1}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(nnAllFunction.invoke(new Object[]{Boolean.FALSE, 1}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(nnAllFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), InvalidParametersEvent.class); } @Test void invokeListParamNull() { - FunctionTestUtil.assertResult(NNAllFunction.invoke((List) null), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke((List) null), true); } @Test void invokeListParamEmptyList() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(Collections.emptyList()), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke(Collections.emptyList()), true); } @Test void invokeListParamReturnTrue() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.TRUE)), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.TRUE)), true); } @Test void invokeListParamReturnFalse() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.FALSE)), false); - FunctionTestUtil.assertResult(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, null, Boolean.FALSE)), false); + FunctionTestUtil.assertResult(nnAllFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.FALSE)), false); + FunctionTestUtil.assertResult(nnAllFunction.invoke(Arrays.asList(Boolean.TRUE, null, Boolean.FALSE)), false); } @Test void invokeListParamReturnNull() { - FunctionTestUtil.assertResult(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, null, Boolean.TRUE)), true); + FunctionTestUtil.assertResult(nnAllFunction.invoke(Arrays.asList(Boolean.TRUE, null, Boolean.TRUE)), true); } @Test void invokeListParamTypeHeterogenousArray() { - FunctionTestUtil.assertResultError(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(NNAllFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), InvalidParametersEvent.class); - FunctionTestUtil.assertResultError(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(nnAllFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(nnAllFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(nnAllFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunctionTest.java index ef3453b7d6e..41c49e4ccbc 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunctionTest.java @@ -22,19 +22,14 @@ import java.util.Collections; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; class NNAnyFunctionTest { - private NNAnyFunction anyFunction; + private static final NNAnyFunction anyFunction = NNAnyFunction.INSTANCE; - @BeforeEach - void setUp() { - anyFunction = new NNAnyFunction(); - } @Test void invokeBooleanParamNull() { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/SumFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/SumFunctionTest.java index 4b08bd0200d..9fed1bd7a63 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/SumFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/SumFunctionTest.java @@ -6,9 +6,9 @@ * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* 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 @@ -22,19 +22,13 @@ import java.util.Arrays; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; class SumFunctionTest { - private NNSumFunction sumFunction; - - @BeforeEach - void setUp() { - sumFunction = new NNSumFunction(); - } + private static final NNSumFunction sumFunction = NNSumFunction.INSTANCE; @Test void invokeNumberParamNull() { @@ -61,22 +55,26 @@ void invokeListParam() { @Test void invokeListParamContainsUnsupportedNumber() { - FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, 2, Double.NaN)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, 2, Double.NaN)), + InvalidParametersEvent.class); } @Test void invokeListParamContainsUnsupportedType() { - FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, "test", 2)), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, "test", 2)), + InvalidParametersEvent.class); } @Test void invokeListParamSupportedTypes() { - FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, (long) 5, BigDecimal.TEN)), BigDecimal.valueOf(30.1)); + FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, (long) 5, BigDecimal.TEN)), + BigDecimal.valueOf(30.1)); } @Test void invokeListParamSupportedTypesWithNull() { - FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, null, (long) 5, null, BigDecimal.TEN)), BigDecimal.valueOf(30.1)); + FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, null, (long) 5, null, + BigDecimal.TEN)), BigDecimal.valueOf(30.1)); } @Test @@ -86,21 +84,25 @@ void invokeArrayParam() { @Test void invokeArrayParamContainsUnsupportedNumber() { - FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, 2, Double.NaN}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, 2, Double.NaN}), + InvalidParametersEvent.class); } @Test void invokeArrayParamContainsUnsupportedType() { - FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, "test", 2}), InvalidParametersEvent.class); + FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, "test", 2}), + InvalidParametersEvent.class); } @Test void invokeArrayParamSupportedTypes() { - FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, 12.1, (long) 5, BigDecimal.TEN}), BigDecimal.valueOf(30.1)); + FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, 12.1, (long) 5, BigDecimal.TEN}), + BigDecimal.valueOf(30.1)); } @Test void invokeArrayParamSupportedTypesWithNull() { - FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, null, 12.1, (long) 5, null, BigDecimal.TEN, null}), BigDecimal.valueOf(30.1)); + FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, null, 12.1, (long) 5, null, + BigDecimal.TEN, null}), BigDecimal.valueOf(30.1)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-signavio/src/main/java/org/kie/dmn/signavio/MultiInstanceDecisionLogic.java b/kie-dmn/kie-dmn-signavio/src/main/java/org/kie/dmn/signavio/MultiInstanceDecisionLogic.java index e8ccbc9bf93..d9a11187fc1 100644 --- a/kie-dmn/kie-dmn-signavio/src/main/java/org/kie/dmn/signavio/MultiInstanceDecisionLogic.java +++ b/kie-dmn/kie-dmn-signavio/src/main/java/org/kie/dmn/signavio/MultiInstanceDecisionLogic.java @@ -280,25 +280,25 @@ public EvaluatorResult evaluate(DMNRuntimeEventManager eventManager, DMNResult d FEELFnResult r; switch (mi.aggregationFunction) { case "SUM": - r = new SumFunction().invoke(invokationResults); + r = SumFunction.INSTANCE.invoke(invokationResults); break; case "MIN": - r = new MinFunction().invoke(invokationResults); + r = MinFunction.INSTANCE.invoke(invokationResults); break; case "MAX": - r = new MaxFunction().invoke(invokationResults); + r = MaxFunction.INSTANCE.invoke(invokationResults); break; case "COUNT": r = FEELFnResult.ofResult(NumberEvalHelper.getBigDecimalOrNull(invokationResults.size())); break; case "ALLTRUE": - r = new AllFunction().invoke(invokationResults); + r = AllFunction.INSTANCE.invoke(invokationResults); break; case "ANYTRUE": - r = new AnyFunction().invoke(invokationResults); + r = AnyFunction.INSTANCE.invoke(invokationResults); break; case "ALLFALSE": - FEELFnResult anyResult = new AnyFunction().invoke(invokationResults); + FEELFnResult anyResult = AnyFunction.INSTANCE.invoke(invokationResults); r = anyResult.map(b -> !b); break; case "COLLECT":