diff --git a/dmn-core/src/main/java/com/gs/dmn/ast/visitor/TraversalVisitor.java b/dmn-core/src/main/java/com/gs/dmn/ast/visitor/TraversalVisitor.java index 801138c3e..762d37ba1 100644 --- a/dmn-core/src/main/java/com/gs/dmn/ast/visitor/TraversalVisitor.java +++ b/dmn-core/src/main/java/com/gs/dmn/ast/visitor/TraversalVisitor.java @@ -719,31 +719,31 @@ private void visitTExpression(TExpression element, C context) { visitTExpressionProperties(element, context); if (element instanceof TContext) { - ((TContext) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TDecisionTable) { - ((TDecisionTable) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TFunctionDefinition) { - ((TFunctionDefinition) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TInvocation) { - ((TInvocation) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TList) { - ((TList) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TLiteralExpression) { - ((TLiteralExpression) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TRelation) { - ((TRelation) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TUnaryTests) { - ((TUnaryTests) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TConditional) { - ((TConditional) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TFor) { - ((TFor) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TFilter) { - ((TFilter) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TEvery) { - ((TEvery) element).accept(this, context); + element.accept(this, context); } else if (element instanceof TSome) { - ((TSome) element).accept(this, context); + element.accept(this, context); } } diff --git a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/FEELSemanticVisitor.java b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/FEELSemanticVisitor.java index d39b50b83..d81a55898 100644 --- a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/FEELSemanticVisitor.java +++ b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/FEELSemanticVisitor.java @@ -48,7 +48,7 @@ import com.gs.dmn.transformation.basic.BasicDMNToNativeTransformer; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -285,7 +285,7 @@ public Element visit(Context element, DMNContext context) { // Derive type ContextType type = new ContextType(); - entries.forEach(e -> type.addMember(e.getKey().getKey(), Arrays.asList(), e.getExpression().getType())); + entries.forEach(e -> type.addMember(e.getKey().getKey(), Collections.emptyList(), e.getExpression().getType())); element.setType(type); return element; diff --git a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/type/FunctionType.java b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/type/FunctionType.java index 64be669cc..9513f67f0 100644 --- a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/type/FunctionType.java +++ b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/type/FunctionType.java @@ -26,7 +26,7 @@ import static com.gs.dmn.feel.analysis.syntax.ast.expression.function.ConversionKind.*; public abstract class FunctionType implements com.gs.dmn.el.analysis.semantics.type.FunctionType { - public static final FunctionType ANY_FUNCTION = new FunctionType(Arrays.asList(), ANY) { + public static final FunctionType ANY_FUNCTION = new FunctionType(Collections.emptyList(), ANY) { @Override public boolean equivalentTo(Type other) { return this == other; diff --git a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/type/ItemDefinitionType.java b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/type/ItemDefinitionType.java index 07ec620cd..382f4e987 100644 --- a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/type/ItemDefinitionType.java +++ b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/type/ItemDefinitionType.java @@ -92,8 +92,8 @@ public boolean equals(Object o) { ItemDefinitionType that = (ItemDefinitionType) o; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (modelName != null ? !modelName.equals(that.modelName) : that.modelName != null) return false; + if (!Objects.equals(name, that.name)) return false; + if (!Objects.equals(modelName, that.modelName)) return false; if (!members.equals(that.members)) return false; return aliases.equals(that.aliases); } diff --git a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/syntax/ast/expression/textual/ForExpression.java b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/syntax/ast/expression/textual/ForExpression.java index be4583d08..b0b2c25ee 100644 --- a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/syntax/ast/expression/textual/ForExpression.java +++ b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/syntax/ast/expression/textual/ForExpression.java @@ -16,7 +16,7 @@ import com.gs.dmn.feel.analysis.syntax.ast.expression.Expression; import com.gs.dmn.feel.analysis.syntax.ast.expression.Iterator; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -51,7 +51,7 @@ public ForExpression toNestedForExpression() { } else { Expression newBody = this.body; for(int i=this.iterators.size()-1; i>=0; i--) { - newBody = new ForExpression<>(Arrays.asList(this.iterators.get(i)), newBody); + newBody = new ForExpression<>(Collections.singletonList(this.iterators.get(i)), newBody); } return (ForExpression) newBody; } diff --git a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/syntax/ast/visitor/TraversalVisitor.java b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/syntax/ast/visitor/TraversalVisitor.java index c339d69a5..85e66d48d 100644 --- a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/syntax/ast/visitor/TraversalVisitor.java +++ b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/syntax/ast/visitor/TraversalVisitor.java @@ -155,10 +155,6 @@ public Element visit(ContextEntry element, C context) { @Override public Element visit(ContextEntryKey element, C context) { - if (element == null) { - return null; - } - return element; } @@ -429,46 +425,26 @@ public Element visit(PositionalParameters element, C context) { // @Override public Element visit(BooleanLiteral element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(DateTimeLiteral element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(NullLiteral element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(NumericLiteral element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(StringLiteral element, C context) { - if (element == null) { - return null; - } - return element; } @@ -484,64 +460,36 @@ public Element visit(ListLiteral element, C context) { @Override public Element visit(QualifiedName element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(Name element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(NamedTypeExpression element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(ContextTypeExpression element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(RangeTypeExpression element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(FunctionTypeExpression element, C context) { - if (element == null) { - return null; - } - return element; } @Override public Element visit(ListTypeExpression element, C context) { - if (element == null) { - return null; - } - return element; } } diff --git a/dmn-core/src/main/java/com/gs/dmn/feel/interpreter/AbstractFEELInterpreterVisitor.java b/dmn-core/src/main/java/com/gs/dmn/feel/interpreter/AbstractFEELInterpreterVisitor.java index 61830e849..f9a88308c 100644 --- a/dmn-core/src/main/java/com/gs/dmn/feel/interpreter/AbstractFEELInterpreterVisitor.java +++ b/dmn-core/src/main/java/com/gs/dmn/feel/interpreter/AbstractFEELInterpreterVisitor.java @@ -526,7 +526,7 @@ public Object visit(FilterExpression element, DMNContext context) { Type filterType = element.getFilter().getType(); Object source = element.getSource().accept(this, context); if (!(sourceType instanceof ListType)) { - source = Arrays.asList(source); + source = Collections.singletonList(source); } if (filterType == BooleanType.BOOLEAN) { List result = new ArrayList<>(); @@ -1062,7 +1062,7 @@ private Object navigate(PathExpression element, Type sourceType, Object so return evaluateRangeMember(source, member); } else if (sourceType instanceof AnyType) { // source is Context - List aliases = Arrays.asList(); + List aliases = Collections.emptyList(); return ((com.gs.dmn.runtime.Context) source).get(member, aliases.toArray()); } else { this.errorHandler.reportError(String.format("Cannot evaluate '%s'.", element)); diff --git a/dmn-core/src/main/java/com/gs/dmn/runtime/interpreter/AbstractDMNInterpreter.java b/dmn-core/src/main/java/com/gs/dmn/runtime/interpreter/AbstractDMNInterpreter.java index 1cbc062ff..236bd57f4 100644 --- a/dmn-core/src/main/java/com/gs/dmn/runtime/interpreter/AbstractDMNInterpreter.java +++ b/dmn-core/src/main/java/com/gs/dmn/runtime/interpreter/AbstractDMNInterpreter.java @@ -1253,7 +1253,7 @@ private Object evaluateDefaultValue(TDRGElement element, TDecisionTable decision // Return result if (repository.isCompoundDecisionTable(element)) { if (dmnTransformer.hasListType(element)) { - return Arrays.asList(defaultValue); + return Collections.singletonList(defaultValue); } else { return defaultValue; } diff --git a/dmn-core/src/main/java/com/gs/dmn/transformation/InputParameters.java b/dmn-core/src/main/java/com/gs/dmn/transformation/InputParameters.java index 19defd805..5b73dd52d 100644 --- a/dmn-core/src/main/java/com/gs/dmn/transformation/InputParameters.java +++ b/dmn-core/src/main/java/com/gs/dmn/transformation/InputParameters.java @@ -84,7 +84,7 @@ protected static boolean getOptionalBooleanParam(Map parameters, private final boolean mockTesting; private final boolean generateExtra; - private boolean checkConstraints; + private final boolean checkConstraints; public InputParameters() { this(new LinkedHashMap<>()); diff --git a/dmn-core/src/main/java/com/gs/dmn/transformation/basic/StandardDMNEnvironmentFactory.java b/dmn-core/src/main/java/com/gs/dmn/transformation/basic/StandardDMNEnvironmentFactory.java index 6849fc13e..d2218946e 100644 --- a/dmn-core/src/main/java/com/gs/dmn/transformation/basic/StandardDMNEnvironmentFactory.java +++ b/dmn-core/src/main/java/com/gs/dmn/transformation/basic/StandardDMNEnvironmentFactory.java @@ -300,7 +300,7 @@ public Type expressionType(TDRGElement element, TExpression expression, DMNConte if (columnType == null) { columnType = AnyType.ANY; } - rowType.addMember(column.getName(), Arrays.asList(), columnType); + rowType.addMember(column.getName(), Collections.emptyList(), columnType); } return new ListType(rowType); } else if (expression instanceof TConditional) { diff --git a/dmn-core/src/main/java/com/gs/dmn/transformation/proto/FieldType.java b/dmn-core/src/main/java/com/gs/dmn/transformation/proto/FieldType.java index db480f203..a534c32b2 100644 --- a/dmn-core/src/main/java/com/gs/dmn/transformation/proto/FieldType.java +++ b/dmn-core/src/main/java/com/gs/dmn/transformation/proto/FieldType.java @@ -15,6 +15,8 @@ import com.gs.dmn.runtime.DMNRuntimeException; import org.apache.commons.lang3.StringUtils; +import java.util.Objects; + public class FieldType { private final String modifier; private final String type; @@ -46,8 +48,8 @@ public boolean equals(Object o) { FieldType fieldType = (FieldType) o; - if (modifier != null ? !modifier.equals(fieldType.modifier) : fieldType.modifier != null) return false; - return type != null ? type.equals(fieldType.type) : fieldType.type == null; + if (!Objects.equals(modifier, fieldType.modifier)) return false; + return Objects.equals(type, fieldType.type); } @Override diff --git a/dmn-core/src/test/java/com/gs/dmn/DMNModelRepositoryTest.java b/dmn-core/src/test/java/com/gs/dmn/DMNModelRepositoryTest.java index b4cc981e4..9abba3e16 100644 --- a/dmn-core/src/test/java/com/gs/dmn/DMNModelRepositoryTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/DMNModelRepositoryTest.java @@ -20,10 +20,7 @@ import java.io.File; import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -113,7 +110,7 @@ public void testDirectSubInvocables() { List> references = this.dmnModelRepository.directSubInvocables(root); List actual = references.stream().map(DRGElementReference::toString).collect(Collectors.toList()); - List expected = Arrays.asList( + List expected = Collections.singletonList( "DMNReference(import='[]', namespace='http://www.trisotech.com/definitions/_4e0f0b70-d31c-471c-bd52-5ca709ed362b', model='Lending1', element='BureauCallTypeTable')" ); assertEquals(expected, actual); diff --git a/dmn-core/src/test/java/com/gs/dmn/TestFilesScripts.java b/dmn-core/src/test/java/com/gs/dmn/TestFilesScripts.java index e59067d28..0699eff56 100644 --- a/dmn-core/src/test/java/com/gs/dmn/TestFilesScripts.java +++ b/dmn-core/src/test/java/com/gs/dmn/TestFilesScripts.java @@ -19,17 +19,17 @@ import java.util.*; public class TestFilesScripts { - private static File LOCAL_TCK_FOLDER = new File("C:/Work/Projects/tck/TestCases/compliance-level-3/"); - - private static File TEST_CASES_FOLDER = new File("dmn-test-cases/standard/"); - private static File TCK_11_CL2_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.1/cl2/"); - private static File TCK_11_CL3_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.1/cl3/"); - private static File TCK_12_CL2_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.2/cl2/"); - private static File TCK_12_CL3_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.2/cl3/"); - private static File TCK_13_CL2_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.3/cl2/"); - private static File TCK_13_CL3_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.3/cl3/"); - private static File COMPOSITE_FOLDER = new File(TEST_CASES_FOLDER, "composite/1.2"); - private static File PROTO_FOLDER = new File(TEST_CASES_FOLDER, "proto/1.1"); + private static final File LOCAL_TCK_FOLDER = new File("C:/Work/Projects/tck/TestCases/compliance-level-3/"); + + private static final File TEST_CASES_FOLDER = new File("dmn-test-cases/standard/"); + private static final File TCK_11_CL2_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.1/cl2/"); + private static final File TCK_11_CL3_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.1/cl3/"); + private static final File TCK_12_CL2_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.2/cl2/"); + private static final File TCK_12_CL3_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.2/cl3/"); + private static final File TCK_13_CL2_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.3/cl2/"); + private static final File TCK_13_CL3_FOLDER = new File(TEST_CASES_FOLDER, "tck/1.3/cl3/"); + private static final File COMPOSITE_FOLDER = new File(TEST_CASES_FOLDER, "composite/1.2"); + private static final File PROTO_FOLDER = new File(TEST_CASES_FOLDER, "proto/1.1"); private static void deleteAlienFilesFromTestFolders(boolean dryRun) throws IOException { deleteAlienFilesFromTestFolders(TCK_11_CL2_FOLDER, dryRun); diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/AbstractFEELProcessorTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/AbstractFEELProcessorTest.java index b49fb9567..f2c18b625 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/AbstractFEELProcessorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/AbstractFEELProcessorTest.java @@ -41,6 +41,7 @@ import java.math.BigDecimal; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -80,7 +81,7 @@ protected AbstractFEELProcessorTest() { @Test public void testAny() { NUMBER input = this.lib.number("1"); - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, input)); doUnaryTestsTest(entries, "input", "-", @@ -116,7 +117,7 @@ public void testPositiveUnaryTests() { @Test public void testNegatedPositiveUnaryTests() { NUMBER input = this.lib.number("1"); - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, input)); doUnaryTestsTest(entries, "input", "not (-1)", @@ -140,7 +141,7 @@ public void testNegatedPositiveUnaryTests() { public void testNullTest() { NUMBER number = this.lib.number("1"); - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("number", NUMBER, number) ); @@ -383,7 +384,7 @@ public void testExpressionTest() { public void testListTest() { NUMBER number = this.lib.number("1"); - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("number", NUMBER, number) ); @@ -593,8 +594,8 @@ public void testOperatorRange() { @Test public void testEndpointsRange() { NUMBER number = this.lib.number("1"); - List entries = Arrays.asList( - new EnvironmentEntry("number", NUMBER, number)); + List entries = Collections.singletonList( + new EnvironmentEntry("number", NUMBER, number)); // // EndpointsRange @@ -623,7 +624,7 @@ public void testEndpointsRange() { public void testEqualOperatorRangeWhenTypeMismatch() { Assertions.assertThrows(SemanticError.class, () -> { Boolean input = true; - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", BOOLEAN, input)); doUnaryTestsTest(entries, "input", "123.56", "", "TupleType(boolean)", "", null, ""); @@ -633,7 +634,7 @@ public void testEqualOperatorRangeWhenTypeMismatch() { @Test public void testOperatorRangeWhenTypeMismatch() { Assertions.assertThrows(SemanticError.class, () -> { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", BOOLEAN, true)); doUnaryTestsTest(entries, "input", "< 123.56", "", "TupleType(boolean)", "", null, ""); @@ -647,7 +648,7 @@ public void testOperatorRangeWhenTypeMismatch() { @Test public void testTextualExpressions() { String input = "abc"; - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, input)); doTextualExpressionsTest(entries, "1 + 2", @@ -660,7 +661,7 @@ public void testTextualExpressions() { @Test public void testForExpression() { - List entries = Arrays.asList(); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "for i in 0..4 return if i = 0 then 1 else i * partial[-1]", "ForExpression(Iterator(i in RangeIteratorDomain(NumericLiteral(0), NumericLiteral(4))) -> IfExpression(Relational(=,Name(i),NumericLiteral(0)), NumericLiteral(1), Multiplication(*,Name(i),FilterExpression(Name(partial), ArithmeticNegation(NumericLiteral(1))))))", @@ -743,7 +744,7 @@ public void testForExpression() { @Test public void testIfExpression() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "if true then 1 else 2", @@ -775,7 +776,7 @@ public void testIfExpression() { @Test public void testIfExpressionWhenConditionIsNotBoolean() { Assertions.assertThrows(SemanticError.class, () -> { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "if 5 then 1 else 2", @@ -790,7 +791,7 @@ public void testIfExpressionWhenConditionIsNotBoolean() { @Test public void testIfExpressionWhenTypesDontMatch() { Assertions.assertThrows(SemanticError.class, () -> { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "if true then true else 2", @@ -804,7 +805,7 @@ public void testIfExpressionWhenTypesDontMatch() { @Test public void testQuantifiedExpression() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "some i in [1..2] j in [2..3] satisfies i + j > 1", @@ -854,7 +855,7 @@ public void testQuantifiedExpression() { @Test public void testRelationalExpression() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); // number @@ -1100,7 +1101,7 @@ public void testRelationalExpression() { @Test public void testNullRelationalExpression() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); // number @@ -1448,7 +1449,7 @@ public void testBetweenExpression() { @Test public void testInExpression() { // operator test - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); // simple types @@ -1630,7 +1631,7 @@ public void testInExpression() { @Test public void testInExpressionWhenOperatorRangeAndTypeMismatch() { Assertions.assertThrows(SemanticError.class, () -> { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "1 in (true)", @@ -1740,7 +1741,7 @@ public void testAddition() { String daysAndTimeDuration = "duration(\"P1DT1H\")"; String string = "\"abc\""; - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); // number, number @@ -1938,7 +1939,7 @@ public void testMultiplication() { String yearsAndMonthsDuration = "duration(\"P1Y1M\")"; String daysAndTimeDuration = "duration(\"P1DT1H\")"; - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); // number, number @@ -2061,7 +2062,7 @@ public void testMultiplication() { @Test public void testExponentiation() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "2 ** 2", @@ -2075,7 +2076,7 @@ public void testExponentiation() { @Test public void testArithmeticNegation() { String number = "1"; - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", String.format("- %s", number), @@ -2106,7 +2107,7 @@ public void testArithmeticNegationOnIncorrectOperands() { String yearsAndMonthsDuration = "duration(\"P1Y1M\")"; String daysAndTimeDuration = "duration(\"P1DT1H\")"; - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", String.format("- %s", yearsAndMonthsDuration), "ArithmeticNegation(DateTimeLiteral(duration, \"P1Y1M\"))", @@ -2125,7 +2126,7 @@ public void testArithmeticNegationOnIncorrectOperands() { @Test public void testComplexArithmeticExpression() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "-1", @@ -2187,14 +2188,14 @@ public void testComplexArithmeticExpression() { @Test public void testPostfixExpression() { ItemDefinitionType employeeTableType = new ItemDefinitionType("tEmployeeTable") - .addMember("id", Arrays.asList(), STRING) - .addMember("name", Arrays.asList(), STRING) - .addMember("deptNum", Arrays.asList(), NUMBER) + .addMember("id", Collections.emptyList(), STRING) + .addMember("name", Collections.emptyList(), STRING) + .addMember("deptNum", Collections.emptyList(), NUMBER) ; ItemDefinitionType deptTableType = new ItemDefinitionType("tDeptTable") - .addMember("number", Arrays.asList(), NUMBER) - .addMember("name", Arrays.asList(), STRING) - .addMember("manager", Arrays.asList(), STRING) + .addMember("number", Collections.emptyList(), NUMBER) + .addMember("name", Collections.emptyList(), STRING) + .addMember("manager", Collections.emptyList(), STRING) ; List entries = Arrays.asList( new EnvironmentEntry("EmployeeTable", new ListType(employeeTableType), null), @@ -2214,9 +2215,9 @@ public void testPostfixExpression() { public void testFilterExpression() { List source = Arrays.asList(this.lib.number("1"), this.lib.number("2"), this.lib.number("3")); ContextType employeeType = new ContextType(); - employeeType.addMember("id", Arrays.asList(), NumberType.NUMBER); - employeeType.addMember("dept", Arrays.asList(), NumberType.NUMBER); - employeeType.addMember("name", Arrays.asList(), StringType.STRING); + employeeType.addMember("id", Collections.emptyList(), NumberType.NUMBER); + employeeType.addMember("dept", Collections.emptyList(), NumberType.NUMBER); + employeeType.addMember("name", Collections.emptyList(), StringType.STRING); Type employeeListType = new ListType(employeeType); List employeeValue = Arrays.asList( @@ -2316,7 +2317,7 @@ public void testFilterExpression() { @Test public void testConversionFunctions() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "date(\"2016-03-01\")", @@ -2366,7 +2367,7 @@ public void testConversionFunctions() { @Disabled @Test public void testFunctionInvocationWhenMultipleMatch() { - List entries = Arrays.asList(); + List entries = Collections.emptyList(); // Multiple matches for date(null) doExpressionTest(entries, "", "date(null)", @@ -2379,8 +2380,8 @@ public void testFunctionInvocationWhenMultipleMatch() { @Test public void testPathExpression() { - ItemDefinitionType type = new ItemDefinitionType("PrivateFundRequirements").addMember("HierarchyNode", Arrays.asList(), STRING); - List entries = Arrays.asList( + ItemDefinitionType type = new ItemDefinitionType("PrivateFundRequirements").addMember("HierarchyNode", Collections.emptyList(), STRING); + List entries = Collections.singletonList( new EnvironmentEntry("PrivateFundRequirements", type, null)); doExpressionTest(entries, "", "[{b: 1}, {b: [2.1, 2.2]}, {b: 3}, {b: 4}, {b: 5}].b = [1, [2.1, 2.2], 3, 4, 5]", @@ -2393,9 +2394,9 @@ public void testPathExpression() { @Test public void testQualifiedName() { - Type bType = new ItemDefinitionType("b").addMember("c", Arrays.asList("C"), STRING); - Type aType = new ItemDefinitionType("a").addMember("b", Arrays.asList("B"), bType); - List entries = Arrays.asList( + Type bType = new ItemDefinitionType("b").addMember("c", Collections.singletonList("C"), STRING); + Type aType = new ItemDefinitionType("a").addMember("b", Collections.singletonList("B"), bType); + List entries = Collections.singletonList( new EnvironmentEntry("a", aType, null)); doExpressionTest(entries, "", "a.b.c", @@ -2408,7 +2409,7 @@ public void testQualifiedName() { @Test public void testPrimaryExpression() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "(123.45)", @@ -2427,7 +2428,7 @@ public void testPrimaryExpression() { @Test public void testNull() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "null", @@ -2440,7 +2441,7 @@ public void testNull() { @Test public void testFunctionDefinition() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "function (x : feel.string, y : feel.string) x + y", @@ -2484,7 +2485,7 @@ public void testFunctionDefinition() { @Test public void testList() { NUMBER number = this.lib.number("1"); - List list = Arrays.asList(this.lib.number("1")); + List list = Collections.singletonList(this.lib.number("1")); List expressionPairs = Arrays.asList( new EnvironmentEntry("number", NUMBER, number), @@ -2498,14 +2499,14 @@ public void testList() { "ListLiteral()", "ListType(Null)", "asList()", - Arrays.asList(), - Arrays.asList()); + Collections.emptyList(), + Collections.emptyList()); doExpressionTest(expressionPairs, "", "[1]", "ListLiteral(NumericLiteral(1))", "ListType(number)", "asList(number(\"1\"))", - Arrays.asList(this.lib.number("1")), - Arrays.asList(this.lib.number("1"))); + Collections.singletonList(this.lib.number("1")), + Collections.singletonList(this.lib.number("1"))); doExpressionTest(expressionPairs, "", "[1, 2, 3]", "ListLiteral(NumericLiteral(1),NumericLiteral(2),NumericLiteral(3))", "ListType(number)", @@ -2552,19 +2553,19 @@ public void testList() { "PositiveUnaryTests(ListTest(ListLiteral()))", "TupleType(boolean)", "listContains(asList(), number)", - this.lib.listContains(Arrays.asList(), number), + this.lib.listContains(Collections.emptyList(), number), false); doUnaryTestsTest(testPairs, "list", "[]", "PositiveUnaryTests(ListTest(ListLiteral()))", "TupleType(boolean)", "listEqual(list, asList())", - this.lib.listEqual(list, Arrays.asList()), + this.lib.listEqual(list, Collections.emptyList()), false); doUnaryTestsTest(testPairs, "list", "[1]", "PositiveUnaryTests(ListTest(ListLiteral(OperatorRange(null,NumericLiteral(1)))))", "TupleType(boolean)", "listEqual(list, asList(number(\"1\")))", - this.lib.listEqual(list, Arrays.asList(this.lib.number("1"))), + this.lib.listEqual(list, Collections.singletonList(this.lib.number("1"))), true); doUnaryTestsTest(testPairs, "list", "[1, 2, 3]", "PositiveUnaryTests(ListTest(ListLiteral(OperatorRange(null,NumericLiteral(1)),OperatorRange(null,NumericLiteral(2)),OperatorRange(null,NumericLiteral(3)))))", @@ -2649,7 +2650,7 @@ public void testContext() { @Test public void testSimpleLiterals() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "123.45", diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/AbstractStandardFEELProcessorTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/AbstractStandardFEELProcessorTest.java index 8944dfd8e..a7387e1d7 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/AbstractStandardFEELProcessorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/AbstractStandardFEELProcessorTest.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -134,7 +135,7 @@ public void testExpressionTest() { public void testBetweenExpression() { super.testBetweenExpression(); - List entries = Arrays.asList(); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "\"a\" between \"b\" and \"d\"", "BetweenExpression(StringLiteral(\"a\"), StringLiteral(\"b\"), StringLiteral(\"d\"))", @@ -150,7 +151,7 @@ public void testInExpression() { super.testInExpression(); // operator test - List entries = Arrays.asList(); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "\"b\" in [[\"f\"..\"h\"], [\"a\"..\"c\"]]", "InExpression(StringLiteral(\"b\"), ListTest(ListLiteral(EndpointsRange(false,StringLiteral(\"f\"),false,StringLiteral(\"h\")),EndpointsRange(false,StringLiteral(\"a\"),false,StringLiteral(\"c\")))))", @@ -292,8 +293,7 @@ public void testFunctionInvocation() { public void testFilterExpression() { super.testFilterExpression(); - List entries = Arrays.asList( - ); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "[ { x: \"1\", y: \"2\" }, { x: null, y: \"3\" } ][ x < \"2\" ]", "FilterExpression(ListLiteral(Context(ContextEntry(ContextEntryKey(x) = StringLiteral(\"1\")),ContextEntry(ContextEntryKey(y) = StringLiteral(\"2\"))),Context(ContextEntry(ContextEntryKey(x) = NullLiteral()),ContextEntry(ContextEntryKey(y) = StringLiteral(\"3\")))), Relational(<,PathExpression(Name(item), x),StringLiteral(\"2\")))", "ListType(ContextType(x = string, y = string))", @@ -313,8 +313,8 @@ public void testFilterExpression() { public void testPathExpression() { super.testPathExpression(); - ItemDefinitionType type = new ItemDefinitionType("PrivateFundRequirements").addMember("HierarchyNode", Arrays.asList(), STRING); - List entries = Arrays.asList( + ItemDefinitionType type = new ItemDefinitionType("PrivateFundRequirements").addMember("HierarchyNode", Collections.emptyList(), STRING); + List entries = Collections.singletonList( new EnvironmentEntry("PrivateFundRequirements", type, null)); doExpressionTest(entries, "", "string length(PrivateFundRequirements.HierarchyNode)", @@ -356,7 +356,7 @@ public void testPathExpression() { public void testConversionFunctions() { super.testConversionFunctions(); - List entries = Arrays.asList(); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "date(\"2012-03-01\")", "DateTimeLiteral(date, \"2012-03-01\")", @@ -464,7 +464,7 @@ public void testConversionFunctions() { @Test public void testNumericFunctions() { - List entries = Arrays.asList(); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "decimal(100, 2)", "FunctionInvocation(Name(decimal) -> PositionalParameters(NumericLiteral(100), NumericLiteral(2)))", @@ -590,7 +590,7 @@ public void testNumericFunctions() { @Test public void testBooleanFunctions() { - List entries = Arrays.asList(); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "not(true)", "LogicNegation(BooleanLiteral(true))", @@ -602,7 +602,7 @@ public void testBooleanFunctions() { @Test public void testStringFunctions() { - List entries = Arrays.asList(); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "substring(\"abc\", 3)", "FunctionInvocation(Name(substring) -> PositionalParameters(StringLiteral(\"abc\"), NumericLiteral(3)))", @@ -776,7 +776,7 @@ public void testStringFunctions() { @Test public void testListFunctions() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "list contains([1, 2, 3], 1)", @@ -1124,7 +1124,7 @@ public void testListFunctions() { @Test public void testContextFunctions() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "get entries({a: \"foo\", b: \"bar\"})", @@ -1217,8 +1217,7 @@ public void testTimeProperties() { @Test public void testDateAndTimeProperties() { - List entries = Arrays.asList( - ); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "date and time(\"2018-12-10T10:30:00\").time offset", "PathExpression(DateTimeLiteral(date and time, \"2018-12-10T10:30:00\"), time offset)", @@ -1407,7 +1406,7 @@ public void testTemporalFunctions() { @Test public void testRangeLiterals() { DATE input = this.lib.date("2010-10-02"); - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", DATE, input)); doExpressionTest(entries, "", "@\"2010-10-01\"", @@ -1462,8 +1461,7 @@ public void testRangeLiterals() { @Test public void testRangeFunctions() { - List entries = Arrays.asList( - ); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "before(1, [5..8])", "FunctionInvocation(Name(before) -> PositionalParameters(NumericLiteral(1), EndpointsRange(false,NumericLiteral(5),false,NumericLiteral(8))))", @@ -1721,7 +1719,7 @@ public void testRangeProperties() { @Test public void testInstanceOfExpression() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "3 instance of number", diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/DefaultStandardFEELProcessorTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/DefaultStandardFEELProcessorTest.java index f7e9d588b..1d15e4f81 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/DefaultStandardFEELProcessorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/DefaultStandardFEELProcessorTest.java @@ -21,7 +21,7 @@ import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; public class DefaultStandardFEELProcessorTest extends AbstractStandardFEELProcessorTest { @@ -35,7 +35,7 @@ protected DMNDialectDefinition entries = Arrays.asList(); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "date and time(date and time(\"2012-03-01T13:14:15Z\"), time(\"10:11:12Z\"))", "FunctionInvocation(Name(date and time) -> PositionalParameters(DateTimeLiteral(date and time, \"2012-03-01T13:14:15Z\"), DateTimeLiteral(time, \"10:11:12Z\")))", @@ -82,8 +82,7 @@ public void testDateTimeFunctions() { @Test @Override public void testDateAndTimeProperties() { - List entries = Arrays.asList( - ); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "date and time(\"2018-12-10T10:30:00\").time offset", "PathExpression(DateTimeLiteral(date and time, \"2018-12-10T10:30:00\"), time offset)", diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/MixedJavaFEELProcessorTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/MixedJavaFEELProcessorTest.java index 2b378caa0..80fb7cd44 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/MixedJavaFEELProcessorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/MixedJavaFEELProcessorTest.java @@ -24,7 +24,7 @@ import java.time.OffsetTime; import java.time.ZonedDateTime; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; public class MixedJavaFEELProcessorTest extends AbstractStandardFEELProcessorTest { @@ -40,7 +40,7 @@ public void testConversionFunctions() { MixedJavaTimeFEELLib lib = (MixedJavaTimeFEELLib) this.lib; - List entries = Arrays.asList(); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "date and time(date and time(\"2012-03-01T13:14:15Z\"), time(\"10:11:12Z\"))", "FunctionInvocation(Name(date and time) -> PositionalParameters(DateTimeLiteral(date and time, \"2012-03-01T13:14:15Z\"), DateTimeLiteral(time, \"10:11:12Z\")))", @@ -87,8 +87,7 @@ public void testDateTimeFunctions() { @Test @Override public void testDateAndTimeProperties() { - List entries = Arrays.asList( - ); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "date and time(\"2018-12-10T10:30:00\").time offset", "PathExpression(DateTimeLiteral(date and time, \"2018-12-10T10:30:00\"), time offset)", diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/AddItemFilterVisitorTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/AddItemFilterVisitorTest.java index 77bb6ab26..66b8fd498 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/AddItemFilterVisitorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/AddItemFilterVisitorTest.java @@ -26,15 +26,15 @@ import com.gs.dmn.feel.analysis.syntax.ast.visitor.BaseVisitorTest; import org.junit.jupiter.api.Test; -import java.util.Arrays; +import java.util.Collections; import static org.junit.jupiter.api.Assertions.assertEquals; public class AddItemFilterVisitorTest extends BaseVisitorTest { private final String parameterName = "parameterName"; private final Type stringType = StringType.STRING; - private final ContextType contextType = new ContextType().addMember(this.parameterName, Arrays.asList(), this.stringType); - private final ItemDefinitionType itemDefinitionType = new ItemDefinitionType("personType").addMember(this.parameterName, Arrays.asList(), this.stringType); + private final ContextType contextType = new ContextType().addMember(this.parameterName, Collections.emptyList(), this.stringType); + private final ItemDefinitionType itemDefinitionType = new ItemDefinitionType("personType").addMember(this.parameterName, Collections.emptyList(), this.stringType); private final ErrorHandler errorHandler = NopErrorHandler.INSTANCE; private final AddItemFilterVisitor contextTypeVisitor = new AddItemFilterVisitor<>(this.parameterName, this.contextType, this.errorHandler); diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/FunctionTypeTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/FunctionTypeTest.java index 95b239845..eca34e7a3 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/FunctionTypeTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/FunctionTypeTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static com.gs.dmn.feel.analysis.semantics.type.DateTimeType.DATE_AND_TIME; @@ -33,15 +34,15 @@ public abstract class FunctionTypeTest { @Test public void testCalculateCandidates() { - doTest(Arrays.asList(), Arrays.asList(), "[]"); - doTest(Arrays.asList(NUMBER), Arrays.asList(NUMBER), "[]"); - doTest(Arrays.asList(NUMBER), Arrays.asList(NUMBER_LIST), "[" + + doTest(Collections.emptyList(), Collections.emptyList(), "[]"); + doTest(Collections.singletonList(NUMBER), Collections.singletonList(NUMBER), "[]"); + doTest(Collections.singletonList(NUMBER), Collections.singletonList(NUMBER_LIST), "[" + "Pair(PositionalParameterTypes(number), PositionalParameterConversions([Conversion(SINGLETON_LIST_TO_ELEMENT, number)]))" + "]"); - doTest(Arrays.asList(NUMBER_LIST), Arrays.asList(NUMBER), "[" + + doTest(Collections.singletonList(NUMBER_LIST), Collections.singletonList(NUMBER), "[" + "Pair(PositionalParameterTypes(ListType(number)), PositionalParameterConversions([Conversion(ELEMENT_TO_SINGLETON_LIST, ListType(number))]))" + "]"); - doTest(Arrays.asList(NUMBER), Arrays.asList(STRING), "[" + + doTest(Collections.singletonList(NUMBER), Collections.singletonList(STRING), "[" + "]"); doTest(Arrays.asList(NUMBER, DATE_AND_TIME), Arrays.asList(NUMBER, DATE), "[" + "Pair(PositionalParameterTypes(number, date and time), PositionalParameterConversions([Conversion(NONE, number), Conversion(DATE_TO_UTC_MIDNIGHT, date and time)]))" + diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeConformanceTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeConformanceTest.java index 9f6d49c97..ae5d55af0 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeConformanceTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeConformanceTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -95,8 +96,8 @@ public void testDataTypes() { @Test public void testFunctionType() { - FEELFunctionType type1 = new FEELFunctionType(Arrays.asList(new FormalParameter<>("p", STRING)), STRING, false); - FEELFunctionType type2 = new FEELFunctionType(Arrays.asList(new FormalParameter<>("p", NUMBER)), STRING, false); + FEELFunctionType type1 = new FEELFunctionType(Collections.singletonList(new FormalParameter<>("p", STRING)), STRING, false); + FEELFunctionType type2 = new FEELFunctionType(Collections.singletonList(new FormalParameter<>("p", NUMBER)), STRING, false); FEELFunctionType tyep3 = new FEELFunctionType(Arrays.asList(new FormalParameter<>("p1", STRING), new FormalParameter<>("p2", NUMBER)), STRING, false); checkConformsTo(true, type1, type1); @@ -143,14 +144,14 @@ public void testContextType() { @Test public void testItemDefinitionType() { ItemDefinitionType type1 = new ItemDefinitionType("ID1"); - type1.addMember("m", Arrays.asList(), NUMBER); + type1.addMember("m", Collections.emptyList(), NUMBER); ItemDefinitionType type2 = new ItemDefinitionType("ID2"); - type2.addMember("m", Arrays.asList(), BOOLEAN); + type2.addMember("m", Collections.emptyList(), BOOLEAN); ItemDefinitionType type3 = new ItemDefinitionType("ID3"); - type3.addMember("m", Arrays.asList(), NUMBER); - type3.addMember("x", Arrays.asList(), NUMBER); + type3.addMember("m", Collections.emptyList(), NUMBER); + type3.addMember("x", Collections.emptyList(), NUMBER); checkConformsTo(true, type1, ANY); checkConformsTo(true, type1, type1); diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeEqualsTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeEqualsTest.java index 6176a0fff..039da3c16 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeEqualsTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeEqualsTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -95,8 +96,8 @@ public void testDataTypes() { @Test public void testFunctionType() { - FEELFunctionType type1 = new FEELFunctionType(Arrays.asList(new FormalParameter<>("p", STRING)), STRING, false); - FEELFunctionType type2 = new FEELFunctionType(Arrays.asList(new FormalParameter<>("p1", NUMBER)), STRING, false); + FEELFunctionType type1 = new FEELFunctionType(Collections.singletonList(new FormalParameter<>("p", STRING)), STRING, false); + FEELFunctionType type2 = new FEELFunctionType(Collections.singletonList(new FormalParameter<>("p1", NUMBER)), STRING, false); FEELFunctionType tyep3 = new FEELFunctionType(Arrays.asList(new FormalParameter<>("p1", STRING), new FormalParameter<>("p2", NUMBER)), STRING, false); checkEquals(true, type1, type1); @@ -142,14 +143,14 @@ public void testContextType() { @Test public void testItemDefinitionType() { ItemDefinitionType type1 = new ItemDefinitionType("ID1"); - type1.addMember("m", Arrays.asList(), NUMBER); + type1.addMember("m", Collections.emptyList(), NUMBER); ItemDefinitionType type2 = new ItemDefinitionType("ID2"); - type2.addMember("m", Arrays.asList(), BOOLEAN); + type2.addMember("m", Collections.emptyList(), BOOLEAN); ItemDefinitionType type3 = new ItemDefinitionType("ID3"); - type3.addMember("m", Arrays.asList(), NUMBER); - type3.addMember("x", Arrays.asList(), NUMBER); + type3.addMember("m", Collections.emptyList(), NUMBER); + type3.addMember("x", Collections.emptyList(), NUMBER); checkEquals(true, type1, type1); diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeEquivalenceTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeEquivalenceTest.java index e6594b830..9f801ae7d 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeEquivalenceTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/semantics/type/TypeEquivalenceTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -95,8 +96,8 @@ public void testDataTypes() { @Test public void testFunctionType() { - FEELFunctionType type1 = new FEELFunctionType(Arrays.asList(new FormalParameter<>("p", STRING)), STRING, false); - FEELFunctionType type2 = new FEELFunctionType(Arrays.asList(new FormalParameter<>("p1", NUMBER)), STRING, false); + FEELFunctionType type1 = new FEELFunctionType(Collections.singletonList(new FormalParameter<>("p", STRING)), STRING, false); + FEELFunctionType type2 = new FEELFunctionType(Collections.singletonList(new FormalParameter<>("p1", NUMBER)), STRING, false); FEELFunctionType tyep3 = new FEELFunctionType(Arrays.asList(new FormalParameter<>("p1", STRING), new FormalParameter<>("p2", NUMBER)), STRING, false); checkEquivalentTo(true, type1, type1); @@ -142,14 +143,14 @@ public void testContextType() { @Test public void testItemDefinitionType() { ItemDefinitionType type1 = new ItemDefinitionType("ID1"); - type1.addMember("m", Arrays.asList(), NUMBER); + type1.addMember("m", Collections.emptyList(), NUMBER); ItemDefinitionType type2 = new ItemDefinitionType("ID2"); - type2.addMember("m", Arrays.asList(), BOOLEAN); + type2.addMember("m", Collections.emptyList(), BOOLEAN); ItemDefinitionType type3 = new ItemDefinitionType("ID3"); - type3.addMember("m", Arrays.asList(), NUMBER); - type3.addMember("x", Arrays.asList(), NUMBER); + type3.addMember("m", Collections.emptyList(), NUMBER); + type3.addMember("x", Collections.emptyList(), NUMBER); checkEquivalentTo(true, type1, type1); diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/FEELLexerTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/FEELLexerTest.java index 67d8df439..bedddb2df 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/FEELLexerTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/FEELLexerTest.java @@ -25,7 +25,7 @@ import static com.gs.dmn.feel.analysis.syntax.antlrv4.FEELLexer.*; public class FEELLexerTest extends AbstractLexerTest { - private static List SPECIAL_NAMES = Arrays.asList( + private static final List SPECIAL_NAMES = Arrays.asList( // constructors "date and time", "days and time duration", diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/ast/visitor/NamesVisitorTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/ast/visitor/NamesVisitorTest.java index 91adb741a..f65f8a512 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/ast/visitor/NamesVisitorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/ast/visitor/NamesVisitorTest.java @@ -14,10 +14,7 @@ import org.antlr.v4.runtime.CommonTokenStream; import org.junit.jupiter.api.Test; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; +import java.util.*; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -26,31 +23,31 @@ public class NamesVisitorTest { public void getNames() { testExpression("function (a, b) a + b", Arrays.asList("a", "b")); testExpression("{ \"a\": a, \"b\": b}", Arrays.asList("a", "b")); - testExpression("for i in 4..2 return i", Arrays.asList("i")); + testExpression("for i in 4..2 return i", Collections.singletonList("i")); testExpression("if a then b else c", Arrays.asList("a", "b", "c")); testExpression("if a then b else c", Arrays.asList("a", "b", "c")); testExpression("every i in [1..2] j in [2..3] satisfies i + j > 1", Arrays.asList("i", "j")); testExpression("some i in [1..2] j in [2..3] satisfies i + j > 1", Arrays.asList("i", "j")); testExpression("DeptTable[number = EmployeeTable[name=LastName].deptNum[1]].manager[1]", Arrays.asList("DeptTable", "number", "EmployeeTable", "name", "LastName")); - testExpression("a instance of number", Arrays.asList("a")); + testExpression("a instance of number", Collections.singletonList("a")); testExpression("[a, b, c]", Arrays.asList("a", "b", "c")); testExpression("not a or b and c", Arrays.asList("a", "b", "c")); testExpression("(a < b) or (b <= c) or (b > c) or (b >= c)", Arrays.asList("a", "b", "c")); testExpression("a between b and c", Arrays.asList("a", "b", "c")); testExpression("a in [b, c]", Arrays.asList("a", "b", "c")); testExpression(" a + b - c * d / e ** f", Arrays.asList("a", "b", "c", "d", "e", "f")); - testExpression(" - a", Arrays.asList("a")); - testExpression("a.b.c", Arrays.asList("a")); + testExpression(" - a", Collections.singletonList("a")); + testExpression("a.b.c", Collections.singletonList("a")); testExpression("a(b, c)", Arrays.asList("a", "b", "c")); testExpression("a(\"first\" = b, \"second\" = c)", Arrays.asList("a", "b", "c")); testUnaryTests("a, b", Arrays.asList("a", "b")); - testUnaryTests("not (a)", Arrays.asList("a")); - testUnaryTests("-", Arrays.asList()); - testUnaryTests("< a", Arrays.asList("a")); - testUnaryTests("<= a", Arrays.asList("a")); - testUnaryTests("> a", Arrays.asList("a")); - testUnaryTests(">= a", Arrays.asList("a")); + testUnaryTests("not (a)", Collections.singletonList("a")); + testUnaryTests("-", Collections.emptyList()); + testUnaryTests("< a", Collections.singletonList("a")); + testUnaryTests("<= a", Collections.singletonList("a")); + testUnaryTests("> a", Collections.singletonList("a")); + testUnaryTests(">= a", Collections.singletonList("a")); } private void testExpression(String text, List expectedNames) { diff --git a/dmn-core/src/test/java/com/gs/dmn/runtime/interpreter/AbstractDMNInterpreterTest.java b/dmn-core/src/test/java/com/gs/dmn/runtime/interpreter/AbstractDMNInterpreterTest.java index 62eb8c80b..73a2026bf 100644 --- a/dmn-core/src/test/java/com/gs/dmn/runtime/interpreter/AbstractDMNInterpreterTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/runtime/interpreter/AbstractDMNInterpreterTest.java @@ -45,7 +45,7 @@ import java.net.URI; import java.net.URL; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -65,7 +65,7 @@ public abstract class AbstractDMNInterpreterTest... extraInputParameters) { - doMultipleModelsTest(dmnVersion, Arrays.asList(dmnFileName), extraInputParameters); + doMultipleModelsTest(dmnVersion, Collections.singletonList(dmnFileName), extraInputParameters); } @SafeVarargs diff --git a/dmn-core/src/test/java/com/gs/dmn/runtime/interpreter/InterpretedRuleOutputTest.java b/dmn-core/src/test/java/com/gs/dmn/runtime/interpreter/InterpretedRuleOutputTest.java index 50ce0dd7b..62ee3bc26 100644 --- a/dmn-core/src/test/java/com/gs/dmn/runtime/interpreter/InterpretedRuleOutputTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/runtime/interpreter/InterpretedRuleOutputTest.java @@ -16,14 +16,14 @@ import com.gs.dmn.runtime.Pair; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class InterpretedRuleOutputTest { @Test public void testEquals() { - assertTrue(new InterpretedRuleOutput(true, "123").equals(new InterpretedRuleOutput(true, "123"))); - assertFalse(new InterpretedRuleOutput(true, "1234").equals(new InterpretedRuleOutput(true, "123"))); + assertEquals(new InterpretedRuleOutput(true, "123"), new InterpretedRuleOutput(true, "123")); + assertNotEquals(new InterpretedRuleOutput(true, "1234"), new InterpretedRuleOutput(true, "123")); Context c1 = new Context(); c1.put("Rate", new Pair<>("Best", null)); @@ -31,6 +31,6 @@ public void testEquals() { Context c2 = new Context(); c2.put("Rate", new Pair<>("Best", null)); c2.put("Status", new Pair<>("Approved", null)); - assertTrue(new InterpretedRuleOutput(true, c1).equals(new InterpretedRuleOutput(true, c2))); + assertEquals(new InterpretedRuleOutput(true, c1), new InterpretedRuleOutput(true, c2)); } } \ No newline at end of file diff --git a/dmn-core/src/test/java/com/gs/dmn/serialization/DMNSerializerTest.java b/dmn-core/src/test/java/com/gs/dmn/serialization/DMNSerializerTest.java index 6e9729804..b2f688a24 100644 --- a/dmn-core/src/test/java/com/gs/dmn/serialization/DMNSerializerTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/serialization/DMNSerializerTest.java @@ -83,7 +83,7 @@ private void checkModel(TDefinitions definitions) { assertNamedElement(decision, "cip-assessments", "CIP Assessments"); TExpression expression = ((TDecision) decision).getExpression(); - assertTrue(expression instanceof TDecisionTable); + assertInstanceOf(TDecisionTable.class, expression); TDecisionTable table = (TDecisionTable) expression; assertEquals("decisionTable", table.getId()); diff --git a/dmn-core/src/test/java/com/gs/dmn/serialization/xstream/v1_1/UnmarshalMarshalTest.java b/dmn-core/src/test/java/com/gs/dmn/serialization/xstream/v1_1/UnmarshalMarshalTest.java index cb0196fc4..f543f6436 100644 --- a/dmn-core/src/test/java/com/gs/dmn/serialization/xstream/v1_1/UnmarshalMarshalTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/serialization/xstream/v1_1/UnmarshalMarshalTest.java @@ -23,7 +23,7 @@ import org.xmlunit.diff.DifferenceEvaluators; import javax.xml.transform.stream.StreamSource; -import java.util.Arrays; +import java.util.Collections; public class UnmarshalMarshalTest extends AbstractXStreamUnmarshalMarshalTest { @Test @@ -78,13 +78,13 @@ public void testHelloWorldSemanticNamespace() throws Exception { @Test public void testHelloWorldSemanticNamespaceWithExtensions() throws Exception { - DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Arrays.asList(new MyTestRegister())); + DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Collections.singletonList(new MyTestRegister())); testRoundTrip("xstream/v1_1/Hello_World_semantic_namespace_with_extensions.dmn", marshaller); } @Test public void testHelloWorldSemanticNamespaceWithExtensionsOtherNsLocation() throws Exception { - DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Arrays.asList(new MyTestRegister())); + DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Collections.singletonList(new MyTestRegister())); testRoundTrip("xstream/v1_1/Hello_World_semantic_namespace_with_extensions_other_ns_location.dmn", marshaller); } diff --git a/dmn-core/src/test/java/com/gs/dmn/serialization/xstream/v1_2/UnmarshalMarshalTest.java b/dmn-core/src/test/java/com/gs/dmn/serialization/xstream/v1_2/UnmarshalMarshalTest.java index a5322e0d9..c98341e8f 100644 --- a/dmn-core/src/test/java/com/gs/dmn/serialization/xstream/v1_2/UnmarshalMarshalTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/serialization/xstream/v1_2/UnmarshalMarshalTest.java @@ -27,7 +27,7 @@ import javax.xml.transform.stream.StreamSource; import java.io.InputStreamReader; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -65,7 +65,7 @@ public void testDMNDIDiagramElementExtension() throws Exception { @Test public void testDMNDIDiagramElementExtensionWithContent() throws Exception { - DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Arrays.asList(new MyTestRegister())); + DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Collections.singletonList(new MyTestRegister())); testRoundTrip("xstream/v1_2/DMNDIDiagramElementExtension_withContent.dmn", marshaller); } diff --git a/dmn-core/src/test/java/com/gs/dmn/transformation/AddMissingNamespaceInTestCasesTransformerTest.java b/dmn-core/src/test/java/com/gs/dmn/transformation/AddMissingNamespaceInTestCasesTransformerTest.java index 02f1abb06..8b672284c 100644 --- a/dmn-core/src/test/java/com/gs/dmn/transformation/AddMissingNamespaceInTestCasesTransformerTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/transformation/AddMissingNamespaceInTestCasesTransformerTest.java @@ -16,7 +16,7 @@ import com.gs.dmn.tck.ast.TestCases; import org.junit.jupiter.api.Test; -import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashMap; import static com.gs.dmn.serialization.DMNConstants.XSI_NS; @@ -25,7 +25,7 @@ public class AddMissingNamespaceInTestCasesTransformerTest extends SimpleDMNTransformerTest { @Test public void testTransform() throws Exception { - doTest("1.1", Arrays.asList("0004-lending.dmn"), + doTest("1.1", Collections.singletonList("0004-lending.dmn"), "0004-lending-test-01.xml", new LinkedHashMap>() {{ put("0004-lending.dmn", new Pair<>("http://www.trisotech.com/definitions/_4e0f0b70-d31c-471c-bd52-5ca709ed362b", "tns")); put("0004-lending-test-01.xml", new Pair<>(XSI_NS, XSI_PREFIX)); diff --git a/dmn-core/src/test/java/com/gs/dmn/transformation/ToQuotedNameTransformerTest.java b/dmn-core/src/test/java/com/gs/dmn/transformation/ToQuotedNameTransformerTest.java index bb8099574..1ffecf10e 100644 --- a/dmn-core/src/test/java/com/gs/dmn/transformation/ToQuotedNameTransformerTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/transformation/ToQuotedNameTransformerTest.java @@ -18,6 +18,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashMap; import static com.gs.dmn.runtime.Assert.assertEquals; @@ -27,25 +28,25 @@ public class ToQuotedNameTransformerTest extends SimpleDMNTransformerTest { @Test public void testTransform() throws Exception { - doTest("1.1", Arrays.asList("0004-lending.dmn"), + doTest("1.1", Collections.singletonList("0004-lending.dmn"), "0004-lending-test-01.xml", new LinkedHashMap>() {{ put("0004-lending.dmn", new Pair<>("http://www.trisotech.com/definitions/_4e0f0b70-d31c-471c-bd52-5ca709ed362b", "tns")); put("0004-lending-test-01.xml", new Pair<>(XSI_NS, XSI_PREFIX)); }} ); - doTest("1.1", Arrays.asList("0007-date-time.dmn"), + doTest("1.1", Collections.singletonList("0007-date-time.dmn"), "0007-date-time-test-01.xml", new LinkedHashMap>() {{ put("0007-date-time.dmn", new Pair<>("http://www.trisotech.com/definitions/_69430b3e-17b8-430d-b760-c505bf6469f9", "tns")); put("0007-date-time-test-01.xml", new Pair<>(XSI_NS, XSI_PREFIX)); }} ); - doTest("1.1", Arrays.asList("0034-drg-scopes.dmn") , + doTest("1.1", Collections.singletonList("0034-drg-scopes.dmn"), "0034-drg-scopes-test-01.xml", new LinkedHashMap>() {{ put("0034-drg-scopes.dmn", new Pair<>("http://www.actico.com/spec/DMN/0.1.0/0034-drg-scopes", "tns")); put("0034-drg-scopes-test-01.xml", new Pair<>(XSI_NS, XSI_PREFIX)); }} ); - doTest("1.2", Arrays.asList("0087-chapter-11-example.dmn") , + doTest("1.2", Collections.singletonList("0087-chapter-11-example.dmn"), "0087-chapter-11-example-test-01.xml", new LinkedHashMap>() {{ put("0087-chapter-11-example.dmn", new Pair<>("http://www.trisotech.com/definitions/_9d01a0c4-f529-4ad8-ad8e-ec5fb5d96ad4", "tns")); put("0087-chapter-11-example-test-01.xml", new Pair<>(XSI_NS, XSI_PREFIX)); diff --git a/dmn-core/src/test/java/com/gs/dmn/transformation/basic/BasicDMNToJavaTransformerTest.java b/dmn-core/src/test/java/com/gs/dmn/transformation/basic/BasicDMNToJavaTransformerTest.java index 262dafe7e..fe1dcbaf8 100644 --- a/dmn-core/src/test/java/com/gs/dmn/transformation/basic/BasicDMNToJavaTransformerTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/transformation/basic/BasicDMNToJavaTransformerTest.java @@ -29,7 +29,7 @@ import java.time.LocalDate; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAmount; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -86,32 +86,32 @@ public void testLowerCaseFirst() { @Test public void testEmptyAnnotation() { TDecision decision = this.dmnTransformer.getDMNModelRepository().findDecisionByRef(null, this.href); - assertEquals(Arrays.asList(), this.dmnTransformer.annotations(decision, Arrays.asList((String) null))); - assertEquals(Arrays.asList(), this.dmnTransformer.annotations(decision, Arrays.asList(""))); + assertEquals(Collections.emptyList(), this.dmnTransformer.annotations(decision, Collections.singletonList(null))); + assertEquals(Collections.emptyList(), this.dmnTransformer.annotations(decision, Collections.singletonList(""))); } @Test public void testAnnotationWithOneString() { TDecision decision = this.dmnTransformer.getDMNModelRepository().findDecisionByRef(null, this.href); - assertEquals(Arrays.asList("string(\"plain text\")"), this.dmnTransformer.annotations(decision, Arrays.asList("string(\"plain text\")"))); - assertEquals(Arrays.asList("string(((java.lang.Number)(requestedProduct != null ? requestedProduct.getTerm() : null)))"), this.dmnTransformer.annotations(decision, Arrays.asList("string(RequestedProduct.Term)"))); - assertEquals(Arrays.asList("string(\"\")"), this.dmnTransformer.annotations(decision,Arrays.asList( "string(\"\")"))); + assertEquals(Collections.singletonList("string(\"plain text\")"), this.dmnTransformer.annotations(decision, Collections.singletonList("string(\"plain text\")"))); + assertEquals(Collections.singletonList("string(((java.lang.Number)(requestedProduct != null ? requestedProduct.getTerm() : null)))"), this.dmnTransformer.annotations(decision, Collections.singletonList("string(RequestedProduct.Term)"))); + assertEquals(Collections.singletonList("string(\"\")"), this.dmnTransformer.annotations(decision, Collections.singletonList("string(\"\")"))); } @Test public void testAnnotationWithExpression() { TDecision decision = this.dmnTransformer.getDMNModelRepository().findDecisionByRef(null, this.href); - assertEquals(Arrays.asList("string(numericAdd(((java.lang.Number)(requestedProduct != null ? requestedProduct.getRate() : null)), number(\"2\")))"), this.dmnTransformer.annotations(decision, Arrays.asList("string(RequestedProduct.Rate + 2)"))); + assertEquals(Collections.singletonList("string(numericAdd(((java.lang.Number)(requestedProduct != null ? requestedProduct.getRate() : null)), number(\"2\")))"), this.dmnTransformer.annotations(decision, Collections.singletonList("string(RequestedProduct.Rate + 2)"))); } @Test public void testAnnotationWithSeveralStrings() { TDecision decision = this.dmnTransformer.getDMNModelRepository().findDecisionByRef(null, this.href); - List expected = Arrays.asList( + List expected = Collections.singletonList( "stringAdd(stringAdd(stringAdd(stringAdd(string(\"Rate is \"), string(((java.lang.Number)(requestedProduct != null ? requestedProduct.getRate() : null)))), " + "string(\". And term is \")), string(((java.lang.Number)(requestedProduct != null ? requestedProduct.getTerm() : null)))), string(\"!\"))"); - assertEquals(expected, this.dmnTransformer.annotations(decision, Arrays.asList("string(\"Rate is \") + string(RequestedProduct.Rate) + string(\". And term is \") + string(RequestedProduct.Term) + string(\"!\")"))); - assertEquals(Arrays.asList("asList(string(\"\"), string(\"\"), string(\"\"))"), this.dmnTransformer.annotations(decision, Arrays.asList("[string(\"\"), string(\"\"), string(\"\")]"))); + assertEquals(expected, this.dmnTransformer.annotations(decision, Collections.singletonList("string(\"Rate is \") + string(RequestedProduct.Rate) + string(\". And term is \") + string(RequestedProduct.Term) + string(\"!\")"))); + assertEquals(Collections.singletonList("asList(string(\"\"), string(\"\"), string(\"\"))"), this.dmnTransformer.annotations(decision, Collections.singletonList("[string(\"\"), string(\"\"), string(\"\")]"))); } @Test diff --git a/dmn-core/src/test/java/com/gs/dmn/validation/DefaultDMNValidatorTest.java b/dmn-core/src/test/java/com/gs/dmn/validation/DefaultDMNValidatorTest.java index 0d9ebcd5b..9d673e5c8 100644 --- a/dmn-core/src/test/java/com/gs/dmn/validation/DefaultDMNValidatorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/validation/DefaultDMNValidatorTest.java @@ -15,6 +15,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -24,7 +25,7 @@ public class DefaultDMNValidatorTest extends AbstractValidatorTest { @Test public void testValidateWhenCorrect() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); validate(validator, tckResource("tck/1.2/cl3/0020-vacation-days/0020-vacation-days.dmn"), expectedErrors); } @@ -42,7 +43,7 @@ public void testValidateDefinitionsWhenNotUniqueNames() { @Test public void testValidateDefinitionsWithError() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='test-dmn', name='CIP Assessments', id='cip-assessments'): error: Missing variable" ); validate(validator, resource("dmn/input/1.1/test-dmn.dmn"), expectedErrors); diff --git a/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingIntervalValidatorTest.java b/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingIntervalValidatorTest.java index f5085bec1..2a821a93d 100644 --- a/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingIntervalValidatorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingIntervalValidatorTest.java @@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -26,13 +27,13 @@ public class SweepMissingIntervalValidatorTest extends AbstractValidatorTest { @Test public void testValidateWhenCorrect() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); validate(validator, tckResource("tck/1.2/cl3/0020-vacation-days/0020-vacation-days.dmn"), expectedErrors); } @Test public void testValidateWhenRepositoryIsEmpty() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); assertEquals(expectedErrors, validator.validate(null)); assertEquals(expectedErrors, validator.validate(new DMNModelRepository())); } @@ -57,7 +58,7 @@ public void testValidateWhenIntervals2() { @Test public void testValidateWhenIntervals3() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='loan-grade', name='Loan Grade', id='_FAF682B2-D00A-469A-8B7D-932154DA95E0'): error: Interval '(1500, 1600)' is not covered for column 1 in 'Loan Grade' table" ); validate(validator, resource("dmn/input/1.3/loan-grade-with-intervals-3.dmn"), expectedErrors); @@ -65,7 +66,7 @@ public void testValidateWhenIntervals3() { @Test public void testValidateWhenRelationalOperators() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='loan-grade', name='Loan Grade', id='_FAF682B2-D00A-469A-8B7D-932154DA95E0'): error: Interval '(3000, 4000)' is not covered for column 2 in 'Loan Grade' table" ); validate(validator, resource("dmn/input/1.3/loan-grade-with-relational-operators.dmn"), expectedErrors); @@ -73,7 +74,7 @@ public void testValidateWhenRelationalOperators() { @Test public void testValidateWhenAny() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='loan-grade', name='Loan Grade', id='_FAF682B2-D00A-469A-8B7D-932154DA95E0'): error: Interval '(3000, 4000)' is not covered for column 2 in 'Loan Grade' table" ); validate(validator, resource("dmn/input/1.3/loan-grade-with-any.dmn"), expectedErrors); @@ -81,21 +82,19 @@ public void testValidateWhenAny() { @Test public void testValidateWhenBoolean() { - List expectedErrors = Arrays.asList( - ); + List expectedErrors = Collections.emptyList(); validate(validator, resource("dmn/input/1.3/loan-grade-with-boolean.dmn"), expectedErrors); } @Test public void testValidateWhenEnumeration() { - List expectedErrors = Arrays.asList( - ); + List expectedErrors = Collections.emptyList(); validate(validator, resource("dmn/input/1.3/loan-grade-with-enumeration.dmn"), expectedErrors); } @Test public void testValidateWhenEnumerationMissing() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='loan-grade', name='Loan Grade', id='_FAF682B2-D00A-469A-8B7D-932154DA95E0'): error: Interval '{\"E23\"}' is not covered for column 2 in 'Loan Grade' table" ); validate(validator, resource("dmn/input/1.3/loan-grade-with-enumeration-missing.dmn"), expectedErrors); diff --git a/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingRuleValidatorTest.java b/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingRuleValidatorTest.java index 9ce963211..9b193fd41 100644 --- a/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingRuleValidatorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingRuleValidatorTest.java @@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -26,13 +27,13 @@ public class SweepMissingRuleValidatorTest extends AbstractValidatorTest { @Test public void testValidateWhenCorrect() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); validate(validator, tckResource("tck/1.2/cl3/0020-vacation-days/0020-vacation-days.dmn"), expectedErrors); } @Test public void testValidateWhenRepositoryIsEmpty() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); assertEquals(expectedErrors, validator.validate(null)); assertEquals(expectedErrors, validator.validate(new DMNModelRepository())); } @@ -95,13 +96,13 @@ public void testValidateWhenAny() { @Test public void testValidateWhenBoolean() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); validate(validator, resource("dmn/input/1.3/loan-grade-with-boolean.dmn"), expectedErrors); } @Test public void testValidateWhenEnumeration() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='loan-grade', name='Loan Grade', id='_FAF682B2-D00A-469A-8B7D-932154DA95E0'): error: Found missing rule '[{\"E11\"}, {\"E22\", \"E23\"}, {\"E32\", \"E33\"}]' in 'Loan Grade' table" ); validate(validator, resource("dmn/input/1.3/loan-grade-with-enumeration.dmn"), expectedErrors); diff --git a/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingRuleValidatorWithMergeTest.java b/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingRuleValidatorWithMergeTest.java index 32b731b56..24bf994bf 100644 --- a/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingRuleValidatorWithMergeTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/validation/SweepMissingRuleValidatorWithMergeTest.java @@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -26,13 +27,13 @@ public class SweepMissingRuleValidatorWithMergeTest extends AbstractValidatorTes @Test public void testValidateWhenCorrect() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); validate(validator, tckResource("tck/1.2/cl3/0020-vacation-days/0020-vacation-days.dmn"), expectedErrors); } @Test public void testValidateWhenRepositoryIsEmpty() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); assertEquals(expectedErrors, validator.validate(null)); assertEquals(expectedErrors, validator.validate(new DMNModelRepository())); } @@ -94,13 +95,13 @@ public void testValidateWhenAny() { @Test public void testValidateWhenBoolean() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); validate(validator, resource("dmn/input/1.3/loan-grade-with-boolean.dmn"), expectedErrors); } @Test public void testValidateWhenEnumeration() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='loan-grade', name='Loan Grade', id='_FAF682B2-D00A-469A-8B7D-932154DA95E0'): error: Found missing rule '[{\"E11\"}, {\"E22\", \"E23\"}, {\"E32\", \"E33\"}]' in 'Loan Grade' table" ); validate(validator, resource("dmn/input/1.3/loan-grade-with-enumeration.dmn"), expectedErrors); diff --git a/dmn-core/src/test/java/com/gs/dmn/validation/SweepRuleOverlapValidatorTest.java b/dmn-core/src/test/java/com/gs/dmn/validation/SweepRuleOverlapValidatorTest.java index 4266db4d6..0daeb9792 100644 --- a/dmn-core/src/test/java/com/gs/dmn/validation/SweepRuleOverlapValidatorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/validation/SweepRuleOverlapValidatorTest.java @@ -26,20 +26,20 @@ public class SweepRuleOverlapValidatorTest extends AbstractValidatorTest { @Test public void testValidateWhenCorrect() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); validate(validator, tckResource("tck/1.2/cl3/0020-vacation-days/0020-vacation-days.dmn"), expectedErrors); } @Test public void testValidateWhenRepositoryIsEmpty() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); assertEquals(expectedErrors, validator.validate(null)); assertEquals(expectedErrors, validator.validate(new DMNModelRepository())); } @Test public void testValidateWhenIntervals1() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='loan-grade', name='Loan Grade', id='_FAF682B2-D00A-469A-8B7D-932154DA95E0'): error: Decision table rules '[1, 3]' overlap in decision 'Loan Grade'" ); validate(validator, resource("dmn/input/1.3/loan-grade-with-intervals-1.dmn"), expectedErrors); @@ -47,7 +47,7 @@ public void testValidateWhenIntervals1() { @Test public void testValidateWhenIntervals2() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='loan-grade', name='Loan Grade', id='_FAF682B2-D00A-469A-8B7D-932154DA95E0'): error: Decision table rules '[1, 3]' overlap in decision 'Loan Grade'" ); validate(validator, resource("dmn/input/1.3/loan-grade-with-intervals-2.dmn"), expectedErrors); @@ -73,7 +73,7 @@ public void testValidateWhenRelationalOperators() { @Test public void testValidateWhenAny() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='loan-grade', name='Loan Grade', id='_FAF682B2-D00A-469A-8B7D-932154DA95E0'): error: Decision table rules '[1, 3, 4]' overlap in decision 'Loan Grade'" ); validate(validator, resource("dmn/input/1.3/loan-grade-with-any.dmn"), expectedErrors); @@ -100,8 +100,7 @@ public void testValidateWhenEnumeration() { @Test public void testValidateWhenEnumerationMissing() { - List expectedErrors = Arrays.asList( - ); + List expectedErrors = Collections.emptyList(); validate(validator, resource("dmn/input/1.3/loan-grade-with-enumeration-missing.dmn"), expectedErrors); } @@ -115,7 +114,7 @@ public void testMaxCliquesBronKerbosch() { neighbor.put(3, new HashSet<>(Arrays.asList(2, 4))); neighbor.put(4, new HashSet<>(Arrays.asList(3, 5, 6))); neighbor.put(5, new HashSet<>(Arrays.asList(1, 2, 4))); - neighbor.put(6, new HashSet<>(Arrays.asList(4))); + neighbor.put(6, new HashSet<>(Collections.singletonList(4))); List maxCliques = new ArrayList<>(); this.validator.maxCliquesBronKerbosch(new RuleGroup(), nodes, new RuleGroup(), neighbor, maxCliques); diff --git a/dmn-core/src/test/java/com/gs/dmn/validation/TypeRefValidatorTest.java b/dmn-core/src/test/java/com/gs/dmn/validation/TypeRefValidatorTest.java index bfc167908..c47547a9c 100644 --- a/dmn-core/src/test/java/com/gs/dmn/validation/TypeRefValidatorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/validation/TypeRefValidatorTest.java @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -25,13 +25,13 @@ public class TypeRefValidatorTest extends AbstractValidatorTest { @Test public void testValidateWhenCorrect() { - List expectedErrors = Arrays.asList(); + List expectedErrors = Collections.emptyList(); validate(validator, tckResource("tck/1.2/cl3/0020-vacation-days/0020-vacation-days.dmn"), expectedErrors); } @Test public void validate() { - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(model='test-dmn', label='Applicant', name='applicant', id='id-d2376567fde3c9400ee327ecec21e36d'): error: Cannot find typeRef 'QualifiedName(null, applicant)'" ); validate(validator, resource("dmn/input/1.1/test-dmn-with-missing-type-ref.dmn"), expectedErrors); diff --git a/dmn-core/src/test/java/com/gs/dmn/validation/table/RuleGroupTest.java b/dmn-core/src/test/java/com/gs/dmn/validation/table/RuleGroupTest.java index 9f676b0fa..d3728765d 100644 --- a/dmn-core/src/test/java/com/gs/dmn/validation/table/RuleGroupTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/validation/table/RuleGroupTest.java @@ -15,6 +15,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.*; @@ -53,17 +54,17 @@ public void testMinusNode() { assertEquals(new RuleGroup(Arrays.asList(1, 2)), new RuleGroup(Arrays.asList(1, 2, 3)).minus(3)); assertEquals(new RuleGroup(Arrays.asList(1, 2, 3)), new RuleGroup(Arrays.asList(1, 2, 3)).minus(4)); - assertEquals(new RuleGroup(), new RuleGroup(Arrays.asList()).minus(3)); - assertEquals(new RuleGroup(), new RuleGroup(Arrays.asList()).minus(4)); + assertEquals(new RuleGroup(), new RuleGroup(Collections.emptyList()).minus(3)); + assertEquals(new RuleGroup(), new RuleGroup(Collections.emptyList()).minus(4)); } @Test public void testMinusList() { - assertEquals(new RuleGroup(Arrays.asList(1, 2)), new RuleGroup(Arrays.asList(1, 2, 3)).minus(Arrays.asList(3))); - assertEquals(new RuleGroup(Arrays.asList(1, 2, 3)), new RuleGroup(Arrays.asList(1, 2, 3)).minus(Arrays.asList(4))); + assertEquals(new RuleGroup(Arrays.asList(1, 2)), new RuleGroup(Arrays.asList(1, 2, 3)).minus(Collections.singletonList(3))); + assertEquals(new RuleGroup(Arrays.asList(1, 2, 3)), new RuleGroup(Arrays.asList(1, 2, 3)).minus(Collections.singletonList(4))); - assertEquals(new RuleGroup(), new RuleGroup(Arrays.asList()).minus(Arrays.asList(3))); - assertEquals(new RuleGroup(), new RuleGroup(Arrays.asList()).minus(Arrays.asList(4))); + assertEquals(new RuleGroup(), new RuleGroup(Collections.emptyList()).minus(Collections.singletonList(3))); + assertEquals(new RuleGroup(), new RuleGroup(Collections.emptyList()).minus(Collections.singletonList(4))); } @Test @@ -71,16 +72,16 @@ public void union() { assertEquals(new RuleGroup(Arrays.asList(1, 2, 3)), new RuleGroup(Arrays.asList(1, 2, 3)).union(3)); assertEquals(new RuleGroup(Arrays.asList(1, 2, 3, 4)), new RuleGroup(Arrays.asList(1, 2, 3)).union(4)); - assertEquals(new RuleGroup(Arrays.asList(3)), new RuleGroup(Arrays.asList()).union(3)); - assertEquals(new RuleGroup(Arrays.asList(4)), new RuleGroup(Arrays.asList()).union(4)); + assertEquals(new RuleGroup(Collections.singletonList(3)), new RuleGroup(Collections.emptyList()).union(3)); + assertEquals(new RuleGroup(Collections.singletonList(4)), new RuleGroup(Collections.emptyList()).union(4)); } @Test public void intersect() { - assertEquals(new RuleGroup(Arrays.asList(3)), new RuleGroup(Arrays.asList(1, 2, 3)).intersect(Arrays.asList(3))); - assertEquals(new RuleGroup(), new RuleGroup(Arrays.asList(1, 2, 3)).intersect(Arrays.asList(4))); + assertEquals(new RuleGroup(Collections.singletonList(3)), new RuleGroup(Arrays.asList(1, 2, 3)).intersect(Collections.singletonList(3))); + assertEquals(new RuleGroup(), new RuleGroup(Arrays.asList(1, 2, 3)).intersect(Collections.singletonList(4))); - assertEquals(new RuleGroup(), new RuleGroup(Arrays.asList()).intersect(Arrays.asList(3))); - assertEquals(new RuleGroup(), new RuleGroup(Arrays.asList()).intersect(Arrays.asList(4))); + assertEquals(new RuleGroup(), new RuleGroup(Collections.emptyList()).intersect(Collections.singletonList(3))); + assertEquals(new RuleGroup(), new RuleGroup(Collections.emptyList()).intersect(Collections.singletonList(4))); } } \ No newline at end of file diff --git a/dmn-core/src/test/java/com/gs/dmn/validation/table/TableFactoryTest.java b/dmn-core/src/test/java/com/gs/dmn/validation/table/TableFactoryTest.java index 28a8d01c1..0bf6fc039 100644 --- a/dmn-core/src/test/java/com/gs/dmn/validation/table/TableFactoryTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/validation/table/TableFactoryTest.java @@ -25,6 +25,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -111,7 +112,7 @@ public void testMakeTableWhenRelationalOperators() { List expectedMinList = Arrays.asList( "[-Infinity", "[0" ); - List expectedMaxList = Arrays.asList( + List expectedMaxList = Collections.singletonList( "+Infinity], 5000]" ); checkTable(resource("dmn/input/1.3/loan-grade-with-relational-operators.dmn"), expectedInputs, expectedRules, expectedMinList, expectedMaxList); diff --git a/dmn-jpa-it/src/main/java/com/gs/jpa/example_credit_decision/ApplicantJPA.java b/dmn-jpa-it/src/main/java/com/gs/jpa/example_credit_decision/ApplicantJPA.java index f9592f64c..19aa61207 100644 --- a/dmn-jpa-it/src/main/java/com/gs/jpa/example_credit_decision/ApplicantJPA.java +++ b/dmn-jpa-it/src/main/java/com/gs/jpa/example_credit_decision/ApplicantJPA.java @@ -16,7 +16,7 @@ import javax.persistence.*; import java.math.BigDecimal; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -70,7 +70,7 @@ public BigDecimal getCreditScore() { @Override public List getPriorIssues() { if (creditIssueTypes == null) { - return Arrays.asList(); + return Collections.emptyList(); } return creditIssueTypes.stream().map(CreditIssueTypeJPA::getName).collect(Collectors.toList()); } diff --git a/dmn-jpa-it/src/main/java/com/gs/jpa/lazy_input_model/LazyPerson.java b/dmn-jpa-it/src/main/java/com/gs/jpa/lazy_input_model/LazyPerson.java index f05faf13c..09f87bc23 100644 --- a/dmn-jpa-it/src/main/java/com/gs/jpa/lazy_input_model/LazyPerson.java +++ b/dmn-jpa-it/src/main/java/com/gs/jpa/lazy_input_model/LazyPerson.java @@ -16,11 +16,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.persistence.*; +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; import java.math.BigDecimal; public class LazyPerson implements Person { - private static Logger LOGGER = LoggerFactory.getLogger(LazyPerson.class); + private static final Logger LOGGER = LoggerFactory.getLogger(LazyPerson.class); private final EntityManager em; private final int id; diff --git a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/BaseStandardFEELLib.java b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/BaseStandardFEELLib.java index eb8b50934..3e8873a0b 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/BaseStandardFEELLib.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/BaseStandardFEELLib.java @@ -1084,13 +1084,13 @@ public T min(List list) { } else if (first instanceof String) { return (T) this.stringLib.min(list); } else if (isDate(first)) { - return (T) this.dateTimeLib.min(list); + return this.dateTimeLib.min(list); } else if (isTime(first)) { - return (T) this.dateTimeLib.min(list); + return this.dateTimeLib.min(list); } else if (isDateTime(first)) { - return (T) this.dateTimeLib.min(list); + return this.dateTimeLib.min(list); } else if (isDuration(first)) { - return (T) this.dateTimeLib.min(list); + return this.dateTimeLib.min(list); } else { throw new DMNRuntimeException(String.format("Not supported yet for '%s'", first)); } @@ -1129,13 +1129,13 @@ public T max(List list) { } else if (first instanceof String) { return (T) this.stringLib.max(list); } else if (isDate(first)) { - return (T) this.dateTimeLib.max(list); + return this.dateTimeLib.max(list); } else if (isTime(first)) { - return (T) this.dateTimeLib.max(list); + return this.dateTimeLib.max(list); } else if (isDateTime(first)) { - return (T) this.dateTimeLib.max(list); + return this.dateTimeLib.max(list); } else if (isDuration(first)) { - return (T) this.dateTimeLib.max(list); + return this.dateTimeLib.max(list); } else { throw new DMNRuntimeException(String.format("Not supported yet for '%s'", first)); } diff --git a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/context/DefaultContextType.java b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/context/DefaultContextType.java index 4b8c47885..00eb31344 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/context/DefaultContextType.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/context/DefaultContextType.java @@ -118,10 +118,7 @@ private boolean validEntry(Object entry) { return false; } Object key = ((Context) entry).get("key"); - if (!(key instanceof String)) { - return false; - } - return true; + return key instanceof String; } @Override diff --git a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/list/DefaultListLib.java b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/list/DefaultListLib.java index 335d76512..614f417a3 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/list/DefaultListLib.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/list/DefaultListLib.java @@ -15,6 +15,7 @@ import com.gs.dmn.runtime.LambdaExpression; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -26,9 +27,7 @@ public List append(List list, T... items) { result.addAll(list); } if (items != null) { - for (T item : items) { - result.add(item); - } + Collections.addAll(result, items); } else { result.add(null); } diff --git a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/time/xml/FEELXMLGregorianCalendar.java b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/time/xml/FEELXMLGregorianCalendar.java index cda6dbc11..e5e8dae85 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/time/xml/FEELXMLGregorianCalendar.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/time/xml/FEELXMLGregorianCalendar.java @@ -21,6 +21,7 @@ import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; +import java.math.RoundingMode; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -852,7 +853,7 @@ public void add(Duration duration) { BigInteger temp = BigInteger.valueOf(startMonth).add(dMonths); setMonth(temp.subtract(BigInteger.ONE).mod(TWELVE).intValue() + 1); BigInteger carry = - new BigDecimal(temp.subtract(BigInteger.ONE)).divide(new BigDecimal(TWELVE), BigDecimal.ROUND_FLOOR).toBigInteger(); + new BigDecimal(temp.subtract(BigInteger.ONE)).divide(new BigDecimal(TWELVE), RoundingMode.FLOOR).toBigInteger(); // Years (may be modified additionally below) @@ -885,7 +886,7 @@ public void add(Duration duration) { // Duration seconds is SECONDS + FRACTIONALSECONDS. BigDecimal dSeconds = sanitize((BigDecimal) duration.getField(DatatypeConstants.SECONDS), signum); BigDecimal tempBD = startSeconds.add(dSeconds); - BigDecimal fQuotient = new BigDecimal(new BigDecimal(tempBD.toBigInteger()).divide(DECIMAL_SIXTY, BigDecimal.ROUND_FLOOR).toBigInteger()); + BigDecimal fQuotient = new BigDecimal(new BigDecimal(tempBD.toBigInteger()).divide(DECIMAL_SIXTY, RoundingMode.FLOOR).toBigInteger()); BigDecimal endSeconds = tempBD.subtract(fQuotient.multiply(DECIMAL_SIXTY)); carry = fQuotient.toBigInteger(); @@ -916,7 +917,7 @@ public void add(Duration duration) { temp = BigInteger.valueOf(startMinutes).add(dMinutes).add(carry); setMinute(temp.mod(SIXTY).intValue()); - carry = new BigDecimal(temp).divide(DECIMAL_SIXTY, BigDecimal.ROUND_FLOOR).toBigInteger(); + carry = new BigDecimal(temp).divide(DECIMAL_SIXTY, RoundingMode.FLOOR).toBigInteger(); // Hours // temp := S[hour] + D[hour] + carry @@ -931,7 +932,7 @@ public void add(Duration duration) { temp = BigInteger.valueOf(startHours).add(dHours).add(carry); setHour(temp.mod(TWENTY_FOUR).intValue(), false); - carry = new BigDecimal(temp).divide(new BigDecimal(TWENTY_FOUR), BigDecimal.ROUND_FLOOR).toBigInteger(); + carry = new BigDecimal(temp).divide(new BigDecimal(TWENTY_FOUR), RoundingMode.FLOOR).toBigInteger(); // Days // if S[day] > maximumDayInMonthFor(E[year], E[month]) @@ -997,7 +998,7 @@ public void add(Duration duration) { int quotient; if (endMonth < 0) { endMonth = (13 - 1) + endMonth + 1; - quotient = new BigDecimal(intTemp - 1).divide(new BigDecimal(TWELVE), BigDecimal.ROUND_UP).intValue(); + quotient = new BigDecimal(intTemp - 1).divide(new BigDecimal(TWELVE), RoundingMode.UP).intValue(); } else { quotient = (intTemp - 1) / (13 - 1); endMonth += 1; diff --git a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/time/xml/XMLCalendarType.java b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/time/xml/XMLCalendarType.java index 9f3215eb0..9640a7ae3 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/time/xml/XMLCalendarType.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/time/xml/XMLCalendarType.java @@ -84,12 +84,12 @@ public boolean isDateTime(Object value) { public boolean isYearsAndMonthsDuration(Object value) { return value instanceof Duration - && isYearMonthDuration((Duration) value); + && isYearMonthDuration(value); } public boolean isDaysAndTimeDuration(Object value) { return value instanceof Duration - && isDayTimeDuration((Duration) value); + && isDayTimeDuration(value); } public Long dateValue(XMLGregorianCalendar date) { diff --git a/dmn-runtime/src/main/java/com/gs/dmn/runtime/Range.java b/dmn-runtime/src/main/java/com/gs/dmn/runtime/Range.java index 1317f4558..c7012239e 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/runtime/Range.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/runtime/Range.java @@ -12,6 +12,8 @@ */ package com.gs.dmn.runtime; +import java.util.Objects; + public class Range { private final boolean startIncluded; private final Object start; @@ -54,8 +56,8 @@ public boolean equals(Object o) { if (this.startIncluded != range.startIncluded) return false; if (this.endIncluded != range.endIncluded) return false; - if (this.start != null ? !this.start.equals(range.start) : range.start != null) return false; - return this.end != null ? this.end.equals(range.end) : range.end == null; + if (!Objects.equals(this.start, range.start)) return false; + return Objects.equals(this.end, range.end); } @Override diff --git a/dmn-runtime/src/main/java/com/gs/dmn/runtime/annotation/Annotation.java b/dmn-runtime/src/main/java/com/gs/dmn/runtime/annotation/Annotation.java index afef6d7e9..e0e7c12f0 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/runtime/annotation/Annotation.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/runtime/annotation/Annotation.java @@ -12,6 +12,8 @@ */ package com.gs.dmn.runtime.annotation; +import java.util.Objects; + public class Annotation { private final String decisionName; // Index starts from 1 @@ -44,8 +46,8 @@ public boolean equals(Object o) { Annotation that = (Annotation) o; if (ruleIndex != that.ruleIndex) return false; - if (decisionName != null ? !decisionName.equals(that.decisionName) : that.decisionName != null) return false; - return annotation != null ? annotation.equals(that.annotation) : that.annotation == null; + if (!Objects.equals(decisionName, that.decisionName)) return false; + return Objects.equals(annotation, that.annotation); } @Override diff --git a/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/CompositeListener.java b/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/CompositeListener.java index 3e6b76393..b64445d93 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/CompositeListener.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/CompositeListener.java @@ -13,6 +13,7 @@ package com.gs.dmn.runtime.listener; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class CompositeListener implements EventListener { @@ -20,9 +21,7 @@ public class CompositeListener implements EventListener { public CompositeListener(EventListener... eventListeners) { if (eventListeners != null) { - for (EventListener eventListener : eventListeners) { - this.eventListeners.add(eventListener); - } + Collections.addAll(this.eventListeners, eventListeners); } } diff --git a/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/node/DRGElementNode.java b/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/node/DRGElementNode.java index 8ba2064be..e3d6b01ca 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/node/DRGElementNode.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/node/DRGElementNode.java @@ -22,8 +22,8 @@ public class DRGElementNode { private final DRGElement element; private final Arguments arguments; private Object output; - private List ruleNodes = new ArrayList<>(); - private List children = new ArrayList<>(); + private final List ruleNodes = new ArrayList<>(); + private final List children = new ArrayList<>(); public DRGElementNode(DRGElement element, Arguments arguments) { this.element = element; diff --git a/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/node/RuleNode.java b/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/node/RuleNode.java index dfd545681..088cdb935 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/node/RuleNode.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/node/RuleNode.java @@ -21,7 +21,7 @@ public class RuleNode { private final Rule rule; private boolean matched; private Object result; - private List columnNodes = new ArrayList<>(); + private final List columnNodes = new ArrayList<>(); public RuleNode(Rule rule) { this.rule = rule; diff --git a/dmn-runtime/src/main/java/com/gs/dmn/signavio/feel/lib/type/time/xml/DefaultSignavioDateTimeLib.java b/dmn-runtime/src/main/java/com/gs/dmn/signavio/feel/lib/type/time/xml/DefaultSignavioDateTimeLib.java index 32b8d9873..e4ca3cdbb 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/signavio/feel/lib/type/time/xml/DefaultSignavioDateTimeLib.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/signavio/feel/lib/type/time/xml/DefaultSignavioDateTimeLib.java @@ -49,27 +49,27 @@ public XMLGregorianCalendar dateAndTime(String literal) { @Override public Integer year(Object date) { - return DEFAULT_DATE_TIME_LIB.year((XMLGregorianCalendar) date); + return DEFAULT_DATE_TIME_LIB.year(date); } @Override public Integer month(Object date) { - return DEFAULT_DATE_TIME_LIB.month((XMLGregorianCalendar) date); + return DEFAULT_DATE_TIME_LIB.month(date); } @Override public Integer day(Object date) { - return DEFAULT_DATE_TIME_LIB.day((XMLGregorianCalendar) date); + return DEFAULT_DATE_TIME_LIB.day(date); } @Override public Integer hour(Object date) { - return DEFAULT_DATE_TIME_LIB.hour((XMLGregorianCalendar) date); + return DEFAULT_DATE_TIME_LIB.hour(date); } @Override public Integer minute(Object date) { - return DEFAULT_DATE_TIME_LIB.minute((XMLGregorianCalendar) date); + return DEFAULT_DATE_TIME_LIB.minute(date); } @Override diff --git a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseFEELLibTest.java b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseFEELLibTest.java index c0cbcec39..16add61b7 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseFEELLibTest.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseFEELLibTest.java @@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.*; @@ -80,7 +81,7 @@ public void testTime() { // // conversion from string // - assertNull(getLib().time((String) null)); + assertNull(getLib().time(null)); assertNull(getLib().time("")); assertNull(getLib().time("xxx")); assertNull(getLib().time("13:20:00+01:00@Europe/Paris")); @@ -160,17 +161,17 @@ public void testDuration() { @Test public void testAsList() { assertEqualsList("[null]", getLib().asList(null)); - assertEquals(Arrays.asList(), getLib().asList()); + assertEquals(Collections.emptyList(), getLib().asList()); assertEquals(Arrays.asList(null, "a"), getLib().asList(null, "a")); } @Test public void testAsElement() { assertNull(getLib().asElement(null)); - assertNull(getLib().asElement(Arrays.asList())); + assertNull(getLib().asElement(Collections.emptyList())); assertNull(getLib().asElement(Arrays.asList("1", "2"))); - assertEquals("1", getLib().asElement(Arrays.asList("1"))); + assertEquals("1", getLib().asElement(Collections.singletonList("1"))); } // @@ -179,10 +180,10 @@ public void testAsElement() { @Test public void testToNull() { assertNull(getLib().toNull(null)); - assertNull(getLib().toNull(Arrays.asList())); + assertNull(getLib().toNull(Collections.emptyList())); assertNull(getLib().toNull(Arrays.asList("1", "2"))); - assertNull(getLib().toNull(Arrays.asList("1"))); + assertNull(getLib().toNull(Collections.singletonList("1"))); } // @@ -202,9 +203,9 @@ public void testRangeToList() { @Test public void testRangeToListNoFlags() { - assertEquals(Arrays.asList(), getLib().rangeToList(null, null)); - assertEquals(Arrays.asList(), getLib().rangeToList(makeNumber("0"), null)); - assertEquals(Arrays.asList(), getLib().rangeToList(null, makeNumber("1"))); + assertEquals(Collections.emptyList(), getLib().rangeToList(null, null)); + assertEquals(Collections.emptyList(), getLib().rangeToList(makeNumber("0"), null)); + assertEquals(Collections.emptyList(), getLib().rangeToList(null, makeNumber("1"))); assertEquals(makeNumberList(1, 2, 3), getLib().rangeToList(makeNumber("1"), makeNumber("3"))); assertEquals(makeNumberList(3, 2, 1), getLib().rangeToList(makeNumber("3"), makeNumber("1"))); @@ -246,7 +247,7 @@ public void testToDateTime() { @Test public void testAnd() { assertNull(getLib().and((List) null)); - assertTrue(getLib().and(Arrays.asList())); + assertTrue(getLib().and(Collections.emptyList())); assertNull(getLib().and(Arrays.asList(null, null))); assertFalse(getLib().and(Arrays.asList(null, false))); assertNull(getLib().and(Arrays.asList(null, true))); @@ -265,7 +266,7 @@ public void testAnd() { @Test public void testOr() { assertNull(getLib().or((List) null)); - assertFalse(getLib().or(Arrays.asList())); + assertFalse(getLib().or(Collections.emptyList())); assertNull(getLib().or(Arrays.asList(null, null))); assertNull(getLib().or(Arrays.asList(null, false))); assertTrue(getLib().or(Arrays.asList(null, true))); @@ -314,7 +315,7 @@ public void testListContains() { public void testFlattenFirstLevel() { assertNull(getLib().flattenFirstLevel(null)); - assertEqualsList("[]", getLib().flattenFirstLevel(Arrays.asList())); + assertEqualsList("[]", getLib().flattenFirstLevel(Collections.emptyList())); assertEqualsList("[l11, l12, l13]", getLib().flattenFirstLevel(Arrays.asList("l11", "l12", "l13"))); assertEqualsList("[l11, l21, l22, l13]", getLib().flattenFirstLevel(Arrays.asList("l11", Arrays.asList("l21", "l22"), "l13"))); assertEqualsList("[l11, l21, [l31, l32], l13]", getLib().flattenFirstLevel(Arrays.asList("l11", Arrays.asList("l21", Arrays.asList("l31", "l32")), "l13"))); @@ -377,8 +378,8 @@ public void testSum() { public void testGetEntries() { assertNull(getLib().getEntries(null)); - assertEquals(Arrays.asList(), getLib().getEntries(new Context())); - assertEquals(Arrays.asList(new Context().add("key", "a").add("value", makeNumber("1"))), getLib().getEntries(new Context().add("a", makeNumber("1")))); + assertEquals(Collections.emptyList(), getLib().getEntries(new Context())); + assertEquals(Collections.singletonList(new Context().add("key", "a").add("value", makeNumber("1"))), getLib().getEntries(new Context().add("a", makeNumber("1")))); } @Test @@ -433,11 +434,11 @@ public void testContextMerge() { assertEquals( makeContext(), - getLib().contextMerge(Arrays.asList()) + getLib().contextMerge(Collections.emptyList()) ); assertEquals( makeContext(), - getLib().contextMerge(Arrays.asList(makeContext())) + getLib().contextMerge(Collections.singletonList(makeContext())) ); // context merge([{x:1}, {y:2}]) = {x:1, y:2} assertEquals( diff --git a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibExceptionsTest.java b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibExceptionsTest.java index 72557874a..b259c73ef 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibExceptionsTest.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibExceptionsTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,14 +34,14 @@ public void testString() { @Test public void testDate() { - assertNull(getLib().date((String) null)); + assertNull(getLib().date(null)); assertNull(getLib().date((DATE) null)); assertNull(getLib().date(null, null, null)); } @Test public void testTime() { - assertNull(getLib().time((String) null)); + assertNull(getLib().time(null)); assertNull(getLib().time((TIME) null)); assertNull(getLib().time(null, null, null, null)); } @@ -380,7 +380,7 @@ public void testReverse() { @Test public void testIndexOf() { - assertEquals(Arrays.asList(), getLib().indexOf(null, null)); + assertEquals(Collections.emptyList(), getLib().indexOf(null, null)); } @Test diff --git a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibTest.java b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibTest.java index 328e23bd9..781191090 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibTest.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibTest.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.*; @@ -833,9 +834,9 @@ public void testDateAndTimeFunctions() { assertFalse(getLib().is(makeDuration("P1Y"), makeDuration("-P1Y"))); assertTrue(getLib().is(makeDuration("P1Y"), makeDuration("P12M"))); - assertTrue(getLib().is(Arrays.asList(), Arrays.asList())); + assertTrue(getLib().is(Collections.emptyList(), Collections.emptyList())); assertTrue(getLib().is(Arrays.asList(makeNumber(1), makeNumber(3)), Arrays.asList(makeNumber(1), makeNumber(3)))); - assertFalse(getLib().is(Arrays.asList(makeNumber(1), makeNumber(3)), Arrays.asList())); + assertFalse(getLib().is(Arrays.asList(makeNumber(1), makeNumber(3)), Collections.emptyList())); assertTrue(getLib().is(new Range(true, makeNumber(1), true, makeNumber(3)), new Range(true, makeNumber(1), true, makeNumber(3)))); assertFalse(getLib().is(new Range(true, makeNumber(1), true, makeNumber(3)), new Range(true, makeNumber(2), true, makeNumber(3)))); @@ -873,7 +874,7 @@ public void testTemporalFunctions() { @Test public void testAppend() { assertEqualsList("[null]", getLib().append(null, null)); - assertEquals(Arrays.asList("3"), getLib().append(null, "3")); + assertEquals(Collections.singletonList("3"), getLib().append(null, "3")); assertEquals(makeNumberList("1", null, "3", null, "3"), getLib().append(makeNumberList(1, null, 3), null, makeNumber(3))); assertEquals(makeNumberList("1", "2", "3", "4"), getLib().append(makeNumberList(1, 2, 3), makeNumber(4))); @@ -908,7 +909,6 @@ public void testSum() { public void testMean() { assertNull(getLib().mean()); assertNull(getLib().mean((Object) null)); - assertNull(getLib().mean(new Object[] {})); assertNull(getLib().mean((List) null)); assertNull(getLib().mean(makeNumberList())); @@ -927,8 +927,7 @@ public void testAll() { assertFalse(getLib().all(Arrays.asList(null, false))); assertTrue(getLib().all()); - assertTrue(getLib().all(new Object[] {})); - assertTrue(getLib().all(Arrays.asList())); + assertTrue(getLib().all(Collections.emptyList())); assertTrue(getLib().all(true, true)); assertTrue(getLib().all(Arrays.asList(true, true))); @@ -950,8 +949,7 @@ public void testAny() { assertTrue(getLib().any(Arrays.asList(null, true))); assertFalse(getLib().any()); - assertFalse(getLib().any(new Object[] {})); - assertFalse(getLib().any(Arrays.asList())); + assertFalse(getLib().any(Collections.emptyList())); assertFalse(getLib().any(false, false, false)); assertFalse(getLib().any(Arrays.asList(false, false, false))); @@ -1000,14 +998,14 @@ public void testRemove() { @Test public void testReverse() { - assertEquals(Arrays.asList(), getLib().reverse(null)); + assertEquals(Collections.emptyList(), getLib().reverse(null)); assertEquals(makeNumberList("3", "2", "1"), getLib().reverse(makeNumberList(1, 2, 3))); } @Test public void testIndexOf() { - assertEquals(Arrays.asList(), getLib().indexOf(null, null)); + assertEquals(Collections.emptyList(), getLib().indexOf(null, null)); assertEquals(makeNumberList("2", "4"), getLib().indexOf(Arrays.asList("1", "2", "3", "2"), "2")); } @@ -1021,7 +1019,7 @@ public void testUnion() { @Test public void testDistinctValues() { - assertEquals(Arrays.asList(), getLib().distinctValues(null)); + assertEquals(Collections.emptyList(), getLib().distinctValues(null)); assertEquals(makeNumberList("1", "2", "3"), getLib().distinctValues(makeNumberList(1, 2, 3, 2, 3))); assertEquals(makeNumberList("1", "2", "3"), getLib().distinctValues(makeNumberList(1, 2, 3, 2, 1))); @@ -1032,8 +1030,8 @@ public void testFlatten() { assertNull(getLib().flatten(null)); assertEqualsList("[1, 2, 3, 4]", getLib().flatten(Arrays.asList( - Arrays.asList(Arrays.asList("1", "2")), - Arrays.asList(Arrays.asList("3")), + Collections.singletonList(Arrays.asList("1", "2")), + Collections.singletonList(Collections.singletonList("3")), "4" ))); } @@ -1042,7 +1040,6 @@ public void testFlatten() { public void testProduct() { assertNull(getLib().product()); assertNull(getLib().product((Object) null)); - assertNull(getLib().product(new Object[] {})); assertNull(getLib().product((List) null)); assertNull(getLib().product((makeNumberList()))); @@ -1060,7 +1057,6 @@ public void testProduct() { public void testMedian() { assertNull(getLib().median()); assertNull(getLib().median((Object) null)); - assertNull(getLib().median(new Object[] {})); assertNull(getLib().median((List) null)); assertNull(getLib().median(makeNumberList())); @@ -1077,7 +1073,6 @@ public void testMedian() { public void testStddev() { assertNull(getLib().stddev()); assertNull(getLib().stddev((Object) null)); - assertNull(getLib().stddev(new Object[] {})); assertNull(getLib().stddev((List) null)); assertNull(getLib().stddev(makeNumberList())); @@ -1094,7 +1089,6 @@ public void testMode() { assertNull(getLib().mode((Object)null)); assertEquals(makeNumberList(), getLib().mode()); - assertEquals(makeNumberList(), getLib().mode(new Object[] {})); assertEquals(makeNumberList(), getLib().mode(makeNumberList())); assertNull(getLib().mode(makeNumber(1), null)); @@ -1109,7 +1103,7 @@ public void testMode() { @Test public void testCollect() { getLib().collect(null, null); - getLib().collect(Arrays.asList(), null); + getLib().collect(Collections.emptyList(), null); List result = new ArrayList<>(); getLib().collect(result, Arrays.asList(Arrays.asList("1", "2"), "3")); @@ -1129,7 +1123,7 @@ public Boolean apply(Object... args) { assertNull(getLib().sort(null, null)); assertNull(getLib().sort(null, comparator)); - assertEquals(Arrays.asList(), getLib().sort(Arrays.asList(), null)); + assertEquals(Collections.emptyList(), getLib().sort(Collections.emptyList(), null)); assertEquals(Arrays.asList("1", "2", "3"), getLib().sort(Arrays.asList("3", "1", "2"), comparator)); } diff --git a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/FEELOperatorsTest.java b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/FEELOperatorsTest.java index 68a680d2b..ce61bf26d 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/FEELOperatorsTest.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/FEELOperatorsTest.java @@ -24,6 +24,7 @@ import java.time.temporal.TemporalAccessor; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.*; @@ -279,7 +280,7 @@ public void testBooleanOr() { assertNull(getLib().booleanOr(true)); assertTrue(getLib().booleanOr(false, false, true)); assertTrue(getLib().booleanOr(Arrays.asList(false, false, true))); - assertNull(getLib().booleanOr(Arrays.asList(Arrays.asList(false, false, true)))); + assertNull(getLib().booleanOr(Collections.singletonList(Arrays.asList(false, false, true)))); } @Test @@ -324,7 +325,7 @@ public void testBooleanAnd() { assertNull(getLib().booleanAnd(true)); assertFalse(getLib().booleanAnd(true, true, false)); assertFalse(getLib().booleanAnd(Arrays.asList(false, false, true))); - assertNull(getLib().booleanAnd(Arrays.asList(Arrays.asList(false, false, true)))); + assertNull(getLib().booleanAnd(Collections.singletonList(Arrays.asList(false, false, true)))); } @Test @@ -1167,31 +1168,31 @@ public void testIsList() { @Test public void testListIs() { assertTrue(getLib().listIs(null, null)); - assertFalse(getLib().listIs(Arrays.asList("a"), null)); - assertFalse(getLib().listIs(null, Arrays.asList("a"))); + assertFalse(getLib().listIs(Collections.singletonList("a"), null)); + assertFalse(getLib().listIs(null, Collections.singletonList("a"))); - assertFalse(getLib().listIs(Arrays.asList("a"), Arrays.asList("b"))); - assertTrue(getLib().listIs(Arrays.asList("a"), Arrays.asList("a"))); + assertFalse(getLib().listIs(Collections.singletonList("a"), Collections.singletonList("b"))); + assertTrue(getLib().listIs(Collections.singletonList("a"), Collections.singletonList("a"))); } @Test public void testListEqual() { assertTrue(getLib().listEqual(null, null)); - assertFalse(getLib().listEqual(Arrays.asList("a"), null)); - assertFalse(getLib().listEqual(null, Arrays.asList("a"))); + assertFalse(getLib().listEqual(Collections.singletonList("a"), null)); + assertFalse(getLib().listEqual(null, Collections.singletonList("a"))); - assertFalse(getLib().listEqual(Arrays.asList("a"), Arrays.asList("b"))); - assertTrue(getLib().listEqual(Arrays.asList("a"), Arrays.asList("a"))); + assertFalse(getLib().listEqual(Collections.singletonList("a"), Collections.singletonList("b"))); + assertTrue(getLib().listEqual(Collections.singletonList("a"), Collections.singletonList("a"))); } @Test public void testListNotEqual() { assertFalse(getLib().listNotEqual(null, null)); - assertTrue(getLib().listNotEqual(Arrays.asList("a"), null)); - assertTrue(getLib().listNotEqual(null, Arrays.asList("a"))); + assertTrue(getLib().listNotEqual(Collections.singletonList("a"), null)); + assertTrue(getLib().listNotEqual(null, Collections.singletonList("a"))); - assertTrue(getLib().listNotEqual(Arrays.asList("a"), Arrays.asList("b"))); - assertFalse(getLib().listNotEqual(Arrays.asList("a"), Arrays.asList("a"))); + assertTrue(getLib().listNotEqual(Collections.singletonList("a"), Collections.singletonList("b"))); + assertFalse(getLib().listNotEqual(Collections.singletonList("a"), Collections.singletonList("a"))); } // @@ -1419,9 +1420,7 @@ protected List makeNumberList(Object... numbers) { protected List makeStringList(String... strings) { List result = new ArrayList<>(); - for (String str: strings) { - result.add(str); - } + Collections.addAll(result, strings); return result; } diff --git a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/type/range/AbstractDefaultRangeLibTest.java b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/type/range/AbstractDefaultRangeLibTest.java index 87cfd76de..bb0d10388 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/type/range/AbstractDefaultRangeLibTest.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/type/range/AbstractDefaultRangeLibTest.java @@ -24,229 +24,229 @@ public abstract class AbstractDefaultRangeLibTest attributes = Arrays.asList("k1", "k2"); assertEquals(Arrays.asList( new Context().add("k1", null).add("k2", "2"), new Context().add("k1", null).add("k2", "4") ), - getLib().zip(attributes, Arrays.asList(Arrays.asList(), Arrays.asList("2", "4")))); + getLib().zip(attributes, Arrays.asList(Collections.emptyList(), Arrays.asList("2", "4")))); assertEquals(Arrays.asList( new Context().add("k1", "1").add("k2", null), new Context().add("k1", "3").add("k2", null) ), - getLib().zip(attributes, Arrays.asList(Arrays.asList("1", "3"), Arrays.asList()))); + getLib().zip(attributes, Arrays.asList(Arrays.asList("1", "3"), Collections.emptyList()))); assertEquals(Arrays.asList( new Context().add("k1", "1").add("k2", "2"), new Context().add("k1", "3").add("k2", "4") @@ -297,12 +298,12 @@ public void testZip() { new Context().add("k1", "1").add("k2", "2"), new Context().add("k1", "3").add("k2", null) ), - getLib().zip(attributes, Arrays.asList(Arrays.asList("1", "3"), Arrays.asList("2")))); + getLib().zip(attributes, Arrays.asList(Arrays.asList("1", "3"), Collections.singletonList("2")))); assertEquals(Arrays.asList( new Context().add("k1", "1").add("k2", "2"), new Context().add("k1", null).add("k2", "4") ), - getLib().zip(attributes, Arrays.asList(Arrays.asList("1"), Arrays.asList("2", "4")))); + getLib().zip(attributes, Arrays.asList(Collections.singletonList("1"), Arrays.asList("2", "4")))); } @Test @@ -310,28 +311,28 @@ public void testRemove() { assertNull(getLib().remove(null, null)); assertNull(getLib().remove(null, "1")); - assertEquals(Arrays.asList(), getLib().remove(Arrays.asList(), null)); - assertEquals(Arrays.asList(), getLib().remove(Arrays.asList(), "1")); + assertEquals(Collections.emptyList(), getLib().remove(Collections.emptyList(), null)); + assertEquals(Collections.emptyList(), getLib().remove(Collections.emptyList(), "1")); assertEquals(Arrays.asList("1", "2"), getLib().remove(Arrays.asList("1", "2"), null)); - assertEquals(Arrays.asList("2"), getLib().remove(Arrays.asList("1", "2"), "1")); - assertEquals(Arrays.asList("1"), getLib().remove(Arrays.asList("2", "1", "2", "2"), "2")); + assertEquals(Collections.singletonList("2"), getLib().remove(Arrays.asList("1", "2"), "1")); + assertEquals(Collections.singletonList("1"), getLib().remove(Arrays.asList("2", "1", "2", "2"), "2")); assertEquals(Arrays.asList("1", "2"), getLib().remove(Arrays.asList("1", "2"), "3")); } @Test public void testRemoveAll() { assertNull(getLib().removeAll(null, null)); - assertNull(getLib().removeAll(null, Arrays.asList())); + assertNull(getLib().removeAll(null, Collections.emptyList())); assertNull(getLib().removeAll(null, Arrays.asList("1", "2"))); - assertNull(getLib().removeAll(Arrays.asList(), null)); + assertNull(getLib().removeAll(Collections.emptyList(), null)); assertNull(getLib().removeAll(Arrays.asList("1", "2"), null)); - assertEquals(Arrays.asList(), getLib().removeAll(Arrays.asList(), Arrays.asList())); - assertEquals(Arrays.asList(), getLib().removeAll(Arrays.asList(), Arrays.asList("1", "2"))); + assertEquals(Collections.emptyList(), getLib().removeAll(Collections.emptyList(), Collections.emptyList())); + assertEquals(Collections.emptyList(), getLib().removeAll(Collections.emptyList(), Arrays.asList("1", "2"))); - assertEquals(Arrays.asList("1", "2"), getLib().removeAll(Arrays.asList("1", "2"), Arrays.asList())); - assertEquals(Arrays.asList("1", "2"), getLib().removeAll(Arrays.asList("1", "2"), Arrays.asList("3"))); + assertEquals(Arrays.asList("1", "2"), getLib().removeAll(Arrays.asList("1", "2"), Collections.emptyList())); + assertEquals(Arrays.asList("1", "2"), getLib().removeAll(Arrays.asList("1", "2"), Collections.singletonList("3"))); } @Test @@ -340,9 +341,9 @@ public void testNotContainsAny() { assertNull(getLib().notContainsAny(Arrays.asList("1", "2"), null)); assertNull(getLib().notContainsAny(null, Arrays.asList("1", "2"))); - assertTrue(getLib().notContainsAny(Arrays.asList(), Arrays.asList())); - assertTrue(getLib().notContainsAny(Arrays.asList("1", "2"), Arrays.asList())); - assertTrue(getLib().notContainsAny(Arrays.asList(), Arrays.asList("1", "2"))); + assertTrue(getLib().notContainsAny(Collections.emptyList(), Collections.emptyList())); + assertTrue(getLib().notContainsAny(Arrays.asList("1", "2"), Collections.emptyList())); + assertTrue(getLib().notContainsAny(Collections.emptyList(), Arrays.asList("1", "2"))); assertFalse(getLib().notContainsAny(Arrays.asList("1", "2"), Arrays.asList("1", "4"))); assertTrue(getLib().notContainsAny(Arrays.asList("1", "2"), Arrays.asList("3", "4"))); @@ -351,15 +352,15 @@ public void testNotContainsAny() { @Test public void testContainsOnly() { assertNull(getLib().containsOnly(null, null)); - assertNull(getLib().containsOnly(null, Arrays.asList())); + assertNull(getLib().containsOnly(null, Collections.emptyList())); assertNull(getLib().containsOnly(null, Arrays.asList("1", "2"))); - assertNull(getLib().containsOnly(Arrays.asList(), null)); - assertTrue(getLib().containsOnly(Arrays.asList(), Arrays.asList())); - assertTrue(getLib().containsOnly(Arrays.asList(), Arrays.asList("1", "2"))); + assertNull(getLib().containsOnly(Collections.emptyList(), null)); + assertTrue(getLib().containsOnly(Collections.emptyList(), Collections.emptyList())); + assertTrue(getLib().containsOnly(Collections.emptyList(), Arrays.asList("1", "2"))); assertNull(getLib().containsOnly(Arrays.asList("1", "2"), null)); - assertFalse(getLib().containsOnly(Arrays.asList("1", "2"), Arrays.asList())); + assertFalse(getLib().containsOnly(Arrays.asList("1", "2"), Collections.emptyList())); assertTrue(getLib().containsOnly(Arrays.asList("1", "2"), Arrays.asList("1", "2"))); assertFalse(getLib().containsOnly(Arrays.asList("1", "2"), Arrays.asList("3", "4"))); } @@ -367,15 +368,15 @@ public void testContainsOnly() { @Test public void testAreElementsOf() { assertNull(getLib().areElementsOf(null, null)); - assertNull(getLib().areElementsOf(null, Arrays.asList())); + assertNull(getLib().areElementsOf(null, Collections.emptyList())); assertNull(getLib().areElementsOf(null, Arrays.asList("1", "2"))); - assertNull(getLib().areElementsOf(Arrays.asList(), null)); - assertTrue(getLib().areElementsOf(Arrays.asList(), Arrays.asList())); - assertTrue(getLib().areElementsOf(Arrays.asList(), Arrays.asList("1", "2"))); + assertNull(getLib().areElementsOf(Collections.emptyList(), null)); + assertTrue(getLib().areElementsOf(Collections.emptyList(), Collections.emptyList())); + assertTrue(getLib().areElementsOf(Collections.emptyList(), Arrays.asList("1", "2"))); assertNull(getLib().areElementsOf(Arrays.asList("1", "2"), null)); - assertFalse(getLib().areElementsOf(Arrays.asList("1", "2"), Arrays.asList())); + assertFalse(getLib().areElementsOf(Arrays.asList("1", "2"), Collections.emptyList())); assertTrue(getLib().areElementsOf(Arrays.asList("1", "2"), Arrays.asList("1", "2"))); assertFalse(getLib().areElementsOf(Arrays.asList("1", "2"), Arrays.asList("1", "3"))); } @@ -383,15 +384,15 @@ public void testAreElementsOf() { @Test public void testElementOf() { assertNull(getLib().elementOf(null, null)); - assertNull(getLib().elementOf(null, Arrays.asList())); + assertNull(getLib().elementOf(null, Collections.emptyList())); assertNull(getLib().elementOf(null, Arrays.asList("1", "2"))); - assertNull(getLib().elementOf(Arrays.asList(), null)); - assertTrue(getLib().elementOf(Arrays.asList(), Arrays.asList())); - assertTrue(getLib().elementOf(Arrays.asList(), Arrays.asList("1", "2"))); + assertNull(getLib().elementOf(Collections.emptyList(), null)); + assertTrue(getLib().elementOf(Collections.emptyList(), Collections.emptyList())); + assertTrue(getLib().elementOf(Collections.emptyList(), Arrays.asList("1", "2"))); assertNull(getLib().elementOf(Arrays.asList("1", "2"), null)); - assertFalse(getLib().elementOf(Arrays.asList("1", "2"), Arrays.asList())); + assertFalse(getLib().elementOf(Arrays.asList("1", "2"), Collections.emptyList())); assertTrue(getLib().elementOf(Arrays.asList("1", "2"), Arrays.asList("1", "2"))); assertFalse(getLib().elementOf(Arrays.asList("1", "2"), Arrays.asList("1", "3"))); } @@ -402,7 +403,7 @@ public void testElementOf() { @Test public void testAvg() { assertNull(getLib().avg(null)); - assertNull(getLib().avg(Arrays.asList())); + assertNull(getLib().avg(Collections.emptyList())); assertEqualsNumber(makeNumber("2"), getLib().avg(Arrays.asList(makeNumber("1"), makeNumber("3")))); assertNull(getLib().avg(Arrays.asList(makeNumber("1"), null))); @@ -411,7 +412,7 @@ public void testAvg() { @Test public void testMedian() { assertNull(getLib().median(null)); - assertNull(getLib().median(Arrays.asList())); + assertNull(getLib().median(Collections.emptyList())); assertNull(getLib().median(Arrays.asList(makeNumber("1"), null))); assertEqualsNumber(makeNumber("2"), getLib().median(Arrays.asList(makeNumber("1"), makeNumber("2"), makeNumber("3")))); @@ -421,7 +422,7 @@ public void testMedian() { @Test public void testMode() { assertNull(getLib().mode(null)); - assertNull(getLib().mode(Arrays.asList())); + assertNull(getLib().mode(Collections.emptyList())); assertNull(getLib().mode(Arrays.asList(makeNumber("1"), null))); assertEqualsNumber(makeNumber("1"), getLib().mode(Arrays.asList(makeNumber("1"), makeNumber("3")))); @@ -447,7 +448,7 @@ public void testStringAdd() { @Test public void testConcat() { assertNull(getLib().concat(null)); - assertNull(getLib().concat(Arrays.asList())); + assertNull(getLib().concat(Collections.emptyList())); assertEquals("123", getLib().concat(Arrays.asList("1", "2", "3"))); assertNull(getLib().concat(Arrays.asList("1", null, "3"))); diff --git a/dmn-runtime/src/test/java/com/gs/dmn/signavio/feel/lib/FEELOperatorsTest.java b/dmn-runtime/src/test/java/com/gs/dmn/signavio/feel/lib/FEELOperatorsTest.java index 2987354ad..0e97997c3 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/signavio/feel/lib/FEELOperatorsTest.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/signavio/feel/lib/FEELOperatorsTest.java @@ -26,7 +26,7 @@ import java.time.OffsetTime; import java.time.ZonedDateTime; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.*; @@ -1131,31 +1131,31 @@ public void testIsList() { @Test public void testListIs() { assertTrue(getLib().listIs(null, null)); - assertFalse(getLib().listIs(Arrays.asList("a"), null)); - assertFalse(getLib().listIs(null, Arrays.asList("a"))); + assertFalse(getLib().listIs(Collections.singletonList("a"), null)); + assertFalse(getLib().listIs(null, Collections.singletonList("a"))); - assertFalse(getLib().listIs(Arrays.asList("a"), Arrays.asList("b"))); - assertTrue(getLib().listIs(Arrays.asList("a"), Arrays.asList("a"))); + assertFalse(getLib().listIs(Collections.singletonList("a"), Collections.singletonList("b"))); + assertTrue(getLib().listIs(Collections.singletonList("a"), Collections.singletonList("a"))); } @Test public void testListEqual() { assertTrue(getLib().listEqual(null, null)); - assertFalse(getLib().listEqual(Arrays.asList("a"), null)); - assertFalse(getLib().listEqual(null, Arrays.asList("a"))); + assertFalse(getLib().listEqual(Collections.singletonList("a"), null)); + assertFalse(getLib().listEqual(null, Collections.singletonList("a"))); - assertFalse(getLib().listEqual(Arrays.asList("a"), Arrays.asList("b"))); - assertTrue(getLib().listEqual(Arrays.asList("a"), Arrays.asList("a"))); + assertFalse(getLib().listEqual(Collections.singletonList("a"), Collections.singletonList("b"))); + assertTrue(getLib().listEqual(Collections.singletonList("a"), Collections.singletonList("a"))); } @Test public void testListNotEqual() { assertFalse(getLib().listNotEqual(null, null)); - assertTrue(getLib().listNotEqual(Arrays.asList("a"), null)); - assertTrue(getLib().listNotEqual(null, Arrays.asList("a"))); + assertTrue(getLib().listNotEqual(Collections.singletonList("a"), null)); + assertTrue(getLib().listNotEqual(null, Collections.singletonList("a"))); - assertTrue(getLib().listNotEqual(Arrays.asList("a"), Arrays.asList("b"))); - assertFalse(getLib().listNotEqual(Arrays.asList("a"), Arrays.asList("a"))); + assertTrue(getLib().listNotEqual(Collections.singletonList("a"), Collections.singletonList("b"))); + assertFalse(getLib().listNotEqual(Collections.singletonList("a"), Collections.singletonList("a"))); } // diff --git a/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/example_credit_decision/PostorderTraceListenerTest.java b/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/example_credit_decision/PostorderTraceListenerTest.java index 8c14ef464..9b9da2339 100644 --- a/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/example_credit_decision/PostorderTraceListenerTest.java +++ b/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/example_credit_decision/PostorderTraceListenerTest.java @@ -23,7 +23,7 @@ import java.io.File; import java.math.BigDecimal; -import java.util.Arrays; +import java.util.Collections; import java.util.List; public class PostorderTraceListenerTest extends AbstractTraceListenerTest { @@ -49,7 +49,7 @@ public void testListener() throws Exception { @Test public void testListenerWithFilter() throws Exception { - PostorderTraceEventListener listener = new PostorderTraceEventListener(Arrays.asList("Make credit decision")); + PostorderTraceEventListener listener = new PostorderTraceEventListener(Collections.singletonList("Make credit decision")); List expectedResult = decision.asList(new com.gs.dmn.generated.example_credit_decision.type.GenerateOutputDataImpl(decision.number("27.5"), "Accept", decision.numericUnaryMinus(decision.number("7.5")))); java.math.BigDecimal currentRiskAppetite = decision.number("50"); diff --git a/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/example_credit_decision_mixed/JsonSerializerTest.java b/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/example_credit_decision_mixed/JsonSerializerTest.java index 472248feb..1cd909e23 100644 --- a/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/example_credit_decision_mixed/JsonSerializerTest.java +++ b/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/example_credit_decision_mixed/JsonSerializerTest.java @@ -19,7 +19,7 @@ import java.io.StringWriter; import java.io.Writer; -import java.util.Arrays; +import java.util.Collections; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -34,7 +34,7 @@ public void testApplicantSerialization() throws Exception { applicant.setName("Amy"); applicant.setAge(decision.number("38")); applicant.setCreditScore(decision.number("100")); - applicant.setPriorIssues(Arrays.asList("Late payment")); + applicant.setPriorIssues(Collections.singletonList("Late payment")); Writer writer = new StringWriter(); JsonSerializer.OBJECT_MAPPER.writeValue(writer, applicant); @@ -50,6 +50,6 @@ public void testApplicantDeserialization() throws Exception { assertTrue(decision.stringEqual("Amy", applicant.getName())); assertTrue(decision.numericEqual(decision.number("38"), applicant.getAge())); assertTrue(decision.numericEqual(decision.number("100"), applicant.getCreditScore())); - assertEquals(Arrays.asList("Late payment"), applicant.getPriorIssues()); + assertEquals(Collections.singletonList("Late payment"), applicant.getPriorIssues()); } } diff --git a/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/null_safe_tests/HandwrittenAllTogetherTest.java b/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/null_safe_tests/HandwrittenAllTogetherTest.java index 2dee8f50f..8f9910a5d 100644 --- a/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/null_safe_tests/HandwrittenAllTogetherTest.java +++ b/dmn-signavio-it/dmn-signavio-it-kotlin-translator/src/test/java/com/gs/dmn/generated/null_safe_tests/HandwrittenAllTogetherTest.java @@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -46,7 +47,7 @@ public void testCase1() { public void testCase2() { String dateTime = "2016-11-16T12:10:00.000+00:00"; String time = "12:00:00"; - String booleanList = toJson(Arrays.asList()); + String booleanList = toJson(Collections.emptyList()); String string = "0.0"; String booleanB = "true"; String numberA = "12"; @@ -80,7 +81,7 @@ public void testCase3() { public void testCase4() { String dateTime = "2016-11-01T01:01:01.000+00:00"; String time = "12:12:12"; - String booleanList = toJson(Arrays.asList(true)); + String booleanList = toJson(Collections.singletonList(true)); String string = "0.0##"; String booleanB = "true"; String numberA = "11"; @@ -114,7 +115,7 @@ public void testCase5() { public void testCase6() { String dateTime = "2016-11-03T04:00:00.000+00:00"; String time = "11:11:11"; - String booleanList = toJson(Arrays.asList(false)); + String booleanList = toJson(Collections.singletonList(false)); String string = "#"; String booleanB = "true"; String numberA = "12"; @@ -131,7 +132,7 @@ public void testCase6() { protected void applyDecision() { String dateTime = "2016-11-03T04:00:00.000+00:00"; String time = "11:11:11"; - String booleanList = toJson(Arrays.asList(false)); + String booleanList = toJson(Collections.singletonList(false)); String string = "#"; String booleanB = "true"; String numberA = "12"; diff --git a/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/example_credit_decision/PostorderTraceListenerTest.java b/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/example_credit_decision/PostorderTraceListenerTest.java index 8c14ef464..9b9da2339 100644 --- a/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/example_credit_decision/PostorderTraceListenerTest.java +++ b/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/example_credit_decision/PostorderTraceListenerTest.java @@ -23,7 +23,7 @@ import java.io.File; import java.math.BigDecimal; -import java.util.Arrays; +import java.util.Collections; import java.util.List; public class PostorderTraceListenerTest extends AbstractTraceListenerTest { @@ -49,7 +49,7 @@ public void testListener() throws Exception { @Test public void testListenerWithFilter() throws Exception { - PostorderTraceEventListener listener = new PostorderTraceEventListener(Arrays.asList("Make credit decision")); + PostorderTraceEventListener listener = new PostorderTraceEventListener(Collections.singletonList("Make credit decision")); List expectedResult = decision.asList(new com.gs.dmn.generated.example_credit_decision.type.GenerateOutputDataImpl(decision.number("27.5"), "Accept", decision.numericUnaryMinus(decision.number("7.5")))); java.math.BigDecimal currentRiskAppetite = decision.number("50"); diff --git a/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/example_credit_decision_mixed/JsonSerializerTest.java b/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/example_credit_decision_mixed/JsonSerializerTest.java index 472248feb..1cd909e23 100644 --- a/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/example_credit_decision_mixed/JsonSerializerTest.java +++ b/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/example_credit_decision_mixed/JsonSerializerTest.java @@ -19,7 +19,7 @@ import java.io.StringWriter; import java.io.Writer; -import java.util.Arrays; +import java.util.Collections; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -34,7 +34,7 @@ public void testApplicantSerialization() throws Exception { applicant.setName("Amy"); applicant.setAge(decision.number("38")); applicant.setCreditScore(decision.number("100")); - applicant.setPriorIssues(Arrays.asList("Late payment")); + applicant.setPriorIssues(Collections.singletonList("Late payment")); Writer writer = new StringWriter(); JsonSerializer.OBJECT_MAPPER.writeValue(writer, applicant); @@ -50,6 +50,6 @@ public void testApplicantDeserialization() throws Exception { assertTrue(decision.stringEqual("Amy", applicant.getName())); assertTrue(decision.numericEqual(decision.number("38"), applicant.getAge())); assertTrue(decision.numericEqual(decision.number("100"), applicant.getCreditScore())); - assertEquals(Arrays.asList("Late payment"), applicant.getPriorIssues()); + assertEquals(Collections.singletonList("Late payment"), applicant.getPriorIssues()); } } diff --git a/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/null_safe_tests/HandwrittenAllTogetherTest.java b/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/null_safe_tests/HandwrittenAllTogetherTest.java index 2dee8f50f..8f9910a5d 100644 --- a/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/null_safe_tests/HandwrittenAllTogetherTest.java +++ b/dmn-signavio-it/dmn-signavio-it-translator/src/test/java/com/gs/dmn/generated/null_safe_tests/HandwrittenAllTogetherTest.java @@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -46,7 +47,7 @@ public void testCase1() { public void testCase2() { String dateTime = "2016-11-16T12:10:00.000+00:00"; String time = "12:00:00"; - String booleanList = toJson(Arrays.asList()); + String booleanList = toJson(Collections.emptyList()); String string = "0.0"; String booleanB = "true"; String numberA = "12"; @@ -80,7 +81,7 @@ public void testCase3() { public void testCase4() { String dateTime = "2016-11-01T01:01:01.000+00:00"; String time = "12:12:12"; - String booleanList = toJson(Arrays.asList(true)); + String booleanList = toJson(Collections.singletonList(true)); String string = "0.0##"; String booleanB = "true"; String numberA = "11"; @@ -114,7 +115,7 @@ public void testCase5() { public void testCase6() { String dateTime = "2016-11-03T04:00:00.000+00:00"; String time = "11:11:11"; - String booleanList = toJson(Arrays.asList(false)); + String booleanList = toJson(Collections.singletonList(false)); String string = "#"; String booleanB = "true"; String numberA = "12"; @@ -131,7 +132,7 @@ public void testCase6() { protected void applyDecision() { String dateTime = "2016-11-03T04:00:00.000+00:00"; String time = "11:11:11"; - String booleanList = toJson(Arrays.asList(false)); + String booleanList = toJson(Collections.singletonList(false)); String string = "#"; String booleanB = "true"; String numberA = "12"; diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/RDFModel.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/RDFModel.java index 74277d504..8b34238f4 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/RDFModel.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/RDFModel.java @@ -269,9 +269,7 @@ public boolean hasSingleOutput(String decisionId) { expression = RDFModel.MAPPER.readValue(decisionText, DecisionExpression.class); if (expression instanceof DecisionTable) { List outputClauses = ((DecisionTable) expression).getOutputClauses(); - if (outputClauses.size() == 1) { - return true; - } + return outputClauses.size() == 1; } return false; } catch (Exception e) { diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/RDFReader.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/RDFReader.java index dcd717aa4..60c5a84ee 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/RDFReader.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/RDFReader.java @@ -42,7 +42,7 @@ public RDFModel readModel(String modelName, InputStream inputStream) throws Exce RDFModel rdfModel = new RDFModel(document); watch.stop(); - this.logger.info("RDF reading time: " + watch.toString()); + this.logger.info("RDF reading time: " + watch); return rdfModel; } diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/json/expression/FeelContext.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/json/expression/FeelContext.java index 0337a5c1f..575cb7dfc 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/json/expression/FeelContext.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/rdf2dmn/json/expression/FeelContext.java @@ -65,7 +65,7 @@ private String findEnumeratorInInputClause(String enumeratorIndex) { String relationIndex = ((Reference) expression).getPathElements().get(0); return findEnumItem(relationList, relationIndex, enumeratorIndex); } else { - throw new DMNRuntimeException(String.format("Cannot find enumerator at index '%s' in inputEntry '%s'", enumeratorIndex, expression.toString())); + throw new DMNRuntimeException(String.format("Cannot find enumerator at index '%s' in inputEntry '%s'", enumeratorIndex, expression)); } } else { throw new UnsupportedOperationException(expression.getClass().getSimpleName() + " not supported"); diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/BooleanLiteral.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/BooleanLiteral.java index 44dbfe1e3..bdee83644 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/BooleanLiteral.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/BooleanLiteral.java @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.gs.dmn.signavio.testlab.Visitor; +import java.util.Objects; + @JsonPropertyOrder({ "type", "value" }) public class BooleanLiteral extends SimpleExpression { private Boolean value; @@ -46,7 +48,7 @@ public boolean equals(Object o) { BooleanLiteral that = (BooleanLiteral) o; - return value != null ? value.equals(that.value) : that.value == null; + return Objects.equals(value, that.value); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/ComplexExpression.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/ComplexExpression.java index fc6dcc076..6854c1d15 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/ComplexExpression.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/ComplexExpression.java @@ -16,6 +16,7 @@ import com.gs.dmn.signavio.testlab.Visitor; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; @JsonPropertyOrder({ "type", "slots" }) @@ -50,7 +51,7 @@ public boolean equals(Object o) { ComplexExpression that = (ComplexExpression) o; - return slots != null ? slots.equals(that.slots) : that.slots == null; + return Objects.equals(slots, that.slots); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/DateLiteral.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/DateLiteral.java index d0f5e6035..a725a44be 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/DateLiteral.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/DateLiteral.java @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.gs.dmn.signavio.testlab.Visitor; +import java.util.Objects; + @JsonPropertyOrder({ "type", "value" }) public class DateLiteral extends SimpleExpression { private String value; @@ -46,7 +48,7 @@ public boolean equals(Object o) { DateLiteral that = (DateLiteral) o; - return value != null ? value.equals(that.value) : that.value == null; + return Objects.equals(value, that.value); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/DatetimeLiteral.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/DatetimeLiteral.java index d140f5914..0032aad7d 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/DatetimeLiteral.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/DatetimeLiteral.java @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.gs.dmn.signavio.testlab.Visitor; +import java.util.Objects; + @JsonPropertyOrder({ "type", "value" }) public class DatetimeLiteral extends SimpleExpression { private String value; @@ -46,7 +48,7 @@ public boolean equals(Object o) { DatetimeLiteral that = (DatetimeLiteral) o; - return value != null ? value.equals(that.value) : that.value == null; + return Objects.equals(value, that.value); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/EnumerationLiteral.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/EnumerationLiteral.java index 7994ed14e..81b4d7119 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/EnumerationLiteral.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/EnumerationLiteral.java @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.gs.dmn.signavio.testlab.Visitor; +import java.util.Objects; + @JsonPropertyOrder({ "type", "value", "name" }) public class EnumerationLiteral extends SimpleExpression { // Enumerator name @@ -54,7 +56,7 @@ public boolean equals(Object o) { EnumerationLiteral that = (EnumerationLiteral) o; - return name != null ? name.equals(that.name) : that.name == null; + return Objects.equals(name, that.name); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/ListExpression.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/ListExpression.java index 041586d1b..d321b8820 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/ListExpression.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/ListExpression.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; @JsonPropertyOrder({ "type", "value" }) public class ListExpression extends Expression { @@ -58,7 +59,7 @@ public boolean equals(Object o) { ListExpression that = (ListExpression) o; - return value != null ? value.equals(that.value) : that.value == null; + return Objects.equals(value, that.value); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/NumberLiteral.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/NumberLiteral.java index 3e59c1c7a..d03f17276 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/NumberLiteral.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/NumberLiteral.java @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.gs.dmn.signavio.testlab.Visitor; +import java.util.Objects; + @JsonPropertyOrder({ "type", "value" }) public class NumberLiteral extends SimpleExpression { private String value; @@ -46,7 +48,7 @@ public boolean equals(Object o) { NumberLiteral that = (NumberLiteral) o; - return value != null ? value.equals(that.value) : that.value == null; + return Objects.equals(value, that.value); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/Slot.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/Slot.java index 581476e15..9b002467e 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/Slot.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/Slot.java @@ -17,6 +17,8 @@ import com.gs.dmn.signavio.testlab.TestLabElement; import com.gs.dmn.signavio.testlab.Visitor; +import java.util.Objects; + @JsonPropertyOrder({ "id", "name", "value", "itemComponentName" }) @JsonInclude(JsonInclude.Include.NON_NULL) public class Slot extends TestLabElement { @@ -70,10 +72,10 @@ public boolean equals(Object o) { Slot slot = (Slot) o; - if (id != null ? !id.equals(slot.id) : slot.id != null) return false; - if (name != null ? !name.equals(slot.name) : slot.name != null) return false; - if (value != null ? !value.equals(slot.value) : slot.value != null) return false; - return itemComponentName != null ? itemComponentName.equals(slot.itemComponentName) : slot.itemComponentName == null; + if (!Objects.equals(id, slot.id)) return false; + if (!Objects.equals(name, slot.name)) return false; + if (!Objects.equals(value, slot.value)) return false; + return Objects.equals(itemComponentName, slot.itemComponentName); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/StringLiteral.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/StringLiteral.java index 965495b42..93cc7952e 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/StringLiteral.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/StringLiteral.java @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.gs.dmn.signavio.testlab.Visitor; +import java.util.Objects; + @JsonPropertyOrder({ "type", "value" }) public class StringLiteral extends SimpleExpression { private String value; @@ -46,7 +48,7 @@ public boolean equals(Object o) { StringLiteral that = (StringLiteral) o; - return value != null ? value.equals(that.value) : that.value == null; + return Objects.equals(value, that.value); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/TimeLiteral.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/TimeLiteral.java index 9c408bd01..65589b13e 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/TimeLiteral.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/testlab/expression/TimeLiteral.java @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.gs.dmn.signavio.testlab.Visitor; +import java.util.Objects; + @JsonPropertyOrder({ "type", "value" }) public class TimeLiteral extends SimpleExpression { private String value; @@ -50,7 +52,7 @@ public boolean equals(Object o) { TimeLiteral that = (TimeLiteral) o; - return value != null ? value.equals(that.value) : that.value == null; + return Objects.equals(value, that.value); } @Override diff --git a/dmn-signavio/src/main/java/com/gs/dmn/signavio/transformation/NormalizeDateTimeLiteralsTransformer.java b/dmn-signavio/src/main/java/com/gs/dmn/signavio/transformation/NormalizeDateTimeLiteralsTransformer.java index ee3d6b562..e9e29c4a5 100644 --- a/dmn-signavio/src/main/java/com/gs/dmn/signavio/transformation/NormalizeDateTimeLiteralsTransformer.java +++ b/dmn-signavio/src/main/java/com/gs/dmn/signavio/transformation/NormalizeDateTimeLiteralsTransformer.java @@ -92,10 +92,10 @@ public DMNBaseElement visit(TDecision element, TransformationContext context) { TExpression expression = repository.expression(element); if (expression instanceof TDecisionTable) { logger.debug(String.format("Process decision table in decision '%s'", element.getName())); - ((TDecisionTable) expression).accept(this, context); + expression.accept(this, context); } else if (expression instanceof TLiteralExpression) { logger.debug(String.format("Process literal expression in decision '%s'", element.getName())); - ((TLiteralExpression) expression).accept(this, context); + expression.accept(this, context); } return element; } diff --git a/dmn-signavio/src/test/java/com/gs/dmn/signavio/feel/AbstractSignavioFEELProcessorTest.java b/dmn-signavio/src/test/java/com/gs/dmn/signavio/feel/AbstractSignavioFEELProcessorTest.java index fce17a7f9..e47b29820 100644 --- a/dmn-signavio/src/test/java/com/gs/dmn/signavio/feel/AbstractSignavioFEELProcessorTest.java +++ b/dmn-signavio/src/test/java/com/gs/dmn/signavio/feel/AbstractSignavioFEELProcessorTest.java @@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -41,7 +42,7 @@ protected DMNModelRepository makeRepository() { public void testBetweenExpression() { super.testBetweenExpression(); - List entries = Arrays.asList(); + List entries = Collections.emptyList(); // Certain relational operators are not supported in Signavio (return null) doExpressionTest(entries, "", "\"a\" between \"b\" and \"d\"", @@ -58,7 +59,7 @@ public void testInExpression() { super.testInExpression(); // operator test - List entries = Arrays.asList(); + List entries = Collections.emptyList(); // Certain relational operators are not supported in Signavio (return null) doExpressionTest(entries, "", "\"b\" in [[\"f\"..\"h\"], [\"a\"..\"c\"]]", @@ -122,20 +123,19 @@ public void testFunctionInvocation() { public void testFilterExpression() { super.testFilterExpression(); - List entries = Arrays.asList( - ); + List entries = Collections.emptyList(); doExpressionTest(entries, "", "[ { x: \"1\", y: \"2\" }, { x: null, y: \"3\" } ][ x < \"2\" ]", "FilterExpression(ListLiteral(Context(ContextEntry(ContextEntryKey(x) = StringLiteral(\"1\")),ContextEntry(ContextEntryKey(y) = StringLiteral(\"2\"))),Context(ContextEntry(ContextEntryKey(x) = NullLiteral()),ContextEntry(ContextEntryKey(y) = StringLiteral(\"3\")))), Relational(<,PathExpression(Name(item), x),StringLiteral(\"2\")))", "ListType(ContextType(x = string, y = string))", "asList(new com.gs.dmn.runtime.Context().add(\"x\", \"1\").add(\"y\", \"2\"), new com.gs.dmn.runtime.Context().add(\"x\", null).add(\"y\", \"3\")).stream().filter(item -> stringLessThan(((String)((com.gs.dmn.runtime.Context)item).get(\"x\")), \"2\") == Boolean.TRUE).collect(Collectors.toList())", - this.lib.asList(new com.gs.dmn.runtime.Context().add("x", "1").add("y", "2"), new com.gs.dmn.runtime.Context().add("x", null).add("y", "3")).stream().filter(item -> this.lib.stringLessThan(((String)((com.gs.dmn.runtime.Context)item).get("x")), "2") == Boolean.TRUE).collect(Collectors.toList()), - Arrays.asList()); + this.lib.asList(new com.gs.dmn.runtime.Context().add("x", "1").add("y", "2"), new com.gs.dmn.runtime.Context().add("x", null).add("y", "3")).stream().filter(item -> this.lib.stringLessThan(((String) item.get("x")), "2") == Boolean.TRUE).collect(Collectors.toList()), + Collections.emptyList()); doExpressionTest(entries, "", "[ { x: null, y: \"2\" }, { x: \"1\", y: \"3\" } ][ x < \"2\" ]", "FilterExpression(ListLiteral(Context(ContextEntry(ContextEntryKey(x) = NullLiteral()),ContextEntry(ContextEntryKey(y) = StringLiteral(\"2\"))),Context(ContextEntry(ContextEntryKey(x) = StringLiteral(\"1\")),ContextEntry(ContextEntryKey(y) = StringLiteral(\"3\")))), Relational(<,PathExpression(Name(item), x),StringLiteral(\"2\")))", "ListType(ContextType(x = string, y = string))", "asList(new com.gs.dmn.runtime.Context().add(\"x\", null).add(\"y\", \"2\"), new com.gs.dmn.runtime.Context().add(\"x\", \"1\").add(\"y\", \"3\")).stream().filter(item -> stringLessThan(((String)((com.gs.dmn.runtime.Context)item).get(\"x\")), \"2\") == Boolean.TRUE).collect(Collectors.toList())", - this.lib.asList(new com.gs.dmn.runtime.Context().add("x", null).add("y", "2"), new com.gs.dmn.runtime.Context().add("x", "1").add("y", "3")).stream().filter(item -> this.lib.stringLessThan(((String)((com.gs.dmn.runtime.Context)item).get("x")), "2") == Boolean.TRUE).collect(Collectors.toList()), - Arrays.asList()); + this.lib.asList(new com.gs.dmn.runtime.Context().add("x", null).add("y", "2"), new com.gs.dmn.runtime.Context().add("x", "1").add("y", "3")).stream().filter(item -> this.lib.stringLessThan(((String) item.get("x")), "2") == Boolean.TRUE).collect(Collectors.toList()), + Collections.emptyList()); } @Override @@ -143,8 +143,8 @@ public void testFilterExpression() { public void testPathExpression() { super.testPathExpression(); - ItemDefinitionType type = new ItemDefinitionType("PrivateFundRequirements").addMember("HierarchyNode", Arrays.asList(), STRING); - List entries = Arrays.asList( + ItemDefinitionType type = new ItemDefinitionType("PrivateFundRequirements").addMember("HierarchyNode", Collections.emptyList(), STRING); + List entries = Collections.singletonList( new EnvironmentEntry("PrivateFundRequirements", type, null)); doExpressionTest(entries, "", "len(PrivateFundRequirements.HierarchyNode)", @@ -160,7 +160,7 @@ public void testPathExpression() { public void testConversionFunctions() { super.testConversionFunctions(); - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "isDefined(\"2000-10-10\")", @@ -198,7 +198,7 @@ public void testConversionFunctions() { @Test public void testNumericFunctions() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "abs(100)", @@ -277,7 +277,7 @@ public void testNumericFunctions() { @Test public void testStringFunctions() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "right(\"abc\", 1)", @@ -380,7 +380,7 @@ public void testStringFunctions() { @Test public void testListFunctions() { - List entries = Arrays.asList( + List entries = Collections.singletonList( new EnvironmentEntry("input", NUMBER, this.lib.number("1"))); doExpressionTest(entries, "", "containsOnly([1, 2, 3], [1])", diff --git a/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedComplexDMNInterpreterTest.java b/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedComplexDMNInterpreterTest.java index 05fc09f92..cddf42f48 100644 --- a/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedComplexDMNInterpreterTest.java +++ b/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedComplexDMNInterpreterTest.java @@ -22,6 +22,7 @@ import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigDecimal; import java.util.Arrays; +import java.util.Collections; public class ExportedComplexDMNInterpreterTest extends AbstractSignavioDMNInterpreterTest { private final DefaultSignavioBaseDecision decision = new DefaultSignavioBaseDecision(); @@ -34,155 +35,147 @@ protected String getInputPath() { @Test public void testChildLinked() throws Exception { doTest(new DecisionTestConfig( - "abc", - "ChildLinked", - makeInformationRequirements(Arrays.asList( - new Pair<>("num", decision.number("3")) - )), - decision.number("6") - ) - ); + "abc", + "ChildLinked", + makeInformationRequirements(Collections.singletonList( + new Pair<>("num", decision.number("3")) + )), + decision.number("6") + )); } @Test public void testCompareLists() throws Exception { doTest(new DecisionTestConfig( - "processL1", - "CompareLists", - makeInformationRequirements(Arrays.asList( - new Pair<>("l1", Arrays.asList(decision.number("1"), decision.number("2"), decision.number("3"), decision.number("4"))), - new Pair<>("l23", Arrays.asList(decision.number("1"), decision.number("1"), decision.number("2"), decision.number("3"), decision.number("5"), decision.number("8"))) - )), - Arrays.asList(decision.number("2"), decision.number("1"), decision.number("1"), decision.number("0")) - ) - ); + "processL1", + "CompareLists", + makeInformationRequirements(Arrays.asList( + new Pair<>("l1", Arrays.asList(decision.number("1"), decision.number("2"), decision.number("3"), decision.number("4"))), + new Pair<>("l23", Arrays.asList(decision.number("1"), decision.number("1"), decision.number("2"), decision.number("3"), decision.number("5"), decision.number("8"))) + )), + Arrays.asList(decision.number("2"), decision.number("1"), decision.number("1"), decision.number("0")) + )); } @Test public void testDecisionWithAnnotations() throws Exception { doTest(new DecisionTestConfig( - "decision", - "decision-with-annotations", - makeInformationRequirements(Arrays.asList( - new Pair<>("numberInput", decision.number("1")), - new Pair<>("stringInput", "abc"), - new Pair<>("booleanInput", true), - new Pair<>("dateInput", decision.date("2017-01-01")), - new Pair<>("enumerationInput", "e1"), - new Pair<>("person", new Context().add("name", "Peter").add("age", decision.number("10"))) - )), - null - ) - ); + "decision", + "decision-with-annotations", + makeInformationRequirements(Arrays.asList( + new Pair<>("numberInput", decision.number("1")), + new Pair<>("stringInput", "abc"), + new Pair<>("booleanInput", true), + new Pair<>("dateInput", decision.date("2017-01-01")), + new Pair<>("enumerationInput", "e1"), + new Pair<>("person", new Context().add("name", "Peter").add("age", decision.number("10"))) + )), + null + )); } @Test public void testDotProduct() throws Exception { doTest(new DecisionTestConfig( - "dotProduct", - "DotProduct", - makeInformationRequirements(Arrays.asList( - new Pair<>("a", decision.asList(decision.number("2"), decision.number("3"))), - new Pair<>("b", decision.asList(decision.number("4"), decision.number("2"))) - )), - new Context().add("dotProduct2", decision.number("14")).add("outputMessage", "2D vector dot product == 14") - ) - ); + "dotProduct", + "DotProduct", + makeInformationRequirements(Arrays.asList( + new Pair<>("a", decision.asList(decision.number("2"), decision.number("3"))), + new Pair<>("b", decision.asList(decision.number("4"), decision.number("2"))) + )), + new Context().add("dotProduct2", decision.number("14")).add("outputMessage", "2D vector dot product == 14") + )); } @Test public void testExampleCreditDecision() throws Exception { doTest(new DecisionTestConfig( - "generateOutputData", - "Example credit decision", - makeInformationRequirements(Arrays.asList( - new Pair<>("applicant", new Context() - .add("name", "Amy") - .add("age", decision.number("38")) - .add("creditScore", decision.number("100")).add("priorIssues", Arrays.asList("Late payment"))), - new Pair<>("currentRiskAppetite", decision.number("50")), - new Pair<>("lendingThreshold", decision.number("25")) - )), - Arrays.asList( - new Context() - .add("Decision", "Accept") - .add("Assessment", decision.number("27.50")) - .add("Issue", decision.numericUnaryMinus(decision.number("7.50")))) - ) - ); + "generateOutputData", + "Example credit decision", + makeInformationRequirements(Arrays.asList( + new Pair<>("applicant", new Context() + .add("name", "Amy") + .add("age", decision.number("38")) + .add("creditScore", decision.number("100")).add("priorIssues", Collections.singletonList("Late payment"))), + new Pair<>("currentRiskAppetite", decision.number("50")), + new Pair<>("lendingThreshold", decision.number("25")) + )), + Collections.singletonList( + new Context() + .add("Decision", "Accept") + .add("Assessment", decision.number("27.50")) + .add("Issue", decision.numericUnaryMinus(decision.number("7.50")))) + )); } @Test public void testNPEValidation2() throws Exception { doTest(new DecisionTestConfig( - "zip", - "NPEValidation2", - makeInformationRequirements(Arrays.asList( - new Pair<>("ages", decision.asList(decision.number("25"), decision.number("40"), decision.number("65"), decision.number("80"), decision.number("105"))), - new Pair<>("day", decision.number("25")), - new Pair<>("hour", decision.number("8")), - new Pair<>("minute", decision.number("5")), - new Pair<>("month", decision.number("12")), - new Pair<>("names", decision.asList("Fred", "Jim", "Tom", "Sarah", "Kate")), - new Pair<>("second", decision.number("10")), - new Pair<>("year", decision.number("2016")) - )), - Arrays.asList( - new Context() - .add("names", "Fred").add("ages", decision.number("25")).add("dateDiffs", decision.number("0")) - .add("dateTimeDiffs", decision.number("0")).add("temporalUnits", decision.number("12")).add("agesListDescription", "not exactly 1 to 5"), - new Context() - .add("names", "Jim").add("ages", decision.number("40")).add("dateDiffs", decision.number("0")) - .add("dateTimeDiffs", decision.number("0")).add("temporalUnits", decision.number("2016")).add("agesListDescription", "non of the numbers 1 to 5"), - new Context() - .add("names", "Tom").add("ages", decision.number("65")).add("dateDiffs", decision.number("0")) - .add("dateTimeDiffs", decision.number("0")).add("temporalUnits", decision.number("7")).add("agesListDescription", null), - new Context() - .add("names", "Sarah").add("ages", decision.number("80")).add("dateDiffs", decision.number("-359")) - .add("dateTimeDiffs", decision.number("-8612")).add("temporalUnits", decision.number("25")).add("agesListDescription", null), - new Context() - .add("names", "Kate").add("ages", decision.number("105")).add("dateDiffs", null) - .add("dateTimeDiffs", null).add("temporalUnits", decision.number("5")).add("agesListDescription", null) + "zip", + "NPEValidation2", + makeInformationRequirements(Arrays.asList( + new Pair<>("ages", decision.asList(decision.number("25"), decision.number("40"), decision.number("65"), decision.number("80"), decision.number("105"))), + new Pair<>("day", decision.number("25")), + new Pair<>("hour", decision.number("8")), + new Pair<>("minute", decision.number("5")), + new Pair<>("month", decision.number("12")), + new Pair<>("names", decision.asList("Fred", "Jim", "Tom", "Sarah", "Kate")), + new Pair<>("second", decision.number("10")), + new Pair<>("year", decision.number("2016")) + )), + Arrays.asList( + new Context() + .add("names", "Fred").add("ages", decision.number("25")).add("dateDiffs", decision.number("0")) + .add("dateTimeDiffs", decision.number("0")).add("temporalUnits", decision.number("12")).add("agesListDescription", "not exactly 1 to 5"), + new Context() + .add("names", "Jim").add("ages", decision.number("40")).add("dateDiffs", decision.number("0")) + .add("dateTimeDiffs", decision.number("0")).add("temporalUnits", decision.number("2016")).add("agesListDescription", "non of the numbers 1 to 5"), + new Context() + .add("names", "Tom").add("ages", decision.number("65")).add("dateDiffs", decision.number("0")) + .add("dateTimeDiffs", decision.number("0")).add("temporalUnits", decision.number("7")).add("agesListDescription", null), + new Context() + .add("names", "Sarah").add("ages", decision.number("80")).add("dateDiffs", decision.number("-359")) + .add("dateTimeDiffs", decision.number("-8612")).add("temporalUnits", decision.number("25")).add("agesListDescription", null), + new Context() + .add("names", "Kate").add("ages", decision.number("105")).add("dateDiffs", null) + .add("dateTimeDiffs", null).add("temporalUnits", decision.number("5")).add("agesListDescription", null) - ) ) - ); + )); } @Test public void testNullSafeTests() throws Exception { doTest(new DecisionTestConfig( - "allTogether", - "Null Safe Tests", - makeInformationRequirements(Arrays.asList( - new Pair<>("booleanA", true), - new Pair<>("booleanB", false), - new Pair<>("booleanList", decision.asList(true, false, true)), - new Pair<>("date", decision.date("2015-01-01")), - new Pair<>("dateTime", decision.dateAndTime("2015-01-01T12:00:00Z")), - new Pair<>("numberA", decision.number("12")), - new Pair<>("numberB", decision.number("34")), - new Pair<>("numberList", Arrays.asList(decision.number("10"), decision.number("20"), decision.number("30"), decision.number("40"))), - new Pair<>("string", "00.00"), - new Pair<>("stringList", Arrays.asList("Foo", "Bar")), - new Pair<>("time", decision.time("13:00:00Z")) - )), - "NotNull" - ) - ); + "allTogether", + "Null Safe Tests", + makeInformationRequirements(Arrays.asList( + new Pair<>("booleanA", true), + new Pair<>("booleanB", false), + new Pair<>("booleanList", decision.asList(true, false, true)), + new Pair<>("date", decision.date("2015-01-01")), + new Pair<>("dateTime", decision.dateAndTime("2015-01-01T12:00:00Z")), + new Pair<>("numberA", decision.number("12")), + new Pair<>("numberB", decision.number("34")), + new Pair<>("numberList", Arrays.asList(decision.number("10"), decision.number("20"), decision.number("30"), decision.number("40"))), + new Pair<>("string", "00.00"), + new Pair<>("stringList", Arrays.asList("Foo", "Bar")), + new Pair<>("time", decision.time("13:00:00Z")) + )), + "NotNull" + )); } @Test public void testParentLinked() throws Exception { doTest(new DecisionTestConfig( - "somethingElse", - "ParentLinked", - makeInformationRequirements(Arrays.asList( - new Pair<>("num", decision.number("2")) - )), - decision.number("14") - ) - ); + "somethingElse", + "ParentLinked", + makeInformationRequirements(Collections.singletonList( + new Pair<>("num", decision.number("2")) + )), + decision.number("14") + )); } @Override diff --git a/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedDecisionTableDMNInterpreterTest.java b/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedDecisionTableDMNInterpreterTest.java index a751618a5..38aa6f9a9 100644 --- a/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedDecisionTableDMNInterpreterTest.java +++ b/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedDecisionTableDMNInterpreterTest.java @@ -22,6 +22,7 @@ import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigDecimal; import java.util.Arrays; +import java.util.Collections; public class ExportedDecisionTableDMNInterpreterTest extends AbstractSignavioDMNInterpreterTest { private final DefaultSignavioBaseDecision decision = new DefaultSignavioBaseDecision(); @@ -50,285 +51,266 @@ public void testCompoundDecisionPrimitiveTypeInputsSfeelInputEntriesCompoundOutp @Test public void testSimpleDecisionComplexTypeInputsSfeelInputEntriesSingleOutputCollectHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-complex-type-inputs-sfeel-input-entries-single-output-collect-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("person", new Context("Person") - .add("firstName", "Peter") - .add("lastName", "Sellers") - .add("gender", "male") - .add("id", decision.number("4")) - .add("dateOfBirth", decision.date("2016-10-01")) - .add("timeOfBirth", decision.time("01:00:00Z")) - .add("dateTimeOfBirth", decision.dateAndTime("2016-10-01T00:00:00Z")) - .add("list", Arrays.asList("abc")) - .add("married", false)), - new Pair<>("employed", true) - )), - Arrays.asList("3") - ) - ); + "decision", + "simple-decision-complex-type-inputs-sfeel-input-entries-single-output-collect-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("person", new Context("Person") + .add("firstName", "Peter") + .add("lastName", "Sellers") + .add("gender", "male") + .add("id", decision.number("4")) + .add("dateOfBirth", decision.date("2016-10-01")) + .add("timeOfBirth", decision.time("01:00:00Z")) + .add("dateTimeOfBirth", decision.dateAndTime("2016-10-01T00:00:00Z")) + .add("list", Collections.singletonList("abc")) + .add("married", false)), + new Pair<>("employed", true) + )), + Collections.singletonList("3") + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsCompoundOutputOutputOrderHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-compound-output-output-order-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - Arrays.asList( - new Context().add("output1", "r5").add("output2", "r6"), - new Context().add("output1", "r4").add("output2", "r7"), - new Context().add("output1", "r3").add("output2", "r8"), - new Context().add("output1", "r2").add("output2", "r9") - ) + "decision", + "simple-decision-primitive-type-inputs-compound-output-output-order-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + Arrays.asList( + new Context().add("output1", "r5").add("output2", "r6"), + new Context().add("output1", "r4").add("output2", "r7"), + new Context().add("output1", "r3").add("output2", "r8"), + new Context().add("output1", "r2").add("output2", "r9") ) - ); + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsCompoundOutputPriorityHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-compound-output-priority-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - new Context().add("output1", "r5").add("output2", "r6") - ) - ); + "decision", + "simple-decision-primitive-type-inputs-compound-output-priority-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + new Context().add("output1", "r5").add("output2", "r6") + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsFeelInputEntriesSingleOutputFirstHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-feel-input-entries-single-output-first-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("booleanInput", true), - new Pair<>("numberInput", decision.number("-1")), - new Pair<>("textInput", "abc"), - new Pair<>("enumerationInput", "e1"), - new Pair<>("dateInput", decision.date("2016-08-01")), - new Pair<>("timeInput", decision.time("12:00:00Z")), - new Pair<>("dateAndTimeInput", decision.dateAndTime("2016-08-01T11:00:00Z")) - )), - "r1" - ) - ); + "decision", + "simple-decision-primitive-type-inputs-feel-input-entries-single-output-first-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("booleanInput", true), + new Pair<>("numberInput", decision.number("-1")), + new Pair<>("textInput", "abc"), + new Pair<>("enumerationInput", "e1"), + new Pair<>("dateInput", decision.date("2016-08-01")), + new Pair<>("timeInput", decision.time("12:00:00Z")), + new Pair<>("dateAndTimeInput", decision.dateAndTime("2016-08-01T11:00:00Z")) + )), + "r1" + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsFeelInputEntriesSingleOutputUniqueHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-feel-input-entries-single-output-unique-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("booleanInput", true), - new Pair<>("numberInput", decision.number("-1")), - new Pair<>("textInput", "abc"), - new Pair<>("enumerationInput", "e1"), - new Pair<>("dateInput", decision.date("2016-08-01")), - new Pair<>("timeInput", decision.time("12:00:00Z")), - new Pair<>("dateAndTimeInput", decision.dateAndTime("2016-08-01T11:00:00Z")) - )), - null - ) - ); + "decision", + "simple-decision-primitive-type-inputs-feel-input-entries-single-output-unique-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("booleanInput", true), + new Pair<>("numberInput", decision.number("-1")), + new Pair<>("textInput", "abc"), + new Pair<>("enumerationInput", "e1"), + new Pair<>("dateInput", decision.date("2016-08-01")), + new Pair<>("timeInput", decision.time("12:00:00Z")), + new Pair<>("dateAndTimeInput", decision.dateAndTime("2016-08-01T11:00:00Z")) + )), + null + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSfeelInputEntriesCompoundOutputFirstHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "compoundOutputDecision", - "simple-decision-primitive-type-inputs-sfeel-input-entries-compound-output-first-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("booleanInput", true), - new Pair<>("numberInput", decision.number("-1")), - new Pair<>("textInput", "abc"), - new Pair<>("enumerationInput", "e1"), - new Pair<>("dateInput", decision.date("2016-08-01")), - new Pair<>("timeInput", decision.time("12:00:00Z")), - new Pair<>("dateAndTimeInput", decision.dateAndTime("2016-08-01T11:00:00Z")) - )), - new Context().add("firstOutput", "r11").add("secondOutput", "r12") - ) - ); + "compoundOutputDecision", + "simple-decision-primitive-type-inputs-sfeel-input-entries-compound-output-first-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("booleanInput", true), + new Pair<>("numberInput", decision.number("-1")), + new Pair<>("textInput", "abc"), + new Pair<>("enumerationInput", "e1"), + new Pair<>("dateInput", decision.date("2016-08-01")), + new Pair<>("timeInput", decision.time("12:00:00Z")), + new Pair<>("dateAndTimeInput", decision.dateAndTime("2016-08-01T11:00:00Z")) + )), + new Context().add("firstOutput", "r11").add("secondOutput", "r12") + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSfeelInputEntriesSingleOutputFirstHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-sfeel-input-entries-single-output-first-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("booleanInput", true), - new Pair<>("numberInput", decision.number("-1")), - new Pair<>("textInput", "abc"), - new Pair<>("enumerationInput", "e1"), - new Pair<>("dateInput", decision.date("2016-08-01")), - new Pair<>("timeInput", decision.time("12:00:00Z")), - new Pair<>("dateAndTimeInput", decision.dateAndTime("2016-08-01T11:00:00Z")) - )), - "r1" - ) - ); + "decision", + "simple-decision-primitive-type-inputs-sfeel-input-entries-single-output-first-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("booleanInput", true), + new Pair<>("numberInput", decision.number("-1")), + new Pair<>("textInput", "abc"), + new Pair<>("enumerationInput", "e1"), + new Pair<>("dateInput", decision.date("2016-08-01")), + new Pair<>("timeInput", decision.time("12:00:00Z")), + new Pair<>("dateAndTimeInput", decision.dateAndTime("2016-08-01T11:00:00Z")) + )), + "r1" + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputAnyHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-any-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - null - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-any-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + null + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputCollectCountHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-collect-count-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - decision.number("4") - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-collect-count-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + decision.number("4") + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputCollectHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-collect-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - Arrays.asList("r5", "r4", "r3", "r2") - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-collect-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + Arrays.asList("r5", "r4", "r3", "r2") + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputCollectMinHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-collect-min-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - decision.number("1") - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-collect-min-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + decision.number("1") + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputCollectSumHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-collect-sum-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - decision.number("10") - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-collect-sum-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + decision.number("10") + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputFirstHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-first-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - "r5" - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-first-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + "r5" + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputOutputOrderHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-output-order-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - Arrays.asList("r5", "r4", "r3", "r2") - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-output-order-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + Arrays.asList("r5", "r4", "r3", "r2") + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputPriorityHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-priority-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - "r5" - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-priority-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + "r5" + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputRuleOrderHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-rule-order-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - Arrays.asList("r5", "r4", "r3", "r2") - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-rule-order-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + Arrays.asList("r5", "r4", "r3", "r2") + )); } @Test public void testSimpleDecisionPrimitiveTypeInputsSingleOutputUniqueHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-inputs-single-output-unique-hit-policy", - makeInformationRequirements(Arrays.asList( - )), - "r2" - ) - ); + "decision", + "simple-decision-primitive-type-inputs-single-output-unique-hit-policy", + makeInformationRequirements(Collections.emptyList()), + "r2" + )); } @Test public void testSimpleDecisionPrimitiveTypeListInputsFeelInputEntriesSingleOutputUniqueHitPolicy() throws Exception { doTest(new DecisionTestConfig( - "decision", - "simple-decision-primitive-type-list-inputs-feel-input-entries-single-output-unique-hit-policy", - makeInformationRequirements(Arrays.asList( - new Pair<>("textInput", "1"), - new Pair<>("numberInput", decision.number("1")) - )), - null - ) - ); + "decision", + "simple-decision-primitive-type-list-inputs-feel-input-entries-single-output-unique-hit-policy", + makeInformationRequirements(Arrays.asList( + new Pair<>("textInput", "1"), + new Pair<>("numberInput", decision.number("1")) + )), + null + )); } @Override diff --git a/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedLiteralDMNInterpreterTest.java b/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedLiteralDMNInterpreterTest.java index 2ec8872ae..25fb575a3 100644 --- a/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedLiteralDMNInterpreterTest.java +++ b/dmn-signavio/src/test/java/com/gs/dmn/signavio/runtime/interpreter/ExportedLiteralDMNInterpreterTest.java @@ -22,6 +22,7 @@ import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigDecimal; import java.util.Arrays; +import java.util.Collections; public class ExportedLiteralDMNInterpreterTest extends AbstractSignavioDMNInterpreterTest { private final DefaultSignavioBaseDecision decision = new DefaultSignavioBaseDecision(); @@ -52,7 +53,7 @@ public void testComplexLiteralExpression() throws Exception { doTest(new DecisionTestConfig( "monthly", "simple-decision-feel-complex-literal-expression", - makeInformationRequirements(Arrays.asList( + makeInformationRequirements(Collections.singletonList( new Pair<>("loan", new Context().add("principal", decision.number("1024")).add("rate", decision.number("5")).add("term", decision.number("25"))) )), decision.number("1024")) diff --git a/dmn-signavio/src/test/java/com/gs/dmn/signavio/testlab/expression/ExpressionTest.java b/dmn-signavio/src/test/java/com/gs/dmn/signavio/testlab/expression/ExpressionTest.java index 7b4ba29d5..eed85994b 100644 --- a/dmn-signavio/src/test/java/com/gs/dmn/signavio/testlab/expression/ExpressionTest.java +++ b/dmn-signavio/src/test/java/com/gs/dmn/signavio/testlab/expression/ExpressionTest.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -45,7 +46,7 @@ public void testToFEELExpression() { assertEquals("\"e1\"", new EnumerationLiteral("e1", "1").toFEELExpression()); assertEquals("{null : null, null : null}", ((Expression) new ComplexExpression(Arrays.asList(new Slot(), new Slot()))).toFEELExpression()); - assertEquals("[null]", ((Expression) new ListExpression(Arrays.asList(new NumberLiteral()))).toFEELExpression()); + assertEquals("[null]", ((Expression) new ListExpression(Collections.singletonList(new NumberLiteral()))).toFEELExpression()); } @Test @@ -82,7 +83,7 @@ public void testToString() { assertEquals("EnumerationLiteral(e1, 1)", new EnumerationLiteral("e1", "1").toString()); assertEquals("ComplexExpression([Slot(null, null, null, null), Slot(null, null, null, null)])", ((Expression) new ComplexExpression(Arrays.asList(new Slot(), new Slot()))).toString()); - assertEquals("ListExpression([NumberLiteral(null)])", ((Expression) new ListExpression(Arrays.asList(new NumberLiteral()))).toString()); + assertEquals("ListExpression([NumberLiteral(null)])", ((Expression) new ListExpression(Collections.singletonList(new NumberLiteral()))).toString()); } private List makeExpressions() { diff --git a/dmn-signavio/src/test/java/com/gs/dmn/signavio/transformation/CorrectPathsInDecisionsTransformerTest.java b/dmn-signavio/src/test/java/com/gs/dmn/signavio/transformation/CorrectPathsInDecisionsTransformerTest.java index d2f935054..d6f2d64da 100644 --- a/dmn-signavio/src/test/java/com/gs/dmn/signavio/transformation/CorrectPathsInDecisionsTransformerTest.java +++ b/dmn-signavio/src/test/java/com/gs/dmn/signavio/transformation/CorrectPathsInDecisionsTransformerTest.java @@ -45,7 +45,7 @@ public void testConfigWhenNoConfig() { configTransformer(null); fail("Should throw exception"); } catch (Exception e) { - assertTrue(e instanceof DMNRuntimeException); + assertInstanceOf(DMNRuntimeException.class, e); assertEquals("Invalid transformer configuration: Incorrect or missing 'corrections' node", e.getMessage()); } } @@ -58,7 +58,7 @@ public void testConfigWhenNullCorrections() { ); fail("Should throw exception"); } catch (Exception e) { - assertTrue(e instanceof DMNRuntimeException); + assertInstanceOf(DMNRuntimeException.class, e); assertEquals("Invalid transformer configuration: Incorrect or missing 'corrections' node", e.getMessage()); } } @@ -71,7 +71,7 @@ public void testConfigWhenEmptyCorrections() { ); fail("Should throw exception"); } catch (Exception e) { - assertTrue(e instanceof DMNRuntimeException); + assertInstanceOf(DMNRuntimeException.class, e); assertEquals("Invalid transformer configuration: Incorrect or missing 'correction' nodes", e.getMessage()); } } @@ -84,7 +84,7 @@ public void testConfigWhenCorrectionIsNotMap() { ); fail("Should throw exception"); } catch (Exception e) { - assertTrue(e instanceof DMNRuntimeException); + assertInstanceOf(DMNRuntimeException.class, e); assertEquals("Invalid transformer configuration: Incorrect or missing 'correction' nodes", e.getMessage()); } } @@ -97,7 +97,7 @@ public void testConfigWhenCorrectionIsNotListOfMap() { ); fail("Should throw exception"); } catch (Exception e) { - assertTrue(e instanceof DMNRuntimeException); + assertInstanceOf(DMNRuntimeException.class, e); assertEquals("Invalid transformer configuration: Incorrect or missing 'correction' nodes", e.getMessage()); } } @@ -110,7 +110,7 @@ public void testConfigWhenCorrectionIsIncorrect() { ); fail("Should throw exception"); } catch (Exception e) { - assertTrue(e instanceof DMNRuntimeException); + assertInstanceOf(DMNRuntimeException.class, e); assertEquals("Invalid transformer configuration: Incorrect fields in 'correction' node", e.getMessage()); } } @@ -123,7 +123,7 @@ public void testConfigWhenCorrectionIndexesAreIncorrect() { ); fail("Should throw exception"); } catch (Exception e) { - assertTrue(e instanceof DMNRuntimeException); + assertInstanceOf(DMNRuntimeException.class, e); assertEquals("Invalid transformer configuration: Unexpected comma separated list of indexes '{abc=abc}'", e.getMessage()); } } @@ -161,10 +161,10 @@ public void testTransformationNormalFlow() throws Exception { String decisionName = "processPriorIssues"; TDRGElement drgElement = repository.findDRGElementByName(decisionName); - assertTrue(drgElement instanceof TDecision); + assertInstanceOf(TDecision.class, drgElement); TDecision decision = (TDecision) drgElement; TExpression expression = repository.expression(decision); - assertTrue(expression instanceof TDecisionTable); + assertInstanceOf(TDecisionTable.class, expression); TDecisionTable decisionTable = (TDecisionTable) expression; assertEquals("applicant.priorIssues", decisionTable.getInput().get(0).getInputExpression().getText()); assertEquals("(count(applicant.priorIssues)*(-5))", decisionTable.getRule().get(4).getOutputEntry().get(0).getText()); @@ -179,10 +179,10 @@ public void testTransformationWhenNoConfiguration() throws Exception { String decisionName = "processPriorIssues"; TDRGElement drgElement = repository.findDRGElementByName(decisionName); - assertTrue(drgElement instanceof TDecision); + assertInstanceOf(TDecision.class, drgElement); TDecision decision = (TDecision) drgElement; TExpression expression = repository.expression(decision); - assertTrue(expression instanceof TDecisionTable); + assertInstanceOf(TDecisionTable.class, expression); TDecisionTable decisionTable = (TDecisionTable) expression; assertEquals("applicant.priorIssues", decisionTable.getInput().get(0).getInputExpression().getText()); assertEquals("(count(applicant.priorIssues)*(-5))", decisionTable.getRule().get(4).getOutputEntry().get(0).getText()); diff --git a/dmn-signavio/src/test/java/com/gs/dmn/signavio/transformation/InOutCorrectPathsInDecisionsTransformerTest.java b/dmn-signavio/src/test/java/com/gs/dmn/signavio/transformation/InOutCorrectPathsInDecisionsTransformerTest.java index fe371875a..dc05a9379 100644 --- a/dmn-signavio/src/test/java/com/gs/dmn/signavio/transformation/InOutCorrectPathsInDecisionsTransformerTest.java +++ b/dmn-signavio/src/test/java/com/gs/dmn/signavio/transformation/InOutCorrectPathsInDecisionsTransformerTest.java @@ -18,23 +18,17 @@ import com.gs.dmn.ast.TDecision; import com.gs.dmn.ast.TDecisionTable; import com.gs.dmn.ast.TExpression; -import com.gs.dmn.runtime.DMNRuntimeException; import com.gs.dmn.runtime.Pair; import com.gs.dmn.signavio.SignavioDMNModelRepository; import com.gs.dmn.signavio.testlab.TestLab; -import com.gs.dmn.signavio.transformation.config.Correction; -import com.gs.dmn.signavio.transformation.config.DecisionTableCorrection; import org.junit.jupiter.api.Test; import java.io.File; -import java.io.IOException; import java.net.URI; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.Map; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; public class InOutCorrectPathsInDecisionsTransformerTest extends AbstractSignavioFileTransformerTest { private static final ObjectMapper MAPPER = new ObjectMapper(); @@ -49,25 +43,25 @@ public void testTransformationNormalFlow() throws Exception { // Check decision with no in-out pattern TDRGElement firstDecision = repository.findDRGElementByName("processPriorIssues"); - assertTrue(firstDecision instanceof TDecision); + assertInstanceOf(TDecision.class, firstDecision); TExpression firstExpression = repository.expression(firstDecision); - assertTrue(firstExpression instanceof TDecisionTable); + assertInstanceOf(TDecisionTable.class, firstExpression); TDecisionTable firstDecisionTable = (TDecisionTable) firstExpression; assertEquals("(count(applicant.priorIssues)*(-5))", firstDecisionTable.getRule().get(4).getOutputEntry().get(0).getText()); // Check decision with in-out pattern for inputs TDRGElement secondDecision = repository.findDRGElementByName("compareAgainstLendingThreshold"); - assertTrue(secondDecision instanceof TDecision); + assertInstanceOf(TDecision.class, secondDecision); TExpression secondExpression = repository.expression(secondDecision); - assertTrue(secondExpression instanceof TDecisionTable); + assertInstanceOf(TDecisionTable.class, secondExpression); TDecisionTable secondDecisionTable = (TDecisionTable) secondExpression; assertEquals("lendingThreshold.lendingThreshold", secondDecisionTable.getRule().get(1).getOutputEntry().get(0).getText()); // Check decision with in-out pattern for inputs TDRGElement thirdDecision = repository.findDRGElementByName("incorrectDecision"); - assertTrue(thirdDecision instanceof TDecision); + assertInstanceOf(TDecision.class, thirdDecision); TExpression thirdExpression = repository.expression(thirdDecision); - assertTrue(thirdExpression instanceof TDecisionTable); + assertInstanceOf(TDecisionTable.class, thirdExpression); TDecisionTable thirdDecisionTable = (TDecisionTable) thirdExpression; assertEquals("assessIssueRisk", thirdDecisionTable.getRule().get(1).getOutputEntry().get(0).getText()); } @@ -81,7 +75,7 @@ public void testTransformationWhenEmptyRepo() { } @Test - public void testTransformationWhenEmptyConfig() {; + public void testTransformationWhenEmptyConfig() { DMNModelRepository repository = new DMNModelRepository(); transformer.transform(repository); Pair> res = transformer.transform(repository, null); diff --git a/dmn-signavio/src/test/java/com/gs/dmn/signavio/validation/RuleDescriptionValidatorTest.java b/dmn-signavio/src/test/java/com/gs/dmn/signavio/validation/RuleDescriptionValidatorTest.java index 0621633fb..09b0df36f 100644 --- a/dmn-signavio/src/test/java/com/gs/dmn/signavio/validation/RuleDescriptionValidatorTest.java +++ b/dmn-signavio/src/test/java/com/gs/dmn/signavio/validation/RuleDescriptionValidatorTest.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -71,7 +72,7 @@ public void testValidateIncorrectStrings() { List actualErrors = new ArrayList<>(); validator.validate(repository, null, makeDecision(), 0, description, actualErrors); - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(name='Test'): error: Description of rule 0 in decision 'Test' contains illegal sequence 'string(-)'" ); assertEquals(expectedErrors, actualErrors); @@ -83,7 +84,7 @@ public void testValidateIncorrectCharacters() { List actualErrors = new ArrayList<>(); validator.validate(repository, null, makeDecision(), 0, description, actualErrors); - List expectedErrors = Arrays.asList( + List expectedErrors = Collections.singletonList( "(name='Test'): error: Description of rule 0 in decision 'Test' contains illegal sequence 'NO-BREAK SPACE'" ); assertEquals(expectedErrors, actualErrors); diff --git a/dmn-tck-it/dmn-tck-it-kotlin-translator/src/test/java/com/gs/dmn/generated/tck/TestEqualsAndHashCode.java b/dmn-tck-it/dmn-tck-it-kotlin-translator/src/test/java/com/gs/dmn/generated/tck/TestEqualsAndHashCode.java index 0b87c71ef..f5a5f4ada 100644 --- a/dmn-tck-it/dmn-tck-it-kotlin-translator/src/test/java/com/gs/dmn/generated/tck/TestEqualsAndHashCode.java +++ b/dmn-tck-it/dmn-tck-it-kotlin-translator/src/test/java/com/gs/dmn/generated/tck/TestEqualsAndHashCode.java @@ -19,7 +19,7 @@ import java.math.BigDecimal; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class TestEqualsAndHashCode { @Test @@ -28,9 +28,9 @@ public void testEquals() { TLoan loan2 = new TLoanImpl(BigDecimal.ONE, BigDecimal.TEN, BigDecimal.ZERO); assertEquals(loan1, loan1); assertEquals(loan2, loan2); - assertFalse(loan1.equals(null)); - assertFalse(loan1.equals(loan2)); - assertFalse(loan2.equals(loan1)); + assertNotEquals(null, loan1); + assertNotEquals(loan1, loan2); + assertNotEquals(loan2, loan1); } @Test diff --git a/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/tck/TestEqualsAndHashCode.java b/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/tck/TestEqualsAndHashCode.java index 0b87c71ef..f5a5f4ada 100644 --- a/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/tck/TestEqualsAndHashCode.java +++ b/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/tck/TestEqualsAndHashCode.java @@ -19,7 +19,7 @@ import java.math.BigDecimal; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class TestEqualsAndHashCode { @Test @@ -28,9 +28,9 @@ public void testEquals() { TLoan loan2 = new TLoanImpl(BigDecimal.ONE, BigDecimal.TEN, BigDecimal.ZERO); assertEquals(loan1, loan1); assertEquals(loan2, loan2); - assertFalse(loan1.equals(null)); - assertFalse(loan1.equals(loan2)); - assertFalse(loan2.equals(loan1)); + assertNotEquals(null, loan1); + assertNotEquals(loan1, loan2); + assertNotEquals(loan2, loan1); } @Test diff --git a/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/tck/cl3_0020_vacation_days/VacationDaysLambdaTest.java b/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/tck/cl3_0020_vacation_days/VacationDaysLambdaTest.java index ab1ea32c1..b19221ab8 100644 --- a/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/tck/cl3_0020_vacation_days/VacationDaysLambdaTest.java +++ b/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/tck/cl3_0020_vacation_days/VacationDaysLambdaTest.java @@ -26,7 +26,7 @@ * Handler for requests to Lambda function for DRG elements in model 0020-vacation-days. */ public class VacationDaysLambdaTest { - private Executor executor = new Executor(new ModelElementRegistry()); + private final Executor executor = new Executor(new ModelElementRegistry()); @Test public void testExecute() {