From 7a7bd2e2fcb3dcb1044fc24cf168c45e59d807b9 Mon Sep 17 00:00:00 2001 From: Yeser Amer Date: Tue, 23 Apr 2024 09:56:24 +0200 Subject: [PATCH 01/10] New test missing header (#5859) --- .../dmn/openapi/impl/FEELSchemaEnumTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELSchemaEnumTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELSchemaEnumTest.java index 70704d44524..4dd1d0933ed 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELSchemaEnumTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELSchemaEnumTest.java @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.kie.dmn.openapi.impl; From 0a6561b2ac164efb2af5eac18961a62e7e21191a Mon Sep 17 00:00:00 2001 From: Mario Fusco Date: Tue, 23 Apr 2024 15:18:01 +0200 Subject: [PATCH 02/10] =?UTF-8?q?[KIE-1106]=20allow=20to=20configure=20Kie?= =?UTF-8?q?Base=20and=20KieSession=20also=20via=20applica=E2=80=A6=20(#586?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [KIE-1106] allow to configure KieBase and KieSession also via application.properties in quarkus extension * wip * wip * split quarkus extension test module to check configuration from both kmodule.xml and application.properties * add warning when a kmodule.xml is ignored --- .../kproject/models/KieBaseModelImpl.java | 16 +- .../kproject/models/KieModuleModelImpl.java | 14 -- .../common/DroolsModelBuildContext.java | 10 +- .../AbstractDroolsModelBuildContext.java | 22 +- .../project/KieModuleModelWrapper.java | 25 ++- .../project/KieSessionModelBuilder.java | 18 +- .../model/codegen/project/RuleCodegen.java | 40 +++- .../deployment/DroolsAssetsProcessor.java | 97 ++++++++- .../pom.xml | 204 ++++++++++++++++++ .../quarkus/test/kmodule}/ProbeCounter.java | 2 +- .../quarkus/test/kmodule}/ProbeEvent.java | 2 +- .../quarkus/test/kmodule}/StockTick.java | 2 +- .../test/kmodule}/TestableResource.java | 4 +- .../src/main/resources/META-INF/kmodule.xml | 16 -- .../src/main/resources/application.properties | 21 ++ .../src/main/resources/org/drools/cep/cep.drl | 2 +- .../main/resources/org/drools/probe/probe.drl | 4 +- .../src/main/resources/org/drools/tms/tms.drl | 0 .../org/drools/quarkus/test/TestableIT.java | 0 .../src/main/resources/application.properties | 15 +- drools-quarkus-extension/pom.xml | 3 +- 21 files changed, 423 insertions(+), 94 deletions(-) create mode 100644 drools-quarkus-extension/drools-quarkus-integration-test-kmodule/pom.xml rename drools-quarkus-extension/{drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test => drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule}/ProbeCounter.java (96%) rename drools-quarkus-extension/{drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test => drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule}/ProbeEvent.java (97%) rename drools-quarkus-extension/{drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test => drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule}/StockTick.java (98%) rename drools-quarkus-extension/{drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test => drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule}/TestableResource.java (94%) rename drools-quarkus-extension/{drools-quarkus-integration-test => drools-quarkus-integration-test-kmodule}/src/main/resources/META-INF/kmodule.xml (74%) create mode 100644 drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/application.properties rename drools-quarkus-extension/{drools-quarkus-integration-test => drools-quarkus-integration-test-kmodule}/src/main/resources/org/drools/cep/cep.drl (75%) rename drools-quarkus-extension/{drools-quarkus-integration-test => drools-quarkus-integration-test-kmodule}/src/main/resources/org/drools/probe/probe.drl (75%) rename drools-quarkus-extension/{drools-quarkus-integration-test => drools-quarkus-integration-test-kmodule}/src/main/resources/org/drools/tms/tms.drl (100%) rename drools-quarkus-extension/{drools-quarkus-integration-test => drools-quarkus-integration-test-kmodule}/src/test/java/org/drools/quarkus/test/TestableIT.java (100%) diff --git a/drools-compiler/src/main/java/org/drools/compiler/kproject/models/KieBaseModelImpl.java b/drools-compiler/src/main/java/org/drools/compiler/kproject/models/KieBaseModelImpl.java index ff42cd4d16d..5f0844c4c24 100644 --- a/drools-compiler/src/main/java/org/drools/compiler/kproject/models/KieBaseModelImpl.java +++ b/drools-compiler/src/main/java/org/drools/compiler/kproject/models/KieBaseModelImpl.java @@ -85,8 +85,11 @@ public class KieBaseModelImpl public KieBaseModelImpl() { } - public KieBaseModelImpl(KieModuleModel kModule, - String name) { + public KieBaseModelImpl(String name) { + this(null, name); + } + + public KieBaseModelImpl(KieModuleModel kModule, String name) { this.kModule = kModule; this.includes = new HashSet<>(); this.name = name; @@ -175,15 +178,6 @@ public KieBaseModel removeKieSessionModel(String qName) { return this; } - public void moveKSession(String oldQName, - String newQName) { - Map newMap = new HashMap<>(); - newMap.putAll( this.kSessions ); - KieSessionModel kieSessionModel = newMap.remove( oldQName ); - newMap.put(newQName, kieSessionModel); - setKSessions( newMap ); - } - public List getRuleTemplates() { return Collections.unmodifiableList( ruleTemplates ); } diff --git a/drools-compiler/src/main/java/org/drools/compiler/kproject/models/KieModuleModelImpl.java b/drools-compiler/src/main/java/org/drools/compiler/kproject/models/KieModuleModelImpl.java index 60e6e4ba872..384c7b0592a 100644 --- a/drools-compiler/src/main/java/org/drools/compiler/kproject/models/KieModuleModelImpl.java +++ b/drools-compiler/src/main/java/org/drools/compiler/kproject/models/KieModuleModelImpl.java @@ -83,20 +83,6 @@ public void removeKieBaseModel(String qName) { setKBases( newMap ); } - /* (non-Javadoc) - * @see org.kie.kModule.KieProject#removeKieBaseModel(org.kie.kModule.KieBaseModel) - */ - public void moveKBase(String oldQName, String newQName) { - Map newMap = new HashMap<>(); - newMap.putAll( this.kBases ); - KieBaseModel kieBaseModel = newMap.remove( oldQName ); - newMap.put( newQName, kieBaseModel); - setKBases( newMap ); - } - - /* (non-Javadoc) - * @see org.kie.kModule.KieProject#getKieBaseModels() - */ public Map getKieBaseModels() { return Collections.unmodifiableMap( kBases ); } diff --git a/drools-model/drools-codegen-common/src/main/java/org/drools/codegen/common/DroolsModelBuildContext.java b/drools-model/drools-codegen-common/src/main/java/org/drools/codegen/common/DroolsModelBuildContext.java index b3f4ffe37c6..a5194eca9ca 100644 --- a/drools-model/drools-codegen-common/src/main/java/org/drools/codegen/common/DroolsModelBuildContext.java +++ b/drools-model/drools-codegen-common/src/main/java/org/drools/codegen/common/DroolsModelBuildContext.java @@ -18,15 +18,15 @@ */ package org.drools.codegen.common; -import org.drools.codegen.common.di.DependencyInjectionAnnotator; -import org.drools.codegen.common.rest.RestAnnotator; - import java.io.File; import java.util.Collection; import java.util.Optional; import java.util.Properties; import java.util.function.Predicate; +import org.drools.codegen.common.di.DependencyInjectionAnnotator; +import org.drools.codegen.common.rest.RestAnnotator; + public interface DroolsModelBuildContext { String APPLICATION_PROPERTIES_FILE_NAME = "application.properties"; @@ -83,16 +83,12 @@ interface Builder { Builder withApplicationProperties(File... files); -// Builder withAddonsConfig(AddonsConfig addonsConfig); - Builder withClassAvailabilityResolver(Predicate classAvailabilityResolver); Builder withClassLoader(ClassLoader classLoader); Builder withAppPaths(AppPaths appPaths); -// Builder withGAV(KogitoGAV gav); - DroolsModelBuildContext build(); } } diff --git a/drools-model/drools-codegen-common/src/main/java/org/drools/codegen/common/context/AbstractDroolsModelBuildContext.java b/drools-model/drools-codegen-common/src/main/java/org/drools/codegen/common/context/AbstractDroolsModelBuildContext.java index eb732b40ebf..584430d4095 100644 --- a/drools-model/drools-codegen-common/src/main/java/org/drools/codegen/common/context/AbstractDroolsModelBuildContext.java +++ b/drools-model/drools-codegen-common/src/main/java/org/drools/codegen/common/context/AbstractDroolsModelBuildContext.java @@ -18,20 +18,10 @@ */ package org.drools.codegen.common.context; -import org.drools.codegen.common.AppPaths; -import org.drools.codegen.common.DroolsModelApplicationPropertyProvider; -import org.drools.codegen.common.DroolsModelBuildContext; -import org.drools.codegen.common.di.DependencyInjectionAnnotator; -import org.drools.codegen.common.rest.RestAnnotator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.lang.model.SourceVersion; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.nio.file.Paths; import java.text.MessageFormat; import java.util.Collection; import java.util.HashMap; @@ -41,6 +31,16 @@ import java.util.Properties; import java.util.function.Predicate; +import javax.lang.model.SourceVersion; + +import org.drools.codegen.common.AppPaths; +import org.drools.codegen.common.DroolsModelApplicationPropertyProvider; +import org.drools.codegen.common.DroolsModelBuildContext; +import org.drools.codegen.common.di.DependencyInjectionAnnotator; +import org.drools.codegen.common.rest.RestAnnotator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public abstract class AbstractDroolsModelBuildContext implements DroolsModelBuildContext { public static final String DEFAULT_GROUP_ID = "org.kie.kogito"; @@ -149,9 +149,9 @@ protected abstract static class AbstractBuilder implements Builder { protected String packageName = DEFAULT_PACKAGE_NAME; protected DroolsModelApplicationPropertyProvider applicationProperties = DroolsModelApplicationPropertyProvider.of(new Properties()); -// protected AddonsConfig addonsConfig; protected ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); protected Predicate classAvailabilityResolver = this::hasClass; + // default fallback value (usually overridden) protected AppPaths appPaths = AppPaths.fromProjectDir(new File(".").toPath()); diff --git a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/KieModuleModelWrapper.java b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/KieModuleModelWrapper.java index 9731c26dc70..307bcef4682 100644 --- a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/KieModuleModelWrapper.java +++ b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/KieModuleModelWrapper.java @@ -18,10 +18,6 @@ */ package org.drools.model.codegen.project; -import org.drools.compiler.kproject.models.KieModuleModelImpl; -import org.kie.api.builder.model.KieBaseModel; -import org.kie.api.builder.model.KieModuleModel; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -33,6 +29,10 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import org.drools.compiler.kproject.models.KieModuleModelImpl; +import org.kie.api.builder.model.KieBaseModel; +import org.kie.api.builder.model.KieModuleModel; + import static org.drools.compiler.kie.builder.impl.KieBuilderImpl.setDefaultsforEmptyKieModule; /** @@ -73,6 +73,23 @@ private static KieModuleModel lookupKieModuleModel(Path[] resourcePaths) { return new KieModuleModelImpl(); } + static boolean hasKieModule(Path[] resourcePaths) { + for (Path resourcePath : resourcePaths) { + if (resourcePath.toString().endsWith(".jar")) { + InputStream inputStream = fromJarFile(resourcePath); + if (inputStream != null) { + return true; + } + } else { + Path moduleXmlPath = resourcePath.resolve(KieModuleModelImpl.KMODULE_JAR_PATH.asString()); + if (Files.exists(moduleXmlPath)) { + return true; + } + } + } + return false; + } + /* * This is really a modified duplicate of org.drools.quarkus.deployment.ResourceCollector#fromJarFile(java.nio.file.Path). * TODO: Refactor https://issues.redhat.com/browse/DROOLS-7254 diff --git a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/KieSessionModelBuilder.java b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/KieSessionModelBuilder.java index d0542bbf8a7..b8a7fb0eba6 100644 --- a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/KieSessionModelBuilder.java +++ b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/KieSessionModelBuilder.java @@ -18,12 +18,6 @@ */ package org.drools.model.codegen.project; -import org.drools.codegen.common.DroolsModelBuildContext; -import org.drools.codegen.common.GeneratedFile; -import org.drools.codegen.common.GeneratedFileType; -import org.drools.model.codegen.execmodel.ModelSourceClass; -import org.kie.api.builder.model.KieBaseModel; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -33,6 +27,12 @@ import java.util.Map; import java.util.Objects; +import org.drools.codegen.common.DroolsModelBuildContext; +import org.drools.codegen.common.GeneratedFile; +import org.drools.codegen.common.GeneratedFileType; +import org.drools.model.codegen.execmodel.ModelSourceClass; +import org.kie.api.builder.model.KieBaseModel; + import static java.util.stream.Collectors.toList; /** @@ -45,8 +45,12 @@ public class KieSessionModelBuilder { private DroolsModelBuildContext context; public KieSessionModelBuilder(DroolsModelBuildContext context, Collection packageSources) { + this(context, packageSources, KieModuleModelWrapper.fromResourcePaths(context.getAppPaths().getPaths()).kieBaseModels()); + } + + public KieSessionModelBuilder(DroolsModelBuildContext context, Collection packageSources, Map kieBaseModels) { this.context = context; - this.kieBaseModels = KieModuleModelWrapper.fromResourcePaths(context.getAppPaths().getPaths()).kieBaseModels(); + this.kieBaseModels = kieBaseModels; this.modelByKBase = getModelByKBase(packageSources, this.kieBaseModels); } diff --git a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/RuleCodegen.java b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/RuleCodegen.java index 3a0de0a66fa..cef015f9638 100644 --- a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/RuleCodegen.java +++ b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/project/RuleCodegen.java @@ -18,6 +18,11 @@ */ package org.drools.model.codegen.project; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Objects; + import org.drools.codegen.common.DroolsModelBuildContext; import org.drools.codegen.common.GeneratedFile; import org.drools.drl.extensions.DecisionTableFactory; @@ -28,9 +33,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Collection; -import java.util.Collections; -import java.util.Objects; +import static org.drools.model.codegen.project.KieModuleModelWrapper.hasKieModule; public class RuleCodegen { @@ -47,11 +50,11 @@ public static RuleCodegen ofResources(DroolsModelBuildContext context, Collectio private final Collection resources; private Collection packageModels; - private Collection kmoduleKieBaseModels; private boolean hotReloadMode = false; private final boolean decisionTableSupported; + private Map kieBaseModels; private RuleCodegen(DroolsModelBuildContext context, Collection resources) { Objects.requireNonNull(context, "context cannot be null"); @@ -73,10 +76,16 @@ protected Collection internalGenerate() { Collection generatedFiles = droolsModelBuilder.generateCanonicalModelSources(); if (!droolsModelBuilder.hasRuleUnits()) { - KieSessionModelBuilder kieSessionModelBuilder = new KieSessionModelBuilder(context(), - droolsModelBuilder.packageSources()); - generatedFiles.addAll(kieSessionModelBuilder.generate()); - this.kmoduleKieBaseModels = kieSessionModelBuilder.getKieBaseModels().values(); + if (kieBaseModels != null) { + if (hasKieModule(context.getAppPaths().getPaths())) { + LOGGER.warn("The Kie Module configuration has been provided externally, so the existing kmodule.xml file will be ignored."); + } + generatedFiles.addAll(new KieSessionModelBuilder(context(), droolsModelBuilder.packageSources(), kieBaseModels).generate()); + } else { + KieSessionModelBuilder kieSessionModelBuilder = new KieSessionModelBuilder(context(), droolsModelBuilder.packageSources()); + generatedFiles.addAll(kieSessionModelBuilder.generate()); + this.kieBaseModels = kieSessionModelBuilder.getKieBaseModels(); + } } if (LOGGER.isDebugEnabled()) { @@ -110,12 +119,23 @@ public RuleCodegen withHotReloadMode() { hotReloadMode = true; return this; } - + + public RuleCodegen withKieBaseModels(Map kieBaseModels) { + if (!kieBaseModels.isEmpty()) { + this.kieBaseModels = kieBaseModels; + } + return this; + } + public Collection getPackageModels() { return packageModels; } public Collection getKmoduleKieBaseModels() { - return kmoduleKieBaseModels; + return hasKieBaseModels() ? kieBaseModels.values() : Collections.emptyList(); + } + + public boolean hasKieBaseModels() { + return kieBaseModels != null && !kieBaseModels.isEmpty(); } } diff --git a/drools-quarkus-extension/drools-quarkus-deployment/src/main/java/org/drools/quarkus/deployment/DroolsAssetsProcessor.java b/drools-quarkus-extension/drools-quarkus-deployment/src/main/java/org/drools/quarkus/deployment/DroolsAssetsProcessor.java index ded98cfc90e..08c68ad06de 100644 --- a/drools-quarkus-extension/drools-quarkus-deployment/src/main/java/org/drools/quarkus/deployment/DroolsAssetsProcessor.java +++ b/drools-quarkus-extension/drools-quarkus-deployment/src/main/java/org/drools/quarkus/deployment/DroolsAssetsProcessor.java @@ -19,6 +19,8 @@ package org.drools.quarkus.deployment; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -39,12 +41,22 @@ import org.drools.codegen.common.DroolsModelBuildContext; import org.drools.codegen.common.GeneratedFile; import org.drools.codegen.common.GeneratedFileType; +import org.drools.compiler.kproject.models.KieBaseModelImpl; import org.drools.model.codegen.execmodel.PackageModel; import org.drools.model.codegen.project.RuleCodegen; import org.drools.quarkus.util.deployment.GlobalsBuildItem; import org.drools.quarkus.util.deployment.KmoduleKieBaseModelsBuiltItem; import org.drools.quarkus.util.deployment.PatternsTypesBuildItem; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.kie.api.builder.model.KieBaseModel; +import org.kie.api.builder.model.KieSessionModel; +import org.kie.api.conf.EventProcessingOption; +import org.kie.api.conf.KieBaseMutabilityOption; +import org.kie.api.conf.PrototypesOption; +import org.kie.api.conf.SessionsPoolOption; import org.kie.api.io.Resource; +import org.kie.api.runtime.conf.ClockTypeOption; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,6 +85,8 @@ public class DroolsAssetsProcessor { private static final String FEATURE = "drools"; + private static final String CONFIG_PREFIX = "drools.kbase."; + @BuildStep public FeatureBuildItem feature() { return new FeatureBuildItem(FEATURE); @@ -87,12 +101,12 @@ public void generateSources( BuildProducer generatedBean BuildProducer kbaseModelsBI, BuildProducer globalsBI, BuildProducer jaxrsProducer) { - DroolsModelBuildContext context = - createDroolsBuildContext(root.getPaths(), combinedIndexBuildItem.getIndex()); + + DroolsModelBuildContext context = createDroolsBuildContext(root.getPaths(), combinedIndexBuildItem.getIndex()); Collection resources = ResourceCollector.fromPaths(context.getAppPaths().getPaths()); - RuleCodegen ruleCodegen = ofResources(context, resources); + RuleCodegen ruleCodegen = ofResources(context, resources).withKieBaseModels(readKieBaseModels()); Collection generatedFiles = ruleCodegen.generate(); generatedFiles.addAll(getRuleUnitDefProducerSource(combinedIndexBuildItem.getIndex())); @@ -115,7 +129,7 @@ public void generateSources( BuildProducer generatedBean registerResources(generatedFiles, staticResProducer, resource, genResBI); otnClasesBI.produce(new PatternsTypesBuildItem(ruleCodegen.getPackageModels().stream().collect(Collectors.toMap(PackageModel::getName, PackageModel::getOtnsClasses)))); - if (ruleCodegen.getKmoduleKieBaseModels() != null) { + if (ruleCodegen.hasKieBaseModels()) { kbaseModelsBI.produce(new KmoduleKieBaseModelsBuiltItem(ruleCodegen.getKmoduleKieBaseModels())); } globalsBI.produce(new GlobalsBuildItem(ruleCodegen.getPackageModels().stream().collect(Collectors.toMap(PackageModel::getName, PackageModel::getGlobals)))); @@ -128,4 +142,79 @@ public void generateSources( BuildProducer generatedBean .filter(b -> restResourceClassNameSet.contains(b.getName())) .forEach(b -> jaxrsProducer.produce(new GeneratedJaxRsResourceBuildItem(b.getName(), b.getData()))); } + + private Map readKieBaseModels() { + Map kieBaseModels = new HashMap<>(); + Config config = ConfigProvider.getConfig(); + + for (String propertyName : config.getPropertyNames()) { + if (!propertyName.startsWith(CONFIG_PREFIX)) { + continue; + } + + String[] splitProp = propertyName.substring(CONFIG_PREFIX.length()).split("\\."); + if (splitProp.length < 2) { + LOGGER.error("Malformed Drools property: " + propertyName); + continue; + } + + String kBaseName = splitProp[0]; + KieBaseModel kieBaseModel = kieBaseModels.computeIfAbsent(kBaseName, KieBaseModelImpl::new); + switch (splitProp[1]) { + case "packages": + for (String pkg : config.getValue(propertyName, String.class).split("\\,")) { + kieBaseModel.addPackage(pkg); + } + break; + case "default": + kieBaseModel.setDefault( config.getValue(propertyName, Boolean.class) ); + break; + case "prototypes": + kieBaseModel.setPrototypes(PrototypesOption.determinePrototypesOption(config.getValue(propertyName, String.class))); + break; + case "eventProcessingMode": + kieBaseModel.setEventProcessingMode(EventProcessingOption.determineEventProcessingMode(config.getValue(propertyName, String.class))); + break; + case "mutability": + kieBaseModel.setMutability(KieBaseMutabilityOption.determineMutability(config.getValue(propertyName, String.class))); + break; + case "sessionsPool": + kieBaseModel.setSessionsPool(SessionsPoolOption.get(config.getValue(propertyName, Integer.class))); + break; + case "ksessions": + for (String ksession : config.getValue(propertyName, String.class).split("\\,")) { + kieBaseModel.newKieSessionModel(ksession); + } + break; + case "ksession": + if (splitProp.length == 2) { + kieBaseModel.newKieSessionModel(config.getValue(propertyName, String.class)); + } else { + if (splitProp.length < 4) { + LOGGER.error("Malformed Drools property: " + propertyName); + break; + } + + String kSessionName = splitProp[2]; + KieSessionModel kieSessionModel = kieBaseModel.getKieSessionModels().get(kSessionName); + if (kieSessionModel == null) { + kieSessionModel = kieBaseModel.newKieSessionModel(kSessionName); + } + + switch (splitProp[3]) { + case "default": + kieSessionModel.setDefault( config.getValue(propertyName, Boolean.class) ); + break; + case "clockType": + kieSessionModel.setClockType( ClockTypeOption.get(config.getValue(propertyName, String.class) ) ); + break; + } + } + break; + } + + } + + return kieBaseModels; + } } diff --git a/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/pom.xml b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/pom.xml new file mode 100644 index 00000000000..026e9ccfcc8 --- /dev/null +++ b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/pom.xml @@ -0,0 +1,204 @@ + + + + 4.0.0 + + org.drools + drools-quarkus-extension + 999-SNAPSHOT + + + Drools :: Quarkus Extension :: Integration Test :: kmodule xml + drools-quarkus-integration-test-kmodule + + + org.drools.quarkus.integrationtest.kmodule + + + + + org.drools + drools-quarkus + + + org.drools + drools-decisiontables + + + org.drools + drools-drlonyaml-todrl + + + io.quarkus + quarkus-core + + + + + io.quarkus + quarkus-resteasy-reactive + + + org.assertj + assertj-core + + + io.quarkus + quarkus-junit5 + test + + + org.codehaus.plexus + plexus-xml + + + org.apache.maven + maven-xml-impl + + + + + io.rest-assured + rest-assured + test + + + + + org.drools + drools-quarkus-deployment + pom + test + + + * + * + + + + + + + + + + + io.quarkus + quarkus-maven-plugin + ${version.io.quarkus} + + true + ${skipTests} + + + + + + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + maven-failsafe-plugin + + false + + **/*IT.java + + + **/*Test.java + **/Native* + + -Xmx2048m -Xmx4g + + ${session.request.localRepositoryPath.path} + ${session.request.userSettingsFile.path} + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + ban-blacklisted-dependencies + validate + + enforce + + + false + + + + + + + + + + native + + + native + + + + native + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + + + + + + + + + + diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/ProbeCounter.java b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/ProbeCounter.java similarity index 96% rename from drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/ProbeCounter.java rename to drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/ProbeCounter.java index d4aef14055c..75139736947 100644 --- a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/ProbeCounter.java +++ b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/ProbeCounter.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.drools.quarkus.test; +package org.drools.quarkus.test.kmodule; public class ProbeCounter { private int total = 0; diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/ProbeEvent.java b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/ProbeEvent.java similarity index 97% rename from drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/ProbeEvent.java rename to drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/ProbeEvent.java index 6fc14eb7512..4b52165629b 100644 --- a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/ProbeEvent.java +++ b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/ProbeEvent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.drools.quarkus.test; +package org.drools.quarkus.test.kmodule; public class ProbeEvent { diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/StockTick.java b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/StockTick.java similarity index 98% rename from drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/StockTick.java rename to drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/StockTick.java index 837a0e05b85..2ca19b2615c 100644 --- a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/StockTick.java +++ b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/StockTick.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.drools.quarkus.test; +package org.drools.quarkus.test.kmodule; import java.util.Date; diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/TestableResource.java b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/TestableResource.java similarity index 94% rename from drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/TestableResource.java rename to drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/TestableResource.java index ce871881146..e773238925c 100644 --- a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/java/org/drools/quarkus/test/TestableResource.java +++ b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/java/org/drools/quarkus/test/kmodule/TestableResource.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.drools.quarkus.test; +package org.drools.quarkus.test.kmodule; import java.util.Collection; import java.util.List; @@ -100,7 +100,7 @@ public Response testAllPkgsKBase() { List pkgNames = kBase.getKiePackages().stream().map(KiePackage::getName).collect(Collectors.toList()); assertThat(pkgNames) - .containsExactlyInAnyOrder("defaultpkg","org.drools.quarkus.test","org.drools.drl","org.drools.dtable","org.drools.cep","org.drools.tms","org.drools.probe","org.drools.yaml","org.drools.prototype"); + .containsExactlyInAnyOrder("org.drools.quarkus.test.kmodule","org.drools.cep","org.drools.tms","org.drools.probe"); return Response.ok().build(); } diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/META-INF/kmodule.xml b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/META-INF/kmodule.xml similarity index 74% rename from drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/META-INF/kmodule.xml rename to drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/META-INF/kmodule.xml index b5f9c8aec41..97f28d085a4 100644 --- a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/META-INF/kmodule.xml +++ b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/META-INF/kmodule.xml @@ -1,6 +1,5 @@ - - - - - - - - - - - - diff --git a/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/application.properties b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/application.properties new file mode 100644 index 00000000000..56b01162596 --- /dev/null +++ b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/application.properties @@ -0,0 +1,21 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +quarkus.http.port=8080 + diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/org/drools/cep/cep.drl b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/org/drools/cep/cep.drl similarity index 75% rename from drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/org/drools/cep/cep.drl rename to drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/org/drools/cep/cep.drl index b2eac70d970..c25819f6798 100644 --- a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/org/drools/cep/cep.drl +++ b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/org/drools/cep/cep.drl @@ -1,6 +1,6 @@ package org.drools.cep -import org.drools.quarkus.test.StockTick +import org.drools.quarkus.test.kmodule.StockTick rule R when $a : StockTick( company == "DROO" ) diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/org/drools/probe/probe.drl b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/org/drools/probe/probe.drl similarity index 75% rename from drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/org/drools/probe/probe.drl rename to drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/org/drools/probe/probe.drl index 9a2806b6de8..2278dd63ce6 100644 --- a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/org/drools/probe/probe.drl +++ b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/org/drools/probe/probe.drl @@ -1,7 +1,7 @@ package org.drools.probe -import org.drools.quarkus.test.ProbeEvent; -import org.drools.quarkus.test.ProbeCounter; +import org.drools.quarkus.test.kmodule.ProbeEvent; +import org.drools.quarkus.test.kmodule.ProbeCounter; declare ProbeCounter @role (event) diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/org/drools/tms/tms.drl b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/org/drools/tms/tms.drl similarity index 100% rename from drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/org/drools/tms/tms.drl rename to drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/main/resources/org/drools/tms/tms.drl diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/test/java/org/drools/quarkus/test/TestableIT.java b/drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/test/java/org/drools/quarkus/test/TestableIT.java similarity index 100% rename from drools-quarkus-extension/drools-quarkus-integration-test/src/test/java/org/drools/quarkus/test/TestableIT.java rename to drools-quarkus-extension/drools-quarkus-integration-test-kmodule/src/test/java/org/drools/quarkus/test/TestableIT.java diff --git a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/application.properties b/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/application.properties index effa45048b9..b26fc31a187 100644 --- a/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/application.properties +++ b/drools-quarkus-extension/drools-quarkus-integration-test/src/main/resources/application.properties @@ -17,4 +17,17 @@ # under the License. # -drools.prototypes=allowed \ No newline at end of file +drools.prototypes=allowed + +drools.kbase.canDrinkKB.packages=org.drools.drl +drools.kbase.canDrinkKB.ksession.canDrinkKS.default=true + +drools.kbase.canDrinkKBDTable.packages=org.drools.dtable +drools.kbase.canDrinkKBDTable.ksession=canDrinkKSDTable + +drools.kbase.canDrinkKBYaml.packages=org.drools.yaml +drools.kbase.canDrinkKBYaml.ksession=canDrinkKSYaml + +drools.kbase.canDrinkKBPrototype.packages=org.drools.prototype +drools.kbase.canDrinkKBPrototype.prototypes=allowed +drools.kbase.canDrinkKBPrototype.ksession=canDrinkKSPrototype diff --git a/drools-quarkus-extension/pom.xml b/drools-quarkus-extension/pom.xml index 832ba1ffe73..7956dc7c1d1 100644 --- a/drools-quarkus-extension/pom.xml +++ b/drools-quarkus-extension/pom.xml @@ -40,6 +40,7 @@ drools-quarkus drools-quarkus-deployment drools-quarkus-integration-test + drools-quarkus-integration-test-kmodule drools-quarkus-integration-test-hotreload drools-quarkus-ruleunit-integration-test drools-quarkus-quickstart-test @@ -58,4 +59,4 @@ - \ No newline at end of file + From e4b91c7f502ed7a267db075a98ca0d5c74357d46 Mon Sep 17 00:00:00 2001 From: Toshiya Kobayashi Date: Fri, 26 Apr 2024 10:19:50 +0900 Subject: [PATCH 03/10] [incubator-kie-drools-5868] exec-model : in operator with BigDecimal and int (#5869) - Enhance InOperator to handle numeric equals - Convert BigDecimalLiteralExpr for OperatorSpec --- .../drools/model/operators/InOperator.java | 6 +-- .../generator/drlxparse/ConstraintParser.java | 13 ++---- .../operatorspec/NativeOperatorSpec.java | 7 +++- .../execmodel/util/ExpressionUtils.java | 39 +++++++++++++++++ .../bigdecimaltest/BigDecimalTest.java | 42 +++++++++++++++++++ .../drlxparse/ConstraintParserTest.java | 16 ++++++- 6 files changed, 107 insertions(+), 16 deletions(-) create mode 100644 drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/util/ExpressionUtils.java diff --git a/drools-model/drools-canonical-model/src/main/java/org/drools/model/operators/InOperator.java b/drools-model/drools-canonical-model/src/main/java/org/drools/model/operators/InOperator.java index adbc42970c8..2502394e36b 100644 --- a/drools-model/drools-canonical-model/src/main/java/org/drools/model/operators/InOperator.java +++ b/drools-model/drools-canonical-model/src/main/java/org/drools/model/operators/InOperator.java @@ -20,6 +20,8 @@ import org.drools.model.functions.Operator; +import static org.drools.model.util.OperatorUtils.areEqual; + public enum InOperator implements Operator.MultipleValue { INSTANCE; @@ -27,9 +29,7 @@ public enum InOperator implements Operator.MultipleValue { @Override public boolean eval( Object a, Object[] bs ) { for (Object b : bs) { - if (a == null && b == null) { - return true; - } else if (a != null && a.equals( b )) { + if (areEqual(a, b)) { return true; } } diff --git a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/drlxparse/ConstraintParser.java b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/drlxparse/ConstraintParser.java index f8a7365708c..fbc43b71673 100644 --- a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/drlxparse/ConstraintParser.java +++ b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/drlxparse/ConstraintParser.java @@ -98,6 +98,7 @@ import static org.drools.model.codegen.execmodel.generator.expressiontyper.ExpressionTyper.convertArithmeticBinaryToMethodCall; import static org.drools.model.codegen.execmodel.generator.expressiontyper.ExpressionTyper.getBinaryTypeAfterConversion; import static org.drools.model.codegen.execmodel.generator.expressiontyper.ExpressionTyper.shouldConvertArithmeticBinaryToMethodCall; +import static org.drools.model.codegen.execmodel.util.ExpressionUtils.convertBigIntegerLiteralExprOrBigDecimalLiteralExpr; import static org.drools.util.StringUtils.lcFirstForBean; import static org.drools.model.codegen.execmodel.generator.DrlxParseUtil.THIS_PLACEHOLDER; import static org.drools.model.codegen.execmodel.generator.DrlxParseUtil.createConstraintCompiler; @@ -356,11 +357,7 @@ private DrlxParseResult compileToJavaRecursive(Class patternType, if (drlxExpr instanceof LiteralExpr) { Class literalExpressionType = getLiteralExpressionType(((LiteralExpr) drlxExpr)); - if (drlxExpr instanceof BigIntegerLiteralExpr) { - drlxExpr = ((BigIntegerLiteralExpr) drlxExpr).convertToObjectCreationExpr(); - } else if (drlxExpr instanceof BigDecimalLiteralExpr) { - drlxExpr = ((BigDecimalLiteralExpr) drlxExpr).convertToObjectCreationExpr(); - } + drlxExpr = convertBigIntegerLiteralExprOrBigDecimalLiteralExpr(drlxExpr); return new SingleDrlxParseSuccess(patternType, bindingId, drlxExpr, literalExpressionType) .setIsPredicate(isBooleanBoxedUnboxed(literalExpressionType)); } @@ -984,11 +981,7 @@ public static Expression toBigDecimalExpression( TypedExpression typedExpression if(arg.isEnclosedExpr()) { arg = arg.asEnclosedExpr().getInner(); } - if (arg instanceof BigIntegerLiteralExpr) { - arg = ((BigIntegerLiteralExpr) arg).convertToObjectCreationExpr(); - } else if (arg instanceof BigDecimalLiteralExpr ) { - arg = ((BigDecimalLiteralExpr) arg).convertToObjectCreationExpr(); - } + arg = convertBigIntegerLiteralExprOrBigDecimalLiteralExpr(arg); toBigDecimalMethod.addArgument( arg ); return toBigDecimalMethod; } diff --git a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/operatorspec/NativeOperatorSpec.java b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/operatorspec/NativeOperatorSpec.java index 164fbf73b11..57fcecda5b0 100644 --- a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/operatorspec/NativeOperatorSpec.java +++ b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/operatorspec/NativeOperatorSpec.java @@ -23,12 +23,12 @@ import com.github.javaparser.ast.expr.Expression; import com.github.javaparser.ast.expr.MethodCallExpr; import com.github.javaparser.ast.expr.UnaryExpr; -import org.drools.model.functions.Operator; import org.drools.model.codegen.execmodel.errors.InvalidExpressionErrorResult; import org.drools.model.codegen.execmodel.generator.RuleContext; import org.drools.model.codegen.execmodel.generator.TypedExpression; import org.drools.model.codegen.execmodel.generator.drlxparse.CoercedExpression; import org.drools.model.codegen.execmodel.generator.expressiontyper.ExpressionTyper; +import org.drools.model.functions.Operator; import org.drools.mvel.parser.ast.expr.PointFreeExpr; import org.drools.mvel.parser.printer.PrintUtil; @@ -36,6 +36,7 @@ import static org.drools.model.codegen.execmodel.generator.DslMethodNames.EVAL_CALL; import static org.drools.model.codegen.execmodel.generator.DslMethodNames.createDslTopLevelMethod; import static org.drools.model.codegen.execmodel.generator.drlxparse.ConstraintParser.getCoercedRightExpression; +import static org.drools.model.codegen.execmodel.util.ExpressionUtils.convertBigIntegerLiteralExprOrBigDecimalLiteralExpr; public class NativeOperatorSpec implements OperatorSpec { public static final NativeOperatorSpec INSTANCE = new NativeOperatorSpec(); @@ -60,7 +61,9 @@ public Expression getExpression(RuleContext context, PointFreeExpr pointFreeExpr } else { coercedRight = right; } - methodCallExpr.addArgument(coercedRight.getExpression() ); + Expression rightExpression = coercedRight.getExpression(); + rightExpression = convertBigIntegerLiteralExprOrBigDecimalLiteralExpr(rightExpression); + methodCallExpr.addArgument(rightExpression); }); } diff --git a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/util/ExpressionUtils.java b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/util/ExpressionUtils.java new file mode 100644 index 00000000000..cfd8ffe180b --- /dev/null +++ b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/util/ExpressionUtils.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.drools.model.codegen.execmodel.util; + +import com.github.javaparser.ast.expr.Expression; +import org.drools.mvel.parser.ast.expr.BigDecimalLiteralExpr; +import org.drools.mvel.parser.ast.expr.BigIntegerLiteralExpr; + +public class ExpressionUtils { + + private ExpressionUtils() { + // utility class + } + + public static Expression convertBigIntegerLiteralExprOrBigDecimalLiteralExpr(Expression expression) { + if (expression instanceof BigIntegerLiteralExpr) { + return ((BigIntegerLiteralExpr) expression).convertToObjectCreationExpr(); + } else if (expression instanceof BigDecimalLiteralExpr) { + return ((BigDecimalLiteralExpr) expression).convertToObjectCreationExpr(); + } + return expression; + } +} diff --git a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/bigdecimaltest/BigDecimalTest.java b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/bigdecimaltest/BigDecimalTest.java index 407462de392..885b27cb026 100644 --- a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/bigdecimaltest/BigDecimalTest.java +++ b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/bigdecimaltest/BigDecimalTest.java @@ -813,4 +813,46 @@ private void bindVariableToBigDecimalCoercion(String binding) { assertThat(result).contains(new BigDecimal("80000")); } + + @Test + public void bigDecimalInWithInt_shouldNotFailToBuild() { + String str = + "package org.drools.modelcompiler.bigdecimals\n" + + "import " + BDFact.class.getCanonicalName() + ";\n" + + "rule \"Rule 1a\"\n" + + " when\n" + + " BDFact( value1 in (100, 200) )\n" + + " then\n" + + "end"; + + KieSession ksession = getKieSession(str); + + BDFact bdFact = new BDFact(); + bdFact.setValue1(new BigDecimal("100")); + + ksession.insert(bdFact); + + assertThat(ksession.fireAllRules()).isEqualTo(1); + } + + @Test + public void bigDecimalInWithBD_shouldNotFailToBuild() { + String str = + "package org.drools.modelcompiler.bigdecimals\n" + + "import " + BDFact.class.getCanonicalName() + ";\n" + + "rule \"Rule 1a\"\n" + + " when\n" + + " BDFact( value1 in (100B, 200B) )\n" + + " then\n" + + "end"; + + KieSession ksession = getKieSession(str); + + BDFact bdFact = new BDFact(); + bdFact.setValue1(new BigDecimal("100")); + + ksession.insert(bdFact); + + assertThat(ksession.fireAllRules()).isEqualTo(1); + } } diff --git a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/generator/drlxparse/ConstraintParserTest.java b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/generator/drlxparse/ConstraintParserTest.java index fa30324b944..cc62dedfdc3 100644 --- a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/generator/drlxparse/ConstraintParserTest.java +++ b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/generator/drlxparse/ConstraintParserTest.java @@ -153,9 +153,23 @@ public void testBigIntegerLiteralWithBindVariable() { } @Test - public void bigDecimalArithmeticInMathodCallScope() { + public void bigDecimalArithmeticInMethodCallScope() { SingleDrlxParseSuccess result = (SingleDrlxParseSuccess) parser.drlxParse(Person.class, "$p", "(money * new java.math.BigDecimal(\"1000\")).longValue()"); assertThat(result.getExpr().toString()).isEqualTo("_this.getMoney().multiply(new java.math.BigDecimal(\"1000\"), java.math.MathContext.DECIMAL128).longValue()"); } + + @Test + public void bigDecimalInWithInt() { + SingleDrlxParseSuccess result = (SingleDrlxParseSuccess) parser.drlxParse(Person.class, "$p", "(money in (100, 200))"); + + assertThat(result.getExpr().toString()).isEqualTo("D.eval(org.drools.model.operators.InOperator.INSTANCE, _this.getMoney(), 100, 200)"); + } + + @Test + public void bigDecimalInWithBD() { + SingleDrlxParseSuccess result = (SingleDrlxParseSuccess) parser.drlxParse(Person.class, "$p", "(money in (100B, 200B))"); + + assertThat(result.getExpr().toString()).isEqualTo("D.eval(org.drools.model.operators.InOperator.INSTANCE, _this.getMoney(), new java.math.BigDecimal(\"100\"), new java.math.BigDecimal(\"200\"))"); + } } From 0978f7ed72edce9c2972ca8bf3c9faea337e4690 Mon Sep 17 00:00:00 2001 From: Mario Fusco Date: Tue, 30 Apr 2024 08:33:14 +0200 Subject: [PATCH 04/10] [KIE-1133] when available always use the fully qualified name of a type during parsing (#5877) --- .../org/drools/mvelcompiler/LHSPhase.java | 2 +- .../integrationtests/ConsequenceTypeTest.java | 61 +++++++++++++++++++ .../integrationtests/domainfirst/Pojo.java | 14 +++++ .../integrationtests/domainsecond/Pojo.java | 14 +++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ConsequenceTypeTest.java create mode 100644 drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/domainfirst/Pojo.java create mode 100644 drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/domainsecond/Pojo.java diff --git a/drools-model/drools-mvel-compiler/src/main/java/org/drools/mvelcompiler/LHSPhase.java b/drools-model/drools-mvel-compiler/src/main/java/org/drools/mvelcompiler/LHSPhase.java index dd634bfcf16..f610dc412fb 100644 --- a/drools-model/drools-mvel-compiler/src/main/java/org/drools/mvelcompiler/LHSPhase.java +++ b/drools-model/drools-mvel-compiler/src/main/java/org/drools/mvelcompiler/LHSPhase.java @@ -395,7 +395,7 @@ private Class getRHSType() { private Class getRHSorLHSType(VariableDeclarator n) { return mvelCompilerContext.resolveType(n.getType() instanceof ClassOrInterfaceType ? - n.getType().asClassOrInterfaceType().getNameAsString() : + n.getType().asClassOrInterfaceType().getNameWithScope() : n.getType().asString()); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ConsequenceTypeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ConsequenceTypeTest.java new file mode 100644 index 00000000000..eb6f574a35a --- /dev/null +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ConsequenceTypeTest.java @@ -0,0 +1,61 @@ +package org.drools.compiler.integrationtests; + +import java.util.Collection; + +import org.drools.testcoverage.common.util.KieBaseTestConfiguration; +import org.drools.testcoverage.common.util.KieBaseUtil; +import org.drools.testcoverage.common.util.TestParametersUtil; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.kie.api.KieBase; +import org.kie.api.runtime.KieSession; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(Parameterized.class) +public class ConsequenceTypeTest { + + private final KieBaseTestConfiguration kieBaseTestConfiguration; + + public ConsequenceTypeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { + this.kieBaseTestConfiguration = kieBaseTestConfiguration; + } + + @Parameterized.Parameters(name = "KieBase type={0}") + public static Collection getParameters() { + return TestParametersUtil.getKieBaseCloudConfigurations(true); + } + + @Test + public void test() { + // KIE-1133 + + int ruleNr = 100; + StringBuilder drl = new StringBuilder(); + drl.append("package org.rules;\n"); + drl.append("import org.drools.compiler.integrationtests.domainfirst.*\n"); + drl.append("import org.drools.compiler.integrationtests.domainsecond.*\n"); + drl.append("dialect \"mvel\"\n"); + for (int i = 0; i < ruleNr; i++) { + drl.append(generatedRule(i)); + } + + final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl.toString()); + final KieSession wm = kbase.newKieSession(); + + wm.insert("test"); + assertThat(wm.fireAllRules()).isEqualTo(ruleNr); + } + + private String generatedRule(int seed) { + return "rule R" + seed + " when $s : String() then\n" + + "org.drools.compiler.integrationtests.domainfirst.Pojo $pojo = new org.drools.compiler.integrationtests.domainfirst.Pojo();\n" + + "org.drools.compiler.integrationtests.domainsecond.Pojo $pojo_No2 = new org.drools.compiler.integrationtests.domainsecond.Pojo();\n" + + "$pojo.setId($s.length() + " + seed + ");\n" + + "$pojo_No2.setId($s.length() + " + seed + ");\n" + + "insert($pojo);\n" + + "insert($pojo_No2);\n" + + "end\n"; + } +} diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/domainfirst/Pojo.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/domainfirst/Pojo.java new file mode 100644 index 00000000000..049b47b0272 --- /dev/null +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/domainfirst/Pojo.java @@ -0,0 +1,14 @@ +package org.drools.compiler.integrationtests.domainfirst; + +public class Pojo { + + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/domainsecond/Pojo.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/domainsecond/Pojo.java new file mode 100644 index 00000000000..6ec7220e33a --- /dev/null +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/domainsecond/Pojo.java @@ -0,0 +1,14 @@ +package org.drools.compiler.integrationtests.domainsecond; + +public class Pojo { + + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} From 6443ddac3e97338e831b30de7576cb75b9da8cf5 Mon Sep 17 00:00:00 2001 From: Alex Porcelli Date: Thu, 2 May 2024 17:29:13 +0200 Subject: [PATCH 05/10] Quarkus LTS Upgrade to 3.8.4 (#5853) * Upgrade to and align with Quarkus 3.8.2 LTS release. * Upgrade to and align with Quarkus 3.8.2 LTS release. * Upgrade to and align with Quarkus 3.8.4 LTS release. * Remove unnecessary util class, as Quarkus 3.8.x does not have the issue anymore. --- build-parent/pom.xml | 258 +++--------------- .../drools-persistence-jpa/pom.xml | 2 +- .../drools-quarkus-deployment/pom.xml | 23 -- .../drools-quarkus/pom.xml | 23 -- drools-traits/pom.xml | 2 +- .../org/drools/util/RemoveCommentsMain.java | 51 ---- .../org/drools/util/RemoveCommentsTest.java | 15 - kie-internal/pom.xml | 6 + kie-test-util/pom.xml | 2 +- 9 files changed, 42 insertions(+), 340 deletions(-) delete mode 100644 drools-util/src/main/java/org/drools/util/RemoveCommentsMain.java delete mode 100644 drools-util/src/test/java/org/drools/util/RemoveCommentsTest.java diff --git a/build-parent/pom.xml b/build-parent/pom.xml index e6acb1c8572..b73c9c37679 100644 --- a/build-parent/pom.xml +++ b/build-parent/pom.xml @@ -54,28 +54,28 @@ - A version property must be specified in the format "version.{groupId}", optionally with a suffix to make it unique. - Version properties must be sorted alphabetically (other form of sorting were found to be unclear and ambiguous). --> - 1.2.13 - 1.16.0 + 1.4.12 + 1.16.1 3.2.2 1.1.1 - 2.13.0 - 1.10.0 - 2.15.2 - 2.15.2 - 2.15.2 + 2.15.1 + 1.11.0 + 2.16.1 + 2.16.1 + 2.16.1 4.31.0 3.7.4 1.0.1 - 3.22.0 + 3.25.0 2.2.220 1.0.86 - 2.3.0 + 4.0.4 1.4.20 0.18.0 - 4.7.4 - 1.11.1 - 3.2.10.Final - 3.4.0 + 4.7.5 + 1.12.2 + 3.8.4 + 3.10.0 8.5.11 4.13.1 1.8.0 @@ -83,27 +83,27 @@ 3.5.2 4.0.7 1.10.11 - 3.12.0 + 3.14.0 3.4.1 - 4.4.15 + 4.4.16 3.8.6 1.7.3 3.5.3 2.0.28 5.2.5 10.1.7 - 3.23.1 + 3.24.2 3.33.0 2.3.32 4.0.4 - 1.3 + 2.2 2.3.0 - 14.0.13.Final + 14.0.25.Final 3.26.0-GA - 6.0.1.Final + 7.0.1.Final 3.5.3.Final - 7.6.1.Final + 8.0.0.Final 3.1.6.Final 3.0.3 4.0.1 @@ -111,28 +111,21 @@ 2.1.2 2.0.1 2.1.1 - 3.2.6 - 2.3.6 - 2.0.0 2.0.1 - 3.1.0 - 4.0.1 3.1.0 - 6.0.0 - 4.0.0 + 4.0.1 3.0.0 1.1.5 - 2.1.2 + 2.1.3 4.0.0 1.6.4 - 5.9.3 + 5.10.2 2.5.1.Final 2.0.7 - 1.7.30 + 2.0.6 0.11.4.1 2.12.0.SP04 - 1.3 @@ -141,19 +134,16 @@ 4.10.1 3.13.0 - 4.15.0.Final - 1.1.0 1.6.2 - 2.0.6 - 2.0.6 + 2.2.19 + 2.1.19 1.0.55 - 2.8.2 + 2.9.1 - 2.0.1.Final 2.2.0 1.5.0 2.3.0-jaxb-1.0.6 - 4.11.0 + 5.2.0 1.21 @@ -198,17 +188,17 @@ 3.8.1 3.3.0 - 1.14.7 + 1.14.11 - 42.6.1 + 42.7.2 2.0.1 3.1.6 3.0.3 - 3.25.3 + 3.25.8 - 32.0.0-jre + 32.0.1-jre @@ -452,41 +442,16 @@ jakarta.annotation-api ${version.jakarta.annotation-api} - - jakarta.servlet.jsp - jakarta.servlet.jsp-api - ${version.jakarta.servlet.jsp-api} - - - jakarta.servlet.jsp.jstl - jakarta.servlet.jsp.jstl-api - ${version.jakarta.servlet.jsp.jstl-api} - jakarta.transaction jakarta.transaction-api ${version.jakarta.transaction-api} - - jakarta.ws.rs - jakarta.ws.rs-api - ${version.jakarta.ws.rs-api} - - - jakarta.xml.ws - jakarta.xml.ws-api - ${version.jakarta.xml.ws-api} - jakarta.persistence jakarta.persistence-api ${version.jakarta.persistence-api} - - jakarta.servlet - jakarta.servlet-api - ${version.jakarta.servlet-api} - jakarta.xml.bind jakarta.xml.bind-api @@ -874,12 +839,6 @@ ${version.xerces} - - xmlunit - xmlunit - ${version.xmlunit} - - org.openjdk.jmh @@ -907,70 +866,6 @@ runtime - - - org.jboss.errai - errai-bus - ${version.org.jboss.errai} - - - com.google.inject - guice - - - - - org.jboss.errai - errai-ioc - ${version.org.jboss.errai} - - - com.google.inject - guice - - - - - org.jboss.errai - errai-tools - ${version.org.jboss.errai} - - - com.google.inject - guice - - - - - org.jboss.errai - errai-cdi-server - ${version.org.jboss.errai} - - - com.google.inject - guice - - - - - - com.google.elemental2 - elemental2-dom - ${version.com.google.elemental2} - - - - com.google.elemental2 - elemental2-core - ${version.com.google.elemental2} - - - - com.google.elemental2 - elemental2-promise - ${version.com.google.elemental2} - - io.swagger swagger-core @@ -1045,7 +940,7 @@ org.jboss - jboss-transaction-spi-jakarta + jboss-transaction-spi ${version.org.jboss.transaction.spi} @@ -1078,19 +973,6 @@ test - - - jakarta.validation - jakarta.validation-api - 3.0.2 - - - jakarta.validation - jakarta.validation-api - 3.0.2 - sources - - net.bytebuddy @@ -1399,22 +1281,6 @@ javax.activation.* - - - org.jboss.errai - errai-ioc - - javax.inject.Provider - - - - - org.jboss.errai - errai-javax-enterprise - - * - - io.quarkus @@ -1423,20 +1289,6 @@ * - - - - org.kie.server - kie-server-router-proxy - jar - - org.jboss.logging.* - org.jboss.threads.* - org.xnio.* - org.wildfly.* - org.apache.commons.* - - io.sundr @@ -1868,48 +1720,6 @@ org.apache.maven.plugins maven-shade-plugin - - - com.google.code.maven-replacer-plugin - replacer - 1.5.2 - - - **/*Constants_de.properties - **/*Constants_es_ES.properties - **/*Constants_fr_FR.properties - **/*Constants_ja_JP.properties - **/*Constants_pt_BR.properties - **/*Constants_zh_CN.properties - - - **/ErraiApp.properties - - - - '' - ' - - - ' - '' - - - - - - - org.zanata - zanata-maven-plugin - 2.3.0 - - **/ErraiApp.properties - ${session.executionRootDirectory}/src/main/config/zanata.xml - src/main/resources/ - src/main/resources/ - **/*Constants.properties,**/*Constants_en.properties - - @@ -2315,8 +2125,6 @@ folder during the build. These are not a subject of test coverage measurement. --> - - - - - org.codehaus.mojo - exec-maven-plugin - 3.1.1 - - - Run Script - prepare-package - - java - - - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-javadoc.properties - - - - - diff --git a/drools-quarkus-extension/drools-quarkus/pom.xml b/drools-quarkus-extension/drools-quarkus/pom.xml index b30722604f1..9c5057e3cce 100644 --- a/drools-quarkus-extension/drools-quarkus/pom.xml +++ b/drools-quarkus-extension/drools-quarkus/pom.xml @@ -149,29 +149,6 @@ io.smallrye jandex-maven-plugin - - - - - org.codehaus.mojo - exec-maven-plugin - 3.1.1 - - - Run Script - prepare-package - - java - - - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-extension.properties - - - - - diff --git a/drools-traits/pom.xml b/drools-traits/pom.xml index 896e33b2774..f2c5f685fd1 100644 --- a/drools-traits/pom.xml +++ b/drools-traits/pom.xml @@ -157,7 +157,7 @@ org.jboss - jboss-transaction-spi-jakarta + jboss-transaction-spi test diff --git a/drools-util/src/main/java/org/drools/util/RemoveCommentsMain.java b/drools-util/src/main/java/org/drools/util/RemoveCommentsMain.java deleted file mode 100644 index 024320a8b28..00000000000 --- a/drools-util/src/main/java/org/drools/util/RemoveCommentsMain.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.drools.util; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Path; -import java.util.stream.Collectors; - -public class RemoveCommentsMain { - - private static final Logger LOGGER = LoggerFactory.getLogger(RemoveCommentsMain.class); - - public static void main(String... args) { - final String ignoreMissingFilesArgument = args[0]; - final boolean ignoreMissingFiles = Boolean.parseBoolean(ignoreMissingFilesArgument); - for (int i = 0; i < args.length; i++) { - // If the ignoreMissingFiles argument is defined, skip it in this iteration. - if ((ignoreMissingFiles || "false".equalsIgnoreCase(ignoreMissingFilesArgument)) && i == 0) { - continue; - } else { - try { - final String fileName = args[i]; - final String result = removeComments(fileName, ignoreMissingFiles); - if (result != null) { - Files.write(Path.of(fileName), result.getBytes()); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - } - - static String removeComments(String fileName, final boolean ignoreMissingFiles) { - try (var lines = Files.lines(Path.of(fileName))) { - return lines.filter(line -> !line.startsWith("#")).collect(Collectors.joining("\n")); - } catch (IOException e) { - // Ignore non-existant files. - if (ignoreMissingFiles && e instanceof NoSuchFileException) { - LOGGER.info("Ignoring file that doesn't exist: " + fileName); - return null; - } else { - throw new RuntimeException(e); - } - } - } - -} diff --git a/drools-util/src/test/java/org/drools/util/RemoveCommentsTest.java b/drools-util/src/test/java/org/drools/util/RemoveCommentsTest.java deleted file mode 100644 index 1b529b5acc7..00000000000 --- a/drools-util/src/test/java/org/drools/util/RemoveCommentsTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.drools.util; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class RemoveCommentsTest { - - @Test - public void test() { - String result = RemoveCommentsMain.removeComments("src/test/resources/commented.properties", false); - String expected = "provides-capabilities=org.drools.drl\ndeployment-artifact=org.drools\\:drools-quarkus-deployment\\:999-SNAPSHOT"; - assertEquals(expected, result); - } -} diff --git a/kie-internal/pom.xml b/kie-internal/pom.xml index 6dc0f3923b4..619f4ee0f49 100644 --- a/kie-internal/pom.xml +++ b/kie-internal/pom.xml @@ -89,6 +89,12 @@ com.sun.xml.bind jaxb-xjc provided + + + com.sun.xml.bind + jaxb-core + + diff --git a/kie-test-util/pom.xml b/kie-test-util/pom.xml index f6fd0e317e5..448bb2f3f6e 100644 --- a/kie-test-util/pom.xml +++ b/kie-test-util/pom.xml @@ -87,7 +87,7 @@ org.jboss - jboss-transaction-spi-jakarta + jboss-transaction-spi org.apache.tomcat From e103c09fb38a7521179829d727344d2ede759e6e Mon Sep 17 00:00:00 2001 From: Gabriele Cardosi Date: Fri, 3 May 2024 08:34:05 +0200 Subject: [PATCH 06/10] [incubator-kie-issues#1112] Dmn schema generation - Replace expression evaluation with parsing/analysys (#5881) * [incubator-kie-issues#1112] WIP * [incubator-kie-issues#1112] WIP - Working with tests * [incubator-kie-issues#1112] Refactoring - cleanup. Working with tests * [incubator-kie-issues#1112] Cleanup. Working with tests * [incubator-kie-issues#1112] Refactoring to extend test coverage * [incubator-kie-issues#1112] Cleanup * [incubator-kie-issues#1112] Extend test coverage. Cleanup * [incubator-kie-issues#1112] Cleanup * [incubator-kie-issues#1112] Updated junit version. Extend test coverage * [incubator-kie-issues#1112] Updated junit version. Extend test coverage * [incubator-kie-issues#1112] Add enum generation test * [incubator-kie-issues#1112] Moved TriConsumer under drools utility * [incubator-kie-issues#1112] Add tests for BUiltInFunctions * [incubator-kie-issues#1112] Fix broken model --------- Co-authored-by: Gabriele-Cardosi --- .../drools/util/functions/TriConsumer.java | 70 ++++++ .../org/kie/dmn/feel/lang/ast/RangeNode.java | 2 +- .../feel/runtime/functions/AllFunction.java | 2 + .../feel/runtime/functions/AnyFunction.java | 2 + .../runtime/functions/AppendFunction.java | 2 + .../runtime/functions/BuiltInFunctions.java | 91 +++---- .../runtime/functions/CeilingFunction.java | 2 + .../functions/ConcatenateFunction.java | 2 + .../runtime/functions/ContainsFunction.java | 2 + .../feel/runtime/functions/CountFunction.java | 2 + .../runtime/functions/DecimalFunction.java | 2 + .../functions/DecisionTableFunction.java | 2 + .../functions/DistinctValuesFunction.java | 2 + .../runtime/functions/EndsWithFunction.java | 2 + .../runtime/functions/FlattenFunction.java | 2 + .../runtime/functions/GetEntriesFunction.java | 2 + .../runtime/functions/GetValueFunction.java | 2 + .../runtime/functions/IndexOfFunction.java | 2 + .../functions/InsertBeforeFunction.java | 2 + .../functions/ListContainsFunction.java | 2 + .../runtime/functions/MatchesFunction.java | 2 + .../feel/runtime/functions/MaxFunction.java | 2 + .../feel/runtime/functions/MeanFunction.java | 4 +- .../feel/runtime/functions/MinFunction.java | 2 + .../feel/runtime/functions/NotFunction.java | 2 + .../runtime/functions/RemoveFunction.java | 2 + .../runtime/functions/ReplaceFunction.java | 2 + .../runtime/functions/ReverseFunction.java | 2 + .../feel/runtime/functions/SortFunction.java | 2 + .../runtime/functions/StartsWithFunction.java | 2 + .../functions/StringLengthFunction.java | 2 + .../functions/StringUpperCaseFunction.java | 2 + .../runtime/functions/SublistFunction.java | 2 + .../functions/SubstringAfterFunction.java | 2 + .../functions/SubstringBeforeFunction.java | 2 + .../runtime/functions/SubstringFunction.java | 2 + .../feel/runtime/functions/SumFunction.java | 2 + .../feel/runtime/functions/UnionFunction.java | 2 + .../functions/BuiltInFunctionsTest.java | 94 ++++++++ kie-dmn/kie-dmn-openapi/pom.xml | 27 ++- .../openapi/impl/BaseNodeSchemaMapper.java | 89 +++++++ .../kie/dmn/openapi/impl/DMNOASConstants.java | 2 + .../kie/dmn/openapi/impl/DMNTypeSchemas.java | 89 +++---- .../dmn/openapi/impl/DMNUnaryTestsMapper.java | 122 ++++++++++ ....java => FEELBuiltinTypeSchemaMapper.java} | 6 +- .../impl/FEELFunctionSchemaMapper.java | 73 ++++++ .../kie/dmn/openapi/impl/FEELSchemaEnum.java | 151 ------------ .../openapi/impl/InfixOpNodeSchemaMapper.java | 50 ++++ .../kie/dmn/openapi/impl/MapperHelper.java | 42 ++++ .../openapi/impl/RangeNodeSchemaMapper.java | 97 ++++++++ .../org/kie/dmn/openapi/AllowNullTest.java | 10 +- .../org/kie/dmn/openapi/BaseDMNOASTest.java | 10 +- .../java/org/kie/dmn/openapi/CH11Test.java | 6 +- .../kie/dmn/openapi/DMNDescriptionTest.java | 6 +- .../openapi/DS004decisionservicesTest.java | 8 +- .../kie/dmn/openapi/DSMultipleOutputTest.java | 6 +- .../kie/dmn/openapi/DiscouragedTypesTest.java | 6 +- .../kie/dmn/openapi/EnumGenerationTest.java | 143 +++++++++++ .../org/kie/dmn/openapi/ImportingTest.java | 6 +- .../org/kie/dmn/openapi/JacksonUtils.java | 2 +- .../kie/dmn/openapi/MultipleModelsTest.java | 12 +- .../java/org/kie/dmn/openapi/MyOrderTest.java | 6 +- .../dmn/openapi/NumberAllowedValuesTest.java | 10 +- .../kie/dmn/openapi/OneOfEachTypeTest.java | 6 +- .../java/org/kie/dmn/openapi/PersonTest.java | 6 +- .../java/org/kie/dmn/openapi/PersonsTest.java | 8 +- .../org/kie/dmn/openapi/ProcessItemTest.java | 12 +- .../kie/dmn/openapi/TypeWithSpaceTest.java | 6 +- .../org/kie/dmn/openapi/UndefinedTest.java | 6 +- .../dmn/openapi/impl/DMNTypeSchemasTest.java | 143 +++++++++++ .../openapi/impl/DMNUnaryTestsMapperTest.java | 140 +++++++++++ .../openapi/impl/DefaultNamingPolicyTest.java | 7 +- .../impl/FEELFunctionSchemaMapperTest.java | 62 +++++ .../dmn/openapi/impl/FEELSchemaEnumTest.java | 224 ------------------ .../impl/InfixOpNodeSchemaMapperTest.java | 64 +++++ .../impl/RangeNodeSchemaMapperTest.java | 127 ++++++++++ .../openapi/impl/SchemaMapperTestUtils.java | 76 ++++++ .../DMNv1_5/ConstraintsChecks.dmn | 74 ++++++ 78 files changed, 1726 insertions(+), 543 deletions(-) create mode 100644 drools-util/src/main/java/org/drools/util/functions/TriConsumer.java create mode 100644 kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctionsTest.java create mode 100644 kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/BaseNodeSchemaMapper.java create mode 100644 kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapper.java rename kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/{FEELBuiltinTypeSchemas.java => FEELBuiltinTypeSchemaMapper.java} (95%) create mode 100644 kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELFunctionSchemaMapper.java delete mode 100644 kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELSchemaEnum.java create mode 100644 kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/InfixOpNodeSchemaMapper.java create mode 100644 kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/MapperHelper.java create mode 100644 kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapper.java create mode 100644 kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java create mode 100644 kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNTypeSchemasTest.java create mode 100644 kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapperTest.java create mode 100644 kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELFunctionSchemaMapperTest.java delete mode 100644 kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELSchemaEnumTest.java create mode 100644 kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/InfixOpNodeSchemaMapperTest.java create mode 100644 kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapperTest.java create mode 100644 kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/SchemaMapperTestUtils.java create mode 100644 kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/ConstraintsChecks.dmn diff --git a/drools-util/src/main/java/org/drools/util/functions/TriConsumer.java b/drools-util/src/main/java/org/drools/util/functions/TriConsumer.java new file mode 100644 index 00000000000..ca57105df7d --- /dev/null +++ b/drools-util/src/main/java/org/drools/util/functions/TriConsumer.java @@ -0,0 +1,70 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.drools.util.functions; + +import java.util.Objects; + +/** + * Represents an operation that accepts three input arguments and returns no + * result. This is the three-arity specialization of {@link Consumer}. + * Unlike most other functional interfaces, {@code TriConsumer} is expected + * to operate via side-effects. + * + *

This is a functional interface + * whose functional method is {@link #accept(Object, Object, Object)}. + * + * @param the type of the first argument to the operation + * @param the type of the second argument to the operation + * @param the type of the third argument to the operation + * + * @see Consumer + */ +@FunctionalInterface +public interface TriConsumer { + + /** + * Performs this operation on the given arguments. + * + * @param t the first input argument + * @param u the second input argument + * @param d the third input argument + */ + void accept(T t, U u, D d); + + /** + * Returns a composed {@code TriConsumer} that performs, in sequence, this + * operation followed by the {@code after} operation. If performing either + * operation throws an exception, it is relayed to the caller of the + * composed operation. If performing this operation throws an exception, + * the {@code after} operation will not be performed. + * + * @param after the operation to perform after this operation + * @return a composed {@code TriConsumer} that performs in sequence this + * operation followed by the {@code after} operation + * @throws NullPointerException if {@code after} is null + */ + default TriConsumer andThen(TriConsumer after) { + Objects.requireNonNull(after); + + return (l, r, d) -> { + accept(l, r, d); + after.accept(l, r, d); + }; + } +} diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/RangeNode.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/RangeNode.java index 52fcc5c43b7..bf4eea94740 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/RangeNode.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/RangeNode.java @@ -33,7 +33,7 @@ public class RangeNode extends BaseNode { - public static enum IntervalBoundary { + public enum IntervalBoundary { OPEN, CLOSED; public static IntervalBoundary low(String input) { switch (input) { diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AllFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AllFunction.java index 12a3905b151..08520f44fff 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AllFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AllFunction.java @@ -26,6 +26,8 @@ public class AllFunction extends BaseFEELFunction { + public static final AllFunction INSTANCE = new AllFunction(); + public AllFunction() { super( "all" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AnyFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AnyFunction.java index 6f36b533bd8..a8d3abff969 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AnyFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AnyFunction.java @@ -26,6 +26,8 @@ public class AnyFunction extends BaseFEELFunction { + public static final AnyFunction INSTANCE = new AnyFunction(); + public AnyFunction() { super( "any" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AppendFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AppendFunction.java index b5a1e3809e0..ef5554da227 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AppendFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/AppendFunction.java @@ -28,6 +28,8 @@ public class AppendFunction extends BaseFEELFunction { + public static final AppendFunction INSTANCE = new AppendFunction(); + public AppendFunction() { super( "append" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctions.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctions.java index 9495c984974..6b90492713a 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctions.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctions.java @@ -44,46 +44,46 @@ public class BuiltInFunctions { DateAndTimeFunction.INSTANCE, DurationFunction.INSTANCE, YearsAndMonthsFunction.INSTANCE, - new StringFunction(), - new NumberFunction(), - new SubstringFunction(), - new SubstringBeforeFunction(), - new SubstringAfterFunction(), - new StringLengthFunction(), - new StringUpperCaseFunction(), - new StringLowerCaseFunction(), - new ContainsFunction(), - new StartsWithFunction(), - new EndsWithFunction(), - new MatchesFunction(), - new ReplaceFunction(), - new ListContainsFunction(), - new CountFunction(), - new MinFunction(), - new MaxFunction(), - new SumFunction(), - new MeanFunction(), - new SublistFunction(), - new AppendFunction(), - new ConcatenateFunction(), - new InsertBeforeFunction(), - new RemoveFunction(), - new ReverseFunction(), - new IndexOfFunction(), - new UnionFunction(), - new DistinctValuesFunction(), - new FlattenFunction(), - new DecimalFunction(), - new FloorFunction(), - new CeilingFunction(), - new DecisionTableFunction(), - new NotFunction(), - new SortFunction(), - new GetEntriesFunction(), - new GetValueFunction(), + StringFunction.INSTANCE, + NumberFunction.INSTANCE, + SubstringFunction.INSTANCE, + SubstringBeforeFunction.INSTANCE, + SubstringAfterFunction.INSTANCE, + StringLengthFunction.INSTANCE, + StringUpperCaseFunction.INSTANCE, + StringLowerCaseFunction.INSTANCE, + ContainsFunction.INSTANCE, + StartsWithFunction.INSTANCE, + EndsWithFunction.INSTANCE, + MatchesFunction.INSTANCE, + ReplaceFunction.INSTANCE, + ListContainsFunction.INSTANCE, + CountFunction.INSTANCE, + MinFunction.INSTANCE, + MaxFunction.INSTANCE, + SumFunction.INSTANCE, + MeanFunction.INSTANCE, + SublistFunction.INSTANCE, + AppendFunction.INSTANCE, + ConcatenateFunction.INSTANCE, + InsertBeforeFunction.INSTANCE, + RemoveFunction.INSTANCE, + ReverseFunction.INSTANCE, + IndexOfFunction.INSTANCE, + UnionFunction.INSTANCE, + DistinctValuesFunction.INSTANCE, + FlattenFunction.INSTANCE, + DecimalFunction.INSTANCE, + FloorFunction.INSTANCE, + CeilingFunction.INSTANCE, + DecisionTableFunction.INSTANCE, + NotFunction.INSTANCE, + SortFunction.INSTANCE, + GetEntriesFunction.INSTANCE, + GetValueFunction.INSTANCE, - new AllFunction(), - new AnyFunction(), + AllFunction.INSTANCE, + AnyFunction.INSTANCE, AbsFunction.INSTANCE, ModuloFunction.INSTANCE, ProductFunction.INSTANCE, @@ -126,10 +126,21 @@ public static FEELFunction[] getFunctions() { return FUNCTIONS; } + @SuppressWarnings("unchecked") public static T getFunction(Class functionClazz) { - return (T) Stream.of(FUNCTIONS) + return Stream.of(FUNCTIONS) .filter(f -> functionClazz.isAssignableFrom(f.getClass())) + .map(f -> (T) f) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Cannot find function by class " + functionClazz.getCanonicalName() + "!")); } + + @SuppressWarnings("unchecked") + public static T getFunction(String functionName) { + return Stream.of(FUNCTIONS) + .filter(f -> f.getName().equals(functionName)) + .map(f -> (T) f) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("Cannot find function by name " + functionName + "!")); + } } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java index ec7d396395e..c3e3a577ea0 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java @@ -28,6 +28,8 @@ public class CeilingFunction extends BaseFEELFunction { + public static final CeilingFunction INSTANCE = new CeilingFunction(); + public CeilingFunction() { super( "ceiling" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunction.java index 4f3cdf2b039..d6a295f4ff2 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunction.java @@ -27,6 +27,8 @@ public class ConcatenateFunction extends BaseFEELFunction { + public static final ConcatenateFunction INSTANCE = new ConcatenateFunction(); + public ConcatenateFunction() { super( "concatenate" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContainsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContainsFunction.java index 4ff86f1cd6f..883d8367d0b 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContainsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ContainsFunction.java @@ -24,6 +24,8 @@ public class ContainsFunction extends BaseFEELFunction { + public static final ContainsFunction INSTANCE = new ContainsFunction(); + public ContainsFunction() { super( "contains" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CountFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CountFunction.java index 717ce5d38f9..32d20f455f9 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CountFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CountFunction.java @@ -29,6 +29,8 @@ public class CountFunction extends BaseFEELFunction { + public static final CountFunction INSTANCE = new CountFunction(); + public CountFunction() { super( "count" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecimalFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecimalFunction.java index ca82db66c17..2e77aa3ceb9 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecimalFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecimalFunction.java @@ -28,6 +28,8 @@ public class DecimalFunction extends BaseFEELFunction { + public static final DecimalFunction INSTANCE = new DecimalFunction(); + public DecimalFunction() { super( "decimal" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java index 2acefa9f890..44d081af66b 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java @@ -45,6 +45,8 @@ public class DecisionTableFunction extends BaseFEELFunction { + public static final DecisionTableFunction INSTANCE = new DecisionTableFunction(); + private static final Logger LOG = LoggerFactory.getLogger( DecisionTableFunction.class ); public DecisionTableFunction() { diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunction.java index b70861c47ec..3de0a290ac9 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunction.java @@ -27,6 +27,8 @@ public class DistinctValuesFunction extends BaseFEELFunction { + public static final DistinctValuesFunction INSTANCE = new DistinctValuesFunction(); + public DistinctValuesFunction() { super( "distinct values" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EndsWithFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EndsWithFunction.java index f079f3b76a7..bbf0b64d037 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EndsWithFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/EndsWithFunction.java @@ -24,6 +24,8 @@ public class EndsWithFunction extends BaseFEELFunction { + public static final EndsWithFunction INSTANCE = new EndsWithFunction(); + public EndsWithFunction() { super( "ends with" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FlattenFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FlattenFunction.java index d159d0224b1..9194eb9da4e 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FlattenFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/FlattenFunction.java @@ -27,6 +27,8 @@ public class FlattenFunction extends BaseFEELFunction { + public static final FlattenFunction INSTANCE = new FlattenFunction(); + public FlattenFunction() { super( "flatten" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetEntriesFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetEntriesFunction.java index 23b8a2343f1..aba3972368e 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetEntriesFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetEntriesFunction.java @@ -29,6 +29,8 @@ public class GetEntriesFunction extends BaseFEELFunction { + public static final GetEntriesFunction INSTANCE = new GetEntriesFunction(); + public GetEntriesFunction() { super("get entries"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetValueFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetValueFunction.java index 7b37aeedd35..1dee390bcdc 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetValueFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/GetValueFunction.java @@ -27,6 +27,8 @@ public class GetValueFunction extends BaseFEELFunction { + public static final GetValueFunction INSTANCE = new GetValueFunction(); + public GetValueFunction() { super("get value"); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IndexOfFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IndexOfFunction.java index 4d9925f0019..529901d8b00 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IndexOfFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/IndexOfFunction.java @@ -27,6 +27,8 @@ public class IndexOfFunction extends BaseFEELFunction { + public static final IndexOfFunction INSTANCE = new IndexOfFunction(); + public IndexOfFunction() { super( "index of" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunction.java index 0d0b415aa8e..ba2a587958d 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunction.java @@ -27,6 +27,8 @@ public class InsertBeforeFunction extends BaseFEELFunction { + public static final InsertBeforeFunction INSTANCE = new InsertBeforeFunction(); + public InsertBeforeFunction() { super( "insert before" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ListContainsFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ListContainsFunction.java index 87aaf19d0a8..dd8f10b318d 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ListContainsFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ListContainsFunction.java @@ -28,6 +28,8 @@ public class ListContainsFunction extends BaseFEELFunction { + public static final ListContainsFunction INSTANCE = new ListContainsFunction(); + public ListContainsFunction() { super( "list contains" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MatchesFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MatchesFunction.java index aed9fcb77e2..e13beaa0fc3 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MatchesFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MatchesFunction.java @@ -28,6 +28,8 @@ public class MatchesFunction extends BaseFEELFunction { + public static final MatchesFunction INSTANCE = new MatchesFunction(); + public MatchesFunction() { super( "matches" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MaxFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MaxFunction.java index 4e1ea61b9f7..2310dfc4652 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MaxFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MaxFunction.java @@ -29,6 +29,8 @@ public class MaxFunction extends BaseFEELFunction { + public static final MaxFunction INSTANCE = new MaxFunction(); + public MaxFunction() { super( "max" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MeanFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MeanFunction.java index 780e13e3e72..9c4faa09232 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MeanFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MeanFunction.java @@ -31,7 +31,9 @@ public class MeanFunction extends BaseFEELFunction { - private SumFunction sum = new SumFunction(); + public static final MeanFunction INSTANCE = new MeanFunction(); + + private SumFunction sum = SumFunction.INSTANCE; public MeanFunction() { super( "mean" ); diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MinFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MinFunction.java index af17411dfff..81a44c0e96f 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MinFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/MinFunction.java @@ -29,6 +29,8 @@ public class MinFunction extends BaseFEELFunction { + public static final MinFunction INSTANCE = new MinFunction(); + public MinFunction() { super( "min" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NotFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NotFunction.java index 4348cc6a62f..287c63331e3 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NotFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/NotFunction.java @@ -29,6 +29,8 @@ public class NotFunction extends BaseFEELFunction { + public static final NotFunction INSTANCE = new NotFunction(); + public NotFunction() { super( "not" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RemoveFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RemoveFunction.java index bf3f32c8d16..f4ee82a787e 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RemoveFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/RemoveFunction.java @@ -27,6 +27,8 @@ public class RemoveFunction extends BaseFEELFunction { + public static final RemoveFunction INSTANCE = new RemoveFunction(); + public RemoveFunction() { super( "remove" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReplaceFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReplaceFunction.java index 63118d98aa7..11a041d4ae4 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReplaceFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReplaceFunction.java @@ -24,6 +24,8 @@ public class ReplaceFunction extends BaseFEELFunction { + public static final ReplaceFunction INSTANCE = new ReplaceFunction(); + public ReplaceFunction() { super( "replace" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReverseFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReverseFunction.java index 20f9676f02d..6b588868e78 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReverseFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/ReverseFunction.java @@ -27,6 +27,8 @@ public class ReverseFunction extends BaseFEELFunction { + public static final ReverseFunction INSTANCE = new ReverseFunction(); + public ReverseFunction() { super( "reverse" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SortFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SortFunction.java index 86c799261f1..8d091ec684b 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SortFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SortFunction.java @@ -29,6 +29,8 @@ public class SortFunction extends BaseFEELFunction { + public static final SortFunction INSTANCE = new SortFunction(); + public SortFunction() { super( "sort" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StartsWithFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StartsWithFunction.java index 630710df2f7..6fac9e2708c 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StartsWithFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StartsWithFunction.java @@ -24,6 +24,8 @@ public class StartsWithFunction extends BaseFEELFunction { + public static final StartsWithFunction INSTANCE = new StartsWithFunction(); + public StartsWithFunction() { super( "starts with" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLengthFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLengthFunction.java index a70b431c572..dfbfd5e86e4 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLengthFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringLengthFunction.java @@ -27,6 +27,8 @@ public class StringLengthFunction extends BaseFEELFunction { + public static final StringLengthFunction INSTANCE = new StringLengthFunction(); + public StringLengthFunction() { super( "string length" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunction.java index cb21b5cbc58..4bffb14476d 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunction.java @@ -24,6 +24,8 @@ public class StringUpperCaseFunction extends BaseFEELFunction { + public static final StringUpperCaseFunction INSTANCE = new StringUpperCaseFunction(); + public StringUpperCaseFunction() { super( "upper case" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SublistFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SublistFunction.java index 2ab672f7cf4..261b75e942b 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SublistFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SublistFunction.java @@ -26,6 +26,8 @@ public class SublistFunction extends BaseFEELFunction { + public static final SublistFunction INSTANCE = new SublistFunction(); + public SublistFunction() { super( "sublist" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunction.java index 18f5d97108c..c0e036d9df0 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunction.java @@ -24,6 +24,8 @@ public class SubstringAfterFunction extends BaseFEELFunction { + public static final SubstringAfterFunction INSTANCE = new SubstringAfterFunction(); + public SubstringAfterFunction() { super( "substring after" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunction.java index a1d30c46428..689bab3ca60 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunction.java @@ -24,6 +24,8 @@ public class SubstringBeforeFunction extends BaseFEELFunction { + public static final SubstringBeforeFunction INSTANCE = new SubstringBeforeFunction(); + public SubstringBeforeFunction() { super( "substring before" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringFunction.java index 07409f7027a..cd5f1939aeb 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SubstringFunction.java @@ -26,6 +26,8 @@ public class SubstringFunction extends BaseFEELFunction { + public static final SubstringFunction INSTANCE = new SubstringFunction(); + public SubstringFunction() { super( "substring" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SumFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SumFunction.java index b5e2011601b..7f61e9ab90e 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SumFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/SumFunction.java @@ -29,6 +29,8 @@ public class SumFunction extends BaseFEELFunction { + public static final SumFunction INSTANCE = new SumFunction(); + public SumFunction() { super( "sum" ); } diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/UnionFunction.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/UnionFunction.java index 02e4f1b4d6d..926627a26ed 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/UnionFunction.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/UnionFunction.java @@ -29,6 +29,8 @@ public class UnionFunction extends BaseFEELFunction { + public static final UnionFunction INSTANCE = new UnionFunction(); + public UnionFunction() { super( "union" ); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctionsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctionsTest.java new file mode 100644 index 00000000000..c0e3b0a15f0 --- /dev/null +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctionsTest.java @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

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

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.feel.runtime.functions; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.Test; +import org.kie.dmn.feel.lang.EvaluationContext; +import org.kie.dmn.feel.lang.Symbol; +import org.kie.dmn.feel.runtime.FEELFunction; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.fail; +import static org.kie.dmn.feel.runtime.functions.BuiltInFunctions.FUNCTIONS; + +public class BuiltInFunctionsTest { + + @Test + public void getFunctions() { + // This test is aimed at verify that all the "INSTANCE" fields are correctly populated, referring to the same class they are defined in + Set< Class> verifiedClasses = Stream.of(FUNCTIONS).map(this::validateFunction) + .filter(Objects::nonNull) + .collect(Collectors.toUnmodifiableSet()); + assertEquals(FUNCTIONS.length, verifiedClasses.size()); + } + + @Test + public void getFunctionsByClassFails() { + assertThrows(IllegalArgumentException.class, () -> BuiltInFunctions.getFunction(FakeFunction.class)); + } + + @Test + public void getFunctionsByNameFails() { + assertThrows(IllegalArgumentException.class, () -> BuiltInFunctions.getFunction(FakeFunction.FAKE_NAME)); + } + + private Class validateFunction(FEELFunction toValidate) { + Class aClass = toValidate.getClass(); + try { + Field instance = aClass.getDeclaredField("INSTANCE"); + assertEquals(aClass, instance.getDeclaringClass()); + return aClass; + } catch (NoSuchFieldException e) { + fail("No INSTANCE field found for " + aClass); + return null; + } + } + + static class FakeFunction implements FEELFunction { + + static String FAKE_NAME = "FAKE_NAME"; + @Override + public String getName() { + return FAKE_NAME; + } + + @Override + public Symbol getSymbol() { + return null; + } + + @Override + public List> getParameters() { + return List.of(); + } + + @Override + public Object invokeReflectively(EvaluationContext ctx, Object[] params) { + return null; + } + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/pom.xml b/kie-dmn/kie-dmn-openapi/pom.xml index 1dd39104235..e4d8419b41a 100644 --- a/kie-dmn/kie-dmn-openapi/pom.xml +++ b/kie-dmn/kie-dmn-openapi/pom.xml @@ -42,6 +42,13 @@ tests ${project.version} + + org.kie + kie-dmn-test-resources + ${project.version} + tests + test + @@ -88,8 +95,18 @@ - junit - junit + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.junit.jupiter + junit-jupiter-params test @@ -108,6 +125,12 @@ tests test + + org.kie + kie-dmn-test-resources + tests + test + com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/BaseNodeSchemaMapper.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/BaseNodeSchemaMapper.java new file mode 100644 index 00000000000..a82733b1e2b --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/BaseNodeSchemaMapper.java @@ -0,0 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

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

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; + +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.kie.dmn.feel.codegen.feel11.Functions; +import org.kie.dmn.feel.lang.ast.AtLiteralNode; +import org.kie.dmn.feel.lang.ast.BaseNode; +import org.kie.dmn.feel.lang.ast.NullNode; +import org.kie.dmn.feel.lang.ast.NumberNode; +import org.kie.dmn.feel.lang.ast.StringNode; +import org.kie.dmn.feel.lang.impl.EvaluationContextImpl; +import org.kie.dmn.feel.lang.impl.FEELEventListenersManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BaseNodeSchemaMapper { + + + private static final Logger LOG = LoggerFactory.getLogger(BaseNodeSchemaMapper.class); + + private static final Map, BiConsumer> SCHEMA_MODIFIERS; + + private static BiConsumer STRINGNODE_CONSUMER = (node, schema) -> populateEnumSchema(schema, ((StringNode) node).getValue()); + + private static BiConsumer NUMBERNODE_CONSUMER = (node, schema) -> populateEnumSchema(schema, ((NumberNode) node).getValue()); + + private static BiConsumer ATLITERALNODE_CONSUMER = (node, schema) -> { + EvaluationContextImpl emptyEvalCtx = + new EvaluationContextImpl(Functions.class.getClassLoader(), new FEELEventListenersManager()); + Object evaluated = node.evaluate(emptyEvalCtx); + Object toStore = evaluated != null ? evaluated : ((AtLiteralNode) node).getStringLiteral().toString(); + populateEnumSchema(schema, toStore); + }; + + private static BiConsumer NULLNODE_CONSUMER = (node, schema) -> populateEnumSchema(schema, null); + + static { + SCHEMA_MODIFIERS = new HashMap<>(); + SCHEMA_MODIFIERS.put(StringNode.class, STRINGNODE_CONSUMER); + SCHEMA_MODIFIERS.put(NumberNode.class, NUMBERNODE_CONSUMER); + SCHEMA_MODIFIERS.put(AtLiteralNode.class, ATLITERALNODE_CONSUMER); + SCHEMA_MODIFIERS.put(NullNode.class, NULLNODE_CONSUMER); + } + + static void populateSchemaFromBaseNode(Schema toPopulate, BaseNode baseNode) { + LOG.debug("populateSchemaFromUnaryTests {} {}", toPopulate, baseNode); + if (SCHEMA_MODIFIERS.containsKey(baseNode.getClass())) { + SCHEMA_MODIFIERS.get(baseNode.getClass()).accept(baseNode, toPopulate); + } + } + + private static void populateEnumSchema(Schema toPopulate, Object toAdd) { + LOG.debug("populateSchemaFromUnaryTests {} {}", toPopulate, toAdd); + Set enums = new HashSet<>(); + enums.add(toAdd); + if (toPopulate.getEnumeration() != null) { + enums.addAll(toPopulate.getEnumeration()); + } + toPopulate.enumeration(new ArrayList<>(enums)); + } + + private BaseNodeSchemaMapper() { + // deliberate intention not to allow instantiation of this class. + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNOASConstants.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNOASConstants.java index 527a1d6545d..4f1b562b3e1 100644 --- a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNOASConstants.java +++ b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNOASConstants.java @@ -24,6 +24,8 @@ public class DMNOASConstants { public static final String X_DMN_ALLOWED_VALUES = "x-dmn-allowed-values"; public static final String X_DMN_TYPE_CONSTRAINTS = "x-dmn-type-constraints"; public static final String X_DMN_DESCRIPTIONS = "x-dmn-descriptions"; + public static final String X_DMN_MINIMUM_VALUE = "x-dmn-minimum-value"; + public static final String X_DMN_MAXIMUM_VALUE = "x-dmn-maximum-value"; private DMNOASConstants() { // no constructor for contants/utility classes. diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNTypeSchemas.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNTypeSchemas.java index 92a04692a81..7f7006f6634 100644 --- a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNTypeSchemas.java +++ b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNTypeSchemas.java @@ -18,10 +18,8 @@ */ package org.kie.dmn.openapi.impl; -import java.time.LocalDate; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -38,7 +36,6 @@ import org.kie.dmn.core.impl.BaseDMNTypeImpl; import org.kie.dmn.core.impl.CompositeTypeImpl; import org.kie.dmn.core.impl.SimpleTypeImpl; -import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.feel.runtime.UnaryTest; import org.kie.dmn.openapi.NamingPolicy; import org.kie.dmn.openapi.model.DMNModelIOSets; @@ -69,9 +66,46 @@ public Map generateSchemas() { return schemas; } + static void populateSchemaWithConstraints(Schema toPopulate, SimpleTypeImpl t) { + if (t.getAllowedValues() != null && !t.getAllowedValues().isEmpty()) { + parseSimpleType(DMNOASConstants.X_DMN_ALLOWED_VALUES, toPopulate, t.getAllowedValuesFEEL(), t.getAllowedValues()); + } + if (t.getTypeConstraint() != null && !t.getTypeConstraint().isEmpty()) { + parseSimpleType(DMNOASConstants.X_DMN_TYPE_CONSTRAINTS, toPopulate, t.getTypeConstraintFEEL(), t.getTypeConstraint()); + } + } + + static void parseSimpleType(String schemaString, Schema schema, List feelUnaryTests, List dmnUnaryTests) { + schema.addExtension(schemaString, feelUnaryTests.stream().map(UnaryTest::toString).collect(Collectors.joining(", "))); + DMNUnaryTestsMapper.populateSchemaFromUnaryTests(schema, dmnUnaryTests); + } + + private Schema schemaFromType(DMNType t) { + if (t instanceof CompositeTypeImpl compositeType) { + return schemaFromCompositeType(compositeType); + } + if (t instanceof SimpleTypeImpl simpleType) { + return schemaFromSimpleType(simpleType); + } + throw new UnsupportedOperationException(); + } + + private Schema schemaFromSimpleType(SimpleTypeImpl t) { + DMNType baseType = t.getBaseType(); + if (baseType == null) { + throw new IllegalStateException(); + } + Schema schema = refOrBuiltinSchema(baseType); + populateSchemaWithConstraints(schema, t); + schema = nestAsItemIfCollection(schema, t); + schema.addExtension(X_DMN_TYPE, getDMNTypeSchemaXDMNTYPEdescr(t)); + processIoSetDoc(schema, t); + return schema; + } + private Schema refOrBuiltinSchema(DMNType t) { if (DMNTypeUtils.isFEELBuiltInType(t)) { - return FEELBuiltinTypeSchemas.from(t); + return FEELBuiltinTypeSchemaMapper.from(t); } if (typesIndex.contains(t)) { return OASFactory.createObject(Schema.class).ref(namingPolicy.getRef(t)); @@ -112,45 +146,6 @@ private Optional> ioSetDoc(DMNType t) { return Optional.ofNullable(res); } - private Schema schemaFromType(DMNType t) { - if (t instanceof CompositeTypeImpl) { - return schemaFromCompositeType((CompositeTypeImpl) t); - } - if (t instanceof SimpleTypeImpl) { - return schemaFromSimpleType((SimpleTypeImpl) t); - } - throw new UnsupportedOperationException(); - } - - private Schema schemaFromSimpleType(SimpleTypeImpl t) { - DMNType baseType = t.getBaseType(); - if (baseType == null) { - throw new IllegalStateException(); - } - Schema schema = refOrBuiltinSchema(baseType); - if (t.getAllowedValues() != null && !t.getAllowedValues().isEmpty()) { - parseSimpleType(DMNOASConstants.X_DMN_ALLOWED_VALUES, t, schema, t.getAllowedValuesFEEL(), t.getAllowedValues()); - } - if (t.getTypeConstraint() != null && !t.getTypeConstraint().isEmpty()) { - parseSimpleType(DMNOASConstants.X_DMN_TYPE_CONSTRAINTS, t, schema, t.getTypeConstraintFEEL(), t.getTypeConstraint()); - } - schema = nestAsItemIfCollection(schema, t); - schema.addExtension(X_DMN_TYPE, getDMNTypeSchemaXDMNTYPEdescr(t)); - processIoSetDoc(schema, t); - return schema; - } - - private void parseSimpleType(String schemaString, SimpleTypeImpl t, Schema schema, List feelUnaryTests, List dmnUnaryTests) { - schema.addExtension(schemaString, feelUnaryTests.stream().map(UnaryTest::toString).collect(Collectors.joining(", "))); - if (DMNTypeUtils.getFEELBuiltInType(ancestor(t)) == BuiltInType.NUMBER) { - FEELSchemaEnum.parseRangeableValuesIntoSchema(schema, dmnUnaryTests, Number.class); - } else if (DMNTypeUtils.getFEELBuiltInType(ancestor(t)) == BuiltInType.DATE) { - FEELSchemaEnum.parseRangeableValuesIntoSchema(schema, dmnUnaryTests, LocalDate.class); - } else { - FEELSchemaEnum.parseValuesIntoSchema(schema, dmnUnaryTests); - } - } - private Schema schemaFromCompositeType(CompositeTypeImpl ct) { Schema schema = OASFactory.createObject(Schema.class).type(SchemaType.OBJECT); if (ct.getBaseType() == null) { // main case @@ -180,14 +175,6 @@ private Schema nestAsItemIfCollection(Schema original, DMNType t) { return original; } } - - private static DMNType ancestor(DMNType type) { - DMNType baseType = type.getBaseType(); - while (baseType.getBaseType() != null) { - baseType = baseType.getBaseType(); - } - return baseType; - } private String getDMNTypeSchemaXDMNTYPEdescr(DMNType t) { if (((BaseDMNTypeImpl) t).getBelongingType() == null) { // internals for anonymous inner types. diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapper.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapper.java new file mode 100644 index 00000000000..c40dd0349f6 --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapper.java @@ -0,0 +1,122 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.antlr.v4.runtime.tree.ParseTree; +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.kie.dmn.api.core.DMNUnaryTest; +import org.kie.dmn.feel.FEEL; +import org.kie.dmn.feel.codegen.feel11.ASTUnaryTestTransform; +import org.kie.dmn.feel.lang.CompilerContext; +import org.kie.dmn.feel.lang.ast.BaseNode; +import org.kie.dmn.feel.lang.ast.InfixOpNode; +import org.kie.dmn.feel.lang.ast.NullNode; +import org.kie.dmn.feel.lang.ast.RangeNode; +import org.kie.dmn.feel.lang.ast.UnaryTestListNode; +import org.kie.dmn.feel.lang.ast.UnaryTestNode; +import org.kie.dmn.feel.lang.ast.visitor.ASTTemporalConstantVisitor; +import org.kie.dmn.feel.lang.impl.FEELEventListenersManager; +import org.kie.dmn.feel.parser.feel11.ASTBuilderVisitor; +import org.kie.dmn.feel.parser.feel11.FEELParser; +import org.kie.dmn.feel.parser.feel11.FEEL_1_1Parser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.util.stream.Collectors.groupingBy; +import static org.kie.dmn.openapi.impl.RangeNodeSchemaMapper.populateSchemaFromListOfRanges; + +public class DMNUnaryTestsMapper { + + private static final Logger LOG = LoggerFactory.getLogger(DMNUnaryTestsMapper.class); + + public static void populateSchemaFromUnaryTests(Schema toPopulate, List unaryTests) { + LOG.debug("populateSchemaFromUnaryTests {} {}", toPopulate, unaryTests); + List unaryEvaluationNodes = getUnaryEvaluationNodesFromUnaryTests(unaryTests); + Map> map = unaryEvaluationNodes.stream().collect(groupingBy(RangeNode.class::isInstance)); + if (map.containsKey(true)) { + populateSchemaFromListOfRanges(toPopulate, map.get(true).stream().map(RangeNode.class::cast).toList()); + } + if (map.containsKey(false)) { + List enumBaseNodes = map.get(false); + List nullNodes = enumBaseNodes.stream().filter(NullNode.class::isInstance).toList(); + if (nullNodes.size() > 1) { + throw new IllegalArgumentException("At most one null value is allowed for enum definition"); + } + // If there is a NullNode, the item is nullable + toPopulate.setNullable(!nullNodes.isEmpty()); + if (enumBaseNodes.size() > nullNodes.size()) { + // Let's create enum only if there is at least one node != NullNode + enumBaseNodes.forEach(unaryEvaluationNode -> populateSchemaFromBaseNode(toPopulate, unaryEvaluationNode)); + } + + } + } + + static void populateSchemaFromBaseNode(Schema toPopulate, BaseNode unaryEvaluationNode) { + LOG.debug("populateSchemaFromBaseNode {} {}", toPopulate, unaryEvaluationNode); + if (unaryEvaluationNode instanceof InfixOpNode infixOpNode) { + InfixOpNodeSchemaMapper.populateSchemaFromFunctionInvocationNode(toPopulate, infixOpNode); + } else { + BaseNodeSchemaMapper.populateSchemaFromBaseNode(toPopulate, unaryEvaluationNode); + } + } + + static List getUnaryEvaluationNodesFromUnaryTests(List unaryTests) { + LOG.debug("getUnaryEvaluationNodesFromUnaryTests {}", unaryTests); + List baseNodes = unaryTests.stream().map(dmnUnaryTest -> getBaseNode(dmnUnaryTest.toString())).toList(); + return baseNodes.stream().map(baseNode -> ((UnaryTestNode) ((UnaryTestListNode) baseNode).getElements().get(0)).getValue()).toList(); + } + + static BaseNode getBaseNode(String expression) { + LOG.debug("getBaseNode {}", expression); + FEEL feelInstance = FEEL.newInstance(); + CompilerContext ctx = feelInstance.newCompilerContext(); + ParseTree tree = getFEELParser(expression, ctx).unaryTestsRoot(); + ASTBuilderVisitor astVisitor = new ASTBuilderVisitor(ctx.getInputVariableTypes(), + ctx.getFEELFeelTypeRegistry()); + BaseNode initialAst = tree.accept(astVisitor); + BaseNode toReturn = initialAst.accept(new ASTUnaryTestTransform()).node(); + if (astVisitor.isVisitedTemporalCandidate()) { + toReturn.accept(new ASTTemporalConstantVisitor(ctx)); + } + return toReturn; + } + + static FEEL_1_1Parser getFEELParser(String expression, CompilerContext ctx) { + LOG.debug("getFEELParser {} {}", expression, ctx); + FEELEventListenersManager eventsManager = + new FEELEventListenersManager(); + return FEELParser.parse( + eventsManager, + expression, + ctx.getInputVariableTypes(), + ctx.getInputVariables(), + ctx.getFEELFunctions(), + Collections.emptyList(), + ctx.getFEELFeelTypeRegistry()); + } + + private DMNUnaryTestsMapper() { + // deliberate intention not to allow instantiation of this class. + } +} diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELBuiltinTypeSchemas.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELBuiltinTypeSchemaMapper.java similarity index 95% rename from kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELBuiltinTypeSchemas.java rename to kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELBuiltinTypeSchemaMapper.java index c0f4d908f4e..78d24419d51 100644 --- a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELBuiltinTypeSchemas.java +++ b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELBuiltinTypeSchemaMapper.java @@ -26,7 +26,7 @@ import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.typesafe.DMNTypeUtils; -public class FEELBuiltinTypeSchemas { +public class FEELBuiltinTypeSchemaMapper { public static Schema from(DMNType t) { BuiltInType builtin = DMNTypeUtils.getFEELBuiltInType(t); @@ -70,11 +70,11 @@ private static Schema convertBuiltInToJavaClass(BuiltInType builtin) { return OASFactory.createObject(Schema.class).addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:context"); // intentional, do NOT add .type(SchemaType.OBJECT), the JSONSchema to represent FEEL:context is {} case DURATION: default: - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Unsupported built-in type: " + builtin); } } - private FEELBuiltinTypeSchemas() { + private FEELBuiltinTypeSchemaMapper() { // deliberate intention not to allow instantiation of this class. } } diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELFunctionSchemaMapper.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELFunctionSchemaMapper.java new file mode 100644 index 00000000000..842adcf8570 --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELFunctionSchemaMapper.java @@ -0,0 +1,73 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.kie.dmn.feel.lang.ast.InfixOperator; +import org.kie.dmn.feel.runtime.FEELFunction; +import org.kie.dmn.feel.runtime.functions.CountFunction; +import org.drools.util.functions.TriConsumer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class FEELFunctionSchemaMapper { + + private static final Logger LOG = LoggerFactory.getLogger(FEELFunctionSchemaMapper.class); + + + static final Map< Class, TriConsumer> SCHEMA_MODIFIERS; + + private static TriConsumer COUNT_CONSUMER = (o, rightValue, schema) -> { + switch (o) { + + case GT -> + schema.setMinItems(((BigDecimal) rightValue).intValue() + 1); + case GTE -> + schema.setMinItems(((BigDecimal) rightValue).intValue()); + case LT -> + schema.setMaxItems(((BigDecimal) rightValue).intValue() -1); + case LTE -> + schema.setMaxItems(((BigDecimal) rightValue).intValue()); + case EQ -> { + schema.setMinItems(((BigDecimal) rightValue).intValue()); + schema.setMaxItems(((BigDecimal) rightValue).intValue()); + } + default -> LOG.debug("Ignore operator {}", o); + } + }; + + static { + SCHEMA_MODIFIERS = new HashMap<>(); + SCHEMA_MODIFIERS.put(CountFunction.class, COUNT_CONSUMER); + } + + static void populateSchemaFromFEELFunction(FEELFunction function, InfixOperator operator, Object rightValue, Schema toPopulate ) { + if (SCHEMA_MODIFIERS.containsKey(function.getClass())) { + SCHEMA_MODIFIERS.get(function.getClass()).accept(operator, rightValue, toPopulate); + } + } + + private FEELFunctionSchemaMapper() { + // deliberate intention not to allow instantiation of this class. + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELSchemaEnum.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELSchemaEnum.java deleted file mode 100644 index ccdb377508f..00000000000 --- a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELSchemaEnum.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.kie.dmn.openapi.impl; - -import org.eclipse.microprofile.openapi.models.media.Schema; -import org.kie.dmn.api.core.DMNUnaryTest; -import org.kie.dmn.feel.FEEL; -import org.kie.dmn.feel.runtime.Range; -import org.kie.dmn.feel.runtime.Range.RangeBoundary; -import org.kie.dmn.feel.runtime.UnaryTestImpl; -import org.kie.dmn.feel.runtime.impl.RangeImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -public class FEELSchemaEnum { - - private static final Logger LOG = LoggerFactory.getLogger(FEELSchemaEnum.class); - - public static void parseValuesIntoSchema(Schema schema, List unaryTests) { - List expectLiterals = evaluateUnaryTests(unaryTests); - try { - checkEvaluatedUnaryTestsForTypeConsistency(expectLiterals); - } catch (IllegalArgumentException e) { - LOG.warn("Unable to parse generic value into the JSON Schema for enumeration"); - return; - } - if (expectLiterals.contains(null)) { - schema.setNullable(true); - } - boolean allLiterals = !expectLiterals.isEmpty() && expectLiterals.stream().allMatch(o -> o == null || o instanceof String || o instanceof Number || o instanceof Boolean); - if (allLiterals) { - schema.enumeration(expectLiterals); - } else { - LOG.warn("Unable to parse generic value into the JSON Schema for enumeration"); - } - } - - public static void parseRangeableValuesIntoSchema(Schema schema, List list, Class expectedType) { - List uts = evaluateUnaryTests(list); // we leverage the property of the *base* FEEL grammar(non visited by ASTVisitor, only the ParseTree->AST Visitor) that `>x` is a Range - boolean allowNull = uts.remove(null); - if (allowNull) { - schema.setNullable(true); - } - if (uts.size() <= 2 && uts.stream().allMatch(o -> o instanceof Range)) { - Range range = consolidateRanges((List) uts); // cast intentional. - if (range != null) { - if (range.getLowEndPoint() != null) { - schema.minimum((BigDecimal) range.getLowEndPoint()); - schema.exclusiveMinimum(range.getLowBoundary() == RangeBoundary.OPEN); - } - if (range.getHighEndPoint() != null) { - schema.maximum((BigDecimal) range.getHighEndPoint()); - schema.exclusiveMaximum(range.getHighBoundary() == RangeBoundary.OPEN); - } - } - } else if (uts.stream().allMatch(expectedType::isInstance)) { - if (allowNull) { - uts.add(null); - } - schema.enumeration(uts); - } else { - LOG.warn("Unable to parse {} value into the JSON Schema for enumeration", expectedType); - } - } - - public static Range consolidateRanges(List ranges) { - boolean consistent = true; - Range result = new RangeImpl(); - for (Range r : ranges) { - if (r.getLowEndPoint() != null) { - if (result.getLowEndPoint() == null) { - result = new RangeImpl(r.getLowBoundary(), r.getLowEndPoint(), result.getHighEndPoint(), result.getHighBoundary()); - } else { - consistent = false; - } - } - if (r.getHighEndPoint() != null) { - if (result.getHighEndPoint() == null) { - result = new RangeImpl(result.getLowBoundary(), result.getLowEndPoint(), r.getHighEndPoint(), r.getHighBoundary()); - } else { - consistent = false; - } - } - } - return consistent ? result : null; - } - - static List evaluateUnaryTests(List list) { - FEEL feelInstance = FEEL.newInstance(); - List toReturn = list.stream() - .map(UnaryTestImpl.class::cast) - .map(UnaryTestImpl::toString) - .filter(str -> !str.contains("?")) // We have to exclude "TEST" expressions, because they can't be evaluated without a context and their return is meaningless - .map(feelInstance::evaluate) - .collect(Collectors.toList()); - checkEvaluatedUnaryTestsForNull(toReturn); - return toReturn; - } - - /** - * Method used to verify if the given List contains at most one null, - * since those should be put in the "enum" attribute - * - * @param toCheck - */ - static void checkEvaluatedUnaryTestsForNull(List toCheck) { - if (toCheck.stream().filter(Objects::isNull).toList().size() > 1) { - throw new IllegalArgumentException("More then one object is null, only one allowed at maximum"); - } - } - - /** - * Method used to verify if the given List contains the same type of Objects, - * since those should be put in the "enum" attribute - * - * @param toCheck - */ - static void checkEvaluatedUnaryTestsForTypeConsistency(List toCheck) { - if (toCheck.stream().filter(Objects::nonNull) - .map(Object::getClass) - .collect(Collectors.toUnmodifiableSet()) - .size() > 1) { - throw new IllegalArgumentException("Different types of objects, only one allowed"); - } - } - - private FEELSchemaEnum() { - // deliberate intention not to allow instantiation of this class. - } -} diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/InfixOpNodeSchemaMapper.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/InfixOpNodeSchemaMapper.java new file mode 100644 index 00000000000..7fdbed5f30e --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/InfixOpNodeSchemaMapper.java @@ -0,0 +1,50 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

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

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.kie.dmn.feel.lang.ast.FunctionInvocationNode; +import org.kie.dmn.feel.lang.ast.InfixOpNode; +import org.kie.dmn.feel.lang.ast.InfixOperator; +import org.kie.dmn.feel.lang.ast.NumberNode; +import org.kie.dmn.feel.runtime.FEELFunction; +import org.kie.dmn.feel.runtime.functions.BuiltInFunctions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class InfixOpNodeSchemaMapper { + + private static final Logger LOG = LoggerFactory.getLogger(InfixOpNodeSchemaMapper.class); + + static void populateSchemaFromFunctionInvocationNode(Schema toPopulate, InfixOpNode infixOpNode) { + LOG.debug("populateSchemaFromFunctionInvocationNode {} {}", toPopulate, infixOpNode); + String functionString = ((FunctionInvocationNode) infixOpNode.getLeft()).getName().getText(); + FEELFunction function = BuiltInFunctions.getFunction(functionString); + InfixOperator operator = infixOpNode.getOperator(); + Object rightValue = infixOpNode.getRight(); + if (rightValue instanceof NumberNode numberNode) { + rightValue = numberNode.getValue(); + } + FEELFunctionSchemaMapper.populateSchemaFromFEELFunction(function, operator, rightValue, toPopulate); + } + + private InfixOpNodeSchemaMapper() { + // deliberate intention not to allow instantiation of this class. + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/MapperHelper.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/MapperHelper.java new file mode 100644 index 00000000000..83b596c05e0 --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/MapperHelper.java @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import org.kie.dmn.feel.lang.ast.AtLiteralNode; +import org.kie.dmn.feel.lang.ast.InfixOpNode; +import org.kie.dmn.feel.lang.impl.EvaluationContextImpl; +import org.kie.dmn.feel.util.ClassLoaderUtil; + +/** + * Class meant to provide evaluation of nodes when there is not a viable alternative to manually parse it + */ +public class MapperHelper { + + static Object evaluateInfixOpNode(InfixOpNode toEvaluate) { + return toEvaluate.evaluate(new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null)); + } + + static Object evaluateAtLiteralNode(AtLiteralNode toEvaluate) { + return toEvaluate.evaluate(new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null)); + } + + private MapperHelper() { + // deliberate intention not to allow instantiation of this class. + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapper.java b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapper.java new file mode 100644 index 00000000000..c435a098b9b --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapper.java @@ -0,0 +1,97 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.math.BigDecimal; +import java.util.List; + +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.kie.dmn.feel.lang.ast.AtLiteralNode; +import org.kie.dmn.feel.lang.ast.NumberNode; +import org.kie.dmn.feel.lang.ast.RangeNode; +import org.kie.dmn.feel.runtime.Range; +import org.kie.dmn.feel.runtime.impl.RangeImpl; + +public class RangeNodeSchemaMapper { + + static void populateSchemaFromListOfRanges(Schema toPopulate, List ranges) { + Range range = consolidateRanges(ranges); + if (range != null) { + if (range.getLowEndPoint() != null) { + if (range.getLowEndPoint() instanceof BigDecimal bigDecimal) { + toPopulate.minimum(bigDecimal); + } else { + toPopulate.addExtension(DMNOASConstants.X_DMN_MINIMUM_VALUE, range.getLowEndPoint()); + } + toPopulate.exclusiveMinimum(range.getLowBoundary() == Range.RangeBoundary.OPEN); + } + if (range.getHighEndPoint() != null) { + if (range.getHighEndPoint() instanceof BigDecimal bigDecimal) { + toPopulate.maximum(bigDecimal); + } else { + toPopulate.addExtension(DMNOASConstants.X_DMN_MAXIMUM_VALUE, range.getHighEndPoint()); + } + toPopulate.exclusiveMaximum(range.getHighBoundary() == Range.RangeBoundary.OPEN); + } + } + } + + static Range consolidateRanges(List ranges) { + boolean consistent = true; + Range result = new RangeImpl(); + for (RangeNode r : ranges) { + Comparable lowValue = null; + if (r.getStart() instanceof NumberNode startNode) { + lowValue = startNode.getValue(); + } else if (r.getStart() instanceof AtLiteralNode atLiteralNode) { + Object evaluated = MapperHelper.evaluateAtLiteralNode(atLiteralNode); + lowValue = evaluated instanceof Comparable ? (Comparable) evaluated : null; + } + if (lowValue != null) { + if (result.getLowEndPoint() == null) { + result = new RangeImpl(Range.RangeBoundary.valueOf(r.getLowerBound().name()), + lowValue, + result.getHighEndPoint(), result.getHighBoundary()); + } else { + consistent = false; + } + } + Comparable highValue = null; + if (r.getEnd() instanceof NumberNode endNode) { + highValue = endNode.getValue(); + } else if (r.getEnd() instanceof AtLiteralNode atLiteralNode) { + Object evaluated = MapperHelper.evaluateAtLiteralNode(atLiteralNode); + highValue = evaluated instanceof Comparable ? (Comparable) evaluated : null; + } + if (highValue != null) { + if (result.getHighEndPoint() == null) { + result = new RangeImpl(result.getLowBoundary(), result.getLowEndPoint(), highValue, + Range.RangeBoundary.valueOf(r.getUpperBound().name())); + } else { + consistent = false; + } + } + } + return consistent ? result : null; + } + + private RangeNodeSchemaMapper() { + // deliberate intention not to allow instantiation of this class. + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/AllowNullTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/AllowNullTest.java index 231d4591fee..ce1758dc84c 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/AllowNullTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/AllowNullTest.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.DMNRuntimeTest; @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class AllowNullTest extends BaseDMNOASTest { +class AllowNullTest extends BaseDMNOASTest { @Test - public void testVowels() throws Exception { + void testVowels() throws Exception { final DMNRuntime runtime = createRuntime("vowels.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -46,7 +46,7 @@ public void testVowels() throws Exception { } @Test - public void testVowelsAllowNull() throws Exception { + void testVowelsAllowNull() throws Exception { final DMNRuntime runtime = createRuntime("vowelsAllowNull.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -61,7 +61,7 @@ public void testVowelsAllowNull() throws Exception { } @Test - public void testSoundItemDefAllowNull() throws Exception { + void testSoundItemDefAllowNull() throws Exception { final DMNRuntime runtime = createRuntime("RecommenderHitPolicy1_allowNull_itemDef.dmn", DMNRuntimeTest.class); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/BaseDMNOASTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/BaseDMNOASTest.java index 877a7c6357f..725a5ceabb3 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/BaseDMNOASTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/BaseDMNOASTest.java @@ -38,11 +38,11 @@ public abstract class BaseDMNOASTest { - protected DMNRuntime createRuntime(String string, Class class1) { + protected static DMNRuntime createRuntime(String string, Class class1) { return BaseVariantTest.VariantTestConf.KIE_API_TYPECHECK.createRuntime(string, class1); } - protected DMNRuntime createRuntimeWithAdditionalResources(String string, Class class1, String... string2) { + protected static DMNRuntime createRuntimeWithAdditionalResources(String string, Class class1, String... string2) { return BaseVariantTest.VariantTestConf.KIE_API_TYPECHECK.createRuntimeWithAdditionalResources(string, class1, string2); } @@ -54,7 +54,7 @@ protected JsonNode readJSON(String content) throws IOException { return mapper.readTree(content); } - protected JsonSchema getJSONSchema(JsonNode schemaContent) { + protected static JsonSchema getJSONSchema(JsonNode schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(com.networknt.schema.SpecVersion.VersionFlag.V4); return factory.getSchema(schemaContent); } @@ -63,12 +63,12 @@ protected Set validateUsing(JsonSchema validator, String json return validator.validate(readJSON(json)); } - protected ObjectNode synthesizeSchema(DMNOASResult result, DMNModel modelUnderTest) { + protected static ObjectNode synthesizeSchema(DMNOASResult result, DMNModel modelUnderTest) { DMNType InputSetTypeUT = result.lookupIOSetsByModel(modelUnderTest).getInputSet(); return synthesizeSchema(result, InputSetTypeUT); } - private ObjectNode synthesizeSchema(DMNOASResult result, DMNType InputSetTypeUT) { + private static ObjectNode synthesizeSchema(DMNOASResult result, DMNType InputSetTypeUT) { String dollarRef = result.getNamingPolicy().getRef(InputSetTypeUT); ObjectNode syntheticJSONSchema = result.getJsonSchemaNode().deepCopy(); JsonUtil.stringProperty(syntheticJSONSchema, "$ref", dollarRef); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/CH11Test.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/CH11Test.java index 276e6dc1cae..4918a19aa22 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/CH11Test.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/CH11Test.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.v1_4.DMN14specificTest; @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CH11Test extends BaseDMNOASTest { +class CH11Test extends BaseDMNOASTest { @Test - public void test_dmn14support() throws Exception { + void test_dmn14support() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("Chapter 11 Example.dmn", DMN14specificTest.class, "Financial.dmn"); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DMNDescriptionTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DMNDescriptionTest.java index b78775f2587..f54fccd62c2 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DMNDescriptionTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DMNDescriptionTest.java @@ -22,17 +22,17 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.openapi.impl.DMNOASConstants.X_DMN_DESCRIPTIONS; -public class DMNDescriptionTest extends BaseDMNOASTest { +class DMNDescriptionTest extends BaseDMNOASTest { @Test - public void test() throws Exception { + void test() throws Exception { final DMNRuntime runtime = createRuntime("dmnDescription.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); JacksonUtils.printoutJSON(result.getJsonSchemaNode()); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DS004decisionservicesTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DS004decisionservicesTest.java index 53d3c2c5209..342359c06a6 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DS004decisionservicesTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DS004decisionservicesTest.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.decisionservices.DMNDecisionServicesTest; @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class DS004decisionservicesTest extends BaseDMNOASTest { +class DS004decisionservicesTest extends BaseDMNOASTest { @Test - public void test0004decisionservices_DS1() throws Exception { + void test0004decisionservices_DS1() throws Exception { final DMNRuntime runtime = createRuntime("0004-decision-services.dmn", DMNDecisionServicesTest.class); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -45,7 +45,7 @@ public void test0004decisionservices_DS1() throws Exception { } @Test - public void test0004decisionservices_DS2() throws Exception { + void test0004decisionservices_DS2() throws Exception { final DMNRuntime runtime = createRuntime("0004-decision-services.dmn", DMNDecisionServicesTest.class); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DSMultipleOutputTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DSMultipleOutputTest.java index 59dc91c62f2..ed8617ded6a 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DSMultipleOutputTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DSMultipleOutputTest.java @@ -20,17 +20,17 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; import static org.assertj.core.api.Assertions.assertThat; -public class DSMultipleOutputTest extends BaseDMNOASTest { +class DSMultipleOutputTest extends BaseDMNOASTest { @Test - public void test() throws Exception { + void test() throws Exception { final DMNRuntime runtime = createRuntime("DSMultipleOutput.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DiscouragedTypesTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DiscouragedTypesTest.java index 966ea9d59a2..c9ab323ecd8 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DiscouragedTypesTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/DiscouragedTypesTest.java @@ -20,17 +20,17 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; import static org.assertj.core.api.Assertions.assertThat; -public class DiscouragedTypesTest extends BaseDMNOASTest { +class DiscouragedTypesTest extends BaseDMNOASTest { @Test - public void test() throws Exception { + void test() throws Exception { final DMNRuntime runtime = createRuntime("discouragedTypes.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java new file mode 100644 index 00000000000..9755f3d1fd7 --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java @@ -0,0 +1,143 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

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

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.List; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.BooleanNode; +import com.fasterxml.jackson.databind.node.DecimalNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.kie.dmn.api.core.DMNModel; +import org.kie.dmn.api.core.DMNRuntime; +import org.kie.dmn.openapi.model.DMNOASResult; + +import static org.assertj.core.api.Assertions.assertThat; + +class EnumGenerationTest extends BaseDMNOASTest { + + private static final String DMN_FILE = "valid_models/DMNv1_5/ConstraintsChecks.dmn"; + private static JsonNode definitions; + + @BeforeAll + public static void setup() { + DMNRuntime runtime = createRuntime(DMN_FILE, EnumGenerationTest.class); + DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); + + DMNModel modelUnderTest = runtime.getModel("http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b" + + "-504f3e77b442", + "ConstraintsChecks"); + ObjectNode syntheticJSONSchema = synthesizeSchema(result, modelUnderTest); + definitions = syntheticJSONSchema.get("definitions"); + } + + @Test + void testNumberAllowedValues() { + JsonNode node = definitions.get("numberAllowedValues"); + assertThat(node).isNotNull(); + ArrayNode arrayNode = (ArrayNode) node.get("enum"); + assertThat(arrayNode).isNotNull(); + List expected = Arrays.asList(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.valueOf(2)); + arrayNode.iterator().forEachRemaining(e -> { + assertThat(e).isInstanceOf(DecimalNode.class); + assertThat(expected).contains(e.decimalValue()); + }); + assertThat(node.get("nullable")).isNotNull().isInstanceOf(BooleanNode.class); + assertThat(node.get("nullable").asBoolean()).isFalse(); + } + + @Test + void testStringAllowedValues() { + JsonNode node = definitions.get("stringAllowedValues"); + assertThat(node).isNotNull(); + ArrayNode arrayNode = (ArrayNode) node.get("enum"); + assertThat(arrayNode).isNotNull(); + List expected = Arrays.asList("a", "b", "c"); + arrayNode.iterator().forEachRemaining(e -> { + assertThat(e).isInstanceOf(TextNode.class); + assertThat(expected).contains(e.textValue()); + }); + assertThat(node.get("nullable")).isNotNull().isInstanceOf(BooleanNode.class); + assertThat(node.get("nullable").asBoolean()).isFalse(); + } + + @Test + void testStringNullableAllowedValues() { + JsonNode node = definitions.get("stringNullableAllowedValues"); + assertThat(node).isNotNull(); + ArrayNode arrayNode = (ArrayNode) node.get("enum"); + assertThat(arrayNode).isNotNull(); + List expected = Arrays.asList("a", "b", "c", null); + arrayNode.iterator().forEachRemaining(e -> { + assertThat(expected).contains(e.textValue()); + }); + assertThat(node.get("nullable")).isNotNull().isInstanceOf(BooleanNode.class); + assertThat(node.get("nullable").asBoolean()).isTrue(); + } + + @Test + void testNumberTypeConstraint() { + JsonNode node = definitions.get("numberTypeConstraint"); + assertThat(node).isNotNull(); + ArrayNode arrayNode = (ArrayNode) node.get("enum"); + assertThat(arrayNode).isNotNull(); + List expected = Arrays.asList(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.valueOf(2)); + arrayNode.iterator().forEachRemaining(e -> { + assertThat(e).isInstanceOf(DecimalNode.class); + assertThat(expected).contains(e.decimalValue()); + }); + assertThat(node.get("nullable")).isNotNull().isInstanceOf(BooleanNode.class); + assertThat(node.get("nullable").asBoolean()).isFalse(); + } + + @Test + void testStringTypeConstraint() { + JsonNode node = definitions.get("stringTypeConstraint"); + assertThat(node).isNotNull(); + ArrayNode arrayNode = (ArrayNode) node.get("enum"); + assertThat(arrayNode).isNotNull(); + List expected = Arrays.asList("a", "b", "c"); + arrayNode.iterator().forEachRemaining(e -> { + assertThat(e).isInstanceOf(TextNode.class); + assertThat(expected).contains(e.textValue()); + }); + assertThat(node.get("nullable")).isNotNull().isInstanceOf(BooleanNode.class); + assertThat(node.get("nullable").asBoolean()).isFalse(); + } + + @Test + void testStringNullableTypeConstraint() { + JsonNode node = definitions.get("stringNullableTypeConstraint"); + assertThat(node).isNotNull(); + ArrayNode arrayNode = (ArrayNode) node.get("enum"); + assertThat(arrayNode).isNotNull(); + List expected = Arrays.asList("a", "b", "c", null); + arrayNode.iterator().forEachRemaining(e -> { + assertThat(expected).contains(e.textValue()); + }); + assertThat(node.get("nullable")).isNotNull().isInstanceOf(BooleanNode.class); + assertThat(node.get("nullable").asBoolean()).isTrue(); + } +} diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ImportingTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ImportingTest.java index 14a277f8f84..17816d04fd6 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ImportingTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ImportingTest.java @@ -18,7 +18,7 @@ */ package org.kie.dmn.openapi; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.imports.ImportsTest; @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class ImportingTest extends BaseDMNOASTest { +class ImportingTest extends BaseDMNOASTest { @Test - public void testBasicImports() throws Exception { + void testBasicImports() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("baseSum.dmn", ImportsTest.class, "importingSum.dmn"); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/JacksonUtils.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/JacksonUtils.java index 6311a968e48..6f9f8cd23d5 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/JacksonUtils.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/JacksonUtils.java @@ -22,7 +22,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class JacksonUtils { +class JacksonUtils { private static final Logger LOG = LoggerFactory.getLogger(JacksonUtils.class); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MultipleModelsTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MultipleModelsTest.java index 345ba02a708..9a3d5da0791 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MultipleModelsTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MultipleModelsTest.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.stronglytyped.DMNRuntimeTypesTest; @@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class MultipleModelsTest extends BaseDMNOASTest { +class MultipleModelsTest extends BaseDMNOASTest { @Test - public void testNSEW() throws Exception { + void testNSEW() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("NSEW.dmn", DMNRuntimeTypesTest.class, "Traffic Violation.dmn"); @@ -50,7 +50,7 @@ public void testNSEW() throws Exception { } @Test - public void testTF() throws Exception { + void testTF() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("NSEW.dmn", DMNRuntimeTypesTest.class, "Traffic Violation.dmn"); @@ -71,7 +71,7 @@ public void testTF() throws Exception { } @Test - public void testCH11() throws Exception { + void testCH11() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("Chapter 11 Example.dmn", DMN13specificTest.class, "Financial.dmn"); @@ -87,7 +87,7 @@ public void testCH11() throws Exception { } @Test - public void testSameName() throws Exception { + void testSameName() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("sameNameNS1.dmn", this.getClass(), "sameNameNS2.dmn"); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MyOrderTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MyOrderTest.java index b9252265b5b..25ca45ac573 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MyOrderTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MyOrderTest.java @@ -20,17 +20,17 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; import static org.assertj.core.api.Assertions.assertThat; -public class MyOrderTest extends BaseDMNOASTest { +class MyOrderTest extends BaseDMNOASTest { @Test - public void test() throws Exception { + void test() throws Exception { final DMNRuntime runtime = createRuntime("myOrder.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/NumberAllowedValuesTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/NumberAllowedValuesTest.java index c94cead05dc..ce4aca2cf9f 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/NumberAllowedValuesTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/NumberAllowedValuesTest.java @@ -18,7 +18,7 @@ */ package org.kie.dmn.openapi; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; @@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class NumberAllowedValuesTest extends BaseDMNOASTest { +class NumberAllowedValuesTest extends BaseDMNOASTest { @Test - public void testAllowedValues() throws Exception { + void testAllowedValues() throws Exception { final DMNRuntime runtime = createRuntime("numberAllowedValues.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -44,7 +44,7 @@ public void testAllowedValues() throws Exception { } @Test - public void testNumberList() throws Exception { + void testNumberList() throws Exception { final DMNRuntime runtime = createRuntime("numberList.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -57,7 +57,7 @@ public void testNumberList() throws Exception { } @Test - public void testGT() throws Exception { + void testGT() throws Exception { final DMNRuntime runtime = createRuntime("numberGT.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/OneOfEachTypeTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/OneOfEachTypeTest.java index 51a03ff41e8..08ebf92120e 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/OneOfEachTypeTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/OneOfEachTypeTest.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.stronglytyped.DMNRuntimeTypesTest; @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class OneOfEachTypeTest extends BaseDMNOASTest { +class OneOfEachTypeTest extends BaseDMNOASTest { @Test - public void test() throws Exception { + void test() throws Exception { final DMNRuntime runtime = createRuntime("OneOfEachType.dmn", DMNRuntimeTypesTest.class); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonTest.java index dfe7bb1fe29..a1cd88badb6 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonTest.java @@ -18,7 +18,7 @@ */ package org.kie.dmn.openapi; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class PersonTest extends BaseDMNOASTest { +class PersonTest extends BaseDMNOASTest { @Test - public void test() throws Exception { + void test() throws Exception { final DMNRuntime runtime = createRuntime("personF.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonsTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonsTest.java index 627024851c3..51dec56d143 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonsTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonsTest.java @@ -20,17 +20,17 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; import static org.assertj.core.api.Assertions.assertThat; -public class PersonsTest extends BaseDMNOASTest { +class PersonsTest extends BaseDMNOASTest { @Test - public void test() throws Exception { + void test() throws Exception { final DMNRuntime runtime = createRuntime("persons.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -43,7 +43,7 @@ public void test() throws Exception { } @Test - public void testForPrefix() throws Exception { + void testForPrefix() throws Exception { final DMNRuntime runtime = createRuntime("persons.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels(), "#/definitions/").build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ProcessItemTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ProcessItemTest.java index 4ec4ab64f2a..5441ed06c3c 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ProcessItemTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ProcessItemTest.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -public class ProcessItemTest extends BaseDMNOASTest { +class ProcessItemTest extends BaseDMNOASTest { @Test - public void test() throws Exception { + void test() throws Exception { final DMNRuntime runtime = createRuntime("processItem.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -51,7 +51,7 @@ private void checkProcessItem(final DMNRuntime runtime, DMNOASResult result) thr } @Test - public void test_2() throws Exception { + void test_2() throws Exception { final DMNRuntime runtime = createRuntime("processItem_2.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -69,7 +69,7 @@ private void checkProcessItem_2(final DMNRuntime runtime, DMNOASResult result) t } @Test - public void test_together() throws Exception { + void test_together() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("processItem.dmn", this.getClass(), "processItem_2.dmn"); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -78,7 +78,7 @@ public void test_together() throws Exception { } @Test - public void test_Colliding() { + void test_Colliding() { final DMNRuntime runtime = createRuntimeWithAdditionalResources("processItem.dmn", this.getClass(), "processItemCollidingNS.dmn"); assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(() -> DMNOASGeneratorFactory.generator(runtime.getModels()).build()) diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/TypeWithSpaceTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/TypeWithSpaceTest.java index 8721d19272e..951af16f7d0 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/TypeWithSpaceTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/TypeWithSpaceTest.java @@ -20,17 +20,17 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; import static org.assertj.core.api.Assertions.assertThat; -public class TypeWithSpaceTest extends BaseDMNOASTest { +class TypeWithSpaceTest extends BaseDMNOASTest { @Test - public void test() throws Exception { + void test() throws Exception { final DMNRuntime runtime = createRuntime("typeWithSpace.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/UndefinedTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/UndefinedTest.java index f64851f6dbc..a0d8ad0a9e6 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/UndefinedTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/UndefinedTest.java @@ -20,17 +20,17 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.JsonSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; import static org.assertj.core.api.Assertions.assertThat; -public class UndefinedTest extends BaseDMNOASTest { +class UndefinedTest extends BaseDMNOASTest { @Test - public void testUndefinedIO() throws Exception { + void testUndefinedIO() throws Exception { final DMNRuntime runtime = createRuntime("undefinedIO.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNTypeSchemasTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNTypeSchemasTest.java new file mode 100644 index 00000000000..93d9fca6f2a --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNTypeSchemasTest.java @@ -0,0 +1,143 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

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

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.junit.jupiter.api.Test; +import org.kie.dmn.core.impl.SimpleTypeImpl; +import org.kie.dmn.feel.lang.types.BuiltInType; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.FEEL_NUMBER; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.FEEL_STRING; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.getSchemaForSimpleType; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.getSimpleType; + +class DMNTypeSchemasTest { + + @Test + void testPopulateSchemaWithConstraintsForAllowedValues() { + List enumBase = Arrays.asList("DMN", "PMML", "JBPMN", "DRL"); + List toEnum = + enumBase.stream().map(toMap -> String.format("\"%s\"", toMap)).collect(Collectors.toUnmodifiableList()); + String allowedValuesString = String.join(",", + toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); + SimpleTypeImpl toRead = getSimpleType(allowedValuesString, null, FEEL_STRING, BuiltInType.STRING); + AtomicReference toPopulate = new AtomicReference<>(getSchemaForSimpleType(toRead)); + DMNTypeSchemas.populateSchemaWithConstraints(toPopulate.get(), toRead); + assertEquals(enumBase.size(), toPopulate.get().getEnumeration().size()); + enumBase.forEach(en -> assertTrue(toPopulate.get().getEnumeration().contains(en))); + assertTrue(toPopulate.get().getExtensions().containsKey(DMNOASConstants.X_DMN_ALLOWED_VALUES)); + String retrieved = + ((String) toPopulate.get().getExtensions().get(DMNOASConstants.X_DMN_ALLOWED_VALUES)).replace(" ", ""); + assertEquals(allowedValuesString, retrieved); + + toEnum = Arrays.asList(1, 3, 6, 78); + allowedValuesString = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); + + toRead = getSimpleType(allowedValuesString, null, FEEL_NUMBER, BuiltInType.NUMBER); + toPopulate.set(getSchemaForSimpleType(toRead)); + DMNTypeSchemas.populateSchemaWithConstraints(toPopulate.get(), toRead); + assertEquals(toEnum.size(), toPopulate.get().getEnumeration().size()); + toEnum.stream().map(i -> BigDecimal.valueOf((int) i)).forEach(en -> assertTrue(toPopulate.get().getEnumeration().contains(en))); + assertTrue(toPopulate.get().getExtensions().containsKey(DMNOASConstants.X_DMN_ALLOWED_VALUES)); + retrieved = ((String) toPopulate.get().getExtensions().get(DMNOASConstants.X_DMN_ALLOWED_VALUES)).replace(" " + , ""); + assertEquals(allowedValuesString, retrieved); + } + + @Test + void testPopulateSchemaWithConstraintsForTypeConstraints() { + List enumBase = Arrays.asList("DMN", "PMML", "JBPMN", "DRL"); + List toEnum = + enumBase.stream().map(toMap -> String.format("\"%s\"", toMap)).collect(Collectors.toUnmodifiableList()); + String typeConstraintsString = String.join(",", + toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); + SimpleTypeImpl toRead = getSimpleType(null, typeConstraintsString, FEEL_STRING, BuiltInType.STRING); + AtomicReference toPopulate = new AtomicReference<>(getSchemaForSimpleType(toRead)); + DMNTypeSchemas.populateSchemaWithConstraints(toPopulate.get(), toRead); + assertEquals(enumBase.size(), toPopulate.get().getEnumeration().size()); + enumBase.forEach(en -> assertTrue(toPopulate.get().getEnumeration().contains(en))); + assertTrue(toPopulate.get().getExtensions().containsKey(DMNOASConstants.X_DMN_TYPE_CONSTRAINTS)); + String retrieved = + ((String) toPopulate.get().getExtensions().get(DMNOASConstants.X_DMN_TYPE_CONSTRAINTS)).replace(" ", + ""); + assertEquals(typeConstraintsString, retrieved); + + toEnum = Arrays.asList(1, 3, 6, 78); + typeConstraintsString = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); + + toRead = getSimpleType(null, typeConstraintsString, FEEL_NUMBER, BuiltInType.NUMBER); + toPopulate.set(getSchemaForSimpleType(toRead)); + DMNTypeSchemas.populateSchemaWithConstraints(toPopulate.get(), toRead); + assertEquals(toEnum.size(), toPopulate.get().getEnumeration().size()); + toEnum.stream().map(i -> BigDecimal.valueOf((int) i)).forEach(en -> assertTrue(toPopulate.get().getEnumeration().contains(en))); + assertTrue(toPopulate.get().getExtensions().containsKey(DMNOASConstants.X_DMN_TYPE_CONSTRAINTS)); + retrieved = ((String) toPopulate.get().getExtensions().get(DMNOASConstants.X_DMN_TYPE_CONSTRAINTS)).replace( + " ", ""); + assertEquals(typeConstraintsString, retrieved); + } + + @Test + void testPopulateSchemaWithRangesForAllowedValues() { + List toRange = Arrays.asList("(>1)", "(<=10)"); + String allowedValuesString = String.join(",", + toRange.stream().map(toMap -> String.format("%s", toMap)).toList()); + SimpleTypeImpl toRead = getSimpleType(allowedValuesString, null, FEEL_STRING, BuiltInType.STRING); + AtomicReference toPopulate = new AtomicReference<>(getSchemaForSimpleType(toRead)); + DMNTypeSchemas.populateSchemaWithConstraints(toPopulate.get(), toRead); + assertEquals(BigDecimal.ONE, toPopulate.get().getMinimum()); + assertTrue(toPopulate.get().getExclusiveMinimum()); + assertEquals(BigDecimal.TEN, toPopulate.get().getMaximum()); + assertFalse(toPopulate.get().getExclusiveMaximum()); + assertTrue(toPopulate.get().getExtensions().containsKey(DMNOASConstants.X_DMN_ALLOWED_VALUES)); + String retrieved = + ((String) toPopulate.get().getExtensions().get(DMNOASConstants.X_DMN_ALLOWED_VALUES)).replace(" ", ""); + String expected = allowedValuesString.replace("(", "").replace(")", ""); + assertEquals(expected, retrieved); + } + + @Test + void testPopulateSchemaWithRangesForTypeConstraints() { + List toRange = Arrays.asList("(>1)", "(<=10)"); + String typeConstraintsString = String.join(",", + toRange.stream().map(toMap -> String.format("%s", toMap)).toList()); + SimpleTypeImpl toRead = getSimpleType(null, typeConstraintsString, FEEL_STRING, BuiltInType.STRING); + AtomicReference toPopulate = new AtomicReference<>(getSchemaForSimpleType(toRead)); + DMNTypeSchemas.populateSchemaWithConstraints(toPopulate.get(), toRead); + assertEquals(BigDecimal.ONE, toPopulate.get().getMinimum()); + assertTrue(toPopulate.get().getExclusiveMinimum()); + assertEquals(BigDecimal.TEN, toPopulate.get().getMaximum()); + assertFalse(toPopulate.get().getExclusiveMaximum()); + assertTrue(toPopulate.get().getExtensions().containsKey(DMNOASConstants.X_DMN_TYPE_CONSTRAINTS)); + String retrieved = + ((String) toPopulate.get().getExtensions().get(DMNOASConstants.X_DMN_TYPE_CONSTRAINTS)).replace(" ", + ""); + String expected = typeConstraintsString.replace("(", "").replace(")", ""); + assertEquals(expected, retrieved); + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapperTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapperTest.java new file mode 100644 index 00000000000..7010edd09d0 --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapperTest.java @@ -0,0 +1,140 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +import org.eclipse.microprofile.openapi.OASFactory; +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.junit.jupiter.api.Test; +import org.kie.dmn.api.core.DMNUnaryTest; +import org.kie.dmn.feel.lang.ast.BaseNode; +import org.kie.dmn.feel.lang.types.BuiltInType; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.kie.dmn.openapi.impl.DMNUnaryTestsMapper.getUnaryEvaluationNodesFromUnaryTests; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.FEEL_NUMBER; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.FEEL_STRING; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.feel; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.getSchemaForSimpleType; + +class DMNUnaryTestsMapperTest { + + @Test + void testPopulateSchemaFromUnaryTestsForEnumsWithoutNull() { + Schema toPopulate = OASFactory.createObject(Schema.class); + List expectedStrings = Arrays.asList("ONE", "TWO"); + List toEnum = expectedStrings.stream().map(toMap -> String.format("\"%s\"", toMap)).collect(Collectors.toUnmodifiableList()); + String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap.toString())).toList()); + expression += ", count (?) > 1"; + List unaryTests = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); + DMNUnaryTestsMapper.populateSchemaFromUnaryTests(toPopulate, unaryTests); + assertFalse(toPopulate.getNullable()); + assertNotNull(toPopulate.getEnumeration()); + assertEquals(expectedStrings.size(), toPopulate.getEnumeration().size()); + expectedStrings.forEach(expectedString -> assertTrue(toPopulate.getEnumeration().contains(expectedString))); + } + + @Test + void testPopulateSchemaFromUnaryTestsForEnumsWithNull() { + Schema toPopulate = OASFactory.createObject(Schema.class); + List expectedStrings = Arrays.asList(null, "ONE", "TWO"); + List toEnum = expectedStrings.stream().map(toFormat -> toFormat == null ? "null": String.format("\"%s\"", toFormat)).collect(Collectors.toUnmodifiableList()); + String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap.toString())).toList()); + List unaryTests = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); + DMNUnaryTestsMapper.populateSchemaFromUnaryTests(toPopulate, unaryTests); + assertTrue(toPopulate.getNullable()); + assertNotNull(toPopulate.getEnumeration()); + assertEquals(expectedStrings.size(), toPopulate.getEnumeration().size()); + expectedStrings.stream().filter(Objects::nonNull).forEach(expectedString -> assertTrue(toPopulate.getEnumeration().contains(expectedString))); + } + + @Test + void testPopulateSchemaFromUnaryTestsForEnumSucceed() { + List enumBase = Arrays.asList("DMN", "PMML", "JBPMN", "DRL"); + List toEnum = enumBase.stream().map(toMap -> String.format("\"%s\"", toMap)).collect(Collectors.toUnmodifiableList()); + String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); + List toCheck = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); + AtomicReference toPopulate = new AtomicReference<>(getSchemaForSimpleType(null, expression, FEEL_STRING, BuiltInType.STRING)); + assertNull(toPopulate.get().getEnumeration()); + DMNUnaryTestsMapper.populateSchemaFromUnaryTests(toPopulate.get(), toCheck); + assertEquals(enumBase.size(), toPopulate.get().getEnumeration().size()); + enumBase.forEach(en -> assertTrue(toPopulate.get().getEnumeration().contains(en))); + + toEnum = Arrays.asList(1, 3, 6, 78); + expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); + toCheck = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); + toPopulate.set(getSchemaForSimpleType(null, expression, FEEL_NUMBER, BuiltInType.NUMBER)); + assertNull(toPopulate.get().getEnumeration()); + DMNUnaryTestsMapper.populateSchemaFromUnaryTests(toPopulate.get(), toCheck); + assertEquals(toEnum.size(), toPopulate.get().getEnumeration().size()); + toEnum.stream().map(i -> BigDecimal.valueOf((int)i)).forEach(en -> assertTrue(toPopulate.get().getEnumeration().contains(en))); + + toPopulate.set(OASFactory.createObject(Schema.class)); + List expectedDates = Arrays.asList(LocalDate.of(2022, 1, 1), LocalDate.of(2024, 1, 1)); + List formattedDates = expectedDates.stream() + .map(toFormat -> String.format("@\"%s-0%s-0%s\"", toFormat.getYear(), toFormat.getMonthValue(), toFormat.getDayOfMonth())) + .toList(); + expression = String.join(",", formattedDates.stream().map(toMap -> String.format("%s", toMap)).toList()); + toCheck = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); + assertNull(toPopulate.get().getNullable()); + DMNUnaryTestsMapper.populateSchemaFromUnaryTests(toPopulate.get(), toCheck); + assertNotNull(toPopulate.get().getEnumeration()); + assertEquals(expectedDates.size(), toPopulate.get().getEnumeration().size()); + expectedDates.forEach(expectedDate -> assertTrue(toPopulate.get().getEnumeration().contains(expectedDate))); + } + + @Test + void testPopulateSchemaFromUnaryTestsFails() { + List toEnum = Arrays.asList(null, null, "@\"2024-01-01\""); + String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); + List toCheck = + feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); + assertEquals(toEnum.size(), toCheck.size()); + Schema toPopulate = getSchemaForSimpleType(null, expression, FEEL_STRING, BuiltInType.STRING); + assertThrows(IllegalArgumentException.class, () -> DMNUnaryTestsMapper.populateSchemaFromUnaryTests(toPopulate, toCheck)); + } + + @Test + void testPopulateSchemaFromBaseNodeSucceed() { + List enumBase = List.of("DMN"); + List toEnum = enumBase.stream().map(toMap -> String.format("\"%s\"", toMap)).toList(); + String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); + List dmnUnaryTests = + feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); + AtomicReference schemaRef = new AtomicReference<>(getSchemaForSimpleType(null, expression, FEEL_STRING, BuiltInType.STRING)); + assertNull(schemaRef.get().getEnumeration()); + BaseNode toCheck = getUnaryEvaluationNodesFromUnaryTests(dmnUnaryTests).get(0); + DMNUnaryTestsMapper.populateSchemaFromBaseNode(schemaRef.get(), toCheck); + assertEquals(enumBase.size(), schemaRef.get().getEnumeration().size()); + enumBase.forEach(en -> assertTrue(schemaRef.get().getEnumeration().contains(en))); + } + +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DefaultNamingPolicyTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DefaultNamingPolicyTest.java index 64293dc19a5..d63e9c4cad5 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DefaultNamingPolicyTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DefaultNamingPolicyTest.java @@ -20,17 +20,16 @@ import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNType; import org.kie.dmn.core.impl.SimpleTypeImpl; -import org.kie.dmn.openapi.impl.DefaultNamingPolicy; import static org.assertj.core.api.Assertions.assertThat; -public class DefaultNamingPolicyTest { +class DefaultNamingPolicyTest { @Test - public void test() { + void test() { DefaultNamingPolicy ut = new DefaultNamingPolicy("#/definitions/"); assertThat(ut.getName(unregisteredType("tPerson"))).isEqualTo("tPerson"); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELFunctionSchemaMapperTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELFunctionSchemaMapperTest.java new file mode 100644 index 00000000000..d26b8c8fd89 --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELFunctionSchemaMapperTest.java @@ -0,0 +1,62 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

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

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.kie.dmn.feel.lang.ast.InfixOperator; +import org.kie.dmn.feel.lang.types.BuiltInType; +import org.kie.dmn.feel.runtime.functions.CountFunction; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.FEEL_NUMBER; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.getSchemaForSimpleType; + +class FEELFunctionSchemaMapperTest { + + @ParameterizedTest + @EnumSource(InfixOperator.class) + void populateSchemaFromFEELFunction(InfixOperator operator) { + List toEnum = Arrays.asList(1, 3, 6, 78); + toEnum.forEach(rightValue -> { + Schema toPopulate = getSchemaForSimpleType(null, null, FEEL_NUMBER, BuiltInType.NUMBER); + FEELFunctionSchemaMapper.populateSchemaFromFEELFunction(CountFunction.INSTANCE, operator, + BigDecimal.valueOf(rightValue), toPopulate); + Integer expectedMinimum = null; + Integer expectedMaximum = null; + switch (operator) { + case GT -> expectedMinimum = rightValue + 1; + case GTE -> expectedMinimum = rightValue; + case LT -> expectedMaximum = rightValue - 1; + case LTE -> expectedMaximum = rightValue; + case EQ -> { + expectedMinimum = rightValue; + expectedMaximum = rightValue; + } + } + assertEquals(expectedMinimum, toPopulate.getMinItems()); + assertEquals(expectedMaximum, toPopulate.getMaxItems()); + }); + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELSchemaEnumTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELSchemaEnumTest.java deleted file mode 100644 index 4dd1d0933ed..00000000000 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/FEELSchemaEnumTest.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.kie.dmn.openapi.impl; - - -import org.eclipse.microprofile.openapi.OASFactory; -import org.eclipse.microprofile.openapi.models.media.Schema; -import org.junit.Test; -import org.kie.dmn.api.core.DMNUnaryTest; -import org.kie.dmn.feel.FEEL; -import org.kie.dmn.feel.runtime.Range; -import org.kie.dmn.feel.runtime.impl.RangeImpl; - -import java.math.BigDecimal; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.kie.dmn.openapi.impl.FEELSchemaEnum.checkEvaluatedUnaryTestsForNull; -import static org.kie.dmn.openapi.impl.FEELSchemaEnum.checkEvaluatedUnaryTestsForTypeConsistency; -import static org.kie.dmn.openapi.impl.FEELSchemaEnum.evaluateUnaryTests; -import static org.kie.dmn.openapi.impl.FEELSchemaEnum.parseRangeableValuesIntoSchema; -import static org.kie.dmn.openapi.impl.FEELSchemaEnum.parseValuesIntoSchema; - -public class FEELSchemaEnumTest { - - private static final FEEL feel = FEEL.newInstance(); - - @Test - public void testParseValuesIntoSchemaWithoutNull() { - Schema toPopulate = OASFactory.createObject(Schema.class); - List expectedStrings = Arrays.asList("ONE", "TWO"); - List toEnum = expectedStrings.stream().map(toMap -> String.format("\"%s\"", toMap)).collect(Collectors.toUnmodifiableList()); - String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap.toString())).toList()); - expression += ", count (?) > 1"; - List unaryTests = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); - parseValuesIntoSchema(toPopulate, unaryTests); - assertNull(toPopulate.getNullable()); - assertNotNull(toPopulate.getEnumeration()); - assertEquals(expectedStrings.size(), toPopulate.getEnumeration().size()); - expectedStrings.forEach(expectedString -> assertTrue(toPopulate.getEnumeration().contains(expectedString))); - } - - @Test - public void testParseValuesIntoSchemaWithNull() { - Schema toPopulate = OASFactory.createObject(Schema.class); - List expectedStrings = Arrays.asList(null, "ONE", "TWO"); - List toEnum = expectedStrings.stream().map(toFormat -> toFormat == null ? "null": String.format("\"%s\"", toFormat)).collect(Collectors.toUnmodifiableList()); - String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap.toString())).toList()); - List unaryTests = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); - parseValuesIntoSchema(toPopulate, unaryTests); - assertTrue(toPopulate.getNullable()); - assertNotNull(toPopulate.getEnumeration()); - assertEquals(expectedStrings.size(), toPopulate.getEnumeration().size()); - expectedStrings.stream().filter(Objects::nonNull).forEach(expectedString -> assertTrue(toPopulate.getEnumeration().contains(expectedString))); - } - - @Test - public void testParseRangeableValuesIntoSchemaNumberWithoutNull() { - Schema toPopulate = OASFactory.createObject(Schema.class); - List expectedNumbers = Arrays.asList(1, 2); - String expression = String.join(",", expectedNumbers.stream().map(toMap -> String.format("%s", toMap)).toList()); - List unaryTests = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); - parseRangeableValuesIntoSchema(toPopulate, unaryTests, Number.class); - assertNull(toPopulate.getNullable()); - assertNotNull(toPopulate.getEnumeration()); - assertEquals(expectedNumbers.size(), toPopulate.getEnumeration().size()); - List expected = Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2)); - expected.forEach(expectedNumber -> assertTrue(toPopulate.getEnumeration().contains(expectedNumber))); - } - - @Test - public void testParseRangeableValuesNumberIntoSchemaWithNull() { - Schema toPopulate = OASFactory.createObject(Schema.class); - List expectedNumbers = Arrays.asList(null, 1, 2); - String expression = String.join(",", expectedNumbers.stream().map(toMap -> String.format("%s", toMap)).toList()); - List unaryTests = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); - parseRangeableValuesIntoSchema(toPopulate, unaryTests, Number.class); - assertTrue(toPopulate.getNullable()); - assertNotNull(toPopulate.getEnumeration()); - assertEquals(expectedNumbers.size(), toPopulate.getEnumeration().size()); - List expected = Arrays.asList(null, BigDecimal.valueOf(1), BigDecimal.valueOf(2)); - expected.stream().forEach(expectedNumber -> assertTrue(toPopulate.getEnumeration().contains(expectedNumber))); - } - - @Test - public void testParseRangeableValuesIntoSchemaLocalDateWithoutNull() { - Schema toPopulate = OASFactory.createObject(Schema.class); - List expectedDates = Arrays.asList(LocalDate.of(2022, 1, 1), LocalDate.of(2024, 1, 1)); - List formattedDates = expectedDates.stream() - .map(toFormat -> String.format("@\"%s-0%s-0%s\"", toFormat.getYear(), toFormat.getMonthValue(), toFormat.getDayOfMonth())) - .toList(); - String expression = String.join(",", formattedDates.stream().map(toMap -> String.format("%s", toMap)).toList()); - List unaryTests = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); - parseRangeableValuesIntoSchema(toPopulate, unaryTests, LocalDate.class); - assertNull(toPopulate.getNullable()); - assertNotNull(toPopulate.getEnumeration()); - assertEquals(expectedDates.size(), toPopulate.getEnumeration().size()); - expectedDates.forEach(expectedDate -> assertTrue(toPopulate.getEnumeration().contains(expectedDate))); - } - - @Test - public void testParseRangeableValuesDateIntoSchemaWithNull() { - Schema toPopulate = OASFactory.createObject(Schema.class); - List expectedDates = Arrays.asList(null, LocalDate.of(2022, 1, 1), LocalDate.of(2024, 1, 1)); - List formattedDates = expectedDates.stream() - .map(toFormat -> toFormat == null ? "null" : String.format("@\"%s-0%s-0%s\"", toFormat.getYear(), toFormat.getMonthValue(), toFormat.getDayOfMonth())) - .toList(); - String expression = String.join(",", formattedDates.stream().map(toMap -> String.format("%s", toMap)).toList()); - List unaryTests = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); - parseRangeableValuesIntoSchema(toPopulate, unaryTests, LocalDate.class); - assertTrue(toPopulate.getNullable()); - assertNotNull(toPopulate.getEnumeration()); - assertEquals(expectedDates.size(), toPopulate.getEnumeration().size()); - expectedDates.forEach(expectedDate -> assertTrue(toPopulate.getEnumeration().contains(expectedDate))); - } - - @Test - public void testConsolidateRangesSucceed() { - Range lowRange = new RangeImpl(Range.RangeBoundary.CLOSED, 0, null, Range.RangeBoundary.CLOSED); - Range highRange = new RangeImpl(Range.RangeBoundary.CLOSED, null, 100, Range.RangeBoundary.CLOSED); - List list = Arrays.asList(lowRange, highRange); - Range result = FEELSchemaEnum.consolidateRanges(list); - assertThat(result).isNotNull().isEqualTo(new RangeImpl(lowRange.getLowBoundary(), lowRange.getLowEndPoint(), highRange.getHighEndPoint(), highRange.getHighBoundary())); - // - lowRange = new RangeImpl(Range.RangeBoundary.CLOSED, LocalDate.of(2022, 1, 1), null, Range.RangeBoundary.CLOSED); - highRange = new RangeImpl(Range.RangeBoundary.CLOSED, null, LocalDate.of(2024, 1, 1), Range.RangeBoundary.CLOSED); - list = Arrays.asList(lowRange, highRange); - result = FEELSchemaEnum.consolidateRanges(list); - assertThat(result).isNotNull().isEqualTo(new RangeImpl(lowRange.getLowBoundary(), lowRange.getLowEndPoint(), highRange.getHighEndPoint(), highRange.getHighBoundary())); - } - - @Test - public void testConsolidateRangesInvalidRepeatedLB() { - List list = new ArrayList<>(); - list.add(new RangeImpl(Range.RangeBoundary.CLOSED, 0, null, Range.RangeBoundary.CLOSED)); - list.add(new RangeImpl(Range.RangeBoundary.CLOSED, 0, 100, Range.RangeBoundary.CLOSED)); - Range result = FEELSchemaEnum.consolidateRanges(list); - assertThat(result).isNull(); - } - - @Test - public void testConsolidateRangesInvalidRepeatedUB() { - List list = new ArrayList<>(); - list.add(new RangeImpl(Range.RangeBoundary.CLOSED, null, 50, Range.RangeBoundary.CLOSED)); - list.add(new RangeImpl(Range.RangeBoundary.CLOSED, null, 100, Range.RangeBoundary.CLOSED)); - Range result = FEELSchemaEnum.consolidateRanges(list); - assertThat(result).isNull(); - } - - @Test - public void testEvaluateUnaryTestsSucceed() { - List toEnum = Arrays.asList("\"a string\"", 3, "@\"2024-01-01\""); - String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap.toString())).toList()); - expression += ", count (?) > 1"; - List toCheck = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); - assertEquals(toEnum.size() + 1, toCheck.size()); - List retrieved = evaluateUnaryTests(toCheck); - List expected = Arrays.asList("a string", BigDecimal.valueOf(3), LocalDate.of(2024, 1, 1)); - assertEquals(expected.size(), retrieved.size()); - expected.forEach(expectedEntry -> assertTrue("Failing asserts for " + expectedEntry, retrieved.stream().anyMatch(ret -> Objects.equals(expectedEntry, ret)))); - } - - @Test(expected = IllegalArgumentException.class) - public void testEvaluateUnaryTestsFails() { - List toEnum = Arrays.asList(null, null, "@\"2024-01-01\""); - String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); - List toCheck = feel.evaluateUnaryTests(expression).stream().map(DMNUnaryTest.class::cast).toList(); - assertEquals(toEnum.size(), toCheck.size()); - evaluateUnaryTests(toCheck); - } - - @Test - public void testCheckEvaluatedUnaryTestsForNullSucceed() { - List toCheck = new ArrayList<>(Arrays.asList("1", "2", "3")); - checkEvaluatedUnaryTestsForNull(toCheck); - toCheck.add(null); - checkEvaluatedUnaryTestsForNull(toCheck); - } - - @Test(expected = IllegalArgumentException.class) - public void testCheckEvaluatedUnaryTestsForNullFails() { - List toCheck = new ArrayList<>(Arrays.asList("1", "2", "3")); - toCheck.add(null); - toCheck.add(null); - checkEvaluatedUnaryTestsForNull(toCheck); - } - - @Test - public void testCheckEvaluatedUnaryTestsForTypeConsistencySucceed() { - List toCheck = Arrays.asList("1", "2", "3"); - checkEvaluatedUnaryTestsForTypeConsistency(toCheck); - } - - @Test(expected = IllegalArgumentException.class) - public void testCheckEvaluatedUnaryTestsForTypeConsistencyFails() { - List toCheck = Arrays.asList("1", "2", 3); - checkEvaluatedUnaryTestsForTypeConsistency(toCheck); - } -} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/InfixOpNodeSchemaMapperTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/InfixOpNodeSchemaMapperTest.java new file mode 100644 index 00000000000..76b768b0eec --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/InfixOpNodeSchemaMapperTest.java @@ -0,0 +1,64 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

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

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.kie.dmn.feel.lang.ast.InfixOpNode; +import org.kie.dmn.feel.lang.ast.InfixOperator; +import org.kie.dmn.feel.lang.types.BuiltInType; +import org.kie.dmn.feel.runtime.functions.CountFunction; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.FEEL_NUMBER; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.getBaseNode; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.getSchemaForSimpleType; + +class InfixOpNodeSchemaMapperTest { + + @ParameterizedTest + @EnumSource(InfixOperator.class) + void populateSchemaFromFunctionInvocationNode(InfixOperator operator) { + List toEnum = Arrays.asList(1, 3, 6, 78); + toEnum.forEach(rightValue -> { + Schema toPopulate = getSchemaForSimpleType(null, null, FEEL_NUMBER, BuiltInType.NUMBER); + String expression = String.format("%s(?) %s %s", CountFunction.INSTANCE.getName(), operator.getSymbol(), rightValue); + InfixOpNode infixOpNode = getBaseNode(expression, InfixOpNode.class); + InfixOpNodeSchemaMapper.populateSchemaFromFunctionInvocationNode(toPopulate, infixOpNode); + Integer expectedMinimum = null; + Integer expectedMaximum = null; + switch (operator) { + case GT -> expectedMinimum = rightValue + 1; + case GTE -> expectedMinimum = rightValue; + case LT -> expectedMaximum = rightValue - 1; + case LTE -> expectedMaximum = rightValue; + case EQ -> { + expectedMinimum = rightValue; + expectedMaximum = rightValue; + } + } + assertEquals(expectedMinimum, toPopulate.getMinItems()); + assertEquals(expectedMaximum, toPopulate.getMaxItems()); + }); + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapperTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapperTest.java new file mode 100644 index 00000000000..e714250e15d --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapperTest.java @@ -0,0 +1,127 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

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

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.microprofile.openapi.OASFactory; +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.FEEL; +import org.kie.dmn.feel.lang.ast.RangeNode; +import org.kie.dmn.feel.runtime.Range; +import org.kie.dmn.feel.runtime.impl.RangeImpl; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.kie.dmn.openapi.impl.SchemaMapperTestUtils.getBaseNodes; + +class RangeNodeSchemaMapperTest { + + private static final FEEL feel = FEEL.newInstance(); + + @Test + void testEvaluateUnaryTestsForNumberRange() { + List toRange = Arrays.asList("(>1)", "(<=10)"); + List ranges = getBaseNodes(toRange, RangeNode.class); + Schema toPopulate = OASFactory.createObject(Schema.class); + RangeNodeSchemaMapper.populateSchemaFromListOfRanges(toPopulate, ranges); + assertEquals(BigDecimal.ONE, toPopulate.getMinimum()); + assertTrue(toPopulate.getExclusiveMinimum()); + assertEquals(BigDecimal.TEN, toPopulate.getMaximum()); + assertFalse(toPopulate.getExclusiveMaximum()); + } + + @Test + void testEvaluateUnaryTestsForDateRange() { + List expectedDates = Arrays.asList(LocalDate.of(2022, 1, 1), LocalDate.of(2024, 1, 1)); + List formattedDates = expectedDates.stream() + .map(toFormat -> String.format("@\"%s-0%s-0%s\"", toFormat.getYear(), toFormat.getMonthValue(), toFormat.getDayOfMonth())) + .toList(); + List toRange = Arrays.asList(String.format("(>%s)", formattedDates.get(0)), String.format("(<=%s)", + formattedDates.get(1))); + List ranges = getBaseNodes(toRange, RangeNode.class); + + Schema toPopulate = OASFactory.createObject(Schema.class); + RangeNodeSchemaMapper.populateSchemaFromListOfRanges(toPopulate, ranges); + assertEquals(expectedDates.get(0), toPopulate.getExtensions().get(DMNOASConstants.X_DMN_MINIMUM_VALUE)); + assertTrue(toPopulate.getExclusiveMinimum()); + assertEquals(expectedDates.get(1), toPopulate.getExtensions().get(DMNOASConstants.X_DMN_MAXIMUM_VALUE)); + assertFalse(toPopulate.getExclusiveMaximum()); + } + + @Test + void testConsolidateRangesForNumberRange() { + Range lowRange = new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, null, Range.RangeBoundary.OPEN); + Range highRange = new RangeImpl(Range.RangeBoundary.OPEN, null, BigDecimal.TEN, Range.RangeBoundary.CLOSED); + List ranges = getRangeNodes(lowRange, highRange); + Range retrieved = RangeNodeSchemaMapper.consolidateRanges(ranges); + assertThat(retrieved).isNotNull().isEqualTo(new RangeImpl(lowRange.getLowBoundary(), lowRange.getLowEndPoint(), + highRange.getHighEndPoint(), + highRange.getHighBoundary())); + } + + @Test + void testConsolidateRangesForDateRange() { + List expectedDates = Arrays.asList(LocalDate.of(2022, 1, 1), LocalDate.of(2024, 1, 1)); + Range lowRange = new RangeImpl(Range.RangeBoundary.OPEN, expectedDates.get(0), null, Range.RangeBoundary.OPEN); + Range highRange = new RangeImpl(Range.RangeBoundary.OPEN, null, expectedDates.get(1), + Range.RangeBoundary.CLOSED); + List formattedDates = expectedDates.stream() + .map(toFormat -> String.format("@\"%s-0%s-0%s\"", toFormat.getYear(), toFormat.getMonthValue(), + toFormat.getDayOfMonth())) + .toList(); + List toRange = Arrays.asList(String.format("(%s .. null)", formattedDates.get(0)), String.format( + "(null .. %s]", formattedDates.get(1))); + List ranges = getBaseNodes(toRange, RangeNode.class); + Range retrieved = RangeNodeSchemaMapper.consolidateRanges(ranges); + assertThat(retrieved).isNotNull().isEqualTo(new RangeImpl(lowRange.getLowBoundary(), lowRange.getLowEndPoint(), + highRange.getHighEndPoint(), + highRange.getHighBoundary())); + } + + @Test + void testConsolidateRangesInvalidRepeatedLB() { + Range lowRange = new RangeImpl(Range.RangeBoundary.CLOSED, 0, null, Range.RangeBoundary.CLOSED); + Range highRange = new RangeImpl(Range.RangeBoundary.CLOSED, 0, 100, Range.RangeBoundary.CLOSED); + List ranges = getRangeNodes(lowRange, highRange); + Range result = RangeNodeSchemaMapper.consolidateRanges(ranges); + assertThat(result).isNull(); + } + + @Test + void testConsolidateRangesInvalidRepeatedUB() { + Range lowRange = new RangeImpl(Range.RangeBoundary.CLOSED, null, 50, Range.RangeBoundary.CLOSED); + Range highRange = new RangeImpl(Range.RangeBoundary.CLOSED, null, 100, Range.RangeBoundary.CLOSED); + List ranges = getRangeNodes(lowRange, highRange); + Range result = RangeNodeSchemaMapper.consolidateRanges(ranges); + assertThat(result).isNull(); + } + + private List getRangeNodes(Range lowRange, Range highRange) { + List toRange = Arrays.asList(lowRange.toString(), highRange.toString()); + return getBaseNodes(toRange, RangeNode.class); + } + +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/SchemaMapperTestUtils.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/SchemaMapperTestUtils.java new file mode 100644 index 00000000000..b9a71f51cfb --- /dev/null +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/SchemaMapperTestUtils.java @@ -0,0 +1,76 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

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

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.openapi.impl; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.microprofile.openapi.models.media.Schema; +import org.kie.dmn.api.core.DMNType; +import org.kie.dmn.core.compiler.DMNTypeRegistry; +import org.kie.dmn.core.compiler.DMNTypeRegistryV15; +import org.kie.dmn.core.impl.SimpleTypeImpl; +import org.kie.dmn.feel.FEEL; +import org.kie.dmn.feel.codegen.feel11.ProcessedExpression; +import org.kie.dmn.feel.lang.ast.BaseNode; +import org.kie.dmn.feel.lang.types.BuiltInType; +import org.kie.dmn.feel.runtime.UnaryTest; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; + +class SchemaMapperTestUtils { + + static final FEEL feel = FEEL.newInstance(); + + static final DMNTypeRegistry typeRegistry = new DMNTypeRegistryV15(Collections.emptyMap()); + static final DMNType FEEL_STRING = typeRegistry.resolveType(KieDMNModelInstrumentedBase.URI_FEEL, "string"); + static final DMNType FEEL_NUMBER = typeRegistry.resolveType(KieDMNModelInstrumentedBase.URI_FEEL, "number"); + + static Schema getSchemaForSimpleType(String allowedValuesString, String typeConstraintString, DMNType baseType, + BuiltInType builtInType) { + DMNType dmnType = getSimpleType(allowedValuesString, typeConstraintString, baseType, builtInType); + return FEELBuiltinTypeSchemaMapper.from(dmnType); + } + + static Schema getSchemaForSimpleType(DMNType dmnType) { + return FEELBuiltinTypeSchemaMapper.from(dmnType); + } + + static SimpleTypeImpl getSimpleType(String allowedValuesString, String typeConstraintString, DMNType baseType, + BuiltInType builtInType) { + List allowedValues = allowedValuesString != null && !allowedValuesString.isEmpty() ? + feel.evaluateUnaryTests(allowedValuesString) : null; + List typeConstraint = typeConstraintString != null && !typeConstraintString.isEmpty() ? + feel.evaluateUnaryTests(typeConstraintString) : null; + return new SimpleTypeImpl("testNS", "tName", null, true, allowedValues, typeConstraint, baseType, builtInType); + } + + static List getBaseNodes(List toRange, Class clazz) { + return toRange.stream().map(expression -> getBaseNode(expression, clazz)) + .toList(); + } + + static T getBaseNode(String expression, Class clazz) { + ProcessedExpression processedExpression = (ProcessedExpression) feel.compile(expression, feel.newCompilerContext()); + return clazz.cast(processedExpression.getInterpreted().getASTNode()); + + } + + private SchemaMapperTestUtils() { + } +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/ConstraintsChecks.dmn b/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/ConstraintsChecks.dmn new file mode 100644 index 00000000000..8c6d51d25d5 --- /dev/null +++ b/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/ConstraintsChecks.dmn @@ -0,0 +1,74 @@ + + + + number + + 0, 1, 2 + + + + string + + "a", "b", "c" + + + + string + + "a", "b", "c", null + + + + number + + 0, 1, 2 + + + + string + + "a", "b", "c" + + + + string + + "a", "b", "c", null + + + + + + + + + + + + + + + + + + + + + + + + + + + From ff9acd5178dad98f9249e418d905e455f6eb3aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Zim=C3=A1nyi?= Date: Fri, 3 May 2024 15:36:08 +0200 Subject: [PATCH 07/10] [kie-issues#1148] Fix tests that require prebuilt artifacts in Drools (#5882) --- .../kiecontainer-from-kierepo/pom.xml | 4 ++++ kie-archetypes/pom.xml | 18 ++++++++++++++++++ .../classloader/DMNRuntimeListenerTest.java | 8 +------- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/drools-examples-api/kiecontainer-from-kierepo/pom.xml b/drools-examples-api/kiecontainer-from-kierepo/pom.xml index 433bc2fb657..d55279a5cc4 100644 --- a/drools-examples-api/kiecontainer-from-kierepo/pom.xml +++ b/drools-examples-api/kiecontainer-from-kierepo/pom.xml @@ -45,6 +45,10 @@ org.drools drools-engine-classic + + org.drools + named-kiesession + junit diff --git a/kie-archetypes/pom.xml b/kie-archetypes/pom.xml index 0e761a3a19b..8600e71c716 100644 --- a/kie-archetypes/pom.xml +++ b/kie-archetypes/pom.xml @@ -46,6 +46,12 @@ + + org.kie + kie-dmn-bom + ${project.version} + pom + org.kie kie-maven-plugin @@ -85,6 +91,18 @@ + + org.kie + kie-dmn-bom + pom + test + + + * + * + + + diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerTest.java index 9e607d75b5f..b19fc4a85c1 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerTest.java @@ -102,13 +102,7 @@ public void testBasicListenerFromKModule() throws Exception { " \n" + " \n" + ""); - kfs.writePomXML(DMNClassloaderTest.getPom(releaseId, - ks.newReleaseId("org.kie", "kie-dmn-api", Drools.getFullVersion()), - ks.newReleaseId("org.kie", "kie-dmn-model", Drools.getFullVersion()), - ks.newReleaseId("org.kie", "kie-api", Drools.getFullVersion()), - ks.newReleaseId("org.kie", "kie-internal", Drools.getFullVersion()) - ) - ); + kfs.writePomXML(DMNClassloaderTest.getPom(releaseId)); final KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll(); assertThat(kieBuilder.getResults().getMessages()).as(kieBuilder.getResults().getMessages().toString()).isEmpty(); From 7fcf80d96bebea74e9e8f4316c380b05b7042304 Mon Sep 17 00:00:00 2001 From: Gabriele Cardosi Date: Mon, 6 May 2024 10:38:20 +0200 Subject: [PATCH 08/10] [incubator-kie-issues#1095] Verify constraints on complextypes hierarchy (#5851) * [incubator-kie-issues#1095] Implemented constraints on complex types. Implemented tests * [incubator-kie-issues#1095] Removed wrong test * [incubator-kie-issues#1095] Fix model --------- Co-authored-by: Gabriele-Cardosi --- .../dmn/core/compiler/DMNCompilerImpl.java | 6 ++ .../org/kie/dmn/core/DMNCompilerTest.java | 51 ++++++++++++- .../java/org/kie/dmn/core/DMNTypeTest.java | 71 +++++++++++++++++-- .../DMNv1_5/InheritedConstraints.dmn | 53 ++++++++++++++ 4 files changed, 173 insertions(+), 8 deletions(-) create mode 100644 kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/InheritedConstraints.dmn diff --git a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java index 640a5c002af..8cc1eb40c26 100644 --- a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java +++ b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java @@ -641,6 +641,12 @@ private DMNType buildTypeDef(DMNCompilerContext ctx, DMNModelImpl dmnModel, DMNN if (type instanceof CompositeTypeImpl) { CompositeTypeImpl compositeTypeImpl = (CompositeTypeImpl) type; type = new CompositeTypeImpl(namespace, name, id, isCollection, compositeTypeImpl.getFields(), baseType, baseFEELType); + if (allowedValues != null && !allowedValues.isEmpty()) { + type.setAllowedValues(allowedValues); + } + if (typeConstraint != null && !typeConstraint.isEmpty()) { + type.setTypeConstraint(typeConstraint); + } } else if (type instanceof SimpleTypeImpl) { type = new SimpleTypeImpl(namespace, name, id, isCollection, allowedValues, typeConstraint, baseType, baseFEELType); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java index 55ef34f927e..a6b8480ddd9 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java @@ -18,9 +18,6 @@ */ package org.kie.dmn.core; -import java.util.Arrays; -import java.util.Map; - import org.junit.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage; @@ -32,6 +29,7 @@ import org.kie.dmn.api.core.ast.ItemDefNode; import org.kie.dmn.core.api.DMNFactory; import org.kie.dmn.core.compiler.DMNTypeRegistry; +import org.kie.dmn.core.impl.BaseDMNTypeImpl; import org.kie.dmn.core.impl.CompositeTypeImpl; import org.kie.dmn.core.impl.DMNContextFPAImpl; import org.kie.dmn.core.impl.DMNModelImpl; @@ -45,10 +43,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Arrays; +import java.util.Map; + import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; import static org.kie.dmn.core.util.DynamicTypeUtils.entry; import static org.kie.dmn.core.util.DynamicTypeUtils.mapOf; +import static org.kie.dmn.core.util.DynamicTypeUtils.prototype; public class DMNCompilerTest extends BaseVariantTest { @@ -345,6 +347,49 @@ public void testWrongComparisonOps() { .count()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isEqualTo(4L); } + @Test + public void testAllowedValuesForSimpleTypeInherited() { + String nameSpace = "http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b-504f3e77b442"; + final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("valid_models/DMNv1_5/InheritedConstraints.dmn", this.getClass()); + final DMNModel dmnModel = runtime.getModel( + nameSpace, + "InheritedConstraints"); + assertThat(dmnModel).isNotNull(); + assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); + final DMNType aStringType = ((DMNModelImpl) dmnModel).getTypeRegistry().getTypes().get(nameSpace).get("AString"); + assertThat(aStringType.isAssignableValue("Bob")).isTrue(); + assertThat(aStringType.isAssignableValue("Joe")).isTrue(); + final DMNType aConstrainedStringType = ((DMNModelImpl) dmnModel).getTypeRegistry().getTypes().get(nameSpace).get("AConstrainedString"); + assertThat(aConstrainedStringType.isAssignableValue("Bob")).isTrue(); + assertThat(aConstrainedStringType.isAssignableValue("Joe")).isFalse(); + } + + @Test + public void testAllowedValuesForComplexTypeInherited() { + String nameSpace = "http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b-504f3e77b442"; + final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("valid_models/DMNv1_5/InheritedConstraints.dmn", this.getClass()); + final DMNModel dmnModel = runtime.getModel( + nameSpace, + "InheritedConstraints"); + assertThat(dmnModel).isNotNull(); + assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); + final BaseDMNTypeImpl dmnAdultPerson = (BaseDMNTypeImpl) ((DMNModelImpl) dmnModel).getTypeRegistry().getTypes().get(nameSpace).get("AdultPerson"); + final Map instanceAdultBob = prototype(entry("name", "Bob"), entry("age", 42)); + assertThat(dmnAdultPerson.isAssignableValue(instanceAdultBob)).isTrue(); + final Map instanceYoungBob = prototype(entry("name", "Bob"), entry("age", 12)); + assertThat(dmnAdultPerson.isAssignableValue(instanceYoungBob)).isFalse(); + + final BaseDMNTypeImpl dmnAdultBobPerson = (BaseDMNTypeImpl) ((DMNModelImpl) dmnModel).getTypeRegistry().getTypes().get(nameSpace).get("AdultBob"); + assertThat(dmnAdultBobPerson.isAssignableValue(instanceAdultBob)).isTrue(); + // UnaryTests are AND - based for constraints defined on different/inherited types + assertThat(dmnAdultBobPerson.isAssignableValue(instanceYoungBob)).isFalse(); + final Map instanceAdultJoe = prototype(entry("name", "Joe"), entry("age", 42)); + // UnaryTests are AND - based for constraints defined on different/inherited types + assertThat(dmnAdultBobPerson.isAssignableValue(instanceAdultJoe)).isFalse(); + final Map instanceYoungJoe = prototype(entry("name", "Joe"), entry("age", 12)); + assertThat(dmnAdultBobPerson.isAssignableValue(instanceYoungJoe)).isFalse(); + } + private void commonValidateUnnamedImport(String importingModelRef, String importedModelRef) { final DMNRuntime runtime = createRuntimeWithAdditionalResources(importingModelRef, this.getClass(), diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java index 96e8e2a7eda..47d0c68b0f6 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java @@ -18,21 +18,22 @@ */ package org.kie.dmn.core; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - import org.junit.Test; import org.kie.dmn.api.core.DMNType; import org.kie.dmn.core.compiler.DMNTypeRegistry; import org.kie.dmn.core.compiler.DMNTypeRegistryV15; +import org.kie.dmn.core.impl.BaseDMNTypeImpl; import org.kie.dmn.core.impl.CompositeTypeImpl; import org.kie.dmn.core.impl.SimpleTypeImpl; import org.kie.dmn.feel.FEEL; import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.core.util.DynamicTypeUtils.entry; import static org.kie.dmn.core.util.DynamicTypeUtils.prototype; @@ -121,5 +122,65 @@ public void testTypeConstraintForASimpleTypeCollection() { assertThat(tDecision1.isAssignableValue(Arrays.asList("sda", "de", "z"))).isTrue(); } + @Test + public void testAllowedValuesForSimpleTypeInherited() { + final String testNS = "testAllowedValuesForSimpleTypeInherited"; + + final FEEL feel = FEEL.newInstance(); + final DMNType aStringSimpleType = typeRegistry.registerType(new SimpleTypeImpl(testNS, "AString", null, false, feel.evaluateUnaryTests("string length( ? ) = 3"), null, FEEL_STRING, BuiltInType.STRING)); + assertThat(aStringSimpleType.isAssignableValue("abc")).isTrue(); + assertThat(aStringSimpleType.isAssignableValue("ab")).isFalse(); + assertThat(aStringSimpleType.isAssignableValue("c")).isFalse(); + final DMNType aConstrainedStringSimpleType = typeRegistry.registerType(new SimpleTypeImpl(testNS, "AConstrainedString", + null, false, feel.evaluateUnaryTests("\"Bob\""), null, aStringSimpleType, BuiltInType.STRING)); + assertThat(aConstrainedStringSimpleType.isAssignableValue("Bob")).isTrue(); + assertThat(aConstrainedStringSimpleType.isAssignableValue("abc")).isFalse(); + } + + @Test + public void testAllowedValuesForComplexType() { + final String testNS = "testAllowedValuesForComplexType"; + final FEEL feel = FEEL.newInstance(); + final Map personPrototype = prototype(entry("name", FEEL_STRING), entry("age", FEEL_NUMBER)); + final BaseDMNTypeImpl dmnPerson = (BaseDMNTypeImpl) typeRegistry.registerType(new CompositeTypeImpl(testNS, "Person", null, false, personPrototype, null, null)); + dmnPerson.setAllowedValues(feel.evaluateUnaryTests("?.name = \"Bob\", ?.age >= 30")); + final Map instanceAdultBob = prototype(entry("name", "Bob"), entry("age", 42)); + assertThat(dmnPerson.isAssignableValue(instanceAdultBob)).isTrue(); + final Map instanceYoungBob = prototype(entry("name", "Bob"), entry("age", 12)); + // UnaryTests are OR - based for constraints defined on the same type + assertThat(dmnPerson.isAssignableValue(instanceYoungBob)).isTrue(); + final Map instanceAdultJoe = prototype(entry("name", "Joe"), entry("age", 42)); + // UnaryTests are OR - based for constraints defined on the same type + assertThat(dmnPerson.isAssignableValue(instanceAdultJoe)).isTrue(); + final Map instanceYoungJoe = prototype(entry("name", "Joe"), entry("age", 12)); + assertThat(dmnPerson.isAssignableValue(instanceYoungJoe)).isFalse(); + } + + @Test + public void testAllowedValuesForComplexTypeInherited() { + final String testNS = "testAllowedValuesForComplexType"; + final FEEL feel = FEEL.newInstance(); + final Map personPrototype = prototype(entry("name", FEEL_STRING), entry("age", FEEL_NUMBER)); + final BaseDMNTypeImpl dmnAdultPerson = (BaseDMNTypeImpl) typeRegistry.registerType(new CompositeTypeImpl(testNS, "AdultPerson", null, false, personPrototype, null, null)); + dmnAdultPerson.setAllowedValues(feel.evaluateUnaryTests("?.age >= 30")); + final Map instanceAdultBob = prototype(entry("name", "Bob"), entry("age", 42)); + assertThat(dmnAdultPerson.isAssignableValue(instanceAdultBob)).isTrue(); + final Map instanceYoungBob = prototype(entry("name", "Bob"), entry("age", 12)); + assertThat(dmnAdultPerson.isAssignableValue(instanceYoungBob)).isFalse(); + + final BaseDMNTypeImpl dmnAdultBobPerson = (BaseDMNTypeImpl) typeRegistry.registerType(new CompositeTypeImpl(testNS, "AdultBobPerson", null, false, personPrototype, dmnAdultPerson, null)); + dmnAdultBobPerson.setAllowedValues(feel.evaluateUnaryTests("?.name = \"Bob\"")); + assertThat(dmnAdultBobPerson.isAssignableValue(instanceAdultBob)).isTrue(); + // UnaryTests are AND - based for constraints defined on different/inherited types + assertThat(dmnAdultBobPerson.isAssignableValue(instanceYoungBob)).isFalse(); + final Map instanceAdultJoe = prototype(entry("name", "Joe"), entry("age", 42)); + // UnaryTests are AND - based for constraints defined on different/inherited types + assertThat(dmnAdultBobPerson.isAssignableValue(instanceAdultJoe)).isFalse(); + final Map instanceYoungJoe = prototype(entry("name", "Joe"), entry("age", 12)); + assertThat(dmnAdultBobPerson.isAssignableValue(instanceYoungJoe)).isFalse(); + } + + + } diff --git a/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/InheritedConstraints.dmn b/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/InheritedConstraints.dmn new file mode 100644 index 00000000000..923060d92b4 --- /dev/null +++ b/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/InheritedConstraints.dmn @@ -0,0 +1,53 @@ + + + + + string + + string length( ? ) = 3 + + + + AString + + "Bob" + + + + + + + string + + + number + + + + Person + + ?.age >= 30 + + + + AdultPerson + + ?.name = "Bob" + + + From f2ded6a2674095c32ce854b30cb16bf36e3c05b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Zim=C3=A1nyi?= Date: Mon, 6 May 2024 14:58:23 +0200 Subject: [PATCH 09/10] [kie-issues#1153] Dispose session in tests. (#5888) --- .../integrationtests/ConsequenceTypeTest.java | 9 ++++++--- .../drools/reteevaluator/ReteEvaluatorTest.java | 15 +++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ConsequenceTypeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ConsequenceTypeTest.java index eb6f574a35a..8f88dd0853c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ConsequenceTypeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ConsequenceTypeTest.java @@ -43,9 +43,12 @@ public void test() { final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl.toString()); final KieSession wm = kbase.newKieSession(); - - wm.insert("test"); - assertThat(wm.fireAllRules()).isEqualTo(ruleNr); + try { + wm.insert("test"); + assertThat(wm.fireAllRules()).isEqualTo(ruleNr); + } finally { + wm.dispose(); + } } private String generatedRule(int seed) { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/reteevaluator/ReteEvaluatorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/reteevaluator/ReteEvaluatorTest.java index e70b6937c34..b9a87e2a067 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/reteevaluator/ReteEvaluatorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/reteevaluator/ReteEvaluatorTest.java @@ -50,13 +50,16 @@ public void testPropertyReactivity() { "end"; ReteEvaluator reteEvaluator = new StatefulKnowledgeSessionImpl( 1L, getKBase( str ) ); + try { + Person me = new Person( "Mario", 40 ); + reteEvaluator.insert( "Mario" ); + reteEvaluator.insert( me ); + assertThat(reteEvaluator.fireAllRules()).isEqualTo(1); - Person me = new Person( "Mario", 40 ); - reteEvaluator.insert( "Mario" ); - reteEvaluator.insert( me ); - assertThat(reteEvaluator.fireAllRules()).isEqualTo(1); - - assertThat(me.getAge()).isEqualTo(41); + assertThat(me.getAge()).isEqualTo(41); + } finally { + reteEvaluator.dispose(); + } } private InternalKnowledgeBase getKBase(String... stringRules) { From ecade589e29bc61a6d0461c8cbedb0f0cdd43adb Mon Sep 17 00:00:00 2001 From: Gabriele Cardosi Date: Mon, 6 May 2024 18:02:05 +0200 Subject: [PATCH 10/10] [incubator-kie-issues#1104] Migrate Junit inside DMN (#5883) * [incubator-kie-issues#1104] Moved to junit 6 /jupiter * [incubator-kie-issues#1104] Fix formatting * [incubator-kie-issues#1104] Fix formatting * [incubator-kie-issues#1104] Fix merge. BAn junit 4 from kie-dmn modules * [incubator-kie-issues#1104] Fix format - attempt * [incubator-kie-issues#1104] Fix xml format --------- Co-authored-by: Gabriele-Cardosi --- bom/kie-dmn-bom/pom.xml | 1 - build-parent/pom.xml | 5 + kie-dmn/kie-dmn-backend/pom.xml | 16 +- .../marshalling/v1_1/DMNXMLLoaderTest.java | 17 +- .../v1_1/MarshallingUtilsTest.java | 16 +- .../v1_1/UnmarshalMarshalTest.java | 46 +- .../v1_2/UnmarshalMarshalTest.java | 24 +- .../v1_3/UnmarshalMarshalTest.java | 20 +- .../v1_4/UnmarshalMarshalTest.java | 28 +- .../v1_5/UnmarshalMarshalTest.java | 57 +- .../org/kie/dmn/core/jsr223/jq/BasicTest.java | 16 +- .../org/kie/dmn/core/jsr223/EscapeTest.java | 4 +- .../org/kie/dmn/core/jsr223/GraalJSTest.java | 12 +- .../java/org/kie/dmn/core/jsr223/JQTest.java | 16 +- .../org/kie/dmn/core/jsr223/NashornTest.java | 16 +- kie-dmn/kie-dmn-core/pom.xml | 11 +- .../BaseInterpretedVsAlphaNetworkTest.java | 18 +- .../core/BaseInterpretedVsCompiledTest.java | 19 +- ...retedVsCompiledTestCanonicalKieModule.java | 21 +- .../dmn/core/BaseVariantNonTypeSafeTest.java | 6 - .../org/kie/dmn/core/BaseVariantTest.java | 13 +- .../dmn/core/DMNAndCanonicalModelTest.java | 19 +- .../org/kie/dmn/core/DMNAssemblerTest.java | 37 +- .../kie/dmn/core/DMNBuildFromReaderTest.java | 6 +- .../org/kie/dmn/core/DMNCompilerTest.java | 97 +- .../core/DMNDecisionTableHitPolicyTest.java | 171 ++- .../dmn/core/DMNDecisionTableRuntimeTest.java | 246 ++-- .../core/DMNDecisionTableWithSymbolsTest.java | 13 +- .../org/kie/dmn/core/DMNInputRuntimeTest.java | 126 +- .../org/kie/dmn/core/DMNMessagesAPITest.java | 39 +- .../java/org/kie/dmn/core/DMNRuntimeTest.java | 1036 +++++++++++------ .../kie/dmn/core/DMNRuntimeTypeCheckTest.java | 74 +- .../dmn/core/DMNStronglyTypedSupportTest.java | 60 +- .../kie/dmn/core/DMNTwoValueLogicTest.java | 87 +- .../java/org/kie/dmn/core/DMNTypeTest.java | 20 +- .../java/org/kie/dmn/core/DMNUpdateTest.java | 54 +- .../org/kie/dmn/core/FlightRebookingTest.java | 40 +- .../org/kie/dmn/core/OnlineDatingTest.java | 13 +- .../org/kie/dmn/core/VacationDaysTest.java | 52 +- .../dmn/core/WBCommonServicesBackendTest.java | 22 +- ...etworkSupportInLargeDecisionTableTest.java | 17 +- .../DMNDecisionTableAlphaSupportingTest.java | 23 +- .../dmn/core/ast/DMNContextEvaluatorTest.java | 10 +- .../core/classloader/DMNClassloaderTest.java | 19 +- .../DMNEvalHelperAccessorCacheTest.java | 12 +- .../DMNRuntimeListenerBKMTest.java | 4 +- .../classloader/DMNRuntimeListenerDSTest.java | 6 +- .../DMNRuntimeListenerPropertyTest.java | 4 +- .../classloader/DMNRuntimeListenerTest.java | 34 +- .../classloader/DTAnnotationListenerTest.java | 12 +- .../compiler/ImportDMNResolverUtilTest.java | 28 +- ...emDefinitionDependenciesGeneratedTest.java | 19 +- .../ItemDefinitionDependenciesTest.java | 28 +- .../core/compiler/UnnamedImportUtilsTest.java | 22 +- .../extensions/DMNExtensionRegisterTest.java | 10 +- .../compiler/profiles/DMNProfilesTest.java | 19 +- .../profiles/ExtendedDMNProfileTest.java | 38 +- .../DMNDecisionServicesTest.java | 139 ++- .../DMNDecisionServicesTypecheckDSxyTest.java | 37 +- .../core/decisiontable/DTListenerTest.java | 18 +- .../kie/dmn/core/extra/DMNRecursionTest.java | 15 +- .../kie/dmn/core/extra/YCombinatorTest.java | 19 +- .../impl/DMNContextFEELCtxWrapperTest.java | 42 +- .../kie/dmn/core/impl/DMNContextImplTest.java | 10 +- .../org/kie/dmn/core/imports/ImportsTest.java | 118 +- .../DMNIncrementalCompilationTest.java | 21 +- .../WBCompilationTest.java | 8 +- .../internal/utils/DMNRuntimeBuilderTest.java | 12 +- .../internal/utils/DRGAnalysisUtilsTest.java | 4 +- .../utils/DynamicDMNContextBuilderTest.java | 20 +- .../utils/MapBackedDMNContextTest.java | 10 +- .../utils/MarshallingStubUtilsTest.java | 14 +- ...NKiePMMLTrustyInvocationEvaluatorTest.java | 20 +- .../core/stronglytyped/AnnotationsTest.java | 28 +- .../stronglytyped/DMNRuntimeTypesTest.java | 150 ++- .../core/stronglytyped/DMNTypeSafeTest.java | 35 +- .../dmn/core/stronglytyped/JavadocTest.java | 15 +- .../kie/dmn/core/typeref/DMNTyperefTest.java | 98 +- .../org/kie/dmn/core/util/CoerceUtilTest.java | 22 +- .../kie/dmn/core/v1_2/DMN12specificTest.java | 31 +- .../core/v1_2/DMNDecisionServicesTest.java | 13 +- .../kie/dmn/core/v1_3/DMN13specificTest.java | 55 +- .../v1_3/DMN13specificTestNonTypesafe.java | 13 +- .../dmn/core/v1_4/DMN14ExpressionsTest.java | 95 +- .../dmn/core/v1_4/DMN14GenericSynthTest.java | 33 +- .../kie/dmn/core/v1_4/DMN14specificTest.java | 75 +- kie-dmn/kie-dmn-feel/pom.xml | 21 +- .../codegen/feel11/DirectCompilerTest.java | 97 +- .../feel11/DirectCompilerUnaryTestsTest.java | 18 +- .../ManualBasicFunctionInvocationTest.java | 4 +- .../codegen/feel11/ManualContextTest.java | 4 +- .../feel/codegen/feel11/ManualFilterTest.java | 4 +- .../feel/codegen/feel11/ManualForTest.java | 4 +- .../ManualNamedFunctionInvocationTest.java | 4 +- .../feel/codegen/feel11/ManualQuantTest.java | 4 +- .../codegen/feel11/ManualUnaryTestsTest.java | 4 +- .../documentation/ADocFEELExamplesTest.java | 7 +- .../FromSpecificationNotInAdocTest.java | 13 +- .../dmn/feel/jandex/AbstractJandexTest.java | 5 +- .../dmn/feel/lang/ast/InfixOperatorTest.java | 14 +- .../BigDecimalRangeIteratorTest.java | 20 +- .../ForIterationTest.java | 18 +- .../ForIterationUtilsTest.java | 32 +- .../LocalDateRangeIteratorTest.java | 26 +- .../ZonedDateTimeRangeIteratorTest.java | 31 +- .../InfixExecutorUtilsTest.java | 27 +- .../lang/examples/CompileEvaluateTest.java | 59 +- .../dmn/feel/lang/examples/ExamplesTest.java | 36 +- .../dmn/feel/lang/impl/FEELProfileTest.java | 7 +- .../feel/lang/impl/JavaBackedTypeTest.java | 10 +- .../dmn/feel/lang/impl/MapBackedTypeTest.java | 13 +- .../TemporalConstantFoldingParserTest.java | 26 +- .../impl/ImmutableFPAWrappingPOJOTest.java | 6 +- .../marshaller/FEELCodeMarshallerTest.java | 41 +- .../FEELCodeMarshallerUnmarshallTest.java | 27 +- .../marshaller/FEELStringMarshallerTest.java | 41 +- .../FEELStringMarshallerUnmarshallTest.java | 27 +- .../parser/feel11/FEELParserSeverityTest.java | 12 +- .../feel/parser/feel11/FEELParserTest.java | 173 +-- .../feel/runtime/BaseFEELCompilerTest.java | 21 +- .../kie/dmn/feel/runtime/BaseFEELTest.java | 22 +- .../runtime/FEEL12ExtendedForLoopTest.java | 18 +- .../runtime/FEEL12ExtendedFunctionsTest.java | 12 +- .../runtime/FEELConditionsAndLoopsTest.java | 13 +- .../dmn/feel/runtime/FEELContextsTest.java | 12 +- .../runtime/FEELDateTimeDurationTest.java | 12 +- .../feel/runtime/FEELErrorMessagesTest.java | 15 +- .../feel/runtime/FEELEventListenerTest.java | 16 +- .../dmn/feel/runtime/FEELExpressionsTest.java | 12 +- .../runtime/FEELFunctionDefinitionTest.java | 12 +- .../dmn/feel/runtime/FEELFunctionsTest.java | 12 +- .../kie/dmn/feel/runtime/FEELListsTest.java | 12 +- .../feel/runtime/FEELMathOperationsTest.java | 12 +- .../feel/runtime/FEELNumberCoercionTest.java | 14 +- .../dmn/feel/runtime/FEELOperatorsTest.java | 12 +- .../kie/dmn/feel/runtime/FEELRangesTest.java | 12 +- .../dmn/feel/runtime/FEELStaticTypeTest.java | 12 +- .../runtime/FEELStringOperationsTest.java | 13 +- .../feel/runtime/FEELTernaryLogicTest.java | 13 +- .../runtime/FEELValuesComparisonTest.java | 13 +- .../feel/runtime/FEELValuesConstantsTest.java | 12 +- .../runtime/KieFEELExtendedFunctionsTest.java | 12 +- .../dmn/feel/runtime/TCFoldNotTCFoldTest.java | 13 +- .../runtime/functions/AbsFunctionTest.java | 20 +- .../runtime/functions/AllFunctionTest.java | 41 +- .../runtime/functions/AnyFunctionTest.java | 41 +- .../runtime/functions/AppendFunctionTest.java | 19 +- .../functions/BuiltInFunctionsTest.java | 16 +- .../functions/CeilingFunctionTest.java | 19 +- .../runtime/functions/CodeFunctionTest.java | 62 +- .../ComposingDifferentFunctionsTest.java | 20 +- .../functions/ConcatenateFunctionTest.java | 20 +- .../functions/ContainsFunctionTest.java | 16 +- .../runtime/functions/CountFunctionTest.java | 22 +- .../runtime/functions/DateFunctionTest.java | 30 +- .../functions/DateTimeFunctionTest.java | 31 +- .../feel/runtime/functions/DayOfWeekTest.java | 12 +- .../feel/runtime/functions/DayOfYearTest.java | 12 +- .../functions/DecimalFunctionTest.java | 23 +- .../functions/DistinctValuesFunctionTest.java | 20 +- .../functions/DurationFunctionTest.java | 24 +- .../functions/EndsWithFunctionTest.java | 16 +- .../functions/FlattenFunctionTest.java | 17 +- .../runtime/functions/FloorFunctionTest.java | 19 +- .../functions/IndexOfFunctionTest.java | 18 +- .../functions/InsertBeforeFunctionTest.java | 26 +- .../functions/ListContainsFunctionTest.java | 20 +- .../functions/ListReplaceFunctionTest.java | 32 +- .../functions/MatchesFunctionTest.java | 26 +- .../runtime/functions/MaxFunctionTest.java | 34 +- .../runtime/functions/MeanFunctionTest.java | 45 +- .../runtime/functions/MinFunctionTest.java | 34 +- .../runtime/functions/MonthOfYearTest.java | 12 +- .../runtime/functions/NotFunctionTest.java | 19 +- .../runtime/functions/NowFunctionTest.java | 13 +- .../runtime/functions/NumberFunctionTest.java | 44 +- .../runtime/functions/RemoveFunctionTest.java | 21 +- .../functions/ReplaceFunctionTest.java | 26 +- .../functions/ReverseFunctionTest.java | 19 +- .../runtime/functions/SortFunctionTest.java | 26 +- .../functions/StartsWithFunctionTest.java | 18 +- .../runtime/functions/StringFunctionTest.java | 66 +- .../functions/StringLengthFunctionTest.java | 17 +- .../StringLowerCaseFunctionTest.java | 18 +- .../StringUpperCaseFunctionTest.java | 18 +- .../functions/SublistFunctionTest.java | 25 +- .../functions/SubstringAfterFunctionTest.java | 16 +- .../SubstringBeforeFunctionTest.java | 16 +- .../functions/SubstringFunctionTest.java | 26 +- .../runtime/functions/SumFunctionTest.java | 33 +- .../runtime/functions/TimeFunctionTest.java | 54 +- .../runtime/functions/TodayFunctionTest.java | 12 +- .../runtime/functions/UnionFunctionTest.java | 37 +- .../runtime/functions/WeekOfYearTest.java | 12 +- .../functions/YearsAndMonthsFunctionTest.java | 26 +- .../functions/extended/RangeFunctionTest.java | 79 +- .../functions/interval/AfterFunctionTest.java | 26 +- .../interval/BeforeFunctionTest.java | 26 +- .../interval/CoincidesFunctionTest.java | 22 +- .../interval/DuringFunctionTest.java | 18 +- .../interval/FEELTemporalFunctionsTest.java | 13 +- .../interval/FinishedByFunctionTest.java | 18 +- .../interval/FinishesFunctionTest.java | 18 +- .../functions/interval/FormulasTest.java | 8 +- .../interval/IncludesFunctionTest.java | 18 +- .../functions/interval/MeetsFunctionTest.java | 16 +- .../functions/interval/MetByFunctionTest.java | 16 +- .../interval/OverlapsFunctionTest.java | 16 +- .../interval/StartedByFunctionTest.java | 18 +- .../interval/StartsFunctionTest.java | 18 +- .../twovaluelogic/CountFunctionTest.java | 26 +- .../twovaluelogic/MaxFunctionTest.java | 36 +- .../twovaluelogic/MeanFunctionTest.java | 54 +- .../twovaluelogic/MedianFunctionTest.java | 40 +- .../twovaluelogic/MinFunctionTest.java | 36 +- .../twovaluelogic/ModeFunctionTest.java | 32 +- .../twovaluelogic/NNAllFunctionTest.java | 46 +- .../twovaluelogic/NNAnyFunctionTest.java | 41 +- .../twovaluelogic/StddevFunctionTest.java | 40 +- .../twovaluelogic/SumFunctionTest.java | 42 +- .../dmn/feel/runtime/impl/RangeImplTest.java | 18 +- .../org/kie/dmn/feel/util/CoerceUtilTest.java | 26 +- .../org/kie/dmn/feel/util/EvalHelperTest.java | 19 +- kie-dmn/kie-dmn-legacy-tests/pom.xml | 11 +- .../core/v1_1/BaseDMN1_1VariantTest.java | 6 - .../tests/core/v1_1/DMNAssemblerTest.java | 40 +- .../tests/core/v1_1/DMNCompilerTest.java | 37 +- .../v1_1/DMNDecisionTableHitPolicyTest.java | 145 ++- .../v1_1/DMNDecisionTableRuntimeTest.java | 126 +- .../v1_1/DMNDecisionTableWithSymbolsTest.java | 13 +- .../tests/core/v1_1/DMNInputRuntimeTest.java | 97 +- .../tests/core/v1_1/DMNRuntimeTest.java | 753 +++++++----- .../tests/core/v1_1/FlightRebookingTest.java | 37 +- .../tests/core/v1_1/OnlineDatingTest.java | 13 +- .../tests/core/v1_1/VacationDaysTest.java | 42 +- .../DMNDecisionServicesTest.java | 81 +- .../tests/core/v1_1/imports/ImportsTest.java | 88 +- .../v1_1/ValidatorArtifactTest.java | 10 +- .../ValidatorAuthorityRequirementTest.java | 40 +- .../v1_1/ValidatorBusinessContextTest.java | 22 +- .../ValidatorBusinessKnowledgeModelTest.java | 22 +- .../validation/v1_1/ValidatorContextTest.java | 34 +- .../ValidatorDMNElementReferenceTest.java | 10 +- .../v1_1/ValidatorDecisionTableTest.java | 28 +- .../v1_1/ValidatorDecisionTest.java | 76 +- .../validation/v1_1/ValidatorImportTest.java | 30 +- .../ValidatorInformationRequirementTest.java | 28 +- .../v1_1/ValidatorInputDataTest.java | 16 +- .../ValidatorKnowledgeRequirementTest.java | 16 +- .../v1_1/ValidatorKnowledgeSourceTest.java | 16 +- .../tests/validation/v1_1/ValidatorTest.java | 93 +- .../validation/v1_1/ValidatorTypeRefTest.java | 32 +- kie-dmn/kie-dmn-model/pom.xml | 10 +- .../model/api/AssociationDirectionTest.java | 6 +- .../api/DecisionTableOrientationTest.java | 6 +- .../kie/dmn/model/api/FunctionKindTest.java | 6 +- .../org/kie/dmn/model/api/HitPolicyTest.java | 8 +- .../kie/dmn/model/api/RowLocationTest.java | 6 +- .../kie/dmn/model/api/TUnaryTestsTest.java | 6 +- .../model/api/dmndi/AlignmentKindTest.java | 6 +- .../dmn/model/api/dmndi/KnownColorTest.java | 6 +- .../model/jandex/KieDMNModelJandexTest.java | 5 +- .../org/kie/dmn/openapi/AllowNullTest.java | 6 +- .../java/org/kie/dmn/openapi/CH11Test.java | 2 +- .../kie/dmn/openapi/EnumGenerationTest.java | 14 +- .../org/kie/dmn/openapi/ImportingTest.java | 9 +- .../kie/dmn/openapi/MultipleModelsTest.java | 8 +- .../dmn/openapi/NumberAllowedValuesTest.java | 13 +- .../java/org/kie/dmn/openapi/PersonsTest.java | 2 +- .../org/kie/dmn/openapi/ProcessItemTest.java | 4 +- .../org/kie/dmn/openapi/UndefinedTest.java | 2 +- .../dmn/openapi/impl/DMNTypeSchemasTest.java | 8 +- .../openapi/impl/DMNUnaryTestsMapperTest.java | 10 +- .../impl/RangeNodeSchemaMapperTest.java | 12 +- .../kie-dmn-pmml-tests-trusty/pom.xml | 5 - .../kie-dmn-pmml-tests/pom.xml | 8 +- .../kie/dmn/pmml/DMNKMeansModelPMMLTest.java | 4 +- .../kie/dmn/pmml/DMNMiningModelPMMLTest.java | 4 +- .../kie/dmn/pmml/DMNNaiveBayesPMMLTest.java | 4 +- .../dmn/pmml/DMNNeuralNetworkPMMLTest.java | 4 +- .../kie/dmn/pmml/DMNRegressionPMMLTest.java | 4 +- .../org/kie/dmn/pmml/DMNRuntimePMMLTest.java | 13 +- .../org/kie/dmn/pmml/DMNTreePMMLTest.java | 6 +- .../java/org/kie/dmn/pmml/PMMLInfoTest.java | 8 +- .../kie/dmn/pmml/PMMLValidatorImportTest.java | 14 +- .../kie-dmn-ruleset2dmn/pom.xml | 10 +- .../org/kie/dmn/ruleset2dmn/AdultTest.java | 7 +- .../ChurnRulesFromSPSSModelerTest.java | 9 +- .../org/kie/dmn/ruleset2dmn/ChurnTest.java | 7 +- .../org/kie/dmn/ruleset2dmn/IrisTest.java | 7 +- .../org/kie/dmn/ruleset2dmn/MiniloanTest.java | 9 +- .../org/kie/dmn/ruleset2dmn/TotoTest.java | 9 +- .../org/kie/dmn/ruleset2dmn/WifiTest.java | 9 +- kie-dmn/kie-dmn-signavio/pom.xml | 18 +- .../MultiInstanceDecisionLogicTest.java | 25 +- .../org/kie/dmn/signavio/SignavioTest.java | 56 +- .../ExtendedFunctionsBaseFEELTest.java | 21 +- .../runtime/FEELExtendedFunctionsTest.java | 13 +- kie-dmn/kie-dmn-trisotech/pom.xml | 13 +- .../v1_3/xstream/UnmarshalMarshalTest.java | 8 +- .../trisotech/core/DMN14ExpressionsTest.java | 83 +- .../trisotech/core/DMN14GenericSynthTest.java | 10 +- .../validation/TrisotechValidationTest.java | 26 +- kie-dmn/kie-dmn-validation/pom.xml | 10 +- .../dmn/validation/AbstractValidatorTest.java | 8 +- .../dmn/validation/MessageReporterTest.java | 10 +- .../UsingResourceValidatorTest.java | 26 +- .../dmn/validation/ValidatorArtifactTest.java | 10 +- .../ValidatorAuthorityRequirementTest.java | 40 +- .../ValidatorBusinessContextTest.java | 22 +- .../ValidatorBusinessKnowledgeModelTest.java | 30 +- .../dmn/validation/ValidatorContextTest.java | 42 +- .../dmn/validation/ValidatorDMN14Test.java | 23 +- .../dmn/validation/ValidatorDMNDITest.java | 10 +- .../ValidatorDMNElementReferenceTest.java | 10 +- .../ValidatorDecisionServiceTest.java | 38 +- .../ValidatorDecisionTableTest.java | 28 +- .../dmn/validation/ValidatorDecisionTest.java | 88 +- .../dmn/validation/ValidatorImportTest.java | 52 +- .../ValidatorInformationRequirementTest.java | 28 +- .../validation/ValidatorInputDataTest.java | 27 +- .../ValidatorKnowledgeRequirementTest.java | 24 +- .../ValidatorKnowledgeSourceTest.java | 16 +- .../org/kie/dmn/validation/ValidatorTest.java | 145 +-- .../dmn/validation/ValidatorTypeRefTest.java | 32 +- .../classloader/ValidatorClassloaderTest.java | 6 +- .../dtanalysis/AK0100domainOnTableTest.java | 6 +- .../dtanalysis/AK0100v2domainOnTableTest.java | 6 +- .../validation/dtanalysis/AgeKittenTest.java | 10 +- .../dtanalysis/BuiltinAndOtherValuesTest.java | 12 +- .../dtanalysis/Check1stNFViolationTest.java | 12 +- .../dtanalysis/Check2ndNFViolationTest.java | 12 +- .../dtanalysis/ContractionRulesTest.java | 6 +- ...DMNDTAnalyserValueFromNodeVisitorTest.java | 6 +- .../DMNDTAnalysisExceptionTest.java | 6 +- .../validation/dtanalysis/DTNestingTest.java | 7 +- .../validation/dtanalysis/DTinBKMTest.java | 6 +- .../dtanalysis/EnumerationWithNullTest.java | 7 +- .../FailingOutputConstraintsTest.java | 10 +- .../dtanalysis/Gaps0100domainOnTableTest.java | 6 +- .../dtanalysis/GapsAndOverlaps1Test.java | 6 +- .../GapsAndOverlaps1domainOnTableTest.java | 6 +- .../validation/dtanalysis/GapsCube3Test.java | 6 +- .../dtanalysis/GapsOverlapsBooleanTest.java | 6 +- .../dmn/validation/dtanalysis/GapsXYTest.java | 14 +- .../dtanalysis/HitPolicyFirstTest.java | 6 +- .../validation/dtanalysis/IntervalTest.java | 40 +- .../dmn/validation/dtanalysis/MaskTest.java | 8 +- .../dtanalysis/MisleadingRulesTest.java | 8 +- .../dtanalysis/MultipleModelsTest.java | 11 +- .../dtanalysis/NoGapsDateAdjacentTest.java | 6 +- .../dtanalysis/NoGapsDomainOnTypeRefTest.java | 8 +- .../dmn/validation/dtanalysis/NotTest.java | 18 +- .../dmn/validation/dtanalysis/NullTest.java | 25 +- .../dtanalysis/OverlapHitPolicyTest.java | 19 +- .../dtanalysis/OverlapsMsgTest.java | 6 +- .../kie/dmn/validation/dtanalysis/PiTest.java | 7 +- .../dtanalysis/PosDoubleNegHalfTest.java | 7 +- .../dtanalysis/RecommenderHitPolicyTest.java | 16 +- .../dtanalysis/RuleOrderDashTest.java | 6 +- .../SRGapsOverlapsSubsumption2Test.java | 6 +- .../dtanalysis/SameMsgInAllAPITest.java | 8 +- .../dtanalysis/SimpleStringNoGapTest.java | 6 +- .../dtanalysis/SomeProblemTest.java | 30 +- .../SomeProblemruleOutsideDomainTest.java | 6 +- .../StringWithoutEnumNoGapTest.java | 6 +- .../dtanalysis/SubsumptionRulesTest.java | 6 +- .../validation/dtanalysis/SymbolInDTTest.java | 10 +- .../dtanalysis/mcdc/ExampleMCDCTest.java | 6 +- .../dtanalysis/model/NullBoundImplTest.java | 6 +- .../validation/v1_5/DMN15ValidationsTest.java | 24 +- kie-dmn/kie-dmn-xls2dmn-cli/pom.xml | 8 +- .../kie/dmn/xls2dmn/cli/CardApprovalTest.java | 11 +- .../xls2dmn/cli/ChineseLunarYearsTest.java | 9 +- .../dmn/xls2dmn/cli/XLS2DMNParserTest.java | 33 +- kie-dmn/pom.xml | 29 + 376 files changed, 6281 insertions(+), 4846 deletions(-) diff --git a/bom/kie-dmn-bom/pom.xml b/bom/kie-dmn-bom/pom.xml index 8258db48be6..a448cd4a15f 100644 --- a/bom/kie-dmn-bom/pom.xml +++ b/bom/kie-dmn-bom/pom.xml @@ -190,7 +190,6 @@ ${project.version} sources - diff --git a/build-parent/pom.xml b/build-parent/pom.xml index b73c9c37679..f91ddc9fbea 100644 --- a/build-parent/pom.xml +++ b/build-parent/pom.xml @@ -473,6 +473,11 @@ junit-jupiter-api ${version.org.junit} + + org.junit.jupiter + junit-jupiter + ${version.org.junit} + org.junit.jupiter junit-jupiter-engine diff --git a/kie-dmn/kie-dmn-backend/pom.xml b/kie-dmn/kie-dmn-backend/pom.xml index f4e3e5ef299..64c6793d64e 100644 --- a/kie-dmn/kie-dmn-backend/pom.xml +++ b/kie-dmn/kie-dmn-backend/pom.xml @@ -61,24 +61,22 @@ com.thoughtworks.xstream xstream - - - junit - junit - test - - org.xmlunit xmlunit-core test - + org.assertj assertj-core test - + + + org.junit.jupiter + junit-jupiter + test + org.slf4j diff --git a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/DMNXMLLoaderTest.java b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/DMNXMLLoaderTest.java index 4528dace133..8c88edee191 100644 --- a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/DMNXMLLoaderTest.java +++ b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/DMNXMLLoaderTest.java @@ -20,12 +20,11 @@ import java.io.InputStream; import java.io.InputStreamReader; -import java.util.Arrays; import java.util.List; import javax.xml.XMLConstants; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.marshalling.DMNMarshaller; import org.kie.dmn.backend.marshalling.v1_1.xstream.extensions.DecisionServicesExtensionRegister; import org.kie.dmn.backend.marshalling.v1x.DMNMarshallerFactory; @@ -37,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class DMNXMLLoaderTest { +class DMNXMLLoaderTest { @Test - public void testLoadingDefinitions() { + void loadingDefinitions() { final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newDefaultMarshaller(); final InputStream is = this.getClass().getResourceAsStream( "0001-input-data-string.dmn" ); @@ -81,7 +80,7 @@ public void testLoadingDefinitions() { } @Test - public void testLoadingDecisionServices() { + void loadingDecisionServices() { final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new DecisionServicesExtensionRegister())); final InputStream is = this.getClass().getResourceAsStream("0004-decision-services.dmn"); @@ -113,7 +112,7 @@ public void testLoadingDecisionServices() { } @Test - public void testLoadingWithNoDecisionServices() { + void loadingWithNoDecisionServices() { final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new DecisionServicesExtensionRegister())); final InputStream is = this.getClass().getResourceAsStream("0001-input-data-string.dmn"); @@ -124,7 +123,7 @@ public void testLoadingWithNoDecisionServices() { } @Test - public void test0004_multiple_extensions() throws Exception { + void test0004_multiple_extensions() throws Exception { DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new DecisionServicesExtensionRegister())); final InputStream is = this.getClass().getResourceAsStream("0004-decision-services_multiple_extensions.dmn"); @@ -136,7 +135,7 @@ public void test0004_multiple_extensions() throws Exception { } @Test - public void testLoadingExample() { + void loadingExample() { final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newDefaultMarshaller(); final InputStream is = this.getClass().getResourceAsStream("ch11example.xml"); @@ -149,7 +148,7 @@ public void testLoadingExample() { } @Test - public void testLoadingDishDecision() { + void loadingDishDecision() { final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newDefaultMarshaller(); final InputStream is = this.getClass().getResourceAsStream("dish-decision.xml"); diff --git a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/MarshallingUtilsTest.java b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/MarshallingUtilsTest.java index af054ae7d2e..45fda624719 100644 --- a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/MarshallingUtilsTest.java +++ b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/MarshallingUtilsTest.java @@ -21,7 +21,7 @@ import javax.xml.XMLConstants; import javax.xml.namespace.QName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.backend.marshalling.v1_1.xstream.MarshallingUtils; import org.kie.dmn.model.api.DMNModelInstrumentedBase; import org.slf4j.Logger; @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class MarshallingUtilsTest { +class MarshallingUtilsTest { protected static final Logger logger = LoggerFactory.getLogger(MarshallingUtilsTest.class); @@ -65,32 +65,32 @@ private void checkAndRoundTrip(QName qname, String formatQName) { } } - @Test - public void testLocal() throws Exception { + @Test + void local() throws Exception { QName qname = new QName("local1"); checkAndRoundTrip(qname, "local1"); } @Test - public void testPrefixLocal() throws Exception { + void prefixLocal() throws Exception { QName qname = new QName(XMLConstants.NULL_NS_URI, "local2", "prefix"); checkAndRoundTrip(qname, "prefix:local2"); } @Test - public void testNamespaceLocal() throws Exception { + void namespaceLocal() throws Exception { QName qname = new QName("http://namespace", "local3"); checkAndRoundTrip(qname, "{http://namespace}local3"); } @Test - public void testNamespaceLocal_b() throws Exception { + void namespaceLocalB() throws Exception { QName qname = new QName("http://namespace", "local3", XMLConstants.DEFAULT_NS_PREFIX); checkAndRoundTrip(qname, "{http://namespace}local3"); } @Test - public void testNamespacePrefixLocal() throws Exception { + void namespacePrefixLocal() throws Exception { QName qname = new QName("http://namespace", "local4", "prefix"); checkAndRoundTrip(qname, "prefix:local4"); } diff --git a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/UnmarshalMarshalTest.java b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/UnmarshalMarshalTest.java index 4ba4abd2176..75c8f52b86b 100644 --- a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/UnmarshalMarshalTest.java +++ b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_1/UnmarshalMarshalTest.java @@ -33,8 +33,8 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.marshalling.DMNMarshaller; import org.kie.dmn.backend.marshalling.v1_1.extensions.MyTestRegister; import org.kie.dmn.backend.marshalling.v1_1.xstream.extensions.DecisionServicesExtensionRegister; @@ -63,99 +63,99 @@ public class UnmarshalMarshalTest { protected static final Logger LOG = LoggerFactory.getLogger(UnmarshalMarshalTest.class); @Test - public void test0001() throws Exception { + void test0001() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "0001-input-data-string.dmn"); } @Test - public void test0002() throws Exception { + void test0002() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "0002-input-data-number.dmn"); } @Test - public void test0003() throws Exception { + void test0003() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "0003-input-data-string-allowed-values.dmn"); } @Test - public void test0004() throws Exception { + void test0004() throws Exception { DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new DecisionServicesExtensionRegister())); testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "0004-decision-services.dmn", marshaller); } @Test - public void test0004_ns_other_location() throws Exception { + void test0004_ns_other_location() throws Exception { DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new DecisionServicesExtensionRegister())); testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "0004-decision-services_ns_other_location.dmn", marshaller); } @Test - public void test0005_decision_list() throws Exception { + void test0005_decision_list() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "0005-decision-list.dmn"); } @Test - public void test_hardcoded_java_max_call() throws Exception { + void hardcoded_java_max_call() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "hardcoded-java-max-call.dmn"); } @Test - public void testDish() throws Exception { + void dish() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "dish-decision.xml"); } - @Ignore("failing to compare over a xsi:type=\"tImport\" attribute, but why content generated 'control' need to explicit it ?") + @Disabled("failing to compare over a xsi:type=\"tImport\" attribute, but why content generated 'control' need to explicit it ?") @Test - public void testDummyDefinitions() throws Exception { + void dummyDefinitions() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "dummy-definitions.xml"); } @Test - public void testDummyRelation() throws Exception { + void dummyRelation() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "dummy-relation.xml"); } @Test - public void testCh11() throws Exception { + void ch11() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "ch11example.xml"); } @Test - public void testHello_World_semantic_namespace() throws Exception { + void helloWorldSemanticNamespace() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "Hello_World_semantic_namespace.dmn"); } @Test - public void testHello_World_semantic_namespace_with_extensions() throws Exception { + void helloWorldSemanticNamespaceWithExtensions() throws Exception { DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new MyTestRegister())); testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "Hello_World_semantic_namespace_with_extensions.dmn", marshaller); } @Test - public void testHello_World_semantic_namespace_with_extensions_other_ns_location() throws Exception { + void helloWorldSemanticNamespaceWithExtensionsOtherNsLocation() throws Exception { DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new MyTestRegister())); testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "Hello_World_semantic_namespace_with_extensions_other_ns_location.dmn", marshaller); } @Test - public void testSemanticNamespace() throws Exception { + void semanticNamespace() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "semantic-namespace.xml"); } - @Ignore("The current file cannot marshal back extension elements because they don't provide converters.") + @Disabled("The current file cannot marshal back extension elements because they don't provide converters.") @Test - public void test20161014() throws Exception { + void test20161014() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "test20161014.xml"); } @Test - public void testQNameSerialization() throws Exception { + void qNameSerialization() throws Exception { testRoundTrip("org/kie/dmn/backend/marshalling/v1_1/", "hardcoded_function_definition.dmn"); } - @Ignore("A problem with the StaxDriver has still to be resolved.") + @Disabled("A problem with the StaxDriver has still to be resolved.") @Test - public void testFAILforMissingNamespaces() { + void faiLforMissingNamespaces() { fail("PERFORM A MANUAL CHECK: does now the Stax driver do output the namespace for 'feel:' ?? "); } diff --git a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_2/UnmarshalMarshalTest.java b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_2/UnmarshalMarshalTest.java index 9d6979b25d8..2fc9d165864 100644 --- a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_2/UnmarshalMarshalTest.java +++ b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_2/UnmarshalMarshalTest.java @@ -33,7 +33,7 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.marshalling.DMNMarshaller; import org.kie.dmn.backend.marshalling.v1_2.extensions.MyTestRegister; import org.kie.dmn.backend.marshalling.v1x.DMNMarshallerFactory; @@ -65,49 +65,49 @@ public class UnmarshalMarshalTest { protected static final Logger LOG = LoggerFactory.getLogger(UnmarshalMarshalTest.class); @Test - public void testV12_simple() throws Exception { + void v12Simple() throws Exception { testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "simple.dmn"); } @Test - public void testV12_ch11example() throws Exception { + void v12Ch11example() throws Exception { testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "ch11example.dmn"); } @Test - public void testV12_ImportName() throws Exception { + void v12_ImportName() throws Exception { testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "ImportName.dmn"); } @Test - public void testV12_DecisionService20180911v12() throws Exception { + void v12_DecisionService20180911v12() throws Exception { // DROOLS-2987 DMN v1.2 marshaller failing marshalling DecisionService node and dmndi:DMNDecisionServiceDividerLine testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "DecisionService20180911v12.dmn"); } @Test - public void testV12_DiamondWithColors() throws Exception { + void v12_DiamondWithColors() throws Exception { testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "diamondWithColors.dmn"); } @Test - public void testV12_DMNDIDiagramElementExtension() throws Exception { + void v12_dmndiDiagramElementExtension() throws Exception { testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "DMNDIDiagramElementExtension.dmn"); } @Test - public void testV12_DMNDIDiagramElementExtension_withContent() throws Exception { + void v12_dmndiDiagramElementExtensionWithContent() throws Exception { DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new MyTestRegister())); testRoundTrip("org/kie/dmn/backend/marshalling/v1_2/", "DMNDIDiagramElementExtension_withContent.dmn", marshaller, DMN12_SCHEMA_SOURCE); } @Test - public void test_hardcoded_java_max_call() throws Exception { + void hardcoded_java_max_call() throws Exception { testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "hardcoded-java-max-call.dmn"); } @Test - public void test_FontSize_sharedStyle() throws Exception { + void font_size_shared_style() throws Exception { testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "test-FontSize-sharedStyle.dmn"); Definitions definitions = MARSHALLER.unmarshal(new InputStreamReader(this.getClass().getResourceAsStream("test-FontSize-sharedStyle.dmn"))); DMNShape shape0 = (DMNShape) definitions.getDMNDI().getDMNDiagram().get(0).getDMNDiagramElement().get(0); @@ -117,12 +117,12 @@ public void test_FontSize_sharedStyle() throws Exception { } @Test - public void test_DMNLabel_Text() throws Exception { + void dmnlabel_text() throws Exception { testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "DMNLabel-Text.dmn"); } @Test - public void testV12_decision_list() throws Exception { + void v12DecisionList() throws Exception { testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "decision-list.dmn"); } diff --git a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_3/UnmarshalMarshalTest.java b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_3/UnmarshalMarshalTest.java index ba2c5e37005..151ea9aa7ee 100644 --- a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_3/UnmarshalMarshalTest.java +++ b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_3/UnmarshalMarshalTest.java @@ -33,7 +33,7 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.marshalling.DMNMarshaller; import org.kie.dmn.backend.marshalling.v1_3.extensions.TrisoExtensionRegister; import org.kie.dmn.backend.marshalling.v1x.DMNMarshallerFactory; @@ -62,48 +62,48 @@ public class UnmarshalMarshalTest { protected static final Logger LOG = LoggerFactory.getLogger(UnmarshalMarshalTest.class); @Test - public void testV13_simple() throws Exception { + void v13Simple() throws Exception { testRoundTripV13("org/kie/dmn/backend/marshalling/v1_3/", "simple.dmn"); } @Test - public void testV13_ch11example_asFromOMG() throws Exception { + void v13Ch11exampleAsFromOMG() throws Exception { DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new TrisoExtensionRegister())); // as the example from OMG contains example of extension element, preserving. testRoundTrip("org/kie/dmn/backend/marshalling/v1_3/", "Chapter 11 Example.dmn", marshaller, DMN13_SCHEMA_SOURCE); } @Test - public void testV13_financial() throws Exception { + void v13Financial() throws Exception { testRoundTripV13("org/kie/dmn/backend/marshalling/v1_3/", "Financial.dmn"); } @Test - public void testV13_loan_info() throws Exception { + void v13LoanInfo() throws Exception { testRoundTripV13("org/kie/dmn/backend/marshalling/v1_3/", "Loan info.dmn"); } @Test - public void testV13_recommended_loan_product() throws Exception { + void v13RecommendedLoanProduct() throws Exception { testRoundTripV13("org/kie/dmn/backend/marshalling/v1_3/", "Recommended Loan Products.dmn"); } @Test - public void testV13_group() throws Exception { + void v13Group() throws Exception { testRoundTripV13("org/kie/dmn/backend/marshalling/v1_3/", "group.dmn"); } @Test - public void testV13_dmnedge() throws Exception { + void v13Dmnedge() throws Exception { testRoundTripV13("org/kie/dmn/backend/marshalling/v1_3/", "dmnedge.dmn"); } @Test - public void testV13_functionItem() throws Exception { + void v13FunctionItem() throws Exception { testRoundTripV13("org/kie/dmn/backend/marshalling/v1_3/", "functionItem.dmn"); } @Test - public void testV13_decision_list() throws Exception { + void v13DecisionList() throws Exception { testRoundTripV13("org/kie/dmn/backend/marshalling/v1_3/", "decision-list.dmn"); } diff --git a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_4/UnmarshalMarshalTest.java b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_4/UnmarshalMarshalTest.java index 214c1f0d566..629dcfc2820 100644 --- a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_4/UnmarshalMarshalTest.java +++ b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_4/UnmarshalMarshalTest.java @@ -33,7 +33,7 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.marshalling.DMNMarshaller; import org.kie.dmn.backend.marshalling.v1_3.extensions.TrisoExtensionRegister; import org.kie.dmn.backend.marshalling.v1x.DMNMarshallerFactory; @@ -62,48 +62,48 @@ public class UnmarshalMarshalTest { protected static final Logger LOG = LoggerFactory.getLogger(UnmarshalMarshalTest.class); @Test - public void testV14_simple() throws Exception { + void v14Simple() throws Exception { testRoundTripV14("org/kie/dmn/backend/marshalling/v1_4/", "simple.dmn"); } @Test - public void testV14_ch11example_asFromOMG() throws Exception { + void v14Ch11exampleAsFromOMG() throws Exception { DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new TrisoExtensionRegister())); // as the example from OMG contains example of extension element, preserving (re-using from package of 1.3) testRoundTrip("org/kie/dmn/backend/marshalling/v1_4/", "Chapter 11 Example.dmn", marshaller, DMN14_SCHEMA_SOURCE); } @Test - public void testV14_financial() throws Exception { + void v14Financial() throws Exception { testRoundTripV14("org/kie/dmn/backend/marshalling/v1_4/", "Financial.dmn"); } @Test - public void testV14_loan_info() throws Exception { + void v14LoanInfo() throws Exception { testRoundTripV14("org/kie/dmn/backend/marshalling/v1_4/", "Loan info.dmn"); } @Test - public void testV14_recommended_loan_product() throws Exception { + void v14RecommendedLoanProduct() throws Exception { testRoundTripV14("org/kie/dmn/backend/marshalling/v1_4/", "Recommended Loan Products.dmn"); } - + @Test - public void testV14_for() throws Exception { + void v14For() throws Exception { testRoundTripV14("org/kie/dmn/backend/marshalling/v1_4/", "sampleFor.dmn"); } - + @Test - public void testV14_quantified() throws Exception { + void v14Quantified() throws Exception { testRoundTripV14("org/kie/dmn/backend/marshalling/v1_4/", "sampleQuantified.dmn"); } - + @Test - public void testV14_conditional() throws Exception { + void v14Conditional() throws Exception { testRoundTripV14("org/kie/dmn/backend/marshalling/v1_4/", "sampleConditional.dmn"); } - + @Test - public void testV14_filter() throws Exception { + void v14Filter() throws Exception { testRoundTripV14("org/kie/dmn/backend/marshalling/v1_4/", "sampleFilter.dmn"); } diff --git a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_5/UnmarshalMarshalTest.java b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_5/UnmarshalMarshalTest.java index de59347f507..54ade650d4c 100644 --- a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_5/UnmarshalMarshalTest.java +++ b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_5/UnmarshalMarshalTest.java @@ -18,7 +18,22 @@ */ package org.kie.dmn.backend.marshalling.v1_5; -import org.junit.Test; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.InputStreamReader; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; + +import org.junit.jupiter.api.Test; import org.kie.dmn.api.marshalling.DMNMarshaller; import org.kie.dmn.backend.marshalling.v1_3.extensions.TrisoExtensionRegister; import org.kie.dmn.backend.marshalling.v1x.DMNMarshallerFactory; @@ -38,20 +53,6 @@ import org.xmlunit.validation.ValidationResult; import org.xmlunit.validation.Validator; -import javax.xml.namespace.QName; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.InputStreamReader; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import static org.assertj.core.api.Assertions.assertThat; public class UnmarshalMarshalTest { @@ -61,48 +62,48 @@ public class UnmarshalMarshalTest { protected static final Logger LOG = LoggerFactory.getLogger(UnmarshalMarshalTest.class); @Test - public void testv15_simple() throws Exception { + void testv15_simple() throws Exception { testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "simple.dmn"); } @Test - public void testv15_ch11example_asFromOMG() throws Exception { + void testv15_ch11example_asFromOMG() throws Exception { DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new TrisoExtensionRegister())); // as the example from OMG contains example of extension element, preserving (re-using from package of 1.3) testRoundTrip("org/kie/dmn/backend/marshalling/v1_5/", "Chapter 11 Example.dmn", marshaller, DMN15_SCHEMA_SOURCE); } @Test - public void testv15_financial() throws Exception { + void testv15_financial() throws Exception { testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "Financial.dmn"); } @Test - public void testv15_loan_info() throws Exception { + void testv15_loan_info() throws Exception { testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "Loan info.dmn"); } @Test - public void testv15_recommended_loan_product() throws Exception { + void testv15_recommended_loan_product() throws Exception { testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "Recommended Loan Products.dmn"); } - + @Test - public void testv15_for() throws Exception { + void testv15_for() throws Exception { testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "sampleFor.dmn"); } - + @Test - public void testv15_quantified() throws Exception { + void testv15_quantified() throws Exception { testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "sampleQuantified.dmn"); } - + @Test - public void testv15_conditional() throws Exception { + void testv15_conditional() throws Exception { testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "sampleConditional.dmn"); } - + @Test - public void testv15_filter() throws Exception { + void testv15_filter() throws Exception { testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "sampleFilter.dmn"); } diff --git a/kie-dmn/kie-dmn-core-jsr223-jq/src/test/java/org/kie/dmn/core/jsr223/jq/BasicTest.java b/kie-dmn/kie-dmn-core-jsr223-jq/src/test/java/org/kie/dmn/core/jsr223/jq/BasicTest.java index 1748472b97e..f5931ceea8e 100644 --- a/kie-dmn/kie-dmn-core-jsr223-jq/src/test/java/org/kie/dmn/core/jsr223/jq/BasicTest.java +++ b/kie-dmn/kie-dmn-core-jsr223-jq/src/test/java/org/kie/dmn/core/jsr223/jq/BasicTest.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class BasicTest { +class BasicTest { private static final Logger LOG = LoggerFactory.getLogger( BasicTest.class ); private static final ScriptEngineManager SEMANAGER = new ScriptEngineManager(); @@ -41,12 +41,12 @@ public class BasicTest { private ScriptEngine engine; @BeforeEach - public void init() { + void init() { engine = SEMANAGER.getEngineByName("jq"); } - + @Test - public void testEval() throws ScriptException { + void eval() throws ScriptException { Map ctx = new HashMap<>(); ctx.put("a", 1); ctx.put("b", 2); @@ -54,9 +54,9 @@ public void testEval() throws ScriptException { LOG.info("{}", result); assertThat(result).asString().isEqualTo("3"); } - + @Test - public void testEvalJSONKey() throws ScriptException { + void evalJSONKey() throws ScriptException { Map ctx = new HashMap<>(); ctx.put("Age", 1); ctx.put("Previous incidents?", false); @@ -64,9 +64,9 @@ public void testEvalJSONKey() throws ScriptException { LOG.info("{}", result); assertThat(result).isEqualTo(false); } - + @Test - public void testTest() throws ScriptException { + void test() throws ScriptException { evalToStringEquals(testCtx(1), " . > 10 ", false); evalToStringEquals(testCtx(47), " . > 10 ", true); evalToStringEquals(testCtx(47), " . > $a ", true); diff --git a/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/EscapeTest.java b/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/EscapeTest.java index 694522bcb11..aff1f511de0 100644 --- a/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/EscapeTest.java +++ b/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/EscapeTest.java @@ -23,10 +23,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.core.jsr223.JSR223Utils.escapeIdentifierForBinding; -public class EscapeTest { +class EscapeTest { @Test - public void test() { + void test() { assertThat(escapeIdentifierForBinding("123abc")).isEqualTo("_123abc"); assertThat(escapeIdentifierForBinding("a+bc")).isEqualTo("a_bc"); assertThat(escapeIdentifierForBinding("full name")).isEqualTo("full_name"); diff --git a/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/GraalJSTest.java b/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/GraalJSTest.java index 05be4d764d7..686d662cb73 100644 --- a/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/GraalJSTest.java +++ b/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/GraalJSTest.java @@ -31,28 +31,28 @@ import static org.assertj.core.api.Assertions.assertThat; -public class GraalJSTest { +class GraalJSTest { private static final Logger LOG = LoggerFactory.getLogger( GraalJSTest.class ); private static final String POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY = "polyglot.engine.WarnInterpreterOnly"; private String warnFlag; @BeforeEach - public void init() { + void init() { warnFlag = System.getProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY); System.setProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY, "false"); } - + @AfterEach - public void end() { + void end() { if (warnFlag != null) { System.setProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY, warnFlag); } else { System.clearProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY); } } - + @Test - public void testNashorn() { + void nashorn() { DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() .setDecisionLogicCompilerFactory(new JSR223EvaluatorCompilerFactory()) .buildConfiguration() diff --git a/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/JQTest.java b/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/JQTest.java index e7d9ad0622b..a2113c3e284 100644 --- a/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/JQTest.java +++ b/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/JQTest.java @@ -29,11 +29,11 @@ import static org.assertj.core.api.Assertions.assertThat; -public class JQTest { +class JQTest { private static final Logger LOG = LoggerFactory.getLogger( JQTest.class ); @Test - public void testJQ_BMI() { + void jqBmi() { DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() .setDecisionLogicCompilerFactory(new JSR223EvaluatorCompilerFactory()) .buildConfiguration() @@ -48,9 +48,9 @@ public void testJQ_BMI() { LOG.info("{}", evaluateAll.getMessages()); assertThat(evaluateAll.getDecisionResultByName("BMI value classification").getResult()).isEqualTo("Normal range"); } - + @Test - public void testJQ_isAdult() { + void jQIsAdult() { DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() .setDecisionLogicCompilerFactory(new JSR223EvaluatorCompilerFactory()) .buildConfiguration() @@ -64,9 +64,9 @@ public void testJQ_isAdult() { LOG.info("{}", evaluateAll.getMessages()); assertThat(evaluateAll.getDecisionResultByName("Is Adult?").getResult()).isEqualTo(true); } - + @Test - public void testJQ_isAdult2() { + void jQIsAdult2() { DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() .setDecisionLogicCompilerFactory(new JSR223EvaluatorCompilerFactory()) .buildConfiguration() @@ -80,9 +80,9 @@ public void testJQ_isAdult2() { LOG.info("{}", evaluateAll.getMessages()); assertThat(evaluateAll.getDecisionResultByName("Is Adult?").getResult()).isEqualTo(false); } - + @Test - public void testIsPersonNameAnAdult() { + void isPersonNameAnAdult() { DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() .setDecisionLogicCompilerFactory(new JSR223EvaluatorCompilerFactory()) .buildConfiguration() diff --git a/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/NashornTest.java b/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/NashornTest.java index 6c6a04ae731..e31b0ec6329 100644 --- a/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/NashornTest.java +++ b/kie-dmn/kie-dmn-core-jsr223/src/test/java/org/kie/dmn/core/jsr223/NashornTest.java @@ -31,19 +31,19 @@ import static org.assertj.core.api.Assertions.assertThat; -public class NashornTest { +class NashornTest { private static final Logger LOG = LoggerFactory.getLogger( NashornTest.class ); private static final String NASHORN_ARGS = "nashorn.args"; private String nashornArgsFromSys; - + @BeforeEach - public void init() { + void init() { nashornArgsFromSys = System.getProperty(NASHORN_ARGS); System.setProperty(NASHORN_ARGS, "--language=es6"); // TODO document: anyway is a partial ES6 support. } - + @AfterEach - public void end() { + void end() { if (nashornArgsFromSys != null) { System.setProperty(NASHORN_ARGS, nashornArgsFromSys); } else { @@ -52,7 +52,7 @@ public void end() { } @Test - public void testNashorn() { + void nashorn() { DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() .setDecisionLogicCompilerFactory(new JSR223EvaluatorCompilerFactory()) .buildConfiguration() @@ -67,9 +67,9 @@ public void testNashorn() { LOG.info("{}", evaluateAll.getMessages()); assertThat(evaluateAll.getDecisionResultByName("BMI value classification").getResult()).isEqualTo("Normal range"); } - + @Test - public void testIsPersonNameAnAdult() { + void isPersonNameAnAdult() { DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() .setDecisionLogicCompilerFactory(new JSR223EvaluatorCompilerFactory()) .buildConfiguration() diff --git a/kie-dmn/kie-dmn-core/pom.xml b/kie-dmn/kie-dmn-core/pom.xml index 092bb3931b1..ab4f01aae28 100644 --- a/kie-dmn/kie-dmn-core/pom.xml +++ b/kie-dmn/kie-dmn-core/pom.xml @@ -156,13 +156,13 @@ pmml-model - junit - junit + org.mockito + mockito-core test org.mockito - mockito-core + mockito-junit-jupiter test @@ -202,6 +202,11 @@ yasson test + + org.junit.jupiter + junit-jupiter + test + io.smallrye smallrye-open-api-core diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsAlphaNetworkTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsAlphaNetworkTest.java index 2bf656bc0e2..19ba2780490 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsAlphaNetworkTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsAlphaNetworkTest.java @@ -18,32 +18,24 @@ */ package org.kie.dmn.core; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.kie.dmn.core.compiler.AlphaNetworkOption; -@RunWith(Parameterized.class) public abstract class BaseInterpretedVsAlphaNetworkTest { - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{true, false}; } - private final boolean alphaNetwork; + protected boolean alphaNetwork; - public BaseInterpretedVsAlphaNetworkTest(final boolean useAlphaNetwork) { - this.alphaNetwork = useAlphaNetwork; - } - - @Before + @BeforeEach public void before() { System.setProperty(AlphaNetworkOption.PROPERTY_NAME, Boolean.toString(alphaNetwork)); } - @After + @AfterEach public void after() { System.clearProperty(AlphaNetworkOption.PROPERTY_NAME); } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsCompiledTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsCompiledTest.java index 345ab0f38a8..830b4c2131d 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsCompiledTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsCompiledTest.java @@ -18,32 +18,23 @@ */ package org.kie.dmn.core; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; import org.kie.dmn.core.compiler.ExecModelCompilerOption; -@RunWith(Parameterized.class) public abstract class BaseInterpretedVsCompiledTest { - @Parameterized.Parameters(name = "{0}") - public static Object[] params() { + protected static Object[] params() { return new Object[]{false}; } - private final boolean useExecModelCompiler; + protected boolean useExecModelCompiler; - public BaseInterpretedVsCompiledTest(final boolean useExecModelCompiler) { + protected void init(boolean useExecModelCompiler){ this.useExecModelCompiler = useExecModelCompiler; - } - - @Before - public void before() { System.setProperty(ExecModelCompilerOption.PROPERTY_NAME, Boolean.toString(useExecModelCompiler)); } - @After + @AfterEach public void after() { System.clearProperty(ExecModelCompilerOption.PROPERTY_NAME); } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsCompiledTestCanonicalKieModule.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsCompiledTestCanonicalKieModule.java index c35fb4e07d6..b9758e6e0e3 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsCompiledTestCanonicalKieModule.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseInterpretedVsCompiledTestCanonicalKieModule.java @@ -23,10 +23,7 @@ import java.util.List; import org.drools.modelcompiler.CanonicalKieModule; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; import org.kie.api.KieServices; import org.kie.api.builder.ReleaseId; import org.kie.api.io.Resource; @@ -39,28 +36,22 @@ * running alongside the CanonicalKieModule, which is needed while using the executable model for DRL file.

* Please note that these tests don't actually verify the correct behaviour of the compiled DRL files, but they only verify the DMN model. Ref: https://github.com/kiegroup/drools/pull/2460#issue-298982811 */ -@RunWith(Parameterized.class) public abstract class BaseInterpretedVsCompiledTestCanonicalKieModule { - @Parameterized.Parameters - public static Object[] params() { + protected static Object[] params() { return new Object[][]{ { false, true}, {false, false} }; } - private final boolean useExecModelCompiler; - protected final boolean canonicalKieModule; + private boolean useExecModelCompiler; + protected boolean canonicalKieModule; - public BaseInterpretedVsCompiledTestCanonicalKieModule(boolean useExecModelCompiler, boolean canonicalKieModule) { + protected void init(boolean useExecModelCompiler, boolean canonicalKieModule) { this.useExecModelCompiler = useExecModelCompiler; this.canonicalKieModule = canonicalKieModule; - } - - @Before - public void before() { System.setProperty(ExecModelCompilerOption.PROPERTY_NAME, Boolean.toString(useExecModelCompiler)); } - @After + @AfterEach public void after() { System.clearProperty(ExecModelCompilerOption.PROPERTY_NAME); } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseVariantNonTypeSafeTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseVariantNonTypeSafeTest.java index 3e69ddaffbb..36934d65683 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseVariantNonTypeSafeTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseVariantNonTypeSafeTest.java @@ -18,19 +18,13 @@ */ package org.kie.dmn.core; -import org.junit.runners.Parameterized; - import static org.kie.dmn.core.BaseVariantTest.VariantTestConf.BUILDER_DEFAULT_NOCL_TYPECHECK; import static org.kie.dmn.core.BaseVariantTest.VariantTestConf.BUILDER_STRICT; import static org.kie.dmn.core.BaseVariantTest.VariantTestConf.KIE_API_TYPECHECK; public abstract class BaseVariantNonTypeSafeTest extends BaseVariantTest { - public BaseVariantNonTypeSafeTest(VariantTestConf testConfig) { - super(testConfig); - } - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{KIE_API_TYPECHECK, BUILDER_STRICT, BUILDER_DEFAULT_NOCL_TYPECHECK}; } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseVariantTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseVariantTest.java index 227a8cd6135..585262a0fa3 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseVariantTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/BaseVariantTest.java @@ -21,13 +21,12 @@ import java.util.HashMap; import java.util.Map; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.api.core.FEELPropertyAccessible; +import org.kie.dmn.core.compiler.ExecModelCompilerOption; import org.kie.dmn.core.compiler.RuntimeTypeCheckOption; import org.kie.dmn.core.impl.DMNContextFPAImpl; import org.kie.dmn.core.impl.DMNResultImpl; @@ -46,7 +45,6 @@ import static org.kie.dmn.core.BaseVariantTest.VariantTestConf.KIE_API_TYPECHECK; import static org.kie.dmn.core.BaseVariantTest.VariantTestConf.KIE_API_TYPECHECK_TYPESAFE; -@RunWith(Parameterized.class) public abstract class BaseVariantTest { private DMNTypeSafePackageName.Factory factory; @@ -146,16 +144,11 @@ public boolean isTypeSafe() { } } - @Parameterized.Parameters(name = "{0}") - public static Object[] params() { + protected static Object[] params() { return new Object[]{KIE_API_TYPECHECK, BUILDER_STRICT, BUILDER_DEFAULT_NOCL_TYPECHECK, BUILDER_DEFAULT_NOCL_TYPECHECK_TYPESAFE, KIE_API_TYPECHECK_TYPESAFE}; } - private final VariantTestConf testConfig; - - public BaseVariantTest(final VariantTestConf testConfig) { - this.testConfig = testConfig; - } + protected VariantTestConf testConfig; public boolean isTypeSafe() { return testConfig.isTypeSafe(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNAndCanonicalModelTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNAndCanonicalModelTest.java index e23afdf1066..1e0d92cf94d 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNAndCanonicalModelTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNAndCanonicalModelTest.java @@ -18,7 +18,8 @@ */ package org.kie.dmn.core; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.ReleaseId; import org.kie.api.runtime.KieContainer; @@ -36,12 +37,10 @@ public class DMNAndCanonicalModelTest extends BaseInterpretedVsCompiledTestCanon public static final Logger LOG = LoggerFactory.getLogger(DMNAndCanonicalModelTest.class); - public DMNAndCanonicalModelTest(final boolean useExecModelCompiler, boolean canonicalKieModule) { - super(useExecModelCompiler, canonicalKieModule); - } - - @Test - public void testDMNAndCanonicalModel() { + @ParameterizedTest + @MethodSource("params") + void dmnAndCanonicalModel(boolean useExecModelCompiler, boolean canonicalKieModule) { + init(useExecModelCompiler, canonicalKieModule); final KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "dmn-and-canonical", "1.0.0"); @@ -62,8 +61,10 @@ public void testDMNAndCanonicalModel() { assertThat(evaluateAll.getDecisionResultByName("Greeting Message").getResult()).isEqualTo("Hello John Doe"); } - @Test - public void testDTAndCanonicalModel() { + @ParameterizedTest + @MethodSource("params") + void dTAndCanonicalModel(boolean useExecModelCompiler, boolean canonicalKieModule) { + init(useExecModelCompiler, canonicalKieModule); final KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "dmn-and-canonical", "1.0.0"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNAssemblerTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNAssemblerTest.java index 55b1f59f245..c73e5c21b17 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNAssemblerTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNAssemblerTest.java @@ -21,8 +21,9 @@ import java.time.OffsetTime; import java.time.format.DateTimeFormatter; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieFileSystem; import org.kie.api.builder.Message.Level; @@ -42,12 +43,10 @@ public class DMNAssemblerTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(DMNAssemblerTest.class); - public DMNAssemblerTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testDuplicateModel() { + @ParameterizedTest + @MethodSource("params") + void duplicateModel(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final KieFileSystem kfs = ks.newKieFileSystem(); @@ -62,8 +61,10 @@ public void testDuplicateModel() { assertThat(results.getMessages(Level.ERROR)).hasSizeGreaterThan(0); } - @Test - public void testExtendedMode() { + @ParameterizedTest + @MethodSource("params") + void extendedMode(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("strictMode.dmn", this.getClass() ); final DMNModel model = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ecf4ea54-2abc-4e2f-a101-4fe14e356a46", "strictMode" ); final DMNContext ctx = runtime.newContext(); @@ -72,8 +73,10 @@ public void testExtendedMode() { assertThat(result.getDecisionResultByName("time").getResult()).isEqualTo(DateTimeFormatter.ISO_TIME.parse("14:30:22z", OffsetTime::from)); } - @Test - public void testStrictMode() { + @ParameterizedTest + @MethodSource("params") + void strictMode(boolean useExecModelCompiler) { + init(useExecModelCompiler); System.setProperty("org.kie.dmn.strictConformance", "true"); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("strictMode.dmn", this.getClass() ); final DMNModel model = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ecf4ea54-2abc-4e2f-a101-4fe14e356a46", "strictMode" ); @@ -83,8 +86,10 @@ public void testStrictMode() { assertThat(result.getDecisionResultByName("time").getResult()).isNull(); } - @Test - public void testStrictModeProp() { + @ParameterizedTest + @MethodSource("params") + void strictModeProp(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices services = KieServices.Factory.get(); final KieFileSystem fileSystem = services.newKieFileSystem(); final KieModuleModel moduleModel = services.newKieModuleModel(); @@ -101,8 +106,8 @@ public void testStrictModeProp() { assertThat(result.getDecisionResultByName("time").getResult()).isNull(); } - @After - public void clearSystemProperty() { + @AfterEach + void clearSystemProperty() { System.clearProperty("org.kie.dmn.strictConformance"); } } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNBuildFromReaderTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNBuildFromReaderTest.java index 42e3631090c..9f5130b4a98 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNBuildFromReaderTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNBuildFromReaderTest.java @@ -20,7 +20,7 @@ import java.io.StringReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.io.Resource; @@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class DMNBuildFromReaderTest { +class DMNBuildFromReaderTest { @Test - public void test() { + void test() { // DROOLS-5127 String dmn = " dm.getSeverity().equals(DMNMessage.Severity.WARN) && dm.getFeelEvent() instanceof HitPolicyViolationEvent && dm.getFeelEvent().getSeverity().equals(FEELEvent.Severity.WARN))).isTrue(); } - @Test - public void testSimpleDecisionTableHitPolicyUniqueNullWarn_ctxe() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyUniqueNullWarnCtxe(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-U-noinputvalues-ctxe.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-U-noinputvalues"); assertThat(dmnModel).isNotNull(); @@ -103,8 +108,10 @@ public void testSimpleDecisionTableHitPolicyUniqueNullWarn_ctxe() { check_testSimpleDecisionTableHitPolicyUniqueNullWarn(runtime, dmnModel); } - @Test - public void testSimpleDecisionTableHitPolicyUniqueNullWarn_ctxr() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyUniqueNullWarnCtxr(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-U-noinputvalues-ctxr.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-U-noinputvalues"); assertThat(dmnModel).isNotNull(); @@ -112,8 +119,10 @@ public void testSimpleDecisionTableHitPolicyUniqueNullWarn_ctxr() { check_testSimpleDecisionTableHitPolicyUniqueNullWarn(runtime, dmnModel); } - @Test - public void testDecisionTableHitPolicyUnique() { + @ParameterizedTest + @MethodSource("params") + void decisionTableHitPolicyUnique(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("BranchDistribution.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_cdf29af2-959b-4004-8271-82a9f5a62147", "Dessin 1"); assertThat(dmnModel).isNotNull(); @@ -129,8 +138,10 @@ public void testDecisionTableHitPolicyUnique() { assertThat(result.get("Branches distribution")).isEqualTo("Medium"); } - @Test - public void testSimpleDecisionTableHitPolicyFirst() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyFirst(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-F.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-F"); assertThat(dmnModel).isNotNull(); @@ -143,13 +154,17 @@ public void testSimpleDecisionTableHitPolicyFirst() { assertThat(decisionResult).containsEntry("Decision Review", "Decision final"); } - @Test - public void testSimpleDecisionTableHitPolicyAnyEqualRules() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyAnyEqualRules(boolean useExecModelCompiler) { + init(useExecModelCompiler); testSimpleDecisionTableHitPolicyAny("0004-simpletable-A.dmn", "0004-simpletable-A", true); } - @Test - public void testSimpleDecisionTableHitPolicyAnyNonEqualRules() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyAnyNonEqualRules(boolean useExecModelCompiler) { + init(useExecModelCompiler); testSimpleDecisionTableHitPolicyAny("0004-simpletable-A-non-equal.dmn", "0004-simpletable-A-non-equal", false); } @@ -169,8 +184,10 @@ private void testSimpleDecisionTableHitPolicyAny(final String resurceName, final } } - @Test - public void testSimpleDecisionTableHitPolicyPriority() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyPriority(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-P.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-P"); assertThat(dmnModel).isNotNull(); @@ -180,8 +197,10 @@ public void testSimpleDecisionTableHitPolicyPriority() { assertThat(result.get("Approval Status")).isEqualTo("Declined"); } - @Test - public void testSimpleDecisionTableHitPolicyPriorityMultipleOutputs() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyPriorityMultipleOutputs(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-P-multiple-outputs.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-P-multiple-outputs"); assertThat(dmnModel).isNotNull(); @@ -194,8 +213,10 @@ public void testSimpleDecisionTableHitPolicyPriorityMultipleOutputs() { assertThat(decisionResult).containsEntry("Decision Review", "Needs verification"); } - @Test - public void testSimpleDecisionTableHitPolicyOutputOrder() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyOutputOrder(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-O.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-O"); assertThat(dmnModel).isNotNull(); @@ -207,8 +228,10 @@ public void testSimpleDecisionTableHitPolicyOutputOrder() { assertThat(decisionResults).contains("Declined", "Declined", "Approved"); } - @Test - public void testSimpleDecisionTableHitPolicyOutputOrderMultipleOutputs() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyOutputOrderMultipleOutputs(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-O-multiple-outputs.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-O-multiple-outputs"); assertThat(dmnModel).isNotNull(); @@ -230,8 +253,10 @@ private void checkMultipleOutputResult(final Map outputResult, assertThat(outputResult).containsEntry("Decision Review", expectedDecisionReview); } - @Test - public void testSimpleDecisionTableHitPolicyRuleOrder() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyRuleOrder(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-R.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-R"); assertThat(dmnModel).isNotNull(); @@ -243,15 +268,19 @@ public void testSimpleDecisionTableHitPolicyRuleOrder() { assertThat(decisionResults).contains("Approved", "Needs review", "Declined"); } - @Test - public void testSimpleDecisionTableHitPolicyCollect() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyCollect(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List decisionResults = executeTestDecisionTableHitPolicyCollect(getSimpleTableContext(BigDecimal.valueOf(70 ), "Medium", true)); assertThat(decisionResults).hasSize(3); assertThat(decisionResults).contains(BigDecimal.valueOf(10), BigDecimal.valueOf(25), BigDecimal.valueOf(13)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectNoHits() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectNoHits(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List decisionResults = executeTestDecisionTableHitPolicyCollect(getSimpleTableContext(BigDecimal.valueOf(5 ), "Medium", true)); assertThat(decisionResults).hasSize(0); } @@ -266,15 +295,19 @@ private List executeTestDecisionTableHitPolicyCollect(final DMNConte return (List) result.get( "Status number"); } - @Test - public void testSimpleDecisionTableHitPolicyCollectSum() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectSum(boolean useExecModelCompiler) { + init(useExecModelCompiler); testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-sum.dmn", "0004-simpletable-C-sum", BigDecimal.valueOf(48), getSimpleTableContext(BigDecimal.valueOf(70), "Medium", true)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectSumMultipleOutputs() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectSumMultipleOutputs(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-C-sum-multiple-outputs.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-C-sum-multiple-outputs"); @@ -290,29 +323,37 @@ public void testSimpleDecisionTableHitPolicyCollectSumMultipleOutputs() { assertThat(decisionResult).containsEntry("Value2", BigDecimal.valueOf(32)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectMin() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectMin(boolean useExecModelCompiler) { + init(useExecModelCompiler); testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-min.dmn", "0004-simpletable-C-min", BigDecimal.valueOf(10), getSimpleTableContext(BigDecimal.valueOf(70), "Medium", true)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectMax() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectMax(boolean useExecModelCompiler) { + init(useExecModelCompiler); testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-max.dmn", "0004-simpletable-C-max", BigDecimal.valueOf(25), getSimpleTableContext(BigDecimal.valueOf(70), "Medium", true)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectCount() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectCount(boolean useExecModelCompiler) { + init(useExecModelCompiler); testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-count.dmn", "0004-simpletable-C-count", BigDecimal.valueOf(3), getSimpleTableContext(BigDecimal.valueOf(70), "Medium", true)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectCountNoHits() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectCountNoHits(boolean useExecModelCompiler) { + init(useExecModelCompiler); testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-count.dmn", "0004-simpletable-C-count", BigDecimal.valueOf(0), getSimpleTableContext(BigDecimal.valueOf(5), "Medium", true)); @@ -341,8 +382,10 @@ private DMNContext getSimpleTableContext(final BigDecimal age, final String risk return context; } - @Test - public void testDecisionTableHitPolicyCollect() { + @ParameterizedTest + @MethodSource("params") + void decisionTableHitPolicyCollect(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Collect_Hit_Policy.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_da1a4dcb-01bf-4dee-9be8-f498bc68178c", "Collect Hit Policy"); assertThat(dmnModel).isNotNull(); @@ -357,8 +400,10 @@ public void testDecisionTableHitPolicyCollect() { assertThat(result.get("Collect")).isEqualTo(BigDecimal.valueOf(50)); } - @Test - public void testDecisionTableHitPolicyAnyWithOverlap_DoOverlap() { + @ParameterizedTest + @MethodSource("params") + void decisionTableHitPolicyAnyWithOverlapDoOverlap(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNResult dmnResult = executeHitPolicyAnyWithOverlap(20); assertThat(dmnResult.hasErrors()).isTrue(); assertThat(dmnResult.getMessages()).hasSizeGreaterThan(0); @@ -366,8 +411,10 @@ public void testDecisionTableHitPolicyAnyWithOverlap_DoOverlap() { assertThat(dmnResult.getDecisionResultByName("a decision").getResult()).isNull(); } - @Test - public void testDecisionTableHitPolicyAnyWithOverlap_NoOverlap() { + @ParameterizedTest + @MethodSource("params") + void decisionTableHitPolicyAnyWithOverlapNoOverlap(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNResult dmnResult = executeHitPolicyAnyWithOverlap(-1); assertThat(dmnResult.hasErrors()).isFalse(); assertThat(dmnResult.getDecisionResultByName("a decision").getResult()).isEqualTo("boh"); @@ -384,9 +431,11 @@ private DMNResult executeHitPolicyAnyWithOverlap(long number) { final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context); return dmnResult; } - - @Test - public void testShortCircuitFIRST() { + + @ParameterizedTest + @MethodSource("params") + void shortCircuitFIRST(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("First DT not stopping.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_e56151c4-d522-4974-88e8-f6c88ffaaba4", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -403,8 +452,10 @@ public void testShortCircuitFIRST() { assertThat(decisionTable).containsEntry("nn abs", BigDecimal.ZERO); } - @Test - public void testShortCircuitFIRST_withNullResults() { + @ParameterizedTest + @MethodSource("params") + void shortCircuitFIRSTWithNullResults(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("First DT not stopping - null result.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_e56151c4-d522-4974-88e8-f6c88ffaaba4", "Drawing 1"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNDecisionTableRuntimeTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNDecisionTableRuntimeTest.java index e5960b6fda2..b184e95f8c4 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNDecisionTableRuntimeTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNDecisionTableRuntimeTest.java @@ -28,8 +28,11 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -74,12 +77,10 @@ public class DMNDecisionTableRuntimeTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(DMNDecisionTableRuntimeTest.class); - public DMNDecisionTableRuntimeTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testDecisionTableWithCalculatedResult() { + @ParameterizedTest + @MethodSource("params") + void decisionTableWithCalculatedResult(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "calculation1.dmn", this.getClass() ); checkDecisionTableWithCalculatedResult(runtime); } @@ -99,9 +100,12 @@ private void checkDecisionTableWithCalculatedResult(final DMNRuntime runtime) { final DMNContext result = dmnResult.getContext(); assertThat( ((BigDecimal) result.get( "Logique de décision 1" )).setScale( 1, RoundingMode.CEILING )).isEqualTo(BigDecimal.valueOf( 0.5 ) ); } - - @Test(timeout = 30_000L) - public void testDecisionTableWithCalculatedResult_parallel() throws Throwable { + + @ParameterizedTest + @MethodSource("params") + @Timeout(value = 30_000L, unit = TimeUnit.MILLISECONDS) + void decisionTableWithCalculatedResultParallel(boolean useExecModelCompiler) throws Throwable { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "calculation1.dmn", this.getClass() ); final Runnable task = () -> checkDecisionTableWithCalculatedResult(runtime); final List problems = Collections.synchronizedList(new ArrayList<>()); @@ -118,8 +122,10 @@ public void testDecisionTableWithCalculatedResult_parallel() throws Throwable { } } - @Test - public void testDecisionTableMultipleResults() { + @ParameterizedTest + @MethodSource("params") + void decisionTableMultipleResults(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "car_damage_responsibility.dmn", this.getClass() ); final DMNRuntimeEventListener listener = Mockito.mock( DMNRuntimeEventListener.class ); runtime.addListener( listener ); @@ -152,8 +158,10 @@ public void testDecisionTableMultipleResults() { assertThat( second.getSelected()).containsExactly(3); } - @Test - public void testSimpleDecisionTableMultipleOutputWrongOutputType() { + @ParameterizedTest + @MethodSource("params") + void simpleDecisionTableMultipleOutputWrongOutputType(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0004-simpletable-P-multiple-outputs-wrong-output.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", "0004-simpletable-P-multiple-outputs-wrong-output" ); assertThat(dmnModel).isNotNull(); @@ -169,8 +177,10 @@ public void testSimpleDecisionTableMultipleOutputWrongOutputType() { message -> message.getFeelEvent().getSourceException() instanceof NullPointerException ).count()).isEqualTo(0L ); } - @Test - public void testDecisionTableInvalidInputErrorMessage() { + @ParameterizedTest + @MethodSource("params") + void decisionTableInvalidInputErrorMessage(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNContext context = DMNFactory.newContext(); context.set( "Branches dispersion", "Province" ); context.set( "Number of Branches", BigDecimal.valueOf( 10 ) ); @@ -178,8 +188,10 @@ public void testDecisionTableInvalidInputErrorMessage() { testDecisionTableInvalidInput( context ); } - @Test - public void testDecisionTableInvalidInputTypeErrorMessage() { + @ParameterizedTest + @MethodSource("params") + void decisionTableInvalidInputTypeErrorMessage(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNContext context = DMNFactory.newContext(); context.set( "Branches dispersion", 1 ); context.set( "Number of Branches", BigDecimal.valueOf( 10 ) ); @@ -187,8 +199,10 @@ public void testDecisionTableInvalidInputTypeErrorMessage() { testDecisionTableInvalidInput( context ); } - @Test - public void testDecisionTableNonexistingInputErrorMessage() { + @ParameterizedTest + @MethodSource("params") + void decisionTableNonexistingInputErrorMessage(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNContext context = DMNFactory.newContext(); context.set( "Not exists", "Province" ); context.set( "Number of Branches", BigDecimal.valueOf( 10 ) ); @@ -208,8 +222,10 @@ private void testDecisionTableInvalidInput(final DMNContext inputContext) { assertThat( result.isDefined( "Branches distribution" )).isEqualTo(Boolean.FALSE); } - @Test - public void testDecisionTableDefaultValue() { + @ParameterizedTest + @MethodSource("params") + void decisionTableDefaultValue(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "decisiontable-default-value.dmn", this.getClass() ); final DMNRuntimeEventListener listener = Mockito.mock( DMNRuntimeEventListener.class ); runtime.addListener( listener ); @@ -236,8 +252,10 @@ public void testDecisionTableDefaultValue() { assertThat( captor.getValue().getSelected()).isEmpty(); } - @Test - public void testTwoDecisionTables() { + @ParameterizedTest + @MethodSource("params") + void twoDecisionTables(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "two_decision_tables.dmn", this.getClass() ); final DMNRuntimeEventListener listener = Mockito.mock( DMNRuntimeEventListener.class ); runtime.addListener( listener ); @@ -263,8 +281,10 @@ public void testTwoDecisionTables() { assertThat( captor.getAllValues().get( 1 ).getDecisionTableName()).isEqualTo("b" ); } - @Test - public void testDTInputExpressionLocalXmlnsInference() { + @ParameterizedTest + @MethodSource("params") + void dTInputExpressionLocalXmlnsInference(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("drools1502-InputExpression.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://www.drools.org/kie-dmn/definitions", @@ -282,8 +302,10 @@ public void testDTInputExpressionLocalXmlnsInference() { assertThat( result.get( "MyDecision" )).isEqualTo("Decision taken" ); } - @Test - public void testDTInContext() { + @ParameterizedTest + @MethodSource("params") + void dTInContext(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DT_in_context.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_4acdcb25-b298-435e-abd5-efd00ed686a5", "Drawing 1" ); assertThat(dmnModel).isNotNull(); @@ -298,8 +320,10 @@ public void testDTInContext() { assertThat( ((Map) result.get( "D1" )).get( "Text color" )).isEqualTo("red" ); } - @Test - public void testDTUsingEqualsUnaryTestWithVariable1() { + @ParameterizedTest + @MethodSource("params") + void dTUsingEqualsUnaryTestWithVariable1(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DT_using_variables.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_ed1ec15b-40aa-424d-b1d0-4936df80b135", "DT Using variables" ); assertThat(dmnModel).isNotNull(); @@ -323,8 +347,10 @@ public void testDTUsingEqualsUnaryTestWithVariable1() { assertThat( result.get( "Compare String" )).isEqualTo("Same String" ); } - @Test - public void testDTUsingEqualsUnaryTestWithVariable2() { + @ParameterizedTest + @MethodSource("params") + void dTUsingEqualsUnaryTestWithVariable2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DT_using_variables.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_ed1ec15b-40aa-424d-b1d0-4936df80b135", "DT Using variables" ); assertThat(dmnModel).isNotNull(); @@ -348,8 +374,10 @@ public void testDTUsingEqualsUnaryTestWithVariable2() { assertThat( result.get( "Compare String" )).isEqualTo("Different String" ); } - @Test - public void testEmptyOutputCell() { + @ParameterizedTest + @MethodSource("params") + void emptyOutputCell(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "DT_empty_output_cell.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_77ae284e-ce52-4579-a50f-f3cc584d7f4b", "Calculation1" ); assertThat(dmnModel).isNotNull(); @@ -363,8 +391,10 @@ public void testEmptyOutputCell() { assertThat(dmnResult.getContext().get("Logique de décision 1")).isNull(); } - @Test - public void testNullRelation() { + @ParameterizedTest + @MethodSource("params") + void nullRelation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("nullrelation.dmn", getClass()); final DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_946a2145-89ae-4197-88b4-40e6f88c8101", "Null in relations"); assertThat(model).isNotNull(); @@ -375,8 +405,10 @@ public void testNullRelation() { assertThat(result.hasErrors()).as(DMNRuntimeUtil.formatMessages(result.getMessages())).isFalse(); } - @Test - public void testDecisionTableOutputDMNTypeCollection() { + @ParameterizedTest + @MethodSource("params") + void decisionTableOutputDMNTypeCollection(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2359 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionTableOutputDMNTypeCollection.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ae5d2033-c6d0-411f-a394-da33a70e5638", "Drawing 1"); @@ -393,8 +425,10 @@ public void testDecisionTableOutputDMNTypeCollection() { assertThat(result.get("a decision")).asList().containsExactly("abc", "xyz"); } - @Test - public void testDecisionTableOutputDMNTypeCollection_NOtypecheck() { + @ParameterizedTest + @MethodSource("params") + void decisionTableOutputDMNTypeCollectionNOtypecheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2359 // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieServices ks = KieServices.Factory.get(); @@ -415,8 +449,10 @@ public void testDecisionTableOutputDMNTypeCollection_NOtypecheck() { assertThat(result.get("a decision")).asList().containsExactly("abc", "xyz"); } - @Test - public void testDecisionTableOutputDMNTypeCollectionWithLOV() { + @ParameterizedTest + @MethodSource("params") + void decisionTableOutputDMNTypeCollectionWithLOV(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2359 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionTableOutputDMNTypeCollectionWithLOV.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ae5d2033-c6d0-411f-a394-da33a70e5638", "List of Words in DT"); @@ -433,8 +469,10 @@ public void testDecisionTableOutputDMNTypeCollectionWithLOV() { assertThat(result.get("a decision")).asList().containsExactly("abc", "a"); } - @Test - public void testDecisionTableOutputDMNTypeCollectionWithLOV_NOtypecheck() { + @ParameterizedTest + @MethodSource("params") + void decisionTableOutputDMNTypeCollectionWithLOVNOtypecheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2359 // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieServices ks = KieServices.Factory.get(); @@ -455,15 +493,19 @@ public void testDecisionTableOutputDMNTypeCollectionWithLOV_NOtypecheck() { assertThat(result.get("a decision")).asList().containsExactly("abc", "a"); } - @Test - public void testDecisionTablesQuestionMarkVariableCorrectEvaluation() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkVariableCorrectEvaluation(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmark.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkAsString() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkAsString(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkAsString.dmn", "NOT OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); @@ -475,99 +517,127 @@ public void testDecisionTablesQuestionMarkAsString() { DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkVariableVsQuestionMarkString() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkVariableVsQuestionMarkString(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkVsQmarkString.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkOnly() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkOnly(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkonly.dmn", null, DMNDecisionResult.DecisionEvaluationStatus.FAILED); } - @Test - public void testDecisionTablesQuestionMarkMultivalue() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkMultivalue(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkMultivalue.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkMultivalueWithBrackets() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkMultivalueWithBrackets(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkMultivalueWithBrackets.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkWithNot() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkWithNot(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkWithNot.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkWithContext() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkWithContext(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkWithContext.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkWithQuantifiedExpression() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkWithQuantifiedExpression(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkWithQuantifiedExpr.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkWithForExpression() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkWithForExpression(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkWithForExpr.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkWithFuncDef() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkWithFuncDef(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkWithFuncDef.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkInstanceOf() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkInstanceOf(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkInstanceOf.dmn", "NOT OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkInWithUnaryTests() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkInWithUnaryTests(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkInWithUnaryTest.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkWithRange() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkWithRange(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkWithRange.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkWithAnd() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkWithAnd(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkWithAnd.dmn", "OK", DMNDecisionResult.DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDecisionTablesQuestionMarkInNonBooleanFunction() { + @ParameterizedTest + @MethodSource("params") + void decisionTablesQuestionMarkInNonBooleanFunction(boolean useExecModelCompiler) { + init(useExecModelCompiler); testDecisionTablesQuestionMarkVariable("questionmarkunarytest/qmarkInNonBooleanFunction.dmn", null, DMNDecisionResult.DecisionEvaluationStatus.FAILED); @@ -587,8 +657,10 @@ private void testDecisionTablesQuestionMarkVariable(final String dmnResourcePath assertThat(result.getResult()).isEqualTo(expectedResult); } - @Test - public void testDecisionTableOutputMessageRowIndex() { + @ParameterizedTest + @MethodSource("params") + void decisionTableOutputMessageRowIndex(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-5606 DMN wrong rule index in message when not conforming final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionTableOutputMessageRowIndex.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_D7A4B999-3178-4929-834F-8979E3C5000F", "DecisionTableOutputMessageRowIndex"); @@ -606,8 +678,10 @@ public void testDecisionTableOutputMessageRowIndex() { assertThat(msg0.getText()).containsIgnoringCase("Invalid result value on rule #1, output #1."); // there is only 1 row, 1 output column } - @Test - public void testDTand() { + @ParameterizedTest + @MethodSource("params") + void dTand(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DTand.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_6697FFDC-B3D9-4B0B-BC07-AE5E5AC96CB4", "DTand"); assertThat(dmnModel).isNotNull(); @@ -621,8 +695,10 @@ public void testDTand() { assertThat(dmnResult.getDecisionResultByName("out1").getResult()).isEqualTo("PASS"); } - @Test - public void testQMarkAndNullShouldNotThrowNPEs() { + @ParameterizedTest + @MethodSource("params") + void qMarkAndNullShouldNotThrowNPEs(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("questionmarkunarytest/qmarkMatches.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_D1CF8332-8443-41C8-B214-D282B82C7632", "qmarkMatches"); assertThat(dmnModel).isNotNull(); @@ -654,8 +730,10 @@ public DMNMessage addMessage(Severity severity, String message, DMNMessageType m assertThat(feelNPEs).as("while it's okay to have error-ed on evaluation of FEEL, there should not be any sort of NPEs when reporting the human friendly message").isEmpty(); } - @Test - public void testDTCollectOperatorsMultipleOutputs() { + @ParameterizedTest + @MethodSource("params") + void dTCollectOperatorsMultipleOutputs(boolean useExecModelCompiler) { + init(useExecModelCompiler); checkDTCollectOperatorsMultipleOutputs(BuiltinAggregator.SUM, 100, 111, 18); checkDTCollectOperatorsMultipleOutputs(BuiltinAggregator.COUNT, 10, 2, 2); checkDTCollectOperatorsMultipleOutputs(BuiltinAggregator.MIN, 100, 1, 3); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNDecisionTableWithSymbolsTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNDecisionTableWithSymbolsTest.java index faac733058e..902cbd3454a 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNDecisionTableWithSymbolsTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNDecisionTableWithSymbolsTest.java @@ -18,7 +18,8 @@ */ package org.kie.dmn.core; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -30,12 +31,10 @@ public class DMNDecisionTableWithSymbolsTest extends BaseInterpretedVsCompiledTest { - public DMNDecisionTableWithSymbolsTest(final boolean useExecModelCompiler ) { - super( useExecModelCompiler ); - } - - @Test - public void testDecisionWithArgumentsOnOutput() { + @ParameterizedTest + @MethodSource("params") + void decisionWithArgumentsOnOutput(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Decide with symbols.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_79b16a68-013b-484c-98f5-49ff77808800", "Decide with symbols"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java index b9bfcf98d95..4feaac9d57a 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java @@ -24,7 +24,9 @@ import java.util.List; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNDecisionResult; import org.kie.dmn.api.core.DMNMessage; @@ -46,12 +48,10 @@ public class DMNInputRuntimeTest extends BaseInterpretedVsCompiledTest { - public DMNInputRuntimeTest(final boolean useExecModelCompiler ) { - super( useExecModelCompiler ); - } - - @Test - public void testInputStringEvaluateAll() { + @ParameterizedTest + @MethodSource("params") + void inputStringEvaluateAll(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -69,8 +69,10 @@ public void testInputStringEvaluateAll() { assertThat( result.get( "Greeting Message" )).isEqualTo("Hello John Doe" ); } - @Test - public void testInputStringEvaluateDecisionByName() { + @ParameterizedTest + @MethodSource("params") + void inputStringEvaluateDecisionByName(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -100,8 +102,10 @@ public void testInputStringEvaluateDecisionByName() { assertThat( dmnResult.getDecisionResultByName( "Greeting Message" ).getEvaluationStatus()).isEqualTo(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED ); } - @Test - public void testInputStringEvaluateDecisionById() { + @ParameterizedTest + @MethodSource("params") + void inputStringEvaluateDecisionById(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -131,8 +135,10 @@ public void testInputStringEvaluateDecisionById() { assertThat( dmnResult.getDecisionResultByName( "Greeting Message" ).getEvaluationStatus()).isEqualTo(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED ); } - @Test - public void testInputStringAllowedValuesEvaluateAll() { + @ParameterizedTest + @MethodSource("params") + void inputStringAllowedValuesEvaluateAll(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0003-input-data-string-allowed-values.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", "0003-input-data-string-allowed-values" ); assertThat(dmnModel).isNotNull(); @@ -147,13 +153,17 @@ public void testInputStringAllowedValuesEvaluateAll() { assertThat( result.get( "Employment Status Statement" )).isEqualTo("You are SELF-EMPLOYED" ); } - @Test - public void testInputStringNotInTypeScopeEvaluateAll() { + @ParameterizedTest + @MethodSource("params") + void inputStringNotInTypeScopeEvaluateAll(boolean useExecModelCompiler) { + init(useExecModelCompiler); testInputStringNotAllowedValuesEvaluateAll("NOT-ALLOWED-VALUE"); } - @Test - public void testInputStringWrongTypeEvaluateAll() { + @ParameterizedTest + @MethodSource("params") + void inputStringWrongTypeEvaluateAll(boolean useExecModelCompiler) { + init(useExecModelCompiler); testInputStringNotAllowedValuesEvaluateAll(new Object()); } @@ -175,15 +185,19 @@ private void testInputStringNotAllowedValuesEvaluateAll(final Object inputValue) assertThat(dmnResult.getDecisionResults().get(0).getMessages().get(0).getSeverity()).isEqualTo(DMNMessage.Severity.ERROR); } - @Test - public void testInputNumberEvaluateAll() { + @ParameterizedTest + @MethodSource("params") + void inputNumberEvaluateAll(boolean useExecModelCompiler) { + init(useExecModelCompiler); inputNumberEvaluateAll( "0002-input-data-number.dmn", "0002-input-data-number"); } - @Test - public void testInputNumberEvaluateAllDMNWithScientificNotation() { + @ParameterizedTest + @MethodSource("params") + void inputNumberEvaluateAllDMNWithScientificNotation(boolean useExecModelCompiler) { + init(useExecModelCompiler); inputNumberEvaluateAll( "0002-input-data-number-scientific-notation.dmn", "0002-input-data-number-scientific-notation"); @@ -206,8 +220,10 @@ private void inputNumberEvaluateAll(final String testDMNFileName, final String m assertThat((BigDecimal) resultValue).usingComparator(BigDecimal::compareTo).isEqualTo(new BigDecimal(12000)); } - @Test - public void testGetRequiredInputsByName() { + @ParameterizedTest + @MethodSource("params") + void getRequiredInputsByName(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -221,8 +237,10 @@ public void testGetRequiredInputsByName() { assertThat( inputs).hasSize(0); } - @Test - public void testGetRequiredInputsById() { + @ParameterizedTest + @MethodSource("params") + void getRequiredInputsById(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -236,8 +254,10 @@ public void testGetRequiredInputsById() { assertThat( inputs).hasSize(0); } - @Test - public void testNonexistantInputNodeName() { + @ParameterizedTest + @MethodSource("params") + void nonexistantInputNodeName(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -255,8 +275,10 @@ public void testNonexistantInputNodeName() { assertThat( dmnResult.getDecisionResults().get(0).getMessages().get(0).getSeverity()).isEqualTo(DMNMessage.Severity.ERROR); } - @Test - public void testAllowedValuesChecksInsideCollectionElement() { + @ParameterizedTest + @MethodSource("params") + void allowedValuesChecksInsideCollectionElement(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "AllowedValuesChecks.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b-504f3e77b442", @@ -289,8 +311,10 @@ public void testAllowedValuesChecksInsideCollectionElement() { assertThat(dmnResult4.getMessages().stream().anyMatch(m -> m.getMessageType().equals(DMNMessageType.ERROR_EVAL_NODE))).isTrue(); } - @Test - public void testAllowedValuesChecksInsideCollection() { + @ParameterizedTest + @MethodSource("params") + void allowedValuesChecksInsideCollection(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b-504f3e77b442", @@ -323,8 +347,10 @@ public void testAllowedValuesChecksInsideCollection() { assertThat(dmnResult4.getMessages().stream().anyMatch(m -> m.getMessageType().equals(DMNMessageType.ERROR_EVAL_NODE))).isTrue(); } - @Test - public void testTypeConstraintsChecks() { + @ParameterizedTest + @MethodSource("params") + void typeConstraintsChecks(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("valid_models/DMNv1_5/TypeConstraintsChecks.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b-504f3e77b442", @@ -351,8 +377,10 @@ public void testTypeConstraintsChecks() { assertThat(dmnResult3.getMessages().stream().anyMatch(m -> m.getMessageType().equals(DMNMessageType.ERROR_EVAL_NODE))).isTrue(); } - @Test - public void testDMNInputDataNodeTypeTest() { + @ParameterizedTest + @MethodSource("params") + void dmnInputDataNodeTypeTest(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1569 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DMNInputDataNodeTypeTest.dmn", this.getClass()); final String MODEL_NAMESPACE = "http://www.trisotech.com/definitions/_17396034-163a-48aa-9a7f-c6eb17f9cc6c"; @@ -392,8 +420,10 @@ public void testDMNInputDataNodeTypeTest() { assertThat(idnCarDamageResponsibility.getType().isComposite()).isTrue(); } - @Test - public void testInputClauseTypeRefWithAllowedValues() { + @ParameterizedTest + @MethodSource("params") + void inputClauseTypeRefWithAllowedValues(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("actualInputMatchInputValues-forTypeRef.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn/definitions", "definitions"); assertThat(dmnModel).isNotNull(); @@ -409,8 +439,10 @@ public void testInputClauseTypeRefWithAllowedValues() { assertThat(result.get("MyDecision")).isEqualTo("Decision taken"); } - @Test - public void testInputDataTypeRefWithAllowedValues() { + @ParameterizedTest + @MethodSource("params") + void inputDataTypeRefWithAllowedValues(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("actualInputMatchInputValues-forTypeRef.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn/definitions", "definitions"); assertThat(dmnModel).isNotNull(); @@ -425,15 +457,19 @@ public void testInputDataTypeRefWithAllowedValues() { assertThat(dmnResult.getMessages().get(0).getSourceId()).isEqualTo("_3d560678-a126-4654-a686-bc6d941fe40b"); } - @Test - public void testMissingInputData() { + @ParameterizedTest + @MethodSource("params") + void missingInputData(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("missing_input_data.dmn", getClass()); assertThat(messages.get(0).getMessageType()).isEqualTo(DMNMessageType.ERR_COMPILING_FEEL); } - - - @Test - public void testOrdering() { + + + @ParameterizedTest + @MethodSource("params") + void ordering(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Order.dmn", this.getClass()); final DMNModel dmnModel = runtime .getModel("http://www.trisotech.com/definitions/_6318588b-c32f-4070-848b-bd8017e6b94e", "Drawing 1"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNMessagesAPITest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNMessagesAPITest.java index 7900c830c0b..5f8bd501619 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNMessagesAPITest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNMessagesAPITest.java @@ -22,7 +22,7 @@ import java.util.UUID; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -38,13 +38,14 @@ import org.slf4j.LoggerFactory; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; public class DMNMessagesAPITest { public static final Logger LOG = LoggerFactory.getLogger(DMNMessagesAPITest.class); @Test - public void testAPIUsage() { + void apiUsage() { // DROOLS-3335 Broken DMN resource should inhibit KJAR and report KieBuilder message final KieServices ks = KieServices.Factory.get(); final KieContainer kieContainer = DMNRuntimeUtil.getKieContainerIgnoringErrors(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"), @@ -69,21 +70,23 @@ public void testAPIUsage() { assertThat(dmnMessage.getPath()).isEqualTo("incomplete_expression.dmn"); } - @Test(expected = IllegalStateException.class) - public void testAPIUsageSnippetForDocumentation() { - KieServices ks = KieServices.Factory.get(); - - ReleaseId releaseId = ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"); - Resource dmnResource = ks.getResources().newClassPathResource("incomplete_expression.dmn", this.getClass()); - - KieFileSystem kfs = ks.newKieFileSystem() - .generateAndWritePomXML(releaseId) - .write(dmnResource); - KieBuilder kieBuilder = ks.newKieBuilder(kfs) - .buildAll(); - Results results = kieBuilder.getResults(); - if (results.hasMessages(Message.Level.ERROR)) { - throw new IllegalStateException(results.getMessages(Message.Level.ERROR).toString()); - } + @Test + void apiUsageSnippetForDocumentation() { + assertThrows(IllegalStateException.class, () -> { + KieServices ks = KieServices.Factory.get(); + + ReleaseId releaseId = ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"); + Resource dmnResource = ks.getResources().newClassPathResource("incomplete_expression.dmn", this.getClass()); + + KieFileSystem kfs = ks.newKieFileSystem() + .generateAndWritePomXML(releaseId) + .write(dmnResource); + KieBuilder kieBuilder = ks.newKieBuilder(kfs) + .buildAll(); + Results results = kieBuilder.getResults(); + if (results.hasMessages(Message.Level.ERROR)) { + throw new IllegalStateException(results.getMessages(Message.Level.ERROR).toString()); + } + }); } } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNRuntimeTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNRuntimeTest.java index 4ea5f5acc85..990c6bc1584 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNRuntimeTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNRuntimeTest.java @@ -37,10 +37,14 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; import org.kie.dmn.api.core.DMNContext; @@ -81,6 +85,7 @@ import org.slf4j.LoggerFactory; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.kie.dmn.core.util.DMNTestUtil.getAndAssertModelNoErrors; import static org.kie.dmn.core.util.DynamicTypeUtils.entry; import static org.kie.dmn.core.util.DynamicTypeUtils.mapOf; @@ -92,14 +97,12 @@ public class DMNRuntimeTest extends BaseInterpretedVsCompiledTest { - public DMNRuntimeTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - public static final Logger LOG = LoggerFactory.getLogger(DMNRuntimeTest.class); - @Test - public void testSimpleItemDefinition() { + @ParameterizedTest + @MethodSource("params") + void simpleItemDefinition(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item-def" ); assertThat(dmnModel).isNotNull(); @@ -116,8 +119,10 @@ public void testSimpleItemDefinition() { assertThat( result.get( "Yearly Salary" )).isEqualTo(new BigDecimal( "12000" ) ); } - @Test - public void testCompositeItemDefinition() { + @ParameterizedTest + @MethodSource("params") + void compositeItemDefinition(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0008-LX-arithmetic.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0008-LX-arithmetic" ); assertThat(dmnModel).isNotNull(); @@ -136,8 +141,10 @@ public void testCompositeItemDefinition() { assertThat( result.get( "payment" )).isEqualTo(new BigDecimal( "2778.693549432766768088520383236299" ) ); } - @Test - public void testTrisotechNamespace() { + @ParameterizedTest + @MethodSource("params") + void trisotechNamespace(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("trisotech_namespace.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_b8feec86-dadf-4051-9feb-8e6093bbb530", "Solution 3" ); assertThat(dmnModel).isNotNull(); @@ -155,8 +162,10 @@ public void testTrisotechNamespace() { assertThat( result.get( "Ship can enter a Dutch port" )).isEqualTo(Boolean.TRUE); } - @Test - public void testEmptyDecision1() { + @ParameterizedTest + @MethodSource("params") + void emptyDecision1(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("empty_decision.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ba9fc4b1-5ced-4d00-9b61-290de4bf3213", "Solution 3" ); assertThat(dmnModel).isNotNull(); @@ -176,8 +185,10 @@ public void testEmptyDecision1() { assertThat( result.get( "Ship Can Enter v2" )).isEqualTo(Boolean.TRUE); } - @Test - public void testEmptyDecision2() { + @ParameterizedTest + @MethodSource("params") + void emptyDecision2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("empty_decision.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ba9fc4b1-5ced-4d00-9b61-290de4bf3213", "Solution 3" ); assertThat(dmnModel).isNotNull(); @@ -205,8 +216,10 @@ public void testEmptyDecision2() { assertThat( result.get( "Ship Can Enter v2" )).isEqualTo(Boolean.TRUE); } - @Test - public void testEventListeners() { + @ParameterizedTest + @MethodSource("params") + void eventListeners(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("car_damage_responsibility.dmn", this.getClass() ); final DMNRuntimeEventListener listener = mock(DMNRuntimeEventListener.class ); @@ -249,8 +262,10 @@ public void testEventListeners() { assertThat(result.get( "Payment method")).isEqualTo("Check"); } - @Test - public void testContextEventListeners() { + @ParameterizedTest + @MethodSource("params") + void contextEventListeners(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("context_listener.dmn", this.getClass() ); final DMNRuntimeEventListener listener = mock(DMNRuntimeEventListener.class ); @@ -316,14 +331,18 @@ public void testContextEventListeners() { assertThat( result.get( "d1" )).isEqualTo("a"); } - @Test - public void testErrorMessages() { + @ParameterizedTest + @MethodSource("params") + void errorMessages(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("car_damage_responsibility2.dmn", this.getClass()); assertThat(messages).isNotEmpty(); } - @Test - public void testOutputReuse() { + @ParameterizedTest + @MethodSource("params") + void outputReuse(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Input_reuse_in_output.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_098bb607-eff7-4772-83ac-6ded8b371fa7", "Input reuse in output" ); assertThat(dmnModel).isNotNull(); @@ -339,8 +358,10 @@ public void testOutputReuse() { assertThat( result.get( "My Decision" )).isEqualTo("Fixed30"); } - @Test - public void testSimpleNot() { + @ParameterizedTest + @MethodSource("params") + void simpleNot(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Simple_Not.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_98436ebb-7c42-48c0-8d11-d693e2a817c9", "Simple Not" ); assertThat(dmnModel).isNotNull(); @@ -355,8 +376,10 @@ public void testSimpleNot() { assertThat( result.get( "a" )).isEqualTo("Is Student" ); } - @Test - public void testSimpleNot2() { + @ParameterizedTest + @MethodSource("params") + void simpleNot2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Simple_Not.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_98436ebb-7c42-48c0-8d11-d693e2a817c9", "Simple Not" ); assertThat(dmnModel).isNotNull(); @@ -371,8 +394,10 @@ public void testSimpleNot2() { assertThat( result.get( "a" )).isEqualTo("Is not a Student" ); } - @Test - public void testDinner() { + @ParameterizedTest + @MethodSource("params") + void dinner(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Dinner.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_0c45df24-0d57-4acc-b296-b4cba8b71a36", "Dinner" ); assertThat(dmnModel).isNotNull(); @@ -392,8 +417,10 @@ public void testDinner() { assertThat( dmnResult.getContext().get("Drinks")).asList().containsExactly("Apero", "Ale", "Juice Boxes"); } - @Test - public void testNotificationsApproved2() { + @ParameterizedTest + @MethodSource("params") + void notificationsApproved2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("NotificationsTest2.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "building-structure-rules" ); assertThat(dmnModel).isNotNull(); @@ -409,8 +436,10 @@ public void testNotificationsApproved2() { assertThat( result.get( "Permit Status" )).isEqualTo("Building Activity Province Permit Required" ); } - @Test - public void testBoxedContext() { + @ParameterizedTest + @MethodSource("params") + void boxedContext(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("BoxedContext.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_0de36357-fec0-4b4e-b7f1-382d381e06e9", "Dessin 1" ); assertThat(dmnModel).isNotNull(); @@ -426,8 +455,10 @@ public void testBoxedContext() { assertThat( (Map) dmnResult.getContext().get( "Math" )).containsEntry( "Product", BigDecimal.valueOf( 50 )); } - @Test - public void testFunctionDefAndInvocation() { + @ParameterizedTest + @MethodSource("params") + void functionDefAndInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("FunctionDefinition.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_0de36357-fec0-4b4e-b7f1-382d381e06e9", "Dessin 1" ); assertThat(dmnModel).isNotNull(); @@ -442,8 +473,10 @@ public void testFunctionDefAndInvocation() { assertThat((Map) dmnResult.getContext().get("Math")).containsEntry("Sum", BigDecimal.valueOf(15)); } - @Test - public void testBuiltInFunctionInvocation() { + @ParameterizedTest + @MethodSource("params") + void builtInFunctionInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("BuiltInFunctionInvocation.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b77219ee-ec28-48e3-b240-8e0dbbabefeb", "built in function invocation" ); assertThat(dmnModel).isNotNull(); @@ -461,8 +494,10 @@ public void testBuiltInFunctionInvocation() { assertThat( dmnResult.getContext().get( "out of order" )).isEqualTo(BigDecimal.valueOf( 5 ) ); } - @Test - public void testBKMNode() { + @ParameterizedTest + @MethodSource("params") + void bkmNode(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0009-invocation-arithmetic.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -485,8 +520,10 @@ public void testBKMNode() { isEqualTo(new BigDecimal("2878.69354943277").setScale(8, BigDecimal.ROUND_DOWN)); } - @Test - public void testItemDefCollection() { + @ParameterizedTest + @MethodSource("params") + void itemDefCollection(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-filter.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -515,8 +552,10 @@ public void testItemDefCollection() { assertThat( dmnResult.getContext().get( "filter01" )).asList().containsExactly("Mary"); } - @Test - public void testList() { + @ParameterizedTest + @MethodSource("params") + void list(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("list-expression.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -530,8 +569,10 @@ public void testList() { assertThat( dmnResult.getContext().get( "Name list" )).asList().containsExactly("John", "Mary"); } - @Test - public void testRelation() { + @ParameterizedTest + @MethodSource("params") + void relation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("relation-expression.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -556,8 +597,10 @@ public void testRelation() { assertThat( e.get( "Salary" )).isEqualTo(BigDecimal.valueOf( 120000 ) ); } - @Test - public void testLendingExample() { + @ParameterizedTest + @MethodSource("params") + void lendingExample(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-lending.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -605,8 +648,10 @@ public void testLendingExample() { assertThat(ctx.get("Routing" )).isEqualTo("ACCEPT"); } - @Test - public void testDateAndTime() { + @ParameterizedTest + @MethodSource("params") + void dateAndTime(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0007-date-time.dmn", getClass() ); runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -659,8 +704,10 @@ public void testDateAndTime() { } - @Test - public void testDateToDateTimeFunction() { + @ParameterizedTest + @MethodSource("params") + void dateToDateTimeFunction(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("valid_models/DMNv1_5/DateToDateTimeFunction.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_A7F17D7B-F0AB-4C0B-B521-02EA26C2FBEE", "new-file"); @@ -677,8 +724,10 @@ public void testDateToDateTimeFunction() { assertThat(dmnResult.getDecisionResultByName("usingNormal").getResult()).isEqualTo(expected); } - @Test - public void testFiltering() { + @ParameterizedTest + @MethodSource("params") + void filtering(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Person_filtering_by_age.dmn", getClass() ); runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -692,8 +741,10 @@ public void testFiltering() { assertThat(((List)dmnResult.getContext().get("Filtering"))).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).hasSize(2); } - @Test - public void testNowFunction() { + @ParameterizedTest + @MethodSource("params") + void nowFunction(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("today_function_test.dmn", getClass() ); runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -707,8 +758,10 @@ public void testNowFunction() { assertThat(dmnResult.getContext().get("When is it")).as(DMNRuntimeUtil.formatMessages( dmnResult.getMessages())).isEqualTo("It is in the past"); } - @Test - public void testTimeFunction() { + @ParameterizedTest + @MethodSource("params") + void timeFunction(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("TimeFromDate.dmn", getClass() ); runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -722,8 +775,10 @@ public void testTimeFunction() { assertThat(dmnResult.getContext().get("time")).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isEqualTo(LocalTime.of(5, 48, 23)); } - @Test - public void testAlternativeNSDecl() { + @ParameterizedTest + @MethodSource("params") + void alternativeNSDecl(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("alternative_feel_ns_declaration.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -741,8 +796,10 @@ public void testAlternativeNSDecl() { assertThat( result.get( "Greeting Message" )).isEqualTo("Hello John Doe" ); } - @Test - public void testLoanComparison() { + @ParameterizedTest + @MethodSource("params") + void loanComparison(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("loanComparison.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_3a1fd8f4-ea04-4453-aa30-ff14140e3441", "loanComparison" ); assertThat(dmnModel).isNotNull(); @@ -755,8 +812,10 @@ public void testLoanComparison() { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isFalse(); } - @Test - public void testGetViableLoanProducts() { + @ParameterizedTest + @MethodSource("params") + void getViableLoanProducts(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Get_Viable_Loan_Products.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_3e1a628d-36bc-45f1-8464-b201735e5ce0", "Get Viable Loan Products" ); assertThat(dmnModel).isNotNull(); @@ -779,8 +838,10 @@ public void testGetViableLoanProducts() { assertThat( (Collection) result.get( "LoanTypes" )).hasSize(3); } - @Test - public void testYearsAndMonthsDuration() { + @ParameterizedTest + @MethodSource("params") + void yearsAndMonthsDuration(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("yearMonthDuration.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_6eda1490-21ca-441e-8a26-ab3ca800e43c", "Drawing 1" ); assertThat(dmnModel).isNotNull(); @@ -799,14 +860,18 @@ public void testYearsAndMonthsDuration() { assertThat( result.get( "How long" )).isEqualTo("Longer than a year" ); } - @Test - public void testInvalidVariableNames() { + @ParameterizedTest + @MethodSource("params") + void invalidVariableNames(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("invalid-variable-names.dmn", this.getClass()); assertThat(messages).isNotEmpty(); } - @Test - public void testNull() { + @ParameterizedTest + @MethodSource("params") + void testNull(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("null_values.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "Null values model" ); assertThat(dmnModel).isNotNull(); @@ -830,8 +895,10 @@ public void testNull() { } - @Test - public void testInvalidUHitPolicy() { + @ParameterizedTest + @MethodSource("params") + void invalidUHitPolicy(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Invalid_U_hit_policy.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_7cf49108-9b55-4f35-b5ef-f83448061757", "Greater than 5 - Invalid U hit policy" ); assertThat(dmnModel).isNotNull(); @@ -847,16 +914,20 @@ public void testInvalidUHitPolicy() { assertThat( dmnResult.getMessages().get( 1 ).getSourceId()).isEqualTo("_5bac3e4c-b59a-4f14-b5cf-d4d88c60877f" ); } - @Test - public void testInvalidModel() { + @ParameterizedTest + @MethodSource("params") + void invalidModel(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("Loan_Prequalification_Condensed_Invalid.dmn", this.getClass()); assertThat(messages).hasSize(2); assertThat(messages.get(0).getSourceId()).isEqualTo("_8b5cac9e-c8ca-4817-b05a-c70fa79a8d48"); assertThat(messages.get(1).getSourceId()).isEqualTo("_ef09d90e-e1a4-4ec9-885b-482d1f4a1cee"); } - @Test - public void testNullOnNumber() { + @ParameterizedTest + @MethodSource("params") + void nullOnNumber(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Number_and_null_entry.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_a293b9f9-c912-41ee-8147-eae59ba86ac5", "Number and null entry" ); assertThat(dmnModel).isNotNull(); @@ -880,8 +951,10 @@ public void testNullOnNumber() { assertThat( result.get( "Decision Logic 1" )).isEqualTo("Positive number" ); } - @Test - public void testLoan_Recommendation2() { + @ParameterizedTest + @MethodSource("params") + void loanRecommendation2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Loan_Recommendation2.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_35c7339b-b868-43da-8f06-eb481708c73c", "Loan Recommendation2" ); assertThat(dmnModel).isNotNull(); @@ -912,9 +985,11 @@ public void testLoan_Recommendation2() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "Loan Recommendation" )).isEqualTo("Decline"); } - - @Test - public void testPriority_table() { + + @ParameterizedTest + @MethodSource("params") + void priorityTable(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("priority_table.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_ff54a44d-b8f5-48fc-b2b7-43db767e8a1c", @@ -930,9 +1005,11 @@ public void testPriority_table() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "Approval Status" )).isEqualTo("Declined"); } - - @Test - public void testPriority_table_context_recursion() { + + @ParameterizedTest + @MethodSource("params") + void priorityTableContextRecursion(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("priority_table_context_recursion.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_ff54a44d-b8f5-48fc-b2b7-43db767e8a1c", @@ -948,15 +1025,19 @@ public void testPriority_table_context_recursion() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "Approval Status" )).isEqualTo("Declined"); } - - @Test - public void testPriority_table_missing_output_values() { + + @ParameterizedTest + @MethodSource("params") + void priorityTableMissingOutputValues(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("DTABLE_PRIORITY_MISSING_OUTVALS.dmn", this.getClass()); assertThat(messages).hasSize(1); } - @Test - public void test_non_Priority_table_missing_output_values() { + @ParameterizedTest + @MethodSource("params") + void non_priority_table_missing_output_values(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DTABLE_NON_PRIORITY_MISSING_OUTVALS.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", @@ -965,8 +1046,10 @@ public void test_non_Priority_table_missing_output_values() { assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); } - @Test - public void testPriority_table_one_output_value() { + @ParameterizedTest + @MethodSource("params") + void priorityTableOneOutputValue(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DTABLE_PRIORITY_ONE_OUTVAL.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", @@ -974,9 +1057,11 @@ public void testPriority_table_one_output_value() { assertThat(dmnModel).isNotNull(); assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); } - - @Test - public void testNoPrefix() { + + @ParameterizedTest + @MethodSource("params") + void noPrefix(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("drools1502-noprefix.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://www.drools.org/kie-dmn/definitions", @@ -993,9 +1078,11 @@ public void testNoPrefix() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "MyDecision" )).isEqualTo("Decision taken" ); } - - @Test - public void testWrongConstraintsInItemDefinition() { + + @ParameterizedTest + @MethodSource("params") + void wrongConstraintsInItemDefinition(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1503 final List messages = DMNRuntimeUtil.createExpectingDMNMessages("WrongConstraintsInItemDefinition.dmn", this.getClass()); assertThat(messages).as(DMNRuntimeUtil.formatMessages(messages)).hasSize(3); @@ -1008,9 +1095,11 @@ public void testWrongConstraintsInItemDefinition() { assertThat(messages.get(2).getSourceId()).isEqualTo("_31911de7-e184-411c-99d1-f33977971270"); assertThat(messages.get(2).getMessageType()).isEqualTo(DMNMessageType.MISSING_TYPE_REF); } - - @Test - public void testResolutionOfVariableWithLeadingOrTrailingSpaces() { + + @ParameterizedTest + @MethodSource("params") + void resolutionOfVariableWithLeadingOrTrailingSpaces(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1504 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("variableLeadingTrailingSpaces.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1032,8 +1121,10 @@ public void testResolutionOfVariableWithLeadingOrTrailingSpaces() { assertThat( result.get( "Further Decision" )).isEqualTo( "The person was greeted with: 'Ciao John Doe'"); } - @Test - public void testOutOfOrderItemsNPE() { + @ParameterizedTest + @MethodSource("params") + void outOfOrderItemsNPE(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("out-of-order-items.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", @@ -1042,9 +1133,11 @@ public void testOutOfOrderItemsNPE() { assertThat(dmnModel.getMessages().stream().anyMatch( m -> m.getMessageType().equals( DMNMessageType.FAILED_VALIDATOR))) .as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); } - - @Test - public void testItemDefDependencies() { + + @ParameterizedTest + @MethodSource("params") + void itemDefDependencies(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1505 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("itemDef-dependency.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1065,9 +1158,11 @@ public void testItemDefDependencies() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "My Decision" )).isEqualTo("The person John Doe is located at 100 East Davie Street" ); } - - @Test - public void testDecisionResultTypeCheck() { + + @ParameterizedTest + @MethodSource("params") + void decisionResultTypeCheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1513 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("LoanRecommendationWrongOutputType.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1091,8 +1186,10 @@ public void testDecisionResultTypeCheck() { assertThat( dmnResult.getMessages().get( 0 ).getMessageType()).isEqualTo(DMNMessageType.ERROR_EVAL_NODE); } - @Test - public void testNPE() { + @ParameterizedTest + @MethodSource("params") + void npe(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1512 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("NPE.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1107,9 +1204,11 @@ public void testNPE() { assertThat(dmnResult.hasErrors()).as(dmnResult.getMessages().toString()).isTrue(); assertThat(dmnResult.getMessages().stream().anyMatch( m -> m.getMessageType().equals( DMNMessageType.REQ_NOT_FOUND))).isTrue(); } - - @Test - public void testUnionofLetters() { + + @ParameterizedTest + @MethodSource("params") + void unionofLetters(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Union_of_letters.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_76362694-41e8-400c-8dea-e5f033d4f405", @@ -1132,23 +1231,29 @@ public void testUnionofLetters() { assertThat(dmnResult2.getMessages().stream().anyMatch(m -> m.getMessageType().equals(DMNMessageType.ERROR_EVAL_NODE))).isTrue(); } - @Test - public void testUnknownVariable1() { + @ParameterizedTest + @MethodSource("params") + void unknownVariable1(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("unknown_variable1.dmn", this.getClass()); assertThat(messages.stream().filter(m -> m.getMessageType().equals(DMNMessageType.ERR_COMPILING_FEEL)) .filter(m -> m.getMessage().contains("Unknown variable 'NonSalaryPct'")) .count()).isEqualTo(1); } - @Test - public void testUnknownVariable2() { + @ParameterizedTest + @MethodSource("params") + void unknownVariable2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("unknown_variable2.dmn", this.getClass()); assertThat(messages.get(0).getMessageType()).isEqualTo(DMNMessageType.ERR_COMPILING_FEEL); assertThat(messages.get(0).getMessage()).containsSequence("Unknown variable 'Borrower.liquidAssetsAmt'"); } - @Test - public void testSingleDecisionWithContext() { + @ParameterizedTest + @MethodSource("params") + void singleDecisionWithContext(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("SingleDecisionWithContext.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_71af58db-e1df-4b0f-aee2-48e0e8d89672", @@ -1164,8 +1269,10 @@ public void testSingleDecisionWithContext() { assertThat( result.get( "MyDecision" )).isEqualTo("Hello John Doe" ); } - @Test - public void testEx_6_1() { + @ParameterizedTest + @MethodSource("params") + void ex61(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Ex_6_1.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_5f1269c8-1e6f-4748-9eca-26aa1b1278ef", @@ -1199,9 +1306,11 @@ public void testEx_6_1() { assertThat( result.get( "Number of teams" )).isEqualTo(new BigDecimal(2) ); assertThat( result.get( "Sum of bonus points" )).isEqualTo(new BigDecimal(47) ); } - - @Test - public void testSingletonlist_function_call() { + + @ParameterizedTest + @MethodSource("params") + void singletonlistFunctionCall(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("singletonlist_fuction_call.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_0768879b-5ee1-410f-92f0-7732573b069d", @@ -1228,8 +1337,10 @@ public void testSingletonlist_function_call() { ); } - @Test - public void testJavaFunctionContext() { + @ParameterizedTest + @MethodSource("params") + void javaFunctionContext(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("java_function_context.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/dmn/definitions/_b42317c4-4f0c-474e-a0bf-2895b0b3c314", @@ -1246,9 +1357,11 @@ public void testJavaFunctionContext() { assertThat( ((BigDecimal) result.get( "D1" )).setScale( 4, BigDecimal.ROUND_HALF_UP )).isEqualTo(new BigDecimal( "-1.0000" ) ); assertThat( ((BigDecimal) result.get( "D2" )).setScale( 4, BigDecimal.ROUND_HALF_UP )).isEqualTo(new BigDecimal( "-1.0000" ) ); } - - @Test - public void testJavaFunctionContext_withErrors() { + + @ParameterizedTest + @MethodSource("params") + void javaFunctionContextWithErrors(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1568 final List messages = DMNRuntimeUtil.createExpectingDMNMessages("java_function_context_with_errors.dmn", this.getClass()); assertThat(messages).hasSize(1); @@ -1259,9 +1372,11 @@ public void testJavaFunctionContext_withErrors() { assertThat(sourceIDs).contains("_a72a7aff-48c3-4806-83ca-fc1f1fe34321"); assertThat(messages).anyMatch(m -> m.getText().contains("java.lang.Mathhh")); } - - @Test - public void testJavaFunctionContext_withErrorsInParamType() { + + @ParameterizedTest + @MethodSource("params") + void javaFunctionContextWithErrorsInParamType(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("java_function_context_with_errors_in_param_type.dmn", this.getClass()); assertThat(messages).hasSize(1); @@ -1270,8 +1385,10 @@ public void testJavaFunctionContext_withErrorsInParamType() { assertThat(messages).anyMatch(m -> m.getText().contains("max(int,int)") && m.getText().contains("max(long,long)")); } - @Test - public void testNestingFnDef() { + @ParameterizedTest + @MethodSource("params") + void nestingFnDef(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("nestingFnDef.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_FC72DC4B-DC64-4E43-9685-945FC3B7E4BC", "new-file"); @@ -1286,8 +1403,10 @@ public void testNestingFnDef() { assertThat(dmnResult.getDecisionResultByName("Decision-1").getResult()).isEqualTo(new BigDecimal(3)); } - @Test - public void testBkmCurried() { + @ParameterizedTest + @MethodSource("params") + void bkmCurried(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("bkmCurried.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_A7F17D7B-F0AB-4C0B-B521-02EA26C2FB7D", "new-file"); @@ -1303,8 +1422,10 @@ public void testBkmCurried() { assertThat(dmnResult.getDecisionResultByName("usingCurried").getResult()).isEqualTo(new BigDecimal(3)); } - @Test - public void testBkmWithDotsInName() { + @ParameterizedTest + @MethodSource("params") + void bkmWithDotsInName(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("bkmWithDotsInName.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_E035C5C5-3571-453D-BD8F-FFF30E74A7F8", "bkmWithDotsInName"); @@ -1321,9 +1442,11 @@ public void testBkmWithDotsInName() { assertThat(dmnResult.getDecisionResultByName("Total Sum").getResult()).isEqualTo(new BigDecimal(3)); } - @Ignore("the purpose of this work is to enable PMML execution.") - @Test - public void testPMMLFunctionContext() { + @Disabled("the purpose of this work is to enable PMML execution.") + @ParameterizedTest + @MethodSource("params") + void pmmlFunctionContext(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("pmml_function_context.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/dmn/definitions/_b42317c4-4f0c-474e-a0bf-2895b0b3c314", @@ -1334,9 +1457,11 @@ public void testPMMLFunctionContext() { assertThat( dmnModel.getMessages().get( 0 ).getMessageType()).isEqualTo(DMNMessageType.INVALID_ATTRIBUTE_VALUE); assertThat( dmnModel.getMessages().get( 0 ).getSeverity()).isEqualTo(DMNMessage.Severity.WARN); } - - @Test - public void test_countCSATradeRatings() { + + @ParameterizedTest + @MethodSource("params") + void count_csatrade_ratings(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1563 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("countCSATradeRatings.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1369,9 +1494,11 @@ public void test_countCSATradeRatings() { assertThat(dmnResult3.hasErrors()).as(DMNRuntimeUtil.formatMessages( dmnResult3.getMessages())).isTrue(); assertThat(dmnResult3.getMessages().stream().anyMatch( m -> m.getMessageType().equals( DMNMessageType.REQ_NOT_FOUND ) )).isTrue(); } - - @Test - public void testForLoopTypeCheck() { + + @ParameterizedTest + @MethodSource("params") + void forLoopTypeCheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1580 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("PersonListHelloBKM.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1393,9 +1520,11 @@ public void testForLoopTypeCheck() { assertThat( (List)result.get("My Decision")).asList().contains( "The person named John Doe is 33 years old.", "The person named 47 is 47 years old."); } - - @Test - public void testTypeInferenceForNestedContextAnonymousEntry() { + + @ParameterizedTest + @MethodSource("params") + void typeInferenceForNestedContextAnonymousEntry(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1585 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("PersonListHelloBKM2.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1418,8 +1547,10 @@ public void testTypeInferenceForNestedContextAnonymousEntry() { prototype( entry("Full Name", "Prof. 47"), entry("Age", EvalHelper.coerceNumber(47)))); } - @Test - public void testSameEveryTypeCheck() { + @ParameterizedTest + @MethodSource("params") + void sameEveryTypeCheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-1587 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("same_every_type_check.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1441,8 +1572,10 @@ public void testSameEveryTypeCheck() { assertThat( result.get("Every are negative")).isEqualTo(Boolean.FALSE); } - @Test - public void testDateAllowedValues() { + @ParameterizedTest + @MethodSource("params") + void dateAllowedValues(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("date_allowed_values.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_fbf002a3-615b-4f02-98e4-c28d4676225a", @@ -1462,9 +1595,11 @@ public void testDateAllowedValues() { assertThat((Map) result.get( "Decision Logic 1")).containsEntry("years and months", duration); assertThat((Map) result.get( "Decision Logic 1")).containsEntry("Date Time", dateTime); } - - @Test - public void testArtificialAttributes() { + + @ParameterizedTest + @MethodSource("params") + void artificialAttributes(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string-artificial-attributes.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools", "0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -1481,9 +1616,11 @@ public void testArtificialAttributes() { assertThat( result.get( "Greeting Message" )).isEqualTo("Hello John Doe" ); } - - @Test - public void testInvokeFunctionSuccess() { + + @ParameterizedTest + @MethodSource("params") + void invokeFunctionSuccess(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Caller.dmn", this.getClass(), "Calling.dmn" ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b0a696d6-3d57-4e97-b5d4-b44a63909d67", "Caller" ); assertThat(dmnModel).isNotNull(); @@ -1502,8 +1639,10 @@ public void testInvokeFunctionSuccess() { assertThat( result.get( "Final decision" )).isEqualTo( "The final decision is: Hello, John Doe your number once double is equal to: 6"); } - @Test - public void testInvokeFunctionWrongNamespace() { + @ParameterizedTest + @MethodSource("params") + void invokeFunctionWrongNamespace(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Caller.dmn", this.getClass(), "Calling.dmn" ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b0a696d6-3d57-4e97-b5d4-b44a63909d67", "Caller" ); assertThat(dmnModel).isNotNull(); @@ -1521,8 +1660,10 @@ public void testInvokeFunctionWrongNamespace() { assertThat(dmnResult.getMessages()).as(DMNRuntimeUtil.formatMessages( dmnResult.getMessages())).hasSize(2); } - @Test - public void testInvokeFunctionWrongDecisionName() { + @ParameterizedTest + @MethodSource("params") + void invokeFunctionWrongDecisionName(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Caller.dmn", this.getClass(), "Calling.dmn" ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b0a696d6-3d57-4e97-b5d4-b44a63909d67", "Caller" ); assertThat(dmnModel).isNotNull(); @@ -1541,8 +1682,10 @@ public void testInvokeFunctionWrongDecisionName() { } - @Test - public void testInvokeFunctionCallerError() { + @ParameterizedTest + @MethodSource("params") + void invokeFunctionCallerError(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Caller.dmn", this.getClass(), "Calling.dmn" ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b0a696d6-3d57-4e97-b5d4-b44a63909d67", "Caller" ); @@ -1562,8 +1705,10 @@ public void testInvokeFunctionCallerError() { assertThat(dmnResult.getMessages()).as(DMNRuntimeUtil.formatMessages( dmnResult.getMessages())).hasSize(2); } - @Test - public void testInvalidFunction() { + @ParameterizedTest + @MethodSource("params") + void invalidFunction(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources( "InvalidFunction.dmn", this.getClass() ); final DMNModel model = runtime.getModel( "http://www.trisotech.com/definitions/_84453b71-5d23-479f-9481-5196d92bacae", "0003-iteration-augmented" ); assertThat(model).isNotNull(); @@ -1591,8 +1736,10 @@ private DecisionNodeImpl buildSimplifiedDecisionNode(final Definitions def, fina return new DecisionNodeImpl(def.getDrgElement().stream().filter(drg -> drg.getName().equals(name)).filter(Decision.class::isInstance).map(Decision.class::cast).findFirst().get()); } - @Test - public void testCycleDetection() { + @ParameterizedTest + @MethodSource("params") + void cycleDetection(boolean useExecModelCompiler) { + init(useExecModelCompiler); final Definitions defs = buildSimplifiedDefinitions("ns", "a", "b"); final DecisionNodeImpl a = buildSimplifiedDecisionNode(defs, "a"); final DecisionNodeImpl b = buildSimplifiedDecisionNode(defs, "b"); @@ -1607,8 +1754,10 @@ public void testCycleDetection() { assertThat(result.hasErrors()).isTrue(); } - @Test - public void testCycleDetectionSelfReference() { + @ParameterizedTest + @MethodSource("params") + void cycleDetectionSelfReference(boolean useExecModelCompiler) { + init(useExecModelCompiler); final Definitions defs = buildSimplifiedDefinitions("ns", "self"); final DecisionNodeImpl decision = buildSimplifiedDecisionNode(defs, "self"); decision.addDependency("self", decision); @@ -1620,8 +1769,10 @@ public void testCycleDetectionSelfReference() { assertThat(result.hasErrors()).isTrue(); } - @Test - public void testSharedDependency() { + @ParameterizedTest + @MethodSource("params") + void sharedDependency(boolean useExecModelCompiler) { + init(useExecModelCompiler); final Definitions defs = buildSimplifiedDefinitions("ns", "a", "b", "c"); final DecisionNodeImpl a = buildSimplifiedDecisionNode(defs, "a"); final DecisionNodeImpl b = buildSimplifiedDecisionNode(defs, "b"); @@ -1638,8 +1789,10 @@ public void testSharedDependency() { assertThat(result.hasErrors()).isFalse(); } - @Test - public void testCycleDetectionDeadlyDiamond() { + @ParameterizedTest + @MethodSource("params") + void cycleDetectionDeadlyDiamond(boolean useExecModelCompiler) { + init(useExecModelCompiler); final Definitions defs = buildSimplifiedDefinitions("ns", "a", "b", "c", "d"); final DecisionNodeImpl a = buildSimplifiedDecisionNode(defs, "a"); final DecisionNodeImpl b = buildSimplifiedDecisionNode(defs, "b"); @@ -1660,8 +1813,10 @@ public void testCycleDetectionDeadlyDiamond() { assertThat(result.hasErrors()).isFalse(); } - @Test - public void testEx_4_3simplified() { + @ParameterizedTest + @MethodSource("params") + void ex43simplified(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Ex_4_3simplified.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_5c5a9c72-627e-4666-ae85-31356fed3658", "Ex_4_3simplified"); assertThat(dmnModel).isNotNull(); @@ -1679,8 +1834,10 @@ public void testEx_4_3simplified() { assertThat(result.get("Formatted Monthly Payment")).isEqualTo("€123.12"); } - @Test - public void testEx_4_3simplifiedASD() { + @ParameterizedTest + @MethodSource("params") + void ex43simplifiedASD(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2117 improve Msg.ERROR_EVAL_NODE_DEP_WRONG_TYPE final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Ex_4_3simplified.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_5c5a9c72-627e-4666-ae85-31356fed3658", "Ex_4_3simplified"); @@ -1700,8 +1857,10 @@ public void testEx_4_3simplifiedASD() { assertThat(dmnResult.getMessages().stream().filter(m -> m.getMessageType() == DMNMessageType.ERROR_EVAL_NODE).anyMatch(m -> m.getMessage().contains("is not allowed by the declared type"))).isTrue(); } - @Test - public void testDrools2125() { + @ParameterizedTest + @MethodSource("params") + void drools2125(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2125 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("drools2125.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_9f976b29-4cdd-42e9-8737-0ccbc2ad9498", "drools2125"); @@ -1723,8 +1882,10 @@ public void testDrools2125() { assertThat(result.get("person is person")).isEqualTo("yes"); } - @Test - public void testDROOLS2147() { + @ParameterizedTest + @MethodSource("params") + void drools2147(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2147 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DROOLS-2147.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_cbdacb7b-f72d-457d-b4f4-54020a06db24", "Drawing 1"); @@ -1748,8 +1909,10 @@ public void testDROOLS2147() { assertThat(((List) peopleGroups.get(2))).hasSize(2); } - @Test - public void testDROOLS2147_message() { + @ParameterizedTest + @MethodSource("params") + void drools2147Message(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2147 truncate message length final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Ex_4_3simplified.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_5c5a9c72-627e-4666-ae85-31356fed3658", "Ex_4_3simplified"); @@ -1770,8 +1933,10 @@ public void testDROOLS2147_message() { assertThat(dmnResult.getMessages().stream().filter(m -> m.getMessageType() == DMNMessageType.ERROR_EVAL_NODE).anyMatch(m -> m.getMessage().contains("... [string clipped after 50 chars, total length is"))).isTrue(); } - @Test - public void testDROOLS2192() { + @ParameterizedTest + @MethodSource("params") + void drools2192(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2192 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("hardcoded_function_definition.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_99854980-65c8-4e9b-b365-bd30ded69f40", "hardcoded_function_definition"); @@ -1787,8 +1952,10 @@ public void testDROOLS2192() { assertThat(((BigDecimal) resultContext.get("hardcoded decision")).intValue()).isEqualTo(47); } - @Test - public void testDROOLS2200() { + @ParameterizedTest + @MethodSource("params") + void drools2200(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2200 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("will_be_null_if_negative.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_c5889555-7ae5-4a67-a872-3a9492caf6e7", "will be null if negative"); @@ -1806,8 +1973,10 @@ public void testDROOLS2200() { assertThat(((Map) resultContext.get("will be null if negative")).get("s2")).isEqualTo("negative"); } - @Test - public void testDROOLS2201() { + @ParameterizedTest + @MethodSource("params") + void drools2201(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2201 // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieServices ks = KieServices.Factory.get(); @@ -1829,8 +1998,10 @@ public void testDROOLS2201() { assertThat(((Map) resultContext.get("an hardcoded person with no name"))).containsKeys("age"); } - @Test - public void testDROOLS2201b() { + @ParameterizedTest + @MethodSource("params") + void drools2201b(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2201 // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieServices ks = KieServices.Factory.get(); @@ -1871,8 +2042,10 @@ public String getSurname() { } - @Test - public void testDROOLS2286() { + @ParameterizedTest + @MethodSource("params") + void drools2286(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2286 final DROOLS2286 johnCena = new DROOLS2286("John", "Cena"); final DROOLS2286 leslieBrown = new DROOLS2286("Leslie", "Brown"); @@ -1888,8 +2061,10 @@ public void testDROOLS2286() { assertDROOLS2286(context); } - @Test - public void testDROOLS2286bis() { + @ParameterizedTest + @MethodSource("params") + void drools2286bis(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2286 (map case) final Map johnCena = prototype(entry("name", "John"), entry("surname", "Cena")); final Map leslieBrown = prototype(entry("name", "Leslie"), entry("surname", "Brown")); @@ -1915,8 +2090,10 @@ private void assertDROOLS2286(final DMNContext context) { assertThat(resultObject).hasSize(2); } - @Test - public void testVerifyExtendedKieFEELFunction_now() { + @ParameterizedTest + @MethodSource("params") + void verifyExtendedKieFEELFunctionNow(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2322 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("just_now.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_56fd6445-ff6a-4c28-8206-71fce7f80436", "just now"); @@ -1931,8 +2108,10 @@ public void testVerifyExtendedKieFEELFunction_now() { assertThat(dmnResult.getDecisionResultByName("a decision just now").getResult()).isNotNull(); } - @Test - public void testNowBetweenTwoDates() { + @ParameterizedTest + @MethodSource("params") + void nowBetweenTwoDates(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3670 DMN `between` FEEL operator alignments final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("is office open.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn/_19170B18-B561-4EB2-9D38-714E2442710E", @@ -1950,8 +2129,10 @@ public void testNowBetweenTwoDates() { assertThat(dmnResult.getDecisionResultByName("is open").getResult()).isNotNull(); } - @Test - public void testVerifyExtendedKieFEELFunction_today() { + @ParameterizedTest + @MethodSource("params") + void verifyExtendedKieFEELFunctionToday(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2322 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("just_today.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_56fd6445-ff6a-4c28-8206-71fce7f80436", "just today"); @@ -1966,8 +2147,10 @@ public void testVerifyExtendedKieFEELFunction_today() { assertThat(dmnResult.getDecisionResultByName("a decision just today").getResult()).isNotNull(); } - @Test - public void testEnhancedForLoop() { + @ParameterizedTest + @MethodSource("params") + void enhancedForLoop(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2307 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("drools2307.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_03d9481e-dcfc-4a59-9bdd-4f021cb2f0d8", "Drawing 1"); @@ -1983,8 +2166,10 @@ public void testEnhancedForLoop() { assertThat(result.get("an hardcoded forloop")).asList().containsExactly(new BigDecimal(2), new BigDecimal(3), new BigDecimal(4)); } - @Test - public void testList_of_Vowels() { + @ParameterizedTest + @MethodSource("params") + void listOfVowels(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2357 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("List_of_Vowels.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_c5f007ce-4d45-4aac-8729-991d4abc7826", "List of Vowels"); @@ -2005,8 +2190,10 @@ public void testList_of_Vowels() { assertThat(result.get("Decide BAD")).isNull(); } - @Test - public void testEnhancedForLoop2() { + @ParameterizedTest + @MethodSource("params") + void enhancedForLoop2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("MACD-enhanced_iteration.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6cfe7d88-6741-45d1-968c-b61a597d0964", "MACD-enhanced iteration"); assertThat(dmnModel).isNotNull(); @@ -2028,8 +2215,10 @@ public void testEnhancedForLoop2() { assertThat(((Map) ((List) resultContext.get("MACDTable")).get(2)).get("aDate")).isEqualTo(LocalDate.of(2018, 3, 7)); } - @Test - public void testNotListInDT() { + @ParameterizedTest + @MethodSource("params") + void notListInDT(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2416 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("anot.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_292c1c7b-6b38-415d-938f-e9ca51d30b2b", "anot"); @@ -2046,8 +2235,10 @@ public void testNotListInDT() { assertThat(result.get("what letter decision")).isEqualTo("vowel"); } - @Test - public void testListContainmentDT() { + @ParameterizedTest + @MethodSource("params") + void listContainmentDT(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2416 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("list_containment_DT.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6ab2bd6d-adaa-45c4-a141-a84382a201eb", "list containment DT"); @@ -2064,8 +2255,10 @@ public void testListContainmentDT() { assertThat(result.get("Boarding Status")).isEqualTo("Denied"); } - @Test - public void testStructureContainment() { + @ParameterizedTest + @MethodSource("params") + void structureContainment(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("structure-containtment.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn/_7FB5C3E4-4DF8-42A6-A7FA-28315DECCDD0", "structure-containtment"); @@ -2082,8 +2275,10 @@ public void testStructureContainment() { assertThat(result.get("is there")).isEqualTo(Boolean.TRUE); } - @Test - public void testRelationwithemptycell() { + @ParameterizedTest + @MethodSource("params") + void relationwithemptycell(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2439 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("relation_with_empty_cell.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_99a00903-2943-47df-bab1-a32f276617ea", "Relation with empty cell"); @@ -2103,8 +2298,10 @@ public void testRelationwithemptycell() { prototype(entry("name", "Matteo"), entry("age", null))); } - @Test - public void testFor() { + @ParameterizedTest + @MethodSource("params") + void testFor(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2317 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Dynamic composition.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_c2d86765-c3c7-4e1d-b1fa-b830fa5bc529", "Dynamic composition"); @@ -2112,8 +2309,10 @@ public void testFor() { assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); } - @Test - public void testUsingReusableKeywordAsPartOfBKMName() { + @ParameterizedTest + @MethodSource("params") + void usingReusableKeywordAsPartOfBKMName(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2317 FEEL Syntax error on function(bkm) containing `for` keyword final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("say_for_hello.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_b6f2a9ca-a246-4f27-896a-e8ef04ea439c", "say for hello"); @@ -2129,8 +2328,10 @@ public void testUsingReusableKeywordAsPartOfBKMName() { assertThat(result.get("just say")).asList().containsExactly("Hello", "Hello", "Hello"); } - @Test - public void testProductFunction() { + @ParameterizedTest + @MethodSource("params") + void productFunction(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("product.dmn", this.getClass() ); final DMNModel model = runtime.getModel("http://www.trisotech.com/dmn/definitions/_40fdbc2c-a631-4ba4-8435-17571b5d1942", "Drawing 1" ); assertThat(model).isNotNull(); @@ -2145,8 +2346,10 @@ public void testProductFunction() { assertThat(result.getResult()).isEqualTo("This is product 1"); } - @Test - public void testNotWithPredicates20180601() { + @ParameterizedTest + @MethodSource("params") + void notWithPredicates20180601(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2605 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("test20180601.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_9b8f2642-2597-4a99-9fcd-f9302692d3dc", "Drawing 1"); @@ -2168,8 +2371,10 @@ public void testNotWithPredicates20180601() { assertThat(dmnResult10.getDecisionResultByName("my decision").getResult()).isEqualTo(Boolean.TRUE); } - @Test - public void testNotWithPredicates20180601b() { + @ParameterizedTest + @MethodSource("params") + void notWithPredicates20180601b(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2605 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("BruceTask20180601.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_3802fcb2-5b93-4502-aff4-0f5c61244eab", "Bruce Task"); @@ -2214,9 +2419,11 @@ public void testNotWithPredicates20180601b() { assertThat(((List) bruce.get("six")).stream().anyMatch(e -> ((Map) e).get("Title").equals("85"))).isTrue(); assertThat(((List) bruce.get("six")).stream().anyMatch(e -> ((Map) e).get("Title").equals("66"))).isTrue(); } - - @Test - public void testModelById() { + + @ParameterizedTest + @MethodSource("params") + void modelById(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModelById("https://github.com/kiegroup/kie-dmn/itemdef", "_simple-item-def" ); assertThat(dmnModel).isNotNull(); @@ -2224,8 +2431,10 @@ public void testModelById() { } - @Test - public void testWeekdayOnDateDMN12() { + @ParameterizedTest + @MethodSource("params") + void weekdayOnDateDMN12(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2648 DMN v1.2 weekday on 'date', 'date and time' final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("weekday-on-date.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_55a2dafd-ab4d-4154-bace-826d426da251", "weekday on date"); @@ -2245,8 +2454,10 @@ public void testWeekdayOnDateDMN12() { } } - @Test - public void testDMN_Vs_FEEL_instanceof_interaction() { + @ParameterizedTest + @MethodSource("params") + void dmn_VsFEELInstanceofInteraction(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2665 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Instance_of.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b5c4d644-5a15-4528-8028-86537cb1c836", "Instance of"); @@ -2270,8 +2481,10 @@ public void testDMN_Vs_FEEL_instanceof_interaction() { assertThat(result.get("Decision Logic 4")).isEqualTo(Boolean.TRUE); } - @Test - public void testInvokingAFunctionOnALiteralContext() { + @ParameterizedTest + @MethodSource("params") + void invokingAFunctionOnALiteralContext(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2732 FEEL invoking a function on a literal context final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("invokingAFunctionOnALiteralContext.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_781968dd-64dc-4231-9cd0-2ce590881f2c", "Drawing 1"); @@ -2288,16 +2501,20 @@ public void testInvokingAFunctionOnALiteralContext() { assertThat(result.get("invoking a function on a literal context")).isEqualTo(new BigDecimal(3)); } - @Test - public void testBoxedInvocationMissingExpression() { + @ParameterizedTest + @MethodSource("params") + void boxedInvocationMissingExpression(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2813 DMN boxed invocation missing expression NPE and Validator issue final List messages = DMNRuntimeUtil.createExpectingDMNMessages("DROOLS-2813-NPE-BoxedInvocationMissingExpression.dmn", this.getClass()); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_EXPRESSION) && p.getSourceId().equals("_a111c4df-c5b5-4d84-81e7-3ec735b50d06"))).isTrue(); } - @Test - public void testNotHeuristicForFunctionInvocation() { + @ParameterizedTest + @MethodSource("params") + void notHeuristicForFunctionInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2822 FEEL augment not() heuristic for function invocation final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Not-heuristic-for-function-invocation-drools-2822.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_82f7e67e-0a8c-492d-aa78-94851c10eee6", "Drawing 1"); @@ -2314,8 +2531,10 @@ public void testNotHeuristicForFunctionInvocation() { assertThat(result.get("Not working")).isEqualTo(Boolean.FALSE); } - @Test - public void testDMNv1_2_ch11Modified() { + @ParameterizedTest + @MethodSource("params") + void dMNv12Ch11Modified(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("v1_2/ch11MODIFIED.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_3068644b-d2c7-4b81-ab9d-64f011f81f47", "DMN Specification Chapter 11 Example"); assertThat(dmnModel).isNotNull(); @@ -2344,9 +2563,12 @@ public void testDMNv1_2_ch11Modified() { assertThat(result.get("Strategy")).isEqualTo("THROUGH"); assertThat(result.get("Routing")).isEqualTo("ACCEPT"); } - - @Test(timeout = 30_000L) - public void testAccessorCache() { + + @ParameterizedTest + @MethodSource("params") + @Timeout(value = 30_000L, unit = TimeUnit.MILLISECONDS) + void accessorCache(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("20180731-pr1997.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_7a39d775-bce9-45e3-aa3b-147d6f0028c7", "20180731-pr1997"); assertThat(dmnModel).isNotNull(); @@ -2365,8 +2587,10 @@ public void testAccessorCache() { } } - @Test - public void testWrongTypeRefForDRGElement() { + @ParameterizedTest + @MethodSource("params") + void wrongTypeRefForDRGElement(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2917 DMN resolveTypeRef returning null in BKM causes NPE during KieContainer compilation final List messages = DMNRuntimeUtil.createExpectingDMNMessages("WrongTypeRefForDRGElement.dmn", this.getClass()); DMNRuntimeUtil.formatMessages(messages); @@ -2376,8 +2600,10 @@ public void testWrongTypeRefForDRGElement() { assertThat(messages.stream().anyMatch(m -> m.getSourceId().equals("_45fa8674-f4f0-4c06-b2fd-52bbd17d8550"))).isEqualTo(Boolean.TRUE); } - @Test - public void testDecisionTableInputClauseImportingItemDefinition() { + @ParameterizedTest + @MethodSource("params") + void decisionTableInputClauseImportingItemDefinition(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2927 DMN DecisionTable inputClause importing ItemDefinition throws NPE at compilation final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("imports/Imported_Model.dmn", this.getClass(), @@ -2398,8 +2624,10 @@ public void testDecisionTableInputClauseImportingItemDefinition() { assertThat(result.get("A Decision Table")).isEqualTo("NOT Allowed"); } - @Test - public void testAssignNullToAllowedValues() { + @ParameterizedTest + @MethodSource("params") + void assignNullToAllowedValues(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3132 DMN assign null to ItemDefinition with allowedValues final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("assignNullToAllowedValues.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_700a46e0-01ed-4361-9034-4afdb2537ea4", "Drawing 1"); @@ -2416,8 +2644,10 @@ public void testAssignNullToAllowedValues() { assertThat(dmnResult.getMessages().stream().anyMatch(m -> m.getSourceId().equals("_09945fda-2b89-4148-8758-0bcb91a66e4a"))).isEqualTo(Boolean.TRUE); } - @Test - public void testAssignNullToAllowedValuesExplicitingNull() { + @ParameterizedTest + @MethodSource("params") + void assignNullToAllowedValuesExplicitingNull(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3132 DMN assign null to ItemDefinition with allowedValues final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("assignNullToAllowedValuesExplicitingNull.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_700a46e0-01ed-4361-9034-4afdb2537ea4", "Drawing 1"); @@ -2435,8 +2665,10 @@ public void testAssignNullToAllowedValuesExplicitingNull() { assertThat(dmnResult.getDecisionResultByName("decision over the input letter").getResult()).isNull(); } - @Test - public void testEmptyinputValuesoutputValuesdefaultOutputEntry() { + @ParameterizedTest + @MethodSource("params") + void emptyinputValuesoutputValuesdefaultOutputEntry(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS- final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("EmptyinputValuesoutputValuesdefaultOutputEntry.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_31f2dde9-b27c-41f8-97b4-5c8dd728942e", "Drawing 1"); @@ -2459,8 +2691,10 @@ private static void checkEmptyinputValuesoutputValuesdefaultOutputEntry(final DM assertThat(result.get("my DT")).isEqualTo(my_DT); } - @Test - public void testAnyExpression() { + @ParameterizedTest + @MethodSource("params") + void anyExpression(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3279 DMN DRGElement typeRef to allow FEEL Any final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("any-expression.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn/_D8154592-7406-4E5A-B7F7-347984A92288", "_40F20B8D-84C1-4AC2-B28C-267892C15077"); @@ -2475,8 +2709,10 @@ public void testAnyExpression() { assertThat(dmnResult.getDecisionResultByName("Decision-1").getResult()).isEqualTo("Hello World"); } - @Test - public void testGetEntries() { + @ParameterizedTest + @MethodSource("params") + void getEntries(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3308 DMN implement missing functions only described in chapter "10.3.2.6 Context" final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("getentriesgetvalue.dmn", this.getClass()); final DMNModel dmnModel = getAndAssertModelNoErrors(runtime, "http://www.trisotech.com/dmn/definitions/_0fad1a80-0642-4278-ac3d-47668c4f689a", "Drawing 1"); @@ -2489,8 +2725,10 @@ public void testGetEntries() { assertThat(dmnResult.getDecisionResultByName("using get entries").getResult()).asList().containsExactly("value2"); } - @Test - public void testGetValue() { + @ParameterizedTest + @MethodSource("params") + void getValue(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3308 DMN implement missing functions only described in chapter "10.3.2.6 Context" final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("getentriesgetvalue.dmn", this.getClass()); final DMNModel dmnModel = getAndAssertModelNoErrors(runtime, "http://www.trisotech.com/dmn/definitions/_0fad1a80-0642-4278-ac3d-47668c4f689a", "Drawing 1"); @@ -2502,9 +2740,11 @@ public void testGetValue() { assertThat(dmnResult.getDecisionResultByName("using get value").getEvaluationStatus()).isEqualTo(DecisionEvaluationStatus.SUCCEEDED); assertThat(dmnResult.getDecisionResultByName("using get value").getResult()).isEqualTo("value2"); } - - @Test - public void testGetEntriesGetValueUsingDTO() { + + @ParameterizedTest + @MethodSource("params") + void getEntriesGetValueUsingDTO(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-7139 FEEL context functions `get value` and `get entries` should support Java POJO as argument final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("getentriesgetvalue_Dto.dmn", this.getClass()); final DMNModel dmnModel = getAndAssertModelNoErrors(runtime, "http://www.trisotech.com/dmn/definitions/_0fad1a80-0642-4278-ac3d-47668c4f689a", "Drawing 1"); @@ -2520,8 +2760,10 @@ public void testGetEntriesGetValueUsingDTO() { assertThat(dmnResult.getDecisionResultByName("using get value").getResult()).isEqualTo("John"); } - @Test - public void testChronoPeriod() { + @ParameterizedTest + @MethodSource("params") + void chronoPeriod(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3848 DMN Years and Months internals expect value is Comparable final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("ChronoPeriod.dmn", this.getClass()); final DMNModel dmnModel = getAndAssertModelNoErrors(runtime, "http://www.trisotech.com/definitions/_f6036734-c7b3-42d2-adde-d7db17953114", "Drawing 1"); @@ -2571,8 +2813,10 @@ private void checkChronoPeriodEvaluateAll(final DMNRuntime runtime, final DMNMod assertThat(((ChronoPeriod) dmnResult.getDecisionResultByName("Decision2").getResult()).get(ChronoUnit.MONTHS)).isEqualTo(1L); } - @Test - public void testTable61ForAliasFeelType() { + @ParameterizedTest + @MethodSource("params") + void table61ForAliasFeelType(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3998 DMN FEEL parser Table61 error with aliased type final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Table61ForAliasFeelType.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_aaff9a5f-a654-40d3-a209-8a7dc1d74eeb", "Drawing 1"); @@ -2591,8 +2835,10 @@ public void testTable61ForAliasFeelType() { assertThat(result.get("my decision")).isEqualTo(new BigDecimal("2019")); } - @Test - public void testcItemDef() { + @ParameterizedTest + @MethodSource("params") + void testcItemDef(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-4173 DMN composite recursive ItemDefinition final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("cItemDef.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_f776b6fb-31bc-43b6-9c89-2bbc2973babf", "Drawing 1"); @@ -2611,14 +2857,18 @@ public void testcItemDef() { assertThat((Map) ((Map) result.get("hardcoded decision")).get("supervisor")).containsEntry("supervisor", null); } - @Test - public void testDTinputExprCollectionWithAllowedValuesA() { + @ParameterizedTest + @MethodSource("params") + void dTinputExprCollectionWithAllowedValuesA(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DROOLS-4379.dmn", this.getClass()); testDTinputExprCollectionWithAllowedValues(runtime); } - @Test - public void testDTinputExprCollectionWithAllowedValuesB() { + @ParameterizedTest + @MethodSource("params") + void dTinputExprCollectionWithAllowedValuesB(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DROOLS-4379b.dmn", this.getClass()); testDTinputExprCollectionWithAllowedValues(runtime); } @@ -2640,8 +2890,10 @@ private void testDTinputExprCollectionWithAllowedValues(final DMNRuntime runtime assertThat((List) result.get("D5")).asList().contains("r1", "r2"); } - @Test - public void testInputDataWithSlash() { + @ParameterizedTest + @MethodSource("params") + void inputDataWithSlash(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-4390 DMN correct FEEL grammar exclusion final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Slash.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_efb0df9e-cd3a-4bda-b731-e6b184a6cd73", "Drawing 1"); @@ -2660,8 +2912,10 @@ public void testInputDataWithSlash() { assertThat(result.get("Litteral Expression")).isEqualTo("A"); } - @Test - public void testTimeOffsetAccessorFromDeclVariable() { + @ParameterizedTest + @MethodSource("params") + void timeOffsetAccessorFromDeclVariable(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-4504 DMN time offset accessor from decl variable type final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("ContextEntryTypeCascade.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_8a15bd3c-c732-42c8-a2e4-60f1a23a1c5a", "Drawing 1"); @@ -2681,8 +2935,10 @@ public void testTimeOffsetAccessorFromDeclVariable() { assertThat(((Map) result.get("Time")).get("Not working Time hours from Variable")).isEqualTo(new BigDecimal("-11")); } - @Test - public void testSO58507157() { + @ParameterizedTest + @MethodSource("params") + void so58507157(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-4679 DMN FEEL list contains() invocation from DMN layer fixes final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("so58507157.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://sample.dmn", "DecisionNumberInList"); @@ -2704,8 +2960,10 @@ public void testSO58507157() { assertThat((Map) result.get("DecisionNumberInList")).containsEntry("Result_4",Boolean.TRUE); } - @Test - public void testNoExpr() { + @ParameterizedTest + @MethodSource("params") + void noExpr(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-4765 DMN validation rule alignment for missing expression final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("noExpr.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_461041dc-9ab9-4e23-ae01-3366a7544cd3", "Drawing 1"); @@ -2727,15 +2985,19 @@ public void testNoExpr() { assertThat(dmnResult.getDecisionResultByName("what to do today?").getEvaluationStatus()).isEqualTo(DecisionEvaluationStatus.SKIPPED); } - @Test - public void testItemDefinitionInXmlns_dmn() { + @ParameterizedTest + @MethodSource("params") + void itemDefinitionInXmlnsDmn(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-4797 DMN itemdef resolution in xml namespaces final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("itemDefXmlns_dmn.dmn", this.getClass()); verify_testItemDefinitionInXmlns(runtime); } - @Test - public void testItemDefinitionInXmlns_model() { + @ParameterizedTest + @MethodSource("params") + void itemDefinitionInXmlnsModel(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-4797 DMN itemdef resolution in xml namespaces final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("itemDefXmlns_model.dmn", this.getClass()); verify_testItemDefinitionInXmlns(runtime); @@ -2755,8 +3017,10 @@ private void verify_testItemDefinitionInXmlns(final DMNRuntime runtime) { assertThat(dmnResult.getDecisionResultByName("greet").getResult()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isEqualTo("Hello, John"); } - @Test - public void testOpInNames1() { + @ParameterizedTest + @MethodSource("params") + void opInNames1(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("OpInNames1.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_dae806ec-f00e-41a8-b6d1-2754fcd7fa2d", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -2770,8 +3034,10 @@ public void testOpInNames1() { assertThat(dmnResult.getDecisionResultByName("decision1").getResult()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isEqualTo("make and model"); } - @Test - public void testOpInNames2() { + @ParameterizedTest + @MethodSource("params") + void opInNames2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("OpInNames2.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_dae806ec-f00e-41a8-b6d1-2754fcd7fa2d", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -2785,8 +3051,10 @@ public void testOpInNames2() { assertThat(dmnResult.getDecisionResultByName("decision1").getResult()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isEqualTo("DMN"); } - @Test - public void testBindingContextTypeCheck() { + @ParameterizedTest + @MethodSource("params") + void bindingContextTypeCheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-4825 DMN v1.3 verify DMN13-132 type conversions final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("v1_3/DMN13-132.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_9d01a0c4-f529-4ad8-ad8e-ec5fb5d96ad4", "DMN13-132"); @@ -2806,8 +3074,10 @@ public void testBindingContextTypeCheck() { assertThat(dmnResult.getDecisionResultByName("decision_003").getResult()).isNull(); } - @Test - public void testClassicComparisonVsRange() { + @ParameterizedTest + @MethodSource("params") + void classicComparisonVsRange(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("classicComparisonVsRange.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_ac6efb68-08ed-43ec-b427-e99e78f51ba1", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -2833,8 +3103,10 @@ public void testClassicComparisonVsRange() { } } - @Test - public void testFunctionDefinitionParameterTrailingSpace() { + @ParameterizedTest + @MethodSource("params") + void functionDefinitionParameterTrailingSpace(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DROOLS4555.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_e1645e17-7e28-4226-ad60-95e6f81cb50b", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -2848,32 +3120,40 @@ public void testFunctionDefinitionParameterTrailingSpace() { assertThat(dmnResult.getDecisionResultByName("hardcoded").getResult()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isEqualTo("Hello, x"); } - @Test(expected = IllegalArgumentException.class) - public void testEvaluateByNameWithEmptyParam() { - final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass()); - final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item-def"); - assertThat(dmnModel).isNotNull(); - assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); + @ParameterizedTest + @MethodSource("params") + void evaluateByNameWithEmptyParam(boolean useExecModelCompiler) { + init(useExecModelCompiler); + assertThrows(IllegalArgumentException.class, () -> { + final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass()); + final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item-def"); + assertThat(dmnModel).isNotNull(); + assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); - final DMNContext context = DMNFactory.newContext(); - context.set("Monthly Salary", 1000); + final DMNContext context = DMNFactory.newContext(); + context.set("Monthly Salary", 1000); - String[] decisionNames = new String[]{}; - runtime.evaluateByName(dmnModel, context, decisionNames); + String[] decisionNames = new String[]{}; + runtime.evaluateByName(dmnModel, context, decisionNames); + }); } - @Test(expected = IllegalArgumentException.class) - public void testEvaluateByIdWithEmptyParam() { - final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass()); - final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item-def"); - assertThat(dmnModel).isNotNull(); - assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); + @ParameterizedTest + @MethodSource("params") + void evaluateByIdWithEmptyParam(boolean useExecModelCompiler) { + init(useExecModelCompiler); + assertThrows(IllegalArgumentException.class, () -> { + final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass()); + final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item-def"); + assertThat(dmnModel).isNotNull(); + assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); - final DMNContext context = DMNFactory.newContext(); - context.set("Monthly Salary", 1000); + final DMNContext context = DMNFactory.newContext(); + context.set("Monthly Salary", 1000); - String[] decisionIds = new String[]{}; - runtime.evaluateById(dmnModel, context, decisionIds); + String[] decisionIds = new String[]{}; + runtime.evaluateById(dmnModel, context, decisionIds); + }); } public static class JavaPojoCharUtilDate { @@ -2903,8 +3183,10 @@ public java.util.Date getWhen() { } } - @Test - public void testJavaPojoCharUtilDate() { + @ParameterizedTest + @MethodSource("params") + void javaPojoCharUtilDate(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("javaPojoCharUtilDate.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_5eaccc88-cbf0-4c58-945a-952d8bf974ed", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -2919,8 +3201,10 @@ public void testJavaPojoCharUtilDate() { assertThat(dmnResult.getDecisionResultByName("my decision").getResult()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isEqualTo("The person: Doe J., on the 28 of the month 1 at the 10 hour."); } - @Test - public void testInstanceOfItemDefBasic() { + @ParameterizedTest + @MethodSource("params") + void instanceOfItemDefBasic(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("instanceOfItemDefBasic.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_CF9357D4-C83F-4F7E-83E3-510310EB16F4", "testItemDefName"); assertThat(dmnModel).isNotNull(); @@ -2935,8 +3219,10 @@ public void testInstanceOfItemDefBasic() { assertThat(dmnResult.getDecisionResultByName("Decision-2").getResult()).isEqualTo(Boolean.TRUE); } - @Test - public void testUniqueMissingMatchDefaultEmpty() { + @ParameterizedTest + @MethodSource("params") + void uniqueMissingMatchDefaultEmpty(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("uniqueNoMatch.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://activiti.org/schema/1.0/dmn", "decisionmulti"); assertThat(dmnModel).isNotNull(); @@ -2956,8 +3242,10 @@ private void checkUniqueMissingMatchDefaultEmpty(final DMNRuntime runtime, final assertThat(dmnResult.getDecisionResultByName("Decision_decisionboolean").getResult()).isEqualTo(output); } - @Test - public void testErrorWhileLiteral() { + @ParameterizedTest + @MethodSource("params") + void errorWhileLiteral(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("errorWhileLiteral.dmn", this.getClass()); runtime.addListener(new DMNRuntimeEventListener() {}); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_8DF63435-B34B-4C19-A06B-C6A3416194A9", "testBasic"); @@ -2972,8 +3260,10 @@ public void testErrorWhileLiteral() { assertThat(dmnResult.getDecisionResultByName("Decision-1").getEvaluationStatus()).isEqualTo(DecisionEvaluationStatus.FAILED); } - @Test - public void testXAsType() { + @ParameterizedTest + @MethodSource("params") + void xAsType(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("xAsType.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_CA816D47-2D7A-41AA-B019-E4B4C5488385", "FEC85B35-BAC9-4FCC-A446-0D546CCAD1A4"); assertThat(dmnModel).isNotNull(); @@ -2989,8 +3279,10 @@ public void testXAsType() { assertThat(dmnResult.getDecisionResultByName("Decision-1").getResult()).isEqualTo("a x, 2020"); } - @Test - public void testExceptionInContextEntry() { + @ParameterizedTest + @MethodSource("params") + void exceptionInContextEntry(boolean useExecModelCompiler) { + init(useExecModelCompiler); // the scope of this test: if an exception occurs while evaluating a ContextEntry, report a DMN message. Before was only SLF4j logged so user no DMN Message at all just null. final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("exceptionInContextEntry.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_001031e1-9f0e-4156-afad-3ee970139021", "Drawing 1"); @@ -3004,8 +3296,10 @@ public void testExceptionInContextEntry() { assertThat(dmnResult.getDecisionResultByName("hardcoded").getEvaluationStatus()).isEqualTo(DecisionEvaluationStatus.FAILED); } - @Test - public void testPersonInReq1() { + @ParameterizedTest + @MethodSource("params") + void personInReq1(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("personInReq1.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_EA9DA906-5A01-4AAA-B341-792486A67097", "personInReq1"); assertThat(dmnModel).isNotNull(); @@ -3023,8 +3317,10 @@ public void testPersonInReq1() { assertThat(dmnResult.getDecisionResultByName("Decision-1").getResult()).isEqualTo(Boolean.TRUE); } - @Test - public void testArthimeticSub1() { + @ParameterizedTest + @MethodSource("params") + void arthimeticSub1(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("arithmeticSub1.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_7B82BF58-74D1-4727-820F-9925FA3F7812", "arithmeticSub1"); assertThat(dmnModel).isNotNull(); @@ -3040,8 +3336,10 @@ public void testArthimeticSub1() { assertThat(dmnResult.getDecisionResultByName("ExpressionTest").getResult()).isEqualTo(new BigDecimal("-10")); } - @Test - public void testArthimeticSub2() { + @ParameterizedTest + @MethodSource("params") + void arthimeticSub2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("arithmeticSub2.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_FCE6849C-6535-4629-A132-8DFD292A4765", "arithmeticSub2"); assertThat(dmnModel).isNotNull(); @@ -3054,8 +3352,10 @@ public void testArthimeticSub2() { assertThat(dmnResult.getDecisionResultByName("ExpressionTest").getResult()).isEqualTo(new BigDecimal("-3")); } - @Test - public void testInvokeJavaReturnArray() { + @ParameterizedTest + @MethodSource("params") + void invokeJavaReturnArray(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("invokeJavaReturnArray.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_C90046D5-8581-4B16-992D-0472F840EFAF", "invokeJavaReturnArray"); assertThat(dmnModel).isNotNull(); @@ -3069,9 +3369,11 @@ public void testInvokeJavaReturnArray() { assertThat(dmnResult.getDecisionResultByName("Decision1").getResult()).isNotNull(); assertThat(dmnResult.getDecisionResultByName("Decision2").getResult()).isEqualTo("cd"); } - - @Test - public void testNotInvocable() { + + @ParameterizedTest + @MethodSource("params") + void notInvocable(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("notInvocable.dmn", this.getClass()); runtime.addListener(new DMNRuntimeEventListener() {}); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_4B70E98C-E74E-48A1-88C6-F3FB1F0C026B", "notInvocable"); @@ -3087,9 +3389,11 @@ public void testNotInvocable() { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isTrue(); assertThat(dmnResult.getDecisionResultByName("Decision-1").getEvaluationStatus()).isEqualTo(DecisionEvaluationStatus.FAILED); } - - @Test - public void testDecisionTableWithNow() { + + @ParameterizedTest + @MethodSource("params") + void decisionTableWithNow(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("decisiontable-with-now.dmn", this.getClass()); runtime.addListener(new DMNRuntimeEventListener() {}); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_fce3104a-30df-41f4-8c8f-0b67d4d996d4", "Drawing 1"); @@ -3103,9 +3407,11 @@ public void testDecisionTableWithNow() { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isFalse(); assertThat(dmnResult.getDecisionResultByName("Compare").getResult()).isEqualTo(Boolean.TRUE); } - - @Test - public void testDupContextEntryKey() { + + @ParameterizedTest + @MethodSource("params") + void dupContextEntryKey(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("dupContextEntryKey.dmn", this.getClass()); runtime.addListener(new DMNRuntimeEventListener() {}); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_730A7A75-F473-4083-93B9-85E0DAF7F4BD", "dupContextEntryKey"); @@ -3119,9 +3425,11 @@ public void testDupContextEntryKey() { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isTrue(); assertThat(dmnResult.getDecisionResultByName("hardcoded").getEvaluationStatus()).isEqualTo(DecisionEvaluationStatus.FAILED); } - - @Test - public void testHyphenInPropertyOfCollectionForAccessor() { + + @ParameterizedTest + @MethodSource("params") + void hyphenInPropertyOfCollectionForAccessor(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("testHyphenInPropertyOfCollectionForAccessor.dmn", this.getClass()); runtime.addListener(new DMNRuntimeEventListener() {}); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b5362305-17be-42d8-acec-f2621e3cc0e0", "Drawing 1"); @@ -3140,9 +3448,11 @@ public void testHyphenInPropertyOfCollectionForAccessor() { */ assertThat((Map) dmnResult.getDecisionResultByName("decision").getResult()).containsExactly(entry("correct", List.of("k987")), entry("incorrect", "k987")); } - - @Test - public void testHyphenInPropertyOfCollectionForAccessorMultiple() { + + @ParameterizedTest + @MethodSource("params") + void hyphenInPropertyOfCollectionForAccessorMultiple(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("testHyphenInPropertyOfCollectionForAccessorMultiple.dmn", this.getClass()); runtime.addListener(new DMNRuntimeEventListener() {}); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b5362305-17be-42d8-acec-f2621e3cc0e0", "Drawing 1"); @@ -3161,9 +3471,11 @@ public void testHyphenInPropertyOfCollectionForAccessorMultiple() { */ assertThat((Map)dmnResult.getDecisionResultByName("decision").getResult()).containsExactly(entry("correct", Arrays.asList("k1", "k2", "k3")),entry("incorrect", Arrays.asList("k1", "k3"))); } - - @Test - public void testSoundLevelAllowNull() { + + @ParameterizedTest + @MethodSource("params") + void soundLevelAllowNull(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("RecommenderHitPolicy1_allowNull.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_50aea0bb-4482-48f6-acfe-4abc1a1bd0d6", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -3177,9 +3489,11 @@ public void testSoundLevelAllowNull() { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isFalse(); assertThat(dmnResult.getDecisionResultByName("Evaluation").getResult()).isEqualTo("Unknown"); } - - @Test - public void testSoundLevelAllowNullItemDef() { + + @ParameterizedTest + @MethodSource("params") + void soundLevelAllowNullItemDef(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("RecommenderHitPolicy1_allowNull_itemDef.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_50aea0bb-4482-48f6-acfe-4abc1a1bd0d6", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -3194,8 +3508,10 @@ public void testSoundLevelAllowNullItemDef() { assertThat(dmnResult.getDecisionResultByName("Evaluation").getResult()).isEqualTo("Unknown"); } - @Test - public void testKieIssue270() { + @ParameterizedTest + @MethodSource("params") + void kieIssue270(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("habitability.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_93836704-04E9-45B6-8D10-51409FEBDF25", "habitability" ); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNRuntimeTypeCheckTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNRuntimeTypeCheckTest.java index 27b622d47a9..7b81e001969 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNRuntimeTypeCheckTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNRuntimeTypeCheckTest.java @@ -22,7 +22,9 @@ import java.util.UUID; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -54,12 +56,10 @@ public class DMNRuntimeTypeCheckTest extends BaseInterpretedVsCompiledTest { private static final KieServices ks = KieServices.Factory.get(); - public DMNRuntimeTypeCheckTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testDefaultNoTypeCheck() { + @ParameterizedTest + @MethodSource("params") + void defaultNoTypeCheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"), ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); @@ -67,14 +67,18 @@ public void testDefaultNoTypeCheck() { assertNoTypeCheck(runtime); } - @Test - public void testAskTypeCheckInKModule() { + @ParameterizedTest + @MethodSource("params") + void askTypeCheckInKModule(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = getRuntimeWithTypeCheckOption("true", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); assertPerformTypeCheck(runtime); } - @Test - public void testAskTypeCheckWithGlobalEnvVariable() { + @ParameterizedTest + @MethodSource("params") + void askTypeCheckWithGlobalEnvVariable(boolean useExecModelCompiler) { + init(useExecModelCompiler); System.setProperty(RuntimeTypeCheckOption.PROPERTY_NAME, "true"); // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"), @@ -84,26 +88,34 @@ public void testAskTypeCheckWithGlobalEnvVariable() { System.clearProperty(RuntimeTypeCheckOption.PROPERTY_NAME); } - @Test - public void testExplicitDisableTypeCheckInKModule() { + @ParameterizedTest + @MethodSource("params") + void explicitDisableTypeCheckInKModule(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = getRuntimeWithTypeCheckOption("false", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); assertNoTypeCheck(runtime); } - @Test - public void testUnreckonOptionTypeCheckInKModuleDefaultsToNoTypeCheck() { + @ParameterizedTest + @MethodSource("params") + void unreckonOptionTypeCheckInKModuleDefaultsToNoTypeCheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = getRuntimeWithTypeCheckOption("boh", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); assertNoTypeCheck(runtime); } - @Test - public void testEmptyOptionTypeCheckInKModuleDefaultsToNoTypeCheck() { + @ParameterizedTest + @MethodSource("params") + void emptyOptionTypeCheckInKModuleDefaultsToNoTypeCheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = getRuntimeWithTypeCheckOption("", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); assertNoTypeCheck(runtime); } - @Test - public void testDefaultNoTypeCheckButOverrideRuntime() { + @ParameterizedTest + @MethodSource("params") + void defaultNoTypeCheckButOverrideRuntime(boolean useExecModelCompiler) { + init(useExecModelCompiler); // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"), ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); @@ -112,15 +124,19 @@ public void testDefaultNoTypeCheckButOverrideRuntime() { assertPerformTypeCheck(runtime); } - @Test - public void testExplicitDisableTypeCheckInKModuleButOverrideRuntime() { + @ParameterizedTest + @MethodSource("params") + void explicitDisableTypeCheckInKModuleButOverrideRuntime(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = getRuntimeWithTypeCheckOption("false", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); ((DMNRuntimeImpl) runtime).setOption(new RuntimeTypeCheckOption(true)); assertPerformTypeCheck(runtime); } - @Test - public void testAskTypeCheckInKModuleButOverrideRuntime() { + @ParameterizedTest + @MethodSource("params") + void askTypeCheckInKModuleButOverrideRuntime(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = getRuntimeWithTypeCheckOption("true", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); ((DMNRuntimeImpl) runtime).setOption(new RuntimeTypeCheckOption(false)); assertPerformTypeCheck(runtime); @@ -190,8 +206,10 @@ private void assertPerformTypeCheck(final DMNRuntime runtime) { assertThat(hundredMinusNumber.getEvaluationStatus()).isEqualTo(DecisionEvaluationStatus.SKIPPED); // dependency failed type check } - @Test - public void testMisleadingNPEbyAPIusage() { + @ParameterizedTest + @MethodSource("params") + void misleadingNPEbyAPIusage(boolean useExecModelCompiler) { + init(useExecModelCompiler); // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"), ks.getResources().newClassPathResource("simple-item-def.dmn", this.getClass())); @@ -215,8 +233,10 @@ public void testMisleadingNPEbyAPIusage() { } } - @Test - public void testSqrtString() { + @ParameterizedTest + @MethodSource("params") + void sqrtString(boolean useExecModelCompiler) { + init(useExecModelCompiler); // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"), ks.getResources().newClassPathResource("notypecheck/sqrtstring.dmn", this.getClass())); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNStronglyTypedSupportTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNStronglyTypedSupportTest.java index bb9ab591bd6..80232261665 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNStronglyTypedSupportTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNStronglyTypedSupportTest.java @@ -29,10 +29,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -56,17 +58,14 @@ /* These are duplicated test that are run against the Typesafe DMN, see https://issues.redhat.com/browse/DROOLS-5061 */ public class DMNStronglyTypedSupportTest extends BaseVariantTest { - public DMNStronglyTypedSupportTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{KIE_API_TYPECHECK, BUILDER_DEFAULT_NOCL_TYPECHECK, BUILDER_DEFAULT_NOCL_TYPECHECK_TYPESAFE, KIE_API_TYPECHECK_TYPESAFE}; } - @Test - public void testDMNInputDataNodeTypeTest() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void dmnInputDataNodeTypeTest(VariantTestConf conf) { + testConfig = conf; // DROOLS-1569 final DMNRuntime runtime = createRuntime("DMNInputDataNodeTypeTest.dmn", this.getClass()); final String MODEL_NAMESPACE = "http://www.trisotech.com/definitions/_17396034-163a-48aa-9a7f-c6eb17f9cc6c"; @@ -106,8 +105,10 @@ public void testDMNInputDataNodeTypeTest() { assertThat(idnCarDamageResponsibility.getType().isComposite()).isTrue(); } - @Test - public void testDateAndTime() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void dateAndTime(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("0007-date-time.dmn", getClass()); runtime.addListener(DMNRuntimeUtil.createListener()); @@ -190,8 +191,10 @@ public void testDateAndTime() { } } - @Test - public void testTimeFunction() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void timeFunction(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("TimeFromDate.dmn", getClass()); runtime.addListener(DMNRuntimeUtil.createListener()); @@ -211,8 +214,10 @@ public void testTimeFunction() { } } - @Test - public void testSO58507157() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void so58507157(VariantTestConf conf) { + testConfig = conf; // DROOLS-4679 DMN FEEL list contains() invocation from DMN layer fixes final DMNRuntime runtime = createRuntime("so58507157.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://sample.dmn", "DecisionNumberInList"); @@ -243,8 +248,10 @@ public void testSO58507157() { } } - @Test - public void testDTinputExprCollectionWithAllowedValuesA() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void dTinputExprCollectionWithAllowedValuesA(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("DROOLS-4379.dmn", this.getClass()); // DROOLS-4379 DMN decision table input expr collection with allowedValues final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_95436b7a-7268-4713-bf84-58bff10407b4", "Dessin 1"); @@ -268,9 +275,12 @@ public void testDTinputExprCollectionWithAllowedValuesA() { } } - @Test(timeout = 30_000L) - @Ignore("This shouldn't be supported by Typesafe DMN") - public void testAccessorCache() { + @ParameterizedTest(name = "{0}") + @Timeout(value = 30_000L, unit = TimeUnit.MILLISECONDS) + @Disabled("This shouldn't be supported by Typesafe DMN") + @MethodSource("params") + public void accessorCache(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("20180731-pr1997.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_7a39d775-bce9-45e3-aa3b-147d6f0028c7", "20180731-pr1997"); assertThat(dmnModel).isNotNull(); @@ -288,9 +298,11 @@ public void testAccessorCache() { } } - @Test - @Ignore("This test has a different assertion as the output is typesafe") - public void testNotWithPredicates20180601b() { + @ParameterizedTest(name = "{0}") + @Disabled("This test has a different assertion as the output is typesafe") + @MethodSource("params") + public void notWithPredicates20180601b(VariantTestConf conf) { + testConfig = conf; // DROOLS-2605 final DMNRuntime runtime = createRuntime("BruceTask20180601.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_3802fcb2-5b93-4502-aff4-0f5c61244eab", "Bruce Task"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTwoValueLogicTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTwoValueLogicTest.java index 6069727f5f4..77527ec8405 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTwoValueLogicTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTwoValueLogicTest.java @@ -18,19 +18,22 @@ */ package org.kie.dmn.core; -import org.junit.BeforeClass; -import org.junit.Test; -import org.kie.dmn.api.core.*; +import java.math.BigDecimal; +import java.math.MathContext; +import java.util.List; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.core.DMNContext; +import org.kie.dmn.api.core.DMNModel; +import org.kie.dmn.api.core.DMNResult; +import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.api.DMNFactory; import org.kie.dmn.core.util.DMNRuntimeUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.math.BigDecimal; -import java.math.MathContext; -import java.util.Arrays; -import java.util.List; - import static org.assertj.core.api.Assertions.assertThat; /** @@ -46,14 +49,10 @@ public class DMNTwoValueLogicTest extends BaseInterpretedVsCompiledTest { private static DMNContext context; private static DMNModel dmnModel; - public DMNTwoValueLogicTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - public static final Logger LOG = LoggerFactory.getLogger(DMNTwoValueLogicTest.class); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Two-Value Logic Tests.dmn", DMNTwoValueLogicTest.class, "/libs/Two-Value Logic.dmn"); @@ -74,53 +73,73 @@ private void runTest(String decisionName, Object expected) { assertThat(result.get(decisionName)).isEqualTo(expected); } - @Test - public void testFunctionAll() { + @ParameterizedTest + @MethodSource("params") + void functionAll(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test all", Boolean.TRUE); } - @Test - public void testFunctionAny() { + @ParameterizedTest + @MethodSource("params") + void functionAny(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test any", Boolean.TRUE); } - @Test - public void testFunctionSum() { + @ParameterizedTest + @MethodSource("params") + void functionSum(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test sum", new BigDecimal(6, MathContext.DECIMAL128 )); } - @Test - public void testFunctionMean() { + @ParameterizedTest + @MethodSource("params") + void functionMean(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test mean", new BigDecimal(20, MathContext.DECIMAL128 )); } - @Test - public void testFunctionCount() { + @ParameterizedTest + @MethodSource("params") + void functionCount(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test count", new BigDecimal(3, MathContext.DECIMAL128 )); } - @Test - public void testFunctionMax() { + @ParameterizedTest + @MethodSource("params") + void functionMax(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test max", new BigDecimal(30, MathContext.DECIMAL128 )); } - @Test - public void testFunctionMin() { + @ParameterizedTest + @MethodSource("params") + void functionMin(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test min", new BigDecimal(10, MathContext.DECIMAL128 )); } - @Test - public void testFunctionMedian() { + @ParameterizedTest + @MethodSource("params") + void functionMedian(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test median", new BigDecimal(20, MathContext.DECIMAL128 )); } - @Test - public void testFunctionMode() { + @ParameterizedTest + @MethodSource("params") + void functionMode(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test mode", List.of(new BigDecimal(20, MathContext.DECIMAL128))); } - @Test - public void testFunctionStddev() { + @ParameterizedTest + @MethodSource("params") + void functionStddev(boolean useExecModelCompiler) { + init(useExecModelCompiler); runTest("Test stddev", new BigDecimal("8.164965809277260327324280249019638", MathContext.DECIMAL128 ) ); } } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java index 47d0c68b0f6..6e6ec5b8ba7 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java @@ -18,7 +18,12 @@ */ package org.kie.dmn.core; -import org.junit.Test; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNType; import org.kie.dmn.core.compiler.DMNTypeRegistry; import org.kie.dmn.core.compiler.DMNTypeRegistryV15; @@ -29,23 +34,18 @@ import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.core.util.DynamicTypeUtils.entry; import static org.kie.dmn.core.util.DynamicTypeUtils.prototype; -public class DMNTypeTest { +class DMNTypeTest { private static final DMNTypeRegistry typeRegistry = new DMNTypeRegistryV15(Collections.emptyMap()); private static final DMNType FEEL_STRING = typeRegistry.resolveType(KieDMNModelInstrumentedBase.URI_FEEL, "string"); private static final DMNType FEEL_NUMBER = typeRegistry.resolveType(KieDMNModelInstrumentedBase.URI_FEEL, "number"); @Test - public void testDROOLS2147() { + void drools2147() { // DROOLS-2147 final String testNS = "testDROOLS2147"; @@ -89,7 +89,7 @@ public void testDROOLS2147() { } @Test - public void testAllowedValuesForASimpleTypeCollection() { + void allowedValuesForASimpleTypeCollection() { // DROOLS-2357 final String testNS = "testDROOLS2357"; @@ -107,7 +107,7 @@ public void testAllowedValuesForASimpleTypeCollection() { } @Test - public void testTypeConstraintForASimpleTypeCollection() { + void typeConstraintForASimpleTypeCollection() { // incubator-kie-issues#926 final String testNS = "testINCUBATORKIEISSUES926"; diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNUpdateTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNUpdateTest.java index 78bc32e7143..ebcb2f114a3 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNUpdateTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNUpdateTest.java @@ -25,7 +25,8 @@ import org.drools.compiler.kie.builder.impl.KieContainerImpl; import org.drools.compiler.kie.builder.impl.KieModuleKieProject; import org.drools.compiler.kie.builder.impl.KieProject; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; @@ -51,13 +52,11 @@ public class DMNUpdateTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(DMNUpdateTest.class); - - public DMNUpdateTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testRemoveAndAddSomething() { + + @ParameterizedTest + @MethodSource("params") + void removeAndAddSomething(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "dmn-test", "1.0.0"); @@ -89,8 +88,10 @@ public void testRemoveAndAddSomething() { assertThat(evaluateAll2.getDecisionResultByName("Greeting Message").getResult()).isEqualTo("Salve John Doe"); } - @Test - public void testReplace() { + @ParameterizedTest + @MethodSource("params") + void replace(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "dmn-test", "1.0.0"); @@ -124,8 +125,10 @@ public void testReplace() { assertThat(evaluateAll2.getDecisionResultByName("Greeting Message").getResult()).isEqualTo("Salve John Doe"); } - @Test - public void testReplaceDisposeCreateReplace() { + @ParameterizedTest + @MethodSource("params") + void replaceDisposeCreateReplace(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final ReleaseId v100 = ks.newReleaseId("org.kie", "dmn-test", "1.0.0"); @@ -181,8 +184,10 @@ public void testReplaceDisposeCreateReplace() { assertThat(evaluateAll4.getDecisionResultByName("Greeting Message").getResult()).isEqualTo("Salve John Doe"); } - @Test - public void testFromClonedKiePackage() { + @ParameterizedTest + @MethodSource("params") + void fromClonedKiePackage(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final ReleaseId v100 = ks.newReleaseId("org.kie", "dmn-test", "1.0.0"); @@ -205,8 +210,10 @@ public void testFromClonedKiePackage() { assertThat(runtime.getModels()).hasSize(1); } - @Test - public void testFromClonedKiePackageThenUpgrade() { + @ParameterizedTest + @MethodSource("params") + void fromClonedKiePackageThenUpgrade(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final ReleaseId v100 = ks.newReleaseId("org.kie", "dmn-test", "1.0.0"); @@ -243,8 +250,9 @@ public void testFromClonedKiePackageThenUpgrade() { assertThat(runtime.getModels()).hasSize(1); } - @Test - public void testKieMarshaller() throws Exception { + @ParameterizedTest + @MethodSource("params") + void kieMarshaller() throws Exception { final KieServices ks = KieServices.Factory.get(); final ReleaseId v100 = ks.newReleaseId("org.kie", "dmn-test", "1.0.0"); @@ -277,8 +285,9 @@ public void testKieMarshaller() throws Exception { check0001_input_data_string(runtime); } - @Test - public void test_as_kie_wb_common_services_backend_Builder() throws Exception { + @ParameterizedTest + @MethodSource("params") + void as_kie_wb_common_services_backend_builder() throws Exception { final KieServices ks = KieServices.Factory.get(); final ReleaseId v100 = ks.newReleaseId("org.kie", "dmn-test", "1.0.0"); @@ -313,8 +322,9 @@ private void check0001_input_data_string(final DMNRuntime runtime) { assertThat(evaluateAll.getDecisionResultByName("Greeting Message").getResult()).isEqualTo("Hello John Doe"); } - @Test - public void test_as_kie_wb_common_services_backend_Builder2() throws Exception { + @ParameterizedTest + @MethodSource("params") + void as_kie_wb_common_services_backend_builder2() throws Exception { final KieServices ks = KieServices.Factory.get(); final ReleaseId v100 = ks.newReleaseId("org.kie", "dmn-test", "1.0.0"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/FlightRebookingTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/FlightRebookingTest.java index 2b3d8ac51b1..f68c35f8d10 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/FlightRebookingTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/FlightRebookingTest.java @@ -25,7 +25,9 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNDecisionResult; import org.kie.dmn.api.core.DMNModel; @@ -37,13 +39,11 @@ import static org.assertj.core.api.Assertions.assertThat; public class FlightRebookingTest extends BaseInterpretedVsCompiledTest { - - public FlightRebookingTest(final boolean useExecModelCompiler ) { - super( useExecModelCompiler ); - } - - @Test - public void testSolution1() { + + @ParameterizedTest + @MethodSource("params") + void solution1(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn", "0019-flight-rebooking" ); assertThat(dmnModel).isNotNull(); @@ -64,8 +64,10 @@ public void testSolution1() { assertThat(result.get( "Rebooked Passengers")).isEqualTo(loadExpectedResult()); } - @Test - public void testSolutionAlternate() { + @ParameterizedTest + @MethodSource("params") + void solutionAlternate(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking-alternative.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn", "0019-flight-rebooking" ); assertThat(dmnModel).isNotNull(); @@ -86,8 +88,10 @@ public void testSolutionAlternate() { assertThat(result.get( "Rebooked Passengers")).isEqualTo(loadExpectedResult()); } - @Test - public void testSolutionSingletonLists() { + @ParameterizedTest + @MethodSource("params") + void solutionSingletonLists(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking-singleton-lists.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn", "0019-flight-rebooking" ); assertThat(dmnModel).isNotNull(); @@ -108,8 +112,10 @@ public void testSolutionSingletonLists() { assertThat(result.get("Rebooked Passengers")).isEqualTo(loadExpectedResult()); } - @Test - public void testSolutionBadExample() { + @ParameterizedTest + @MethodSource("params") + void solutionBadExample(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking-bad-example.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn", "0019-flight-rebooking" ); assertThat(dmnModel).isNotNull(); @@ -130,8 +136,10 @@ public void testSolutionBadExample() { assertThat(result.get( "Rebooked Passengers")).isEqualTo(loadExpectedResult()); } - @Test - public void testUninterpreted() { + @ParameterizedTest + @MethodSource("params") + void uninterpreted(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking-uninterpreted.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_188d6caf-a355-49b5-a692-bd6ce713da08", "0019-flight-rebooking" ); runtime.addListener( DMNRuntimeUtil.createListener() ); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/OnlineDatingTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/OnlineDatingTest.java index 476ef924eed..1d1424f7d78 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/OnlineDatingTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/OnlineDatingTest.java @@ -25,7 +25,8 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -34,12 +35,10 @@ public class OnlineDatingTest extends BaseInterpretedVsCompiledTest { - public OnlineDatingTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testDMChallengeMarch2017() { + @ParameterizedTest + @MethodSource("params") + void dMChallengeMarch2017(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("dmcommunity_challenge_2017_03.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_1b5a3a8f-ccf0-459b-8783-38601977e828", diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/VacationDaysTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/VacationDaysTest.java index a00637c17ef..9b1569c6de3 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/VacationDaysTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/VacationDaysTest.java @@ -20,7 +20,9 @@ import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -31,43 +33,53 @@ import static org.assertj.core.api.Assertions.assertThat; public class VacationDaysTest extends BaseInterpretedVsCompiledTest { - - public VacationDaysTest(final boolean useExecModelCompiler ) { - super( useExecModelCompiler ); - } - - @Test - public void testSolutionCase1() { + + @ParameterizedTest + @MethodSource("params") + void solutionCase1(boolean useExecModelCompiler) { + init(useExecModelCompiler); executeTest( 16, 1, 27 ); } - @Test - public void testSolutionCase2() { + @ParameterizedTest + @MethodSource("params") + void solutionCase2(boolean useExecModelCompiler) { + init(useExecModelCompiler); executeTest( 25, 5, 22 ); } - @Test - public void testSolutionCase3() { + @ParameterizedTest + @MethodSource("params") + void solutionCase3(boolean useExecModelCompiler) { + init(useExecModelCompiler); executeTest( 44, 20, 24 ); } - @Test - public void testSolutionCase4() { + @ParameterizedTest + @MethodSource("params") + void solutionCase4(boolean useExecModelCompiler) { + init(useExecModelCompiler); executeTest( 44, 30, 30 ); } - @Test - public void testSolutionCase5() { + @ParameterizedTest + @MethodSource("params") + void solutionCase5(boolean useExecModelCompiler) { + init(useExecModelCompiler); executeTest( 50, 20, 24 ); } - @Test - public void testSolutionCase6() { + @ParameterizedTest + @MethodSource("params") + void solutionCase6(boolean useExecModelCompiler) { + init(useExecModelCompiler); executeTest( 50, 30, 30 ); } - @Test - public void testSolutionCase7() { + @ParameterizedTest + @MethodSource("params") + void solutionCase7(boolean useExecModelCompiler) { + init(useExecModelCompiler); executeTest( 60, 20, 30 ); } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/WBCommonServicesBackendTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/WBCommonServicesBackendTest.java index 5f04bca3e72..22694fb61c5 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/WBCommonServicesBackendTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/WBCommonServicesBackendTest.java @@ -25,7 +25,9 @@ import org.drools.compiler.kie.builder.impl.KieContainerImpl; import org.drools.compiler.kie.builder.impl.KieModuleKieProject; import org.drools.compiler.kie.builder.impl.KieProject; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; import org.kie.api.builder.ReleaseId; @@ -49,12 +51,10 @@ public class WBCommonServicesBackendTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(WBCommonServicesBackendTest.class); - public WBCommonServicesBackendTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testAsKieWbCommonServicesBackendBuilder() throws Exception { + @ParameterizedTest + @MethodSource("params") + void asKieWbCommonServicesBackendBuilder(boolean useExecModelCompiler) throws Exception { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final ReleaseId v100 = ks.newReleaseId("org.kie", "dmn-test", "1.0.0"); @@ -95,9 +95,11 @@ private void checkApp(DMNRuntime runtime) { final DMNContext result = dmnResult.getContext(); assertThat(result.get("the shortest distance")).isEqualTo(new BigDecimal("5")); } - - @Test - public void testProfileWithKieWbCommonServicesBackendBuilder() throws Exception { + + @ParameterizedTest + @MethodSource("params") + void profileWithKieWbCommonServicesBackendBuilder(boolean useExecModelCompiler) throws Exception { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final ReleaseId v100 = ks.newReleaseId("org.kie", "dmn-test-"+UUID.randomUUID(), "1.0.0"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/alphanetwork/AlphaNetworkSupportInLargeDecisionTableTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/alphanetwork/AlphaNetworkSupportInLargeDecisionTableTest.java index 258c7b04e52..7514d335e70 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/alphanetwork/AlphaNetworkSupportInLargeDecisionTableTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/alphanetwork/AlphaNetworkSupportInLargeDecisionTableTest.java @@ -22,9 +22,8 @@ import java.math.BigDecimal; import java.util.UUID; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -42,22 +41,22 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.core.classloader.DMNClassloaderTest.getPom; -@RunWith(Parameterized.class) public class AlphaNetworkSupportInLargeDecisionTableTest { - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{true, false}; } - private final boolean useAlphaNetwork; + private boolean useAlphaNetwork; - public AlphaNetworkSupportInLargeDecisionTableTest(final boolean useAlphaNetwork) { + public void initAlphaNetworkSupportInLargeDecisionTableTest(final boolean useAlphaNetwork) { this.useAlphaNetwork = useAlphaNetwork; } - @Test - public void evaluateDecisionTable() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void evaluateDecisionTable(final boolean useAlphaNetwork) { + initAlphaNetworkSupportInLargeDecisionTableTest(useAlphaNetwork); System.setProperty(AlphaNetworkOption.PROPERTY_NAME, Boolean.toString(useAlphaNetwork)); KieServices kieServices = KieServices.get(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/alphanetwork/DMNDecisionTableAlphaSupportingTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/alphanetwork/DMNDecisionTableAlphaSupportingTest.java index 9e26402a705..0f97add5549 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/alphanetwork/DMNDecisionTableAlphaSupportingTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/alphanetwork/DMNDecisionTableAlphaSupportingTest.java @@ -19,8 +19,13 @@ package org.kie.dmn.core.alphanetwork; import java.math.BigDecimal; +import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -36,12 +41,10 @@ public class DMNDecisionTableAlphaSupportingTest extends BaseInterpretedVsAlphaN private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(DMNDecisionTableAlphaSupportingTest.class); - public DMNDecisionTableAlphaSupportingTest(final boolean useAlphaNetwork ) { - super( useAlphaNetwork ); - } - - @Test - public void testSimpleDecision() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecision(boolean useAlphaNetwork) { + alphaNetwork = useAlphaNetwork; DMNRuntime runtime = DMNRuntimeUtil.createRuntime("alphasupport.dmn", this.getClass()); DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_c0cf6e20-0b43-43ce-9def-c759a5f86df2", "DMN Specification Chapter 11 Example Reduced"); assertThat(dmnModel).isNotNull(); @@ -54,8 +57,10 @@ public void testSimpleDecision() { assertThat(dmnResult.getContext().get("Pre-bureau risk category table")).isEqualTo("LOW"); } - @Test - public void testSimpleTableMultipleTests() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleTableMultipleTests(boolean useAlphaNetwork) { + alphaNetwork = useAlphaNetwork; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("an-simpletable-multipletests.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "an-simpletable-multipletests"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/ast/DMNContextEvaluatorTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/ast/DMNContextEvaluatorTest.java index a7183d95c05..4b8ac9d25df 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/ast/DMNContextEvaluatorTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/ast/DMNContextEvaluatorTest.java @@ -5,7 +5,7 @@ import java.util.stream.Collectors; import org.drools.util.FileUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; @@ -19,15 +19,15 @@ import org.kie.dmn.core.util.DMNRuntimeUtil; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -public class DMNContextEvaluatorTest { +class DMNContextEvaluatorTest { private DMNResultImplFactory dmnResultFactory = new DMNResultImplFactory(); @Test - public void dateToDateTime() { + void dateToDateTime() { File file = FileUtils.getFile("0007-date-time.dmn"); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime(file); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_69430b3e-17b8-430d-b760-c505bf6469f9", "dateTime Table 58"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNClassloaderTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNClassloaderTest.java index f9a88dc7884..e2b599455c2 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNClassloaderTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNClassloaderTest.java @@ -22,7 +22,8 @@ import java.util.Arrays; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -43,12 +44,10 @@ public class DMNClassloaderTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(DMNClassloaderTest.class); - public DMNClassloaderTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testClassloaderFunctionInvocation() { + @ParameterizedTest + @MethodSource("params") + void classloaderFunctionInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final String javaSource = "package com.acme.functions;\n" + "\n" + "import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;\n" + @@ -127,8 +126,10 @@ public static String getPom(final ReleaseId releaseId, final ReleaseId... depend return pom.toString(); } - @Test - public void testInvokeJavaReturnArrayPrimitives() { + @ParameterizedTest + @MethodSource("params") + void invokeJavaReturnArrayPrimitives(boolean useExecModelCompiler) { + init(useExecModelCompiler); final String javaSource = "package org.acme.functions;\n" + "\n" + "public class MyFunctions {\n" + diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNEvalHelperAccessorCacheTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNEvalHelperAccessorCacheTest.java index b9211467954..5a69d987ca9 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNEvalHelperAccessorCacheTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNEvalHelperAccessorCacheTest.java @@ -20,7 +20,8 @@ import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -42,12 +43,11 @@ public class DMNEvalHelperAccessorCacheTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(DMNEvalHelperAccessorCacheTest.class); - public DMNEvalHelperAccessorCacheTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - @Test - public void testClassloaderFunctionInvocation() throws Exception { + @ParameterizedTest + @MethodSource("params") + void classloaderFunctionInvocation(boolean useExecModelCompiler) throws Exception { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final KieContainer container1 = createKieContainer1(ks); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerBKMTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerBKMTest.java index 80d113bd80b..c7c02935b6d 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerBKMTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerBKMTest.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -70,7 +70,7 @@ public List getInvResults() { } @Test - public void test() { + void test() { final BKMListener listenerUT = new BKMListener(); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("sumWithBKM.dmn", this.getClass()); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerDSTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerDSTest.java index f150112e903..4e75b2325a5 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerDSTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerDSTest.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -71,7 +71,7 @@ public List> getOutputDecisionsResults() { } @Test - public void testWholeModel() { + void wholeModel() { final DSListener listenerUT = new DSListener(); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("helloDS.dmn", this.getClass()); @@ -105,7 +105,7 @@ public void testWholeModel() { } @Test - public void testDS() { + void ds() { final DSListener listenerUT = new DSListener(); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("helloDS.dmn", this.getClass()); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerPropertyTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerPropertyTest.java index a11d494c8fe..dd024582a53 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerPropertyTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerPropertyTest.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -78,7 +78,7 @@ private DMNRuntime setup() { } @Test - public void test() { + void test() { final String LISTENER_KEY = "org.kie.dmn.runtime.listeners.DMNRuntimeListenerPropertyTest"; final String LISTENER_VALUE = "com.acme.TestPropertyListener"; System.setProperty(LISTENER_KEY, LISTENER_VALUE); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerTest.java index b19fc4a85c1..e3e950ce324 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DMNRuntimeListenerTest.java @@ -25,7 +25,9 @@ import java.util.UUID; import org.drools.base.util.Drools; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -57,10 +59,6 @@ public class DMNRuntimeListenerTest extends BaseInterpretedVsCompiledTest { - public DMNRuntimeListenerTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - public static final Logger LOG = LoggerFactory.getLogger(DMNRuntimeListenerTest.class); public static final Map TEST_METADATA = new HashMap() {{ @@ -68,8 +66,10 @@ public DMNRuntimeListenerTest(final boolean useExecModelCompiler) { put("fieldName", "fieldValue"); }}; - @Test - public void testBasicListenerFromKModule() throws Exception { + @ParameterizedTest + @MethodSource("params") + void basicListenerFromKModule(boolean useExecModelCompiler) throws Exception { + init(useExecModelCompiler); final String javaSource = "package com.acme;" + "" + "public class TestListener implements org.kie.dmn.api.core.event.DMNRuntimeEventListener {\n" + @@ -85,7 +85,7 @@ public void testBasicListenerFromKModule() throws Exception { " }\n" + " }\n" + "\n" + - " public java.util.List getResults() {\n" + + " public java.util.List getResults() {;\n" + " return java.util.Collections.unmodifiableList(decisionResults);\n" + " }\n" + "}"; @@ -132,8 +132,10 @@ public void testBasicListenerFromKModule() throws Exception { assertThat(results).contains("Hello John Doe"); } - @Test - public void testListenerWithBKM() throws Exception { + @ParameterizedTest + @MethodSource("params") + void listenerWithBKM(boolean useExecModelCompiler) throws Exception { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("org/kie/dmn/core/say_for_hello.dmn", this.getClass()); TestEventListener listener = new TestEventListener(); runtime.addListener(listener); @@ -194,8 +196,10 @@ public void testListenerWithBKM() throws Exception { assertThat(((AfterEvaluateDecisionEvent) eventList.get(11)).getDecision().getName()).isEqualTo("just say"); } - @Test - public void testListenerWithDecisionService() { + @ParameterizedTest + @MethodSource("params") + void listenerWithDecisionService(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("org/kie/dmn/core/decisionservices/DecisionServiceABC.dmn", this.getClass()); TestEventListener listener = new TestEventListener(); runtime.addListener(listener); @@ -241,8 +245,10 @@ public void testListenerWithDecisionService() { assertThat(((AfterEvaluateDecisionEvent) eventList.get(5)).getDecision().getName()).isEqualTo("Invoking Decision"); } - @Test - public void testBeforeAndAfterEvaluateAllEvents() { + @ParameterizedTest + @MethodSource("params") + void beforeAndAfterEvaluateAllEvents(boolean useExecModelCompiler) { + init(useExecModelCompiler); final String modelResource = "org/kie/dmn/core/say_for_hello.dmn"; final String modelNamespace = "http://www.trisotech.com/dmn/definitions/_b6f2a9ca-a246-4f27-896a-e8ef04ea439c"; final String modelName = "say for hello"; diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DTAnnotationListenerTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DTAnnotationListenerTest.java index fb465a1a98a..bdb69ca7a64 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DTAnnotationListenerTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/classloader/DTAnnotationListenerTest.java @@ -18,15 +18,11 @@ */ package org.kie.dmn.core.classloader; -import static org.assertj.core.api.Assertions.assertThat; -import static org.kie.dmn.core.util.DynamicTypeUtils.entry; -import static org.kie.dmn.core.util.DynamicTypeUtils.mapOf; - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -42,6 +38,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.assertj.core.api.Assertions.assertThat; +import static org.kie.dmn.core.util.DynamicTypeUtils.entry; +import static org.kie.dmn.core.util.DynamicTypeUtils.mapOf; + public class DTAnnotationListenerTest { public static final Logger LOG = LoggerFactory.getLogger(DTAnnotationListenerTest.class); @@ -82,7 +82,7 @@ public List getSelectedAnns() { } @Test - public void test() { + void test() { final DTAnnotationListener listenerUT = new DTAnnotationListener(); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("license.dmn", this.getClass()); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ImportDMNResolverUtilTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ImportDMNResolverUtilTest.java index dbaec33b325..87156dc70c5 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ImportDMNResolverUtilTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ImportDMNResolverUtilTest.java @@ -26,17 +26,17 @@ import javax.xml.namespace.QName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.util.Either; import org.kie.dmn.model.api.Import; import org.kie.dmn.model.v1_1.TImport; import static org.assertj.core.api.Assertions.assertThat; -public class ImportDMNResolverUtilTest { +class ImportDMNResolverUtilTest { @Test - public void testNSonly() { + void nSonly() { final Import i = makeImport("ns1", null, null); final List available = Arrays.asList(new QName("ns1", "m1"), new QName("ns2", "m2"), @@ -47,7 +47,7 @@ public void testNSonly() { } @Test - public void testNSandModelName() { + void nSandModelName() { final Import i = makeImport("ns1", null, "m1"); final List available = Arrays.asList(new QName("ns1", "m1"), new QName("ns2", "m2"), @@ -58,7 +58,7 @@ public void testNSandModelName() { } @Test - public void testNSandModelNameWithAlias() { + void nSandModelNameWithAlias() { final Import i = makeImport("ns1", "aliased", "m1"); final List available = Arrays.asList(new QName("ns1", "m1"), new QName("ns2", "m2"), @@ -69,7 +69,7 @@ public void testNSandModelNameWithAlias() { } @Test - public void testNSnoModelNameWithAlias() { + void nSnoModelNameWithAlias() { final Import i = makeImport("ns1", "mymodel", null); final List available = Arrays.asList(new QName("ns1", "m1"), new QName("ns2", "m2"), @@ -80,7 +80,7 @@ public void testNSnoModelNameWithAlias() { } @Test - public void testNSandUnexistentModelName() { + void nSandUnexistentModelName() { final Import i = makeImport("ns1", null, "boh"); final List available = Arrays.asList(new QName("ns1", "m1"), new QName("ns2", "m2"), @@ -90,7 +90,7 @@ public void testNSandUnexistentModelName() { } @Test - public void testNSnoModelNameDefaultWithAlias2() { + void nSnoModelNameDefaultWithAlias2() { final Import i = makeImport("ns1", "boh", null); final List available = Arrays.asList(new QName("ns1", "m1"), new QName("ns2", "m2"), @@ -101,7 +101,7 @@ public void testNSnoModelNameDefaultWithAlias2() { } @Test - public void testLocateInNS() { + void locateInNS() { final Import i = makeImport("nsA", null, "m1"); final List available = Arrays.asList(new QName("nsA", "m1"), new QName("nsA", "m2"), @@ -112,7 +112,7 @@ public void testLocateInNS() { } @Test - public void testLocateInNSnoModelNameWithAlias() { + void locateInNSnoModelNameWithAlias() { final Import i = makeImport("nsA", "m1", null); final List available = Arrays.asList(new QName("nsA", "m1"), new QName("nsA", "m2"), @@ -122,7 +122,7 @@ public void testLocateInNSnoModelNameWithAlias() { } @Test - public void testLocateInNSAliased() { + void locateInNSAliased() { final Import i = makeImport("nsA", "aliased", "m1"); final List available = Arrays.asList(new QName("nsA", "m1"), new QName("nsA", "m2"), @@ -133,7 +133,7 @@ public void testLocateInNSAliased() { } @Test - public void testLocateInNSunexistent() { + void locateInNSunexistent() { final Import i = makeImport("nsA", null, "boh"); final List available = Arrays.asList(new QName("nsA", "m1"), new QName("nsA", "m2"), @@ -143,7 +143,7 @@ public void testLocateInNSunexistent() { } @Test - public void testLocateInNSnoModelNameWithAlias2() { + void locateInNSnoModelNameWithAlias2() { final Import i = makeImport("nsA", "boh", null); final List available = Arrays.asList(new QName("nsA", "m1"), new QName("nsA", "m2"), @@ -153,7 +153,7 @@ public void testLocateInNSnoModelNameWithAlias2() { } @Test - public void testLocateInNSAliasedBadScenario() { + void locateInNSAliasedBadScenario() { // this is a BAD scenario are in namespace `nsA` there are 2 models with the same name. final Import i = makeImport("nsA", "aliased", "mA"); final List available = Arrays.asList(new QName("nsA", "mA"), diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ItemDefinitionDependenciesGeneratedTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ItemDefinitionDependenciesGeneratedTest.java index ebc8f93cc55..2d3d258fa6f 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ItemDefinitionDependenciesGeneratedTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ItemDefinitionDependenciesGeneratedTest.java @@ -27,9 +27,8 @@ import javax.xml.namespace.QName; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.model.api.ItemDefinition; import org.kie.dmn.model.v1_1.TItemDefinition; import org.slf4j.Logger; @@ -37,7 +36,6 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class ItemDefinitionDependenciesGeneratedTest { private final Logger logger = LoggerFactory.getLogger(ItemDefinitionDependenciesGeneratedTest.class); @@ -46,11 +44,8 @@ public class ItemDefinitionDependenciesGeneratedTest { private static final int LEVELS_OF_DEPENDENCIES = 3; private static final String ITEM_DEFINITION_NAME_BASE = "ItemDefinition"; private static final String TEST_NS = "https://www.drools.org/"; - - @Parameterized.Parameter public static List itemDefinitions; - @Parameterized.Parameters public static Collection> generateParameters() { final List baseItemDefinitions = getBaseListOfItemDefinitions(1); @@ -181,8 +176,10 @@ private List orderingStrategy(final List ins) { return new ItemDefinitionDependenciesSorter(TEST_NS).sort(ins); } - @Test - public void testOrdering() { + @MethodSource("generateParameters") + @ParameterizedTest + public void ordering(List itemDefinitions) { + initItemDefinitionDependenciesGeneratedTest(itemDefinitions); logger.trace("Item definitions:"); itemDefinitions.forEach(itemDefinition -> { logger.trace(itemDefinition.getName()); @@ -217,4 +214,8 @@ private int indexOfItemDefinitionByName(final String name, final List itemDefinitions) { + this.itemDefinitions = itemDefinitions; + } } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ItemDefinitionDependenciesTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ItemDefinitionDependenciesTest.java index 4123beab6c0..a7a63efc433 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ItemDefinitionDependenciesTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/ItemDefinitionDependenciesTest.java @@ -23,14 +23,14 @@ import javax.xml.namespace.QName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.model.api.ItemDefinition; import org.kie.dmn.model.v1_1.TItemDefinition; import static org.assertj.core.api.Assertions.assertThat; -public class ItemDefinitionDependenciesTest { +class ItemDefinitionDependenciesTest { private static final String TEST_NS = "https://www.drools.org/"; @@ -53,9 +53,9 @@ private void addComponent(ItemDefinition i, String componentName) { private List orderingStrategy(final List ins) { return new ItemDefinitionDependenciesSorter(TEST_NS).sort(ins); } - + @Test - public void testGeneric() { + void generic() { final ItemDefinition a = build("a"); final ItemDefinition b = build("b"); @@ -71,9 +71,9 @@ public void testGeneric() { assertThat(orderedList.subList(0, 2)).contains(a,b); assertThat(orderedList.subList(2, 4)).contains(c,d); } - + @Test - public void testGeneric2() { + void generic2() { final ItemDefinition z = build("z"); final ItemDefinition b = build("b"); @@ -86,9 +86,9 @@ public void testGeneric2() { assertThat(orderedList.indexOf(z) < orderedList.indexOf(a)).as("Index of z < a").isTrue(); } - + @Test - public void testOrdering1() { + void ordering1() { final ItemDefinition tCollateralRiskCategory = build("tCollateralRiskCategory"); final ItemDefinition tCreditRiskCategory = build("tCreditRiskCategory"); final ItemDefinition tAffordabilityCategory = build("tAffordabilityCategory"); @@ -120,9 +120,9 @@ public void testOrdering1() { assertThat(orderedList.indexOf(tAge) < orderedList.indexOf(tBorrowe)).as("Index of tAge < tBorrowe").isTrue(); assertThat(orderedList.indexOf(temploementStatus) < orderedList.indexOf(tBorrowe)).as("Index of temploementStatus < tBorrowe").isTrue(); } - + @Test - public void testOrdering2() { + void ordering2() { final ItemDefinition tMortgageType = build("tMortgageType"); final ItemDefinition tObjective = build("tObjective"); final ItemDefinition tRequested = build("tRequested", tMortgageType, tObjective); @@ -149,9 +149,9 @@ public void testOrdering2() { assertThat(orderedList.indexOf(tMortgageType) < orderedList.indexOf(tLoanTypes)).as("Index of tMortgageType < tLoanTypes").isTrue(); assertThat(orderedList.indexOf(tConformanceType) < orderedList.indexOf(tLoanTypes)).as("Index of tConformanceType < tLoanTypes").isTrue(); } - + @Test - public void testOrdering3() { + void ordering3() { final ItemDefinition tNumberList = build("tNumberList"); final ItemDefinition tTax = build("tTax"); final ItemDefinition tStateModel = build("tStateModel"); @@ -180,7 +180,7 @@ public void testOrdering3() { } @Test - public void testOrdering4() { + void ordering4() { final ItemDefinition _TypeDecisionA1 = build("TypeDecisionA1"); final ItemDefinition _TypeDecisionA2_x = build("TypeDecisionA2.x", _TypeDecisionA1); final ItemDefinition _TypeDecisionA3 = build("TypeDecisionA3", _TypeDecisionA2_x); @@ -212,7 +212,7 @@ public void testOrdering4() { } @Test - public void testCircular3() { + void circular3() { final ItemDefinition fhirAge = build("fhirAge"); addComponent(fhirAge, "fhirExtension"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/UnnamedImportUtilsTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/UnnamedImportUtilsTest.java index 2f317557a5b..a0cf0258884 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/UnnamedImportUtilsTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/UnnamedImportUtilsTest.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.backend.marshalling.v1x.DMNMarshallerFactory; @@ -17,28 +17,28 @@ import org.kie.dmn.model.api.NamedElement; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.kie.dmn.core.compiler.UnnamedImportUtils.addIfNotPresent; import static org.kie.dmn.core.compiler.UnnamedImportUtils.isInUnnamedImport; -public class UnnamedImportUtilsTest { +class UnnamedImportUtilsTest { @Test - public void isInUnnamedImportTrueWithHrefNamespace() { + void isInUnnamedImportTrueWithHrefNamespace() { commonIsInUnnamedImportTrue("valid_models/DMNv1_5/Importing_EmptyNamed_Model_With_Href_Namespace.dmn", "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"); } @Test - public void isInUnnamedImportTrueWithoutHrefNamespace() { + void isInUnnamedImportTrueWithoutHrefNamespace() { commonIsInUnnamedImportTrue("valid_models/DMNv1_5/Importing_EmptyNamed_Model_Without_Href_Namespace.dmn", "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"); } @Test - public void isInUnnamedImportFalse() { + void isInUnnamedImportFalse() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("valid_models/DMNv1_5/Importing_Named_Model.dmn", this.getClass(), "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"); @@ -57,7 +57,7 @@ public void isInUnnamedImportFalse() { } @Test - public void addIfNotPresentTrue() throws IOException { + void addIfNotPresentTrue() throws IOException { URL importedModelFileResource = Thread.currentThread().getContextClassLoader().getResource( "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"); assertNotNull(importedModelFileResource); @@ -73,13 +73,13 @@ public void addIfNotPresentTrue() throws IOException { } @Test - public void addIfNotPresentFalseWithHrefNamespace() throws IOException { + void addIfNotPresentFalseWithHrefNamespace() throws IOException { commonAddIfNotPresentFalse("valid_models/DMNv1_5/Importing_EmptyNamed_Model_With_Href_Namespace.dmn", "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"); } @Test - public void addIfNotPresentFalseWithoutHrefNamespace() throws IOException { + void addIfNotPresentFalseWithoutHrefNamespace() throws IOException { commonAddIfNotPresentFalse("valid_models/DMNv1_5/Importing_EmptyNamed_Model_Without_Href_Namespace.dmn", "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"); } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/extensions/DMNExtensionRegisterTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/extensions/DMNExtensionRegisterTest.java index c25ab09234b..05e7e65b2bd 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/extensions/DMNExtensionRegisterTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/extensions/DMNExtensionRegisterTest.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -40,11 +40,11 @@ import static org.assertj.core.api.Assertions.assertThat; -public class DMNExtensionRegisterTest { +class DMNExtensionRegisterTest { private static final Logger LOG = LoggerFactory.getLogger(DMNExtensionRegisterTest.class); @Test - public void testUsingSystemProperty() { + void usingSystemProperty() { try { System.setProperty("org.kie.dmn.profiles.FirstNameLastNameProfile", FirstNameLastNameProfile.class.getCanonicalName()); assertThat(System.getProperty("org.kie.dmn.profiles.FirstNameLastNameProfile")).isEqualTo(FirstNameLastNameProfile.class.getCanonicalName()); @@ -81,7 +81,7 @@ public void testUsingSystemProperty() { } @Test - public void testUsingKModuleProperty() { + void usingKModuleProperty() { final KieServices ks = KieServices.Factory.get(); final KieFileSystem kfs = ks.newKieFileSystem(); @@ -126,7 +126,7 @@ public void testUsingKModuleProperty() { } @Test - public void testUsingKModuleProperty_WrongClasses() { + void usingKModulePropertyWrongClasses() { final KieServices ks = KieServices.Factory.get(); final KieFileSystem kfs = ks.newKieFileSystem(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/profiles/DMNProfilesTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/profiles/DMNProfilesTest.java index 63717eb85e4..cf4d25cec53 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/profiles/DMNProfilesTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/profiles/DMNProfilesTest.java @@ -20,7 +20,8 @@ import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -43,12 +44,10 @@ public class DMNProfilesTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(DMNProfilesTest.class); - public DMNProfilesTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testJust47() { + @ParameterizedTest + @MethodSource("params") + void just47(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final KieFileSystem kfs = ks.newKieFileSystem(); @@ -79,8 +78,10 @@ public void testJust47() { assertThat(result.get("decision result")).isEqualTo(new BigDecimal(47)); } - @Test - public void testCustomModelCount() { + @ParameterizedTest + @MethodSource("params") + void customModelCount(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final KieFileSystem kfs = ks.newKieFileSystem(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/profiles/ExtendedDMNProfileTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/profiles/ExtendedDMNProfileTest.java index 1002cf1bdd8..62f84cfc623 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/profiles/ExtendedDMNProfileTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/profiles/ExtendedDMNProfileTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.functions.AbsFunction; import org.kie.dmn.feel.runtime.functions.EvenFunction; import org.kie.dmn.feel.runtime.functions.ExpFunction; @@ -46,7 +46,7 @@ import static java.math.BigDecimal.valueOf; import static org.assertj.core.api.Assertions.assertThat; -public class ExtendedDMNProfileTest { +class ExtendedDMNProfileTest { private final DateFunction dateFunction = DateFunction.INSTANCE; private final TimeFunction timeFunction = TimeFunction.INSTANCE; private final SplitFunction splitFunction = SplitFunction.INSTANCE; @@ -63,101 +63,101 @@ public class ExtendedDMNProfileTest { private final OddFunction oddFunction = OddFunction.INSTANCE; @Test - public void testDateFunction_invokeParamStringDateTime() { + void dateFunctionInvokeParamStringDateTime() { assertResult(dateFunction.invoke("2017-09-07T10:20:30"), LocalDate.of(2017, 9, 7)); } @Test - public void testDateFunction_invokeExtended() { + void dateFunctionInvokeExtended() { assertResult(dateFunction.invoke("2016-12-20T14:30:22"), DateTimeFormatter.ISO_DATE.parse( "2016-12-20", LocalDate::from )); assertResult(dateFunction.invoke("2016-12-20T14:30:22-05:00"), DateTimeFormatter.ISO_DATE.parse( "2016-12-20", LocalDate::from )); assertResult(dateFunction.invoke("2016-12-20T14:30:22z"), DateTimeFormatter.ISO_DATE.parse( "2016-12-20", LocalDate::from )); } @Test - public void testTimeFunction_invokeStringParamDate() { + void timeFunctionInvokeStringParamDate() { assertResult(timeFunction.invoke("2017-10-09"), LocalTime.of(0,0,0)); assertResult(timeFunction.invoke("2017-10-09T10:15:06"), LocalTime.of(10,15,6)); } @Test - public void testTimeFunction_invokeExtended() { + void timeFunctionInvokeExtended() { assertResult(timeFunction.invoke("2016-12-20T14:30:22"), DateTimeFormatter.ISO_TIME.parse( "14:30:22", LocalTime::from )); assertResult(timeFunction.invoke("2016-12-20T14:30:22-05:00"), DateTimeFormatter.ISO_TIME.parse( "14:30:22-05:00", OffsetTime::from )); assertResult(timeFunction.invoke("2016-12-20T14:30:22z"), DateTimeFormatter.ISO_TIME.parse( "14:30:22z", OffsetTime::from )); } @Test - public void testSplitFunction() { + void splitFunction() { assertResult(splitFunction.invoke("John Doe", "\\s"), Arrays.asList("John", "Doe")); assertResult(splitFunction.invoke("a;b;c;;", ";"), Arrays.asList("a", "b", "c", "", "")); } @Test - public void testProductFunction() { + void productFunction() { assertResult(productFunction.invoke(Arrays.asList(valueOf(2), valueOf(3), valueOf(4))), valueOf(24)); } @Test - public void testMedianFunction() { + void medianFunction() { assertResult(medianFunction.invoke(new Object[]{valueOf(8), valueOf(2), valueOf(5), valueOf(3), valueOf(4)}), valueOf(4)); assertResult(medianFunction.invoke(Arrays.asList(valueOf(6), valueOf(1), valueOf(2), valueOf(3))), valueOf(2.5)); assertNull(medianFunction.invoke(new Object[]{})); } @Test - public void testStddevFunction() { + void stddevFunction() { assertResultDoublePrecision(stddevFunction.invoke(new Object[]{2, 4, 7, 5}), valueOf(2.0816659994661326)); } @Test - public void testModeFunction() { + void modeFunction() { assertResult(modeFunction.invoke(new Object[]{6, 3, 9, 6, 6}), Collections.singletonList(valueOf(6))); assertResult(modeFunction.invoke(Arrays.asList(6, 1, 9, 6, 1)), Arrays.asList(valueOf(1), valueOf(6))); assertResult(modeFunction.invoke(Collections.emptyList()), Collections.emptyList()); } @Test - public void testModuloFunction() { + void moduloFunction() { assertResult(moduloFunction.invoke(valueOf(12), valueOf(5)), valueOf(2)); } @Test - public void testSqrtFunction() { + void sqrtFunction() { assertResultDoublePrecision(sqrtFunction.invoke(valueOf(16)), valueOf(4)); assertResultDoublePrecision(sqrtFunction.invoke(valueOf(2)), valueOf(1.4142135623730951)); } @Test - public void testLogFunction() { + void logFunction() { assertResultDoublePrecision(logFunction.invoke(valueOf(10)), valueOf(2.302585092994046)); } @Test - public void testExpFunction() { + void expFunction() { assertResultDoublePrecision(expFunction.invoke(valueOf(5)), valueOf(148.4131591025766)); } @Test - public void testOddFunction() { + void oddFunction() { assertResult(oddFunction.invoke(valueOf(5)), Boolean.TRUE); assertResult(oddFunction.invoke(valueOf(2)), Boolean.FALSE); } @Test - public void testOddFunction_fractional() { + void oddFunctionFractional() { assertNull(oddFunction.invoke(valueOf(5.5))); assertResult(oddFunction.invoke(valueOf(5.0)), Boolean.TRUE); } @Test - public void testEvenFunction() { + void evenFunction() { assertResult(evenFunction.invoke(valueOf(5)), Boolean.FALSE); assertResult(evenFunction.invoke(valueOf(2)), Boolean.TRUE); } @Test - public void testEvenFunction_fractional() { + void evenFunctionFractional() { assertNull(evenFunction.invoke(valueOf(5.5))); assertResult(evenFunction.invoke(valueOf(2.0)), Boolean.TRUE); } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisionservices/DMNDecisionServicesTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisionservices/DMNDecisionServicesTest.java index e4706403be4..69be0798dd9 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisionservices/DMNDecisionServicesTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisionservices/DMNDecisionServicesTest.java @@ -21,7 +21,8 @@ import java.math.BigDecimal; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.builder.Message.Level; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; @@ -42,12 +43,10 @@ public class DMNDecisionServicesTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(DMNDecisionServicesTest.class); - public DMNDecisionServicesTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testBasic() { + @ParameterizedTest + @MethodSource("params") + void basic(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-decision-services.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -103,8 +102,10 @@ private void checkDSwithInputDecision2(final DMNRuntime runtime, final DMNModel assertThat(result.get("A")).isEqualTo("inBinC"); } - @Test - public void testDSInLiteralExpression() { + @ParameterizedTest + @MethodSource("params") + void dSInLiteralExpression(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServicesInLiteralExpression.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -123,8 +124,10 @@ public void testDSInLiteralExpression() { assertThat(result.get("Decide based on A and DS")).isEqualTo("xyde"); } - @Test - public void testDSInLiteralExpressionWithBKM() { + @ParameterizedTest + @MethodSource("params") + void dSInLiteralExpressionWithBKM(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServicesInLiteralExpressionWithBKM.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -143,8 +146,10 @@ public void testDSInLiteralExpressionWithBKM() { assertThat(result.get("Decide based on A and DS")).isEqualTo("xydemn"); } - @Test - public void testDSInLiteralExpressionWithBKMUsingInvocation() { + @ParameterizedTest + @MethodSource("params") + void dSInLiteralExpressionWithBKMUsingInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServicesInLiteralExpressionWithBKMUsingInvocation.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -163,8 +168,10 @@ public void testDSInLiteralExpressionWithBKMUsingInvocation() { assertThat(result.get("Decide based on A and DS")).isEqualTo("xydemn"); } - @Test - public void testDSInLiteralExpressionOnlyfromBKMUsingInvocation() { + @ParameterizedTest + @MethodSource("params") + void dSInLiteralExpressionOnlyfromBKMUsingInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServicesInLiteralExpressionOnlyFromBKMUsingInvocation.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -183,8 +190,10 @@ public void testDSInLiteralExpressionOnlyfromBKMUsingInvocation() { assertThat(result.get("Decide based on A and DS")).isEqualTo("demn"); } - @Test - public void testMixtypeDS() { + @ParameterizedTest + @MethodSource("params") + void mixtypeDS(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("mixtype-DS.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_c9885563-aa54-4c7b-ae8a-738cfd29b544", "mixtype DS"); assertThat(dmnModel).isNotNull(); @@ -276,8 +285,10 @@ private void testMixtypeDS_checkDSgreetadult(final DMNRuntime runtime, final DMN assertThat(result.getAll()).doesNotContainKey("hardcoded now"); } - @Test - public void testDSForTypeCheck() { + @ParameterizedTest + @MethodSource("params") + void dSForTypeCheck(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionService20180718.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_6eef3a7c-bb0d-40bb-858d-f9067789c18a", "Decision Service 20180718"); assertThat(dmnModel).isNotNull(); @@ -344,8 +355,10 @@ private void testDSForTypeCheck_runDecisionService_WithWrongTypes(final DMNRunti .as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isTrue(); } - @Test - public void testDSSingletonOrMultipleOutputDecisions() { + @ParameterizedTest + @MethodSource("params") + void dSSingletonOrMultipleOutputDecisions(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Decision-Services-singleton-or-multiple-output-decisions.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_b4ebfbf2-8608-4297-9662-be70bab01974", "Decision Services singleton or multiple output decisions"); assertThat(dmnModel).isNotNull(); @@ -383,8 +396,10 @@ public void testDSSingletonOrMultipleOutputDecisions() { assertThat(dmnResultMultiple.getContext().getAll()).doesNotContainKey("a Value"); // Decision Service will not expose (nor encapsulate hence not execute) this decision. } - @Test - public void testDSSingletonOrMultipleOutputDecisions_OVERRIDE() { + @ParameterizedTest + @MethodSource("params") + void dSSingletonOrMultipleOutputDecisionsOVERRIDE(boolean useExecModelCompiler) { + init(useExecModelCompiler); try { System.setProperty(CoerceDecisionServiceSingletonOutputOption.PROPERTY_NAME, "false"); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Decision-Services-singleton-or-multiple-output-decisions.dmn", this.getClass()); @@ -431,8 +446,10 @@ public void testDSSingletonOrMultipleOutputDecisions_OVERRIDE() { } } - @Test - public void testImportDS() { + @ParameterizedTest + @MethodSource("params") + void importDS(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2768 DMN Decision Service encapsulate Decision which imports a Decision Service final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("DecisionService20180718.dmn", this.getClass(), "ImportDecisionService20180718.dmn"); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_0ff3708a-c861-4a96-b85c-7b882f18b7a1", "Import Decision Service 20180718"); @@ -473,8 +490,10 @@ private void testImportDS_testEvaluateDS(final DMNRuntime runtime, final DMNMode assertThat(result.get("final Import L1 decision")).isEqualTo("Hello, L1 Import Evaluate DS NAME the result of invoking the imported DS is: Hello, L1 Import Evaluate DS NAME; you are allowed"); } - @Test - public void testTransitiveImportDS() { + @ParameterizedTest + @MethodSource("params") + void transitiveImportDS(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2768 DMN Decision Service encapsulate Decision which imports a Decision Service final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("DecisionService20180718.dmn", this.getClass(), "ImportDecisionService20180718.dmn", @@ -515,8 +534,10 @@ private void testTransitiveImportDS_testEvaluateDS(final DMNRuntime runtime, fin assertThat(result.get("Final L2 Decision")).isEqualTo("The result of invoking the L1 DS was: Hello, L2 Bob DS the result of invoking the imported DS is: Hello, L2 Bob DS; you are allowed"); } - @Test - public void testDecisionServiceCompiler20180830() { + @ParameterizedTest + @MethodSource("params") + void decisionServiceCompiler20180830(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2943 DMN DecisionServiceCompiler not correctly wired for DMNv1.2 format final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServiceABC.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_2443d3f5-f178-47c6-a0c9-b1fd1c933f60", "Drawing 1"); @@ -554,8 +575,10 @@ public static void testDecisionServiceCompiler20180830_testEvaluateDS(final DMNR assertThat(result.get("ABC")).isEqualTo("abc"); } - @Test - public void testDecisionService20180920() { + @ParameterizedTest + @MethodSource("params") + void decisionService20180920(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3005 DMN DecisionService having an imported requiredInput final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("DSWithImportRequiredInput20180920.dmn", this.getClass(), @@ -596,8 +619,10 @@ private static void testDecisionService20180920_testEvaluateDS(final DMNRuntime assertThat(result.get("Decision B")).isEqualTo("input 1 value"); } - @Test - public void test20190520() { + @ParameterizedTest + @MethodSource("params") + void test20190520(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DStypecheck.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6e76b9ca-ce06-426a-91c0-99b70665321a", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -611,9 +636,11 @@ public void test20190520() { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isFalse(); assertThat((Map) dmnResult.getDecisionResultByName("my invoke DS1").getResult()).containsEntry("outDS1", true); } - - @Test - public void testImportingBasic() { + + @ParameterizedTest + @MethodSource("params") + void importingBasic(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("0004-decision-services.dmn", this.getClass(), "importing0004.dmn"); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_346B2E00-71E5-4CEA-ADE1-7A0872481F38", "importing0004"); assertThat(dmnModel).isNotNull(); @@ -634,9 +661,11 @@ private void assertSupplyingBandC(final DMNRuntime runtime, final DMNModel dmnMo final DMNContext result = dmnResult.getContext(); assertThat(result.get("Decision1")).isEqualTo("inBinC"); } - - @Test - public void testImportingBoxedInvocation() { + + @ParameterizedTest + @MethodSource("params") + void importingBoxedInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("0004-decision-services.dmn", this.getClass(), "importing0004boxedInvocation.dmn"); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_346B2E00-71E5-4CEA-ADE1-7A0872481F38", "importing0004"); assertThat(dmnModel).isNotNull(); @@ -644,9 +673,11 @@ public void testImportingBoxedInvocation() { assertSupplyingBandC(runtime, dmnModel); } - - @Test - public void testImportingBkmBoxedInvocation() { + + @ParameterizedTest + @MethodSource("params") + void importingBkmBoxedInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("0004-decision-services.dmn", this.getClass(), "importing0004bkmBoxedInvocation.dmn"); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_0CA8CCDE-106B-4805-B0C1-8D8D740C80F7", "importing0004bkmBoxedInvocation"); assertThat(dmnModel).isNotNull(); @@ -654,9 +685,11 @@ public void testImportingBkmBoxedInvocation() { assertSupplyingBandC(runtime, dmnModel); } - - @Test - public void testImportingWithSameDSName() { + + @ParameterizedTest + @MethodSource("params") + void importingWithSameDSName(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("myHelloDS.dmn", this.getClass(), "importingMyHelloDS.dmn"); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_3295867F-C02D-4312-849B-844F74C51ADE", "importingMyHelloDS"); assertThat(dmnModel).isNotNull(); @@ -676,9 +709,11 @@ private void assertSupplyingPersonname(final DMNRuntime runtime, final DMNModel final DMNContext result = dmnResult.getContext(); assertThat(result.get("Decision1")).isEqualTo("Hello, John Doe"); } - - @Test - public void testImportingWithSameDSNameBoxedInvocation() { + + @ParameterizedTest + @MethodSource("params") + void importingWithSameDSNameBoxedInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("myHelloDS.dmn", this.getClass(), "importingMyHelloDSboxedInvocation.dmn"); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_3295867F-C02D-4312-849B-844F74C51ADE", "importingMyHelloDS"); assertThat(dmnModel).isNotNull(); @@ -686,9 +721,11 @@ public void testImportingWithSameDSNameBoxedInvocation() { assertSupplyingPersonname(runtime, dmnModel); } - - @Test - public void testImportingWithSameDSNameBKMBoxedInvocation() { + + @ParameterizedTest + @MethodSource("params") + void importingWithSameDSNameBKMBoxedInvocation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("myHelloDS.dmn", this.getClass(), "importingMyHelloDSbkmBoxedInvocation.dmn"); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_3295867F-C02D-4312-849B-844F74C51ADE", "importingMyHelloDS"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisionservices/DMNDecisionServicesTypecheckDSxyTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisionservices/DMNDecisionServicesTypecheckDSxyTest.java index 75359cea754..1d73b4e3de3 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisionservices/DMNDecisionServicesTypecheckDSxyTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisionservices/DMNDecisionServicesTypecheckDSxyTest.java @@ -20,10 +20,9 @@ import java.math.BigDecimal; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNDecisionResult.DecisionEvaluationStatus; import org.kie.dmn.api.core.DMNModel; @@ -40,7 +39,6 @@ import static org.kie.dmn.core.util.DynamicTypeUtils.entry; import static org.kie.dmn.core.util.DynamicTypeUtils.mapOf; -@RunWith(Parameterized.class) public class DMNDecisionServicesTypecheckDSxyTest { public static final Logger LOG = LoggerFactory.getLogger(DMNDecisionServicesTypecheckDSxyTest.class); @@ -51,23 +49,22 @@ public static interface TestEitherModelOrDS { DMNResult apply(DMNRuntime runtime, DMNModel dmnModel, DMNContext context); } - public DMNDecisionServicesTypecheckDSxyTest(final TestEitherModelOrDS variant) { + public void initDMNDecisionServicesTypecheckDSxyTest(final TestEitherModelOrDS variant) { fn = variant; } - @Parameterized.Parameters() public static Object[] params() { return new TestEitherModelOrDS[]{(runtime, dmnModel, context) -> runtime.evaluateAll(dmnModel, context), (runtime, dmnModel, context) -> runtime.evaluateDecisionService(dmnModel, context, "DecisionService-1")}; } - private final TestEitherModelOrDS fn; + private TestEitherModelOrDS fn; private DMNRuntime runtime; private DMNModel dmnModel; - @Before() - public void init() { + @BeforeEach() + void init() { runtime = DMNRuntimeUtil.createRuntime("DSxy.dmn", this.getClass()); dmnModel = runtime.getModel("https://kiegroup.org/dmn/_127520A0-364A-4ADA-A012-3AB6A7E3585E", "DSxy"); @@ -75,8 +72,10 @@ public void init() { assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); } - @Test - public void testDSParamsTConOK() { + @MethodSource("params") + @ParameterizedTest() + public void dSParamsTConOK(final TestEitherModelOrDS variant) { + initDMNDecisionServicesTypecheckDSxyTest(variant); final DMNContext context = DMNFactory.newContext(); context.set("x", mapOf(entry("x", new BigDecimal(1)), entry("y", new BigDecimal(2)))); @@ -89,9 +88,11 @@ public void testDSParamsTConOK() { assertThat(dmnResult.getDecisionResultByName("Decision-1").getEvaluationStatus()).isEqualTo(DecisionEvaluationStatus.SUCCEEDED); assertThat(dmnResult.getDecisionResultByName("Decision-1").getResult()).isEqualTo(new BigDecimal(1)); } - - @Test - public void testDSParamsTConFAIL() { + + @MethodSource("params") + @ParameterizedTest() + public void dSParamsTConFAIL(final TestEitherModelOrDS variant) { + initDMNDecisionServicesTypecheckDSxyTest(variant); final DMNContext context = DMNFactory.newContext(); context.set("x", mapOf(entry("x", new BigDecimal(1)))); @@ -103,8 +104,10 @@ public void testDSParamsTConFAIL() { assertThat(dmnResult.getDecisionResultByName("Decision-1").getEvaluationStatus()).isNotEqualTo(DecisionEvaluationStatus.SUCCEEDED); } - @Test - public void testDSParamsTCoff() { + @MethodSource("params") + @ParameterizedTest() + public void dSParamsTCoff(final TestEitherModelOrDS variant) { + initDMNDecisionServicesTypecheckDSxyTest(variant); // IMPORTANT !! ((DMNRuntimeImpl) runtime).setOption(new RuntimeTypeCheckOption(false)); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisiontable/DTListenerTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisiontable/DTListenerTest.java index a7ceecc85bc..27eb139fb87 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisiontable/DTListenerTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/decisiontable/DTListenerTest.java @@ -18,15 +18,15 @@ */ package org.kie.dmn.core.decisiontable; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import org.assertj.core.api.SoftAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -40,14 +40,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.assertj.core.api.Assertions.assertThat; + public class DTListenerTest extends BaseInterpretedVsAlphaNetworkTest { private static final String E1 = "e1"; - public DTListenerTest(boolean useAlphaNetwork) { - super(useAlphaNetwork); - } - public static final Logger LOG = LoggerFactory.getLogger(DTListenerTest.class); public static class ExampleDTListener extends DefaultDMNRuntimeEventListener { @@ -63,8 +61,10 @@ public List getEvents() { } } - @Test - public void test() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void test(boolean useAlphaNetwork) { + alphaNetwork = useAlphaNetwork; final ExampleDTListener listenerUT = new ExampleDTListener(); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("dtevent.dmn", this.getClass()); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/extra/DMNRecursionTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/extra/DMNRecursionTest.java index d29f0227ff8..32340e21e8a 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/extra/DMNRecursionTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/extra/DMNRecursionTest.java @@ -20,7 +20,8 @@ import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -36,16 +37,14 @@ public class DMNRecursionTest extends BaseInterpretedVsCompiledTest { - public DMNRecursionTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - public static final Logger LOG = LoggerFactory.getLogger(DMNRecursionTest.class); - @Test - public void testBasicRecursion() { + @ParameterizedTest + @MethodSource("params") + void basicRecursion(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("basicRecursion.dmn", this.getClass()); - runtime.addListener(new DMNRuntimeEventListener() {}); + runtime.addListener(new DMNRuntimeEventListener(){}); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_16EF6BF4-9B59-40E8-8C99-A3A3D58B88CC", "factorial"); assertThat(dmnModel).isNotNull(); assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/extra/YCombinatorTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/extra/YCombinatorTest.java index 883ca518ab4..e91c6862c2d 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/extra/YCombinatorTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/extra/YCombinatorTest.java @@ -20,7 +20,8 @@ import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -34,14 +35,12 @@ public class YCombinatorTest extends BaseInterpretedVsCompiledTest { - public YCombinatorTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - public static final Logger LOG = LoggerFactory.getLogger(YCombinatorTest.class); - @Test - public void testY() { + @ParameterizedTest + @MethodSource("params") + void y(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Y.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_2E160C58-B13A-4C35-B161-BB4B31E049B4", "new-file"); @@ -61,8 +60,10 @@ public void testY() { new BigDecimal(5)); } - @Test - public void testYboxed() { + @ParameterizedTest + @MethodSource("params") + void yboxed(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Yboxed.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_2E160C58-B13A-4C35-B161-BB4B31E049B4", "new-file"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNContextFEELCtxWrapperTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNContextFEELCtxWrapperTest.java index 9bfef517881..a0dd83951cd 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNContextFEELCtxWrapperTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNContextFEELCtxWrapperTest.java @@ -24,49 +24,57 @@ import java.util.Map; import java.util.function.Supplier; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.api.feel.runtime.events.FEELEventListener; import org.kie.dmn.core.BaseDMNContextTest; import org.kie.dmn.feel.lang.EvaluationContext; -public class DMNContextFEELCtxWrapperTest extends BaseDMNContextTest { +import static org.junit.jupiter.api.Assertions.assertThrows; + +class DMNContextFEELCtxWrapperTest extends BaseDMNContextTest { @Test - public void testEmptyContext() { + void emptyContext() { DMNContextFEELCtxWrapper ctx = new DMNContextFEELCtxWrapper(new EvaluationContextMock(Collections.emptyMap())); testCloneAndAlter(ctx, Collections.emptyMap(), Collections.emptyMap()); } @Test - public void testContextWithEntries() { + void contextWithEntries() { DMNContextFEELCtxWrapper ctx = new DMNContextFEELCtxWrapper(new EvaluationContextMock(DEFAULT_ENTRIES)); testCloneAndAlter(ctx, DEFAULT_ENTRIES, Collections.emptyMap()); } @Test - public void testContextWithEntriesAndMetadata() { + void contextWithEntriesAndMetadata() { DMNContextFEELCtxWrapper ctx = new DMNContextFEELCtxWrapper(new EvaluationContextMock(DEFAULT_ENTRIES), DEFAULT_METADATA); testCloneAndAlter(ctx, DEFAULT_ENTRIES, DEFAULT_METADATA); } - @Test(expected = UnsupportedOperationException.class) - public void testPushScopeException() { - DMNContextFEELCtxWrapper ctx = new DMNContextFEELCtxWrapper(new EvaluationContextMock(Collections.emptyMap())); - ctx.pushScope("scopeName", "scopeNamespace"); + @Test + void pushScopeException() { + assertThrows(UnsupportedOperationException.class, () -> { + DMNContextFEELCtxWrapper ctx = new DMNContextFEELCtxWrapper(new EvaluationContextMock(Collections.emptyMap())); + ctx.pushScope("scopeName", "scopeNamespace"); + }); } - @Test(expected = UnsupportedOperationException.class) - public void testPopScopeException() { - DMNContextFEELCtxWrapper ctx = new DMNContextFEELCtxWrapper(new EvaluationContextMock(Collections.emptyMap())); - ctx.popScope(); + @Test + void popScopeException() { + assertThrows(UnsupportedOperationException.class, () -> { + DMNContextFEELCtxWrapper ctx = new DMNContextFEELCtxWrapper(new EvaluationContextMock(Collections.emptyMap())); + ctx.popScope(); + }); } - @Test(expected = UnsupportedOperationException.class) - public void testScopeNamespaceException() { - DMNContextFEELCtxWrapper ctx = new DMNContextFEELCtxWrapper(new EvaluationContextMock(Collections.emptyMap())); - ctx.scopeNamespace(); + @Test + void scopeNamespaceException() { + assertThrows(UnsupportedOperationException.class, () -> { + DMNContextFEELCtxWrapper ctx = new DMNContextFEELCtxWrapper(new EvaluationContextMock(Collections.emptyMap())); + ctx.scopeNamespace(); + }); } private static class EvaluationContextMock implements EvaluationContext { diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNContextImplTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNContextImplTest.java index 92cc885fa8b..700b37f813c 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNContextImplTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNContextImplTest.java @@ -20,13 +20,13 @@ import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.core.BaseDMNContextTest; -public class DMNContextImplTest extends BaseDMNContextTest { +class DMNContextImplTest extends BaseDMNContextTest { @Test - public void testEmptyContext() { + void emptyContext() { DMNContextImpl ctx1 = new DMNContextImpl(); testCloneAndAlter(ctx1, Collections.emptyMap(), Collections.emptyMap()); @@ -35,7 +35,7 @@ public void testEmptyContext() { } @Test - public void testContextWithEntries() { + void contextWithEntries() { DMNContextImpl ctx1 = new DMNContextImpl(DEFAULT_ENTRIES); testCloneAndAlter(ctx1, DEFAULT_ENTRIES, Collections.emptyMap()); @@ -44,7 +44,7 @@ public void testContextWithEntries() { } @Test - public void testContextWithEntriesAndMetadata() { + void contextWithEntriesAndMetadata() { DMNContextImpl ctx1 = new DMNContextImpl(DEFAULT_ENTRIES, DEFAULT_METADATA); testCloneAndAlter(ctx1, DEFAULT_ENTRIES, DEFAULT_METADATA); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/imports/ImportsTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/imports/ImportsTest.java index 002a77781ff..dee99fa9dbd 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/imports/ImportsTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/imports/ImportsTest.java @@ -23,7 +23,9 @@ import java.util.Collections; import java.util.function.Function; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -41,14 +43,12 @@ public class ImportsTest extends BaseInterpretedVsCompiledTest { - public ImportsTest(final boolean useExecModelCompiler ) { - super( useExecModelCompiler ); - } - public static final Logger LOG = LoggerFactory.getLogger(ImportsTest.class); - @Test - public void testImportDependenciesForDTInAContext() { + @ParameterizedTest + @MethodSource("params") + void importDependenciesForDTInAContext(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Imported_Model.dmn", this.getClass(), "Import_BKM_and_have_a_Decision_Ctx_with_DT.dmn"); @@ -72,9 +72,11 @@ public void testImportDependenciesForDTInAContext() { LOG.debug("{}", evaluateAll); assertThat(evaluateAll.getDecisionResultByName("A Decision Ctx with DT").getResult()).isEqualTo("Respectfully, Hello John!"); } - - @Test - public void testImport2BKMs() { + + @ParameterizedTest + @MethodSource("params") + void import2BKMs(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Do_say_hello_with_2_bkms.dmn", this.getClass(), "Saying_hello_2_bkms.dmn"); @@ -100,8 +102,10 @@ public void testImport2BKMs() { assertThat(evaluateAll.getDecisionResultByName("what about hello").getResult()).isEqualTo("Hello"); } - @Test - public void testImport2BKMsInvoke() { + @ParameterizedTest + @MethodSource("params") + void import2BKMsInvoke(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Do_invoke_hello_with_2_bkms.dmn", this.getClass(), "Saying_hello_2_bkms.dmn"); @@ -125,8 +129,10 @@ public void testImport2BKMsInvoke() { assertThat(evaluateAll.getDecisionResultByName("invocation of hello").getResult()).isEqualTo("Hello, John"); } - @Test - public void testImport2BKMsInvokeUsingInputData() { + @ParameterizedTest + @MethodSource("params") + void import2BKMsInvokeUsingInputData(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2746 DMN Invocation parameters resolution with imported function final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Do_invoke_hello_with_2_bkms_using_inputdata.dmn", this.getClass(), @@ -152,8 +158,10 @@ public void testImport2BKMsInvokeUsingInputData() { assertThat(evaluateAll.getDecisionResultByName("what about hello").getResult()).isEqualTo("Hello, Bob"); } - @Test - public void testImport3Levels() { + @ParameterizedTest + @MethodSource("params") + void import3Levels(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("L3_Do_say_hello.dmn", this.getClass(), "Do_say_hello_with_2_bkms.dmn", @@ -191,8 +199,10 @@ public void testImport3Levels() { assertThat(evaluateAll.getDecisionResultByName("L3 what about hello").getResult()).isEqualTo("Hello"); } - @Test - public void testImportHardcodedDecisions() { + @ParameterizedTest + @MethodSource("params") + void importHardcodedDecisions(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Spell_Greeting.dmn", this.getClass(), "Import_Spell_Greeting.dmn"); @@ -217,8 +227,10 @@ public void testImportHardcodedDecisions() { assertThat(evaluateAll.getDecisionResultByName("Say the Greeting to Person").getResult()).isEqualTo("Hello, John"); } - @Test - public void testImportTransitiveBaseModel() { + @ParameterizedTest + @MethodSource("params") + void importTransitiveBaseModel(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), "ModelB.dmn", @@ -227,8 +239,10 @@ public void testImportTransitiveBaseModel() { getAndAssertModelNoErrors(runtime, "http://www.trisotech.com/dmn/definitions/_ae5b3c17-1ac3-4e1d-b4f9-2cf861aec6d9", "Say hello 1ID1D"); } - @Test - public void testImportTransitiveEvaluate2Layers() { + @ParameterizedTest + @MethodSource("params") + void importTransitiveEvaluate2Layers(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), "ModelB.dmn", @@ -246,8 +260,10 @@ public void testImportTransitiveEvaluate2Layers() { assertThat(evaluateAll.getDecisionResultByName("Evaluating Say Hello").getResult()).isEqualTo("Evaluating Say Hello to: Hello, John"); } - @Test - public void testImportTransitiveEvaluate3Layers() { + @ParameterizedTest + @MethodSource("params") + void importTransitiveEvaluate3Layers(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), "ModelB.dmn", @@ -266,8 +282,10 @@ public void testImportTransitiveEvaluate3Layers() { assertThat(evaluateAll.getDecisionResultByName("Model C Decision based on Bs").getResult()).isEqualTo("B: Evaluating Say Hello to: Hello, B.A.John; B2:Evaluating Say Hello to: Hello, B2.A.John2"); } - @Test - public void testImportingID() { + @ParameterizedTest + @MethodSource("params") + void importingID(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2944 DMN decision logic referencing DMN InputData final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), @@ -284,8 +302,10 @@ public void testImportingID() { assertThat(evaluateAll.getDecisionResultByName("Hello decision using imported InputData").getResult()).isEqualTo("Hello, DROOLS-2944"); } - @Test - public void testAllowDMNAPItoEvaluateDirectDependencyImportedDecisions() { + @ParameterizedTest + @MethodSource("params") + void allowDMNAPItoEvaluateDirectDependencyImportedDecisions(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3012 Allow DMN API to evaluate direct-dependency imported Decisions final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), @@ -317,8 +337,10 @@ private void testAllowDMNAPItoEvaluateDirectDependencyImportedDecisions_evaluate assertThat(evaluateAll.getDecisionResultByName("modelA.Greet the Person").getResult()).isEqualTo("Hello, John"); } - @Test - public void testRetrieveDecisionByIDName() { + @ParameterizedTest + @MethodSource("params") + void retrieveDecisionByIDName(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3026 final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), @@ -340,8 +362,10 @@ public void testRetrieveDecisionByIDName() { assertThat(dmnModel.getInputByName("modelA.Person name").getId()).isEqualTo("_4f6c136c-8512-4d71-8bbf-7c9eb6e74063"); // this is an imported InputData node. } - @Test - public void testImportChain() { + @ParameterizedTest + @MethodSource("params") + void importChain(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3045 DMN model API to display namespace transitive import dependencies final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), @@ -372,8 +396,10 @@ public void testImportChain() { Arrays.asList("Model B", "modelA")); } - @Test - public void testImportDependenciesBKMchain() { + @ParameterizedTest + @MethodSource("params") + void importDependenciesBKMchain(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("base join.dmn", this.getClass(), "use join.dmn"); @@ -399,8 +425,10 @@ public void testImportDependenciesBKMchain() { assertThat(evaluateAll.getDecisionResultByName("greet2").getResult()).isEqualTo("Hello, John Doe"); } - @Test - public void testImportInstanceOf() { + @ParameterizedTest + @MethodSource("params") + void importInstanceOf(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("instanceof base model.dmn", this.getClass(), "instanceof checks.dmn"); @@ -433,8 +461,10 @@ public void testImportInstanceOf() { assertThat(evaluateAll.getDecisionResultByName("is yes yes collection of ps?").getResult()).isEqualTo(Boolean.TRUE); } - @Test - public void testImportCalculation() { + @ParameterizedTest + @MethodSource("params") + void importCalculation(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("baseSum.dmn", this.getClass(), "importingSum.dmn"); @@ -460,8 +490,10 @@ public void testImportCalculation() { assertThat(evaluateAll.getDecisionResultByName("importing Decision").getResult()).isEqualTo(new BigDecimal(3)); } - @Test - public void testImportAliasedWithDots() { + @ParameterizedTest + @MethodSource("params") + void importAliasedWithDots(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("ComparatorModel.dmn", this.getClass(), "Import_ComparatorModel_and_alias_with_dots.dmn"); @@ -487,8 +519,10 @@ public void testImportAliasedWithDots() { assertThat(evaluateAll.getDecisionResultByName("Is A Bigger?").getResult()).isEqualTo(Boolean.TRUE); } - @Test - public void testImportContainingDotsAndAliasedWithDots() { + @ParameterizedTest + @MethodSource("params") + void importContainingDotsAndAliasedWithDots(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("ComparatorModelNamedWithDots.dmn", this.getClass(), "Import_ComparatorModelNamedWithDots_and_alias_with_dots.dmn"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/DMNIncrementalCompilationTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/DMNIncrementalCompilationTest.java index 1a76c87c455..64e809bd5bf 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/DMNIncrementalCompilationTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/DMNIncrementalCompilationTest.java @@ -20,7 +20,9 @@ import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.ReleaseId; import org.kie.api.runtime.KieContainer; @@ -30,6 +32,7 @@ import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.BaseInterpretedVsCompiledTest; import org.kie.dmn.core.api.DMNFactory; +import org.kie.dmn.core.compiler.ExecModelCompilerOption; import org.kie.dmn.core.util.DMNRuntimeUtil; import org.kie.dmn.core.util.KieHelper; import org.slf4j.Logger; @@ -41,12 +44,10 @@ public class DMNIncrementalCompilationTest extends BaseInterpretedVsCompiledTest public static final Logger LOG = LoggerFactory.getLogger(DMNIncrementalCompilationTest.class); - public DMNIncrementalCompilationTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testUpgrade() throws Exception { + @ParameterizedTest + @MethodSource("params") + void upgrade(boolean useExecModelCompiler) throws Exception { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final ReleaseId releaseId_v10 = ks.newReleaseId("org.kie", "dmn-test-PR1997", "1.0"); @@ -101,8 +102,10 @@ private void checkTestUpgrade(final KieContainer kieContainer, assertThat(result.get("Say hello and age")).isEqualTo(sayHelloAndAgeDecisionResultValue);// change v1.0 -> v1.1 } - @Test - public void testUpgradeWithImport() { + @ParameterizedTest + @MethodSource("params") + void upgradeWithImport(boolean useExecModelCompiler) { + init(useExecModelCompiler); final KieServices ks = KieServices.Factory.get(); final ReleaseId releaseId_v10 = ks.newReleaseId("org.kie", "dmn-test-RHDM-965", "1.0"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/WBCompilationTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/WBCompilationTest.java index 91a77f011b3..8172522b892 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/WBCompilationTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/WBCompilationTest.java @@ -19,7 +19,7 @@ package org.kie.dmn.core.incrementalcompilation; import org.drools.compiler.kie.builder.impl.DrlProject; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class WBCompilationTest { +class WBCompilationTest { static final String DMN_1 = "\n" + "\n" + @@ -78,7 +78,7 @@ public class WBCompilationTest { ""; @Test - public void testSteppedCompilation() { + void steppedCompilation() { KieServices ks = KieServices.Factory.get(); ReleaseId id = ks.newReleaseId("org.test", "foo", "1.0-SNAPSHOT"); @@ -100,7 +100,7 @@ public void testSteppedCompilation() { } @Test - public void testSteppedCompilationFromEmptyKbuilder() { + void steppedCompilationFromEmptyKbuilder() { // DROOLS-5584 KieServices ks = KieServices.Factory.get(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/DMNRuntimeBuilderTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/DMNRuntimeBuilderTest.java index e5e71412263..f10cec99ede 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/DMNRuntimeBuilderTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/DMNRuntimeBuilderTest.java @@ -20,24 +20,24 @@ import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.core.impl.DMNRuntimeImpl; import static org.assertj.core.api.Assertions.assertThat; -public class DMNRuntimeBuilderTest { +class DMNRuntimeBuilderTest { private DMNRuntimeBuilder dmnRuntimeBuilder; - @Before - public void setup() { + @BeforeEach + void setup() { dmnRuntimeBuilder = DMNRuntimeBuilder.fromDefaults(); assertThat(dmnRuntimeBuilder).isNotNull(); } @Test - public void buildFromConfiguration() { + void buildFromConfiguration() { final DMNRuntimeImpl retrieved = (DMNRuntimeImpl) dmnRuntimeBuilder .buildConfiguration() .fromResources(Collections.emptyList()).getOrElseThrow(RuntimeException::new); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/DRGAnalysisUtilsTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/DRGAnalysisUtilsTest.java index 9687c9ad47a..8dab011a8c3 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/DRGAnalysisUtilsTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/DRGAnalysisUtilsTest.java @@ -21,7 +21,7 @@ import java.util.Collection; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.BaseVariantTest; @@ -47,7 +47,7 @@ protected DMNRuntime createRuntimeWithAdditionalResources(String string, Class readJSON(String content) throws Exception { } @Test - public void testOneOfEachType() throws Exception { + void oneOfEachType() throws Exception { DMNRuntime runtime = createRuntime("OneOfEachType.dmn", DMNRuntimeTypesTest.class); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_4f5608e9-4d74-4c22-a47e-ab657257fc9c", "OneOfEachType"); assertThat(dmnModel).isNotNull(); @@ -96,7 +96,7 @@ public void testOneOfEachType() throws Exception { } @Test - public void testNextDays() throws Exception { + void nextDays() throws Exception { final DMNRuntime runtime = createRuntime("nextDays.dmn", DMNRuntimeTypesTest.class); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_8A1F9719-02AA-4517-97D4-5C4F5D22FE82", "nextDays"); assertThat(dmnModel).isNotNull(); @@ -115,7 +115,7 @@ public void testNextDays() throws Exception { } @Test - public void testTrafficViolationAll() throws Exception { + void trafficViolationAll() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("Traffic Violation.dmn", DMNRuntimeTypesTest.class); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF", "Traffic Violation"); assertThat(dmnModel).isNotNull(); @@ -145,7 +145,7 @@ public void testTrafficViolationAll() throws Exception { } @Test - public void testTrafficViolationMin() throws Exception { + void trafficViolationMin() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("Traffic Violation.dmn", DMNRuntimeTypesTest.class); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF", "Traffic Violation"); assertThat(dmnModel).isNotNull(); @@ -169,7 +169,7 @@ public void testTrafficViolationMin() throws Exception { } @Test - public void testTrafficViolationArbitraryFine() throws Exception { + void trafficViolationArbitraryFine() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("Traffic Violation.dmn", DMNRuntimeTypesTest.class); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF", "Traffic Violation"); assertThat(dmnModel).isNotNull(); @@ -206,7 +206,7 @@ private void assertTrafficViolationSuspendedCase(final DMNRuntime runtime, final } @Test - public void testDSBasicDS1() throws Exception { + void dSBasicDS1() throws Exception { final DMNRuntime runtime = createRuntime("0004-decision-services.dmn", DMNDecisionServicesTest.class); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -223,7 +223,7 @@ public void testDSBasicDS1() throws Exception { } @Test - public void testDSBasicDS2() throws Exception { + void dSBasicDS2() throws Exception { final DMNRuntime runtime = createRuntime("0004-decision-services.dmn", DMNDecisionServicesTest.class); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -238,9 +238,9 @@ public void testDSBasicDS2() throws Exception { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isFalse(); assertThat(dmnResult.getDecisionResultByName("A").getResult()).isEqualTo("inBinC"); } - + @Test - public void testFloatFromREST() throws Exception { + void floatFromREST() throws Exception { final DMNRuntime runtime = createRuntime("numberRESTinLIST.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_91CAD4BC-859F-465A-9294-300EABF4EC8A", "numberRESTinLIST"); Assertions.assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/MapBackedDMNContextTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/MapBackedDMNContextTest.java index 0511554ccbe..984d593f9ec 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/MapBackedDMNContextTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/MapBackedDMNContextTest.java @@ -21,13 +21,13 @@ import java.util.Collections; import java.util.HashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.core.BaseDMNContextTest; -public class MapBackedDMNContextTest extends BaseDMNContextTest { +class MapBackedDMNContextTest extends BaseDMNContextTest { @Test - public void testEmptyContext() { + void emptyContext() { MapBackedDMNContext ctx1 = MapBackedDMNContext.of(new HashMap<>(Collections.emptyMap())); testCloneAndAlter(ctx1, Collections.emptyMap(), Collections.emptyMap()); @@ -36,7 +36,7 @@ public void testEmptyContext() { } @Test - public void testContextWithEntries() { + void contextWithEntries() { MapBackedDMNContext ctx1 = MapBackedDMNContext.of(new HashMap<>(DEFAULT_ENTRIES)); testCloneAndAlter(ctx1, DEFAULT_ENTRIES, Collections.emptyMap()); @@ -45,7 +45,7 @@ public void testContextWithEntries() { } @Test - public void testContextWithEntriesAndMetadata() { + void contextWithEntriesAndMetadata() { MapBackedDMNContext ctx1 = MapBackedDMNContext.of(new HashMap<>(DEFAULT_ENTRIES), new HashMap<>(DEFAULT_METADATA)); testCloneAndAlter(ctx1, DEFAULT_ENTRIES, DEFAULT_METADATA); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/MarshallingStubUtilsTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/MarshallingStubUtilsTest.java index d05098f7465..6cb7c18006b 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/MarshallingStubUtilsTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/MarshallingStubUtilsTest.java @@ -20,7 +20,9 @@ import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -37,12 +39,10 @@ public class MarshallingStubUtilsTest extends BaseVariantTest { public static final Logger LOG = LoggerFactory.getLogger(MarshallingStubUtilsTest.class); - public MarshallingStubUtilsTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testComparablePeriod() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + void comparablePeriod(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("comparablePeriod.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_CB283B9C-8581-447E-8625-4D1186F0B3A6", "A1B0FA02-D1C4-4386-AF36-0280AA45A7B7"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/pmml/DMNKiePMMLTrustyInvocationEvaluatorTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/pmml/DMNKiePMMLTrustyInvocationEvaluatorTest.java index 4105cc1a412..d87c0e5bdb3 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/pmml/DMNKiePMMLTrustyInvocationEvaluatorTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/pmml/DMNKiePMMLTrustyInvocationEvaluatorTest.java @@ -30,8 +30,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.io.Resource; import org.kie.api.pmml.PMML4Result; import org.kie.api.pmml.PMMLRequestData; @@ -50,7 +50,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class DMNKiePMMLTrustyInvocationEvaluatorTest { +class DMNKiePMMLTrustyInvocationEvaluatorTest { private static DMNKiePMMLTrustyInvocationEvaluator dmnKiePMMLTrustyInvocationEvaluator; @@ -58,8 +58,8 @@ public class DMNKiePMMLTrustyInvocationEvaluatorTest { private static final String pmmlFileName = pmmlFileNameNoSuffix + ".pmml"; private static final String model = "LogisticRegression"; - @Before - public void setup() throws IOException { + @BeforeEach + void setup() throws IOException { URL pmmlUrl = DMNKiePMMLTrustyInvocationEvaluatorTest.class.getResource(pmmlFileName); assertThat(pmmlUrl).isNotNull(); String pmmlFilePath = pmmlUrl.getPath(); @@ -88,7 +88,7 @@ protected PMMLRequestData getPMMLRequestData(String correlationId, String modelN } @Test - public void getPMML4Result() { + void getPMML4Result() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); DMNRuntime dmnRuntimeMock = mock(DMNRuntime.class); when(dmnRuntimeMock.getRootClassLoader()).thenReturn(classLoader); @@ -101,7 +101,7 @@ public void getPMML4Result() { } @Test - public void getOutputFieldValues() { + void getOutputFieldValues() { List values = getValues(); Map resultVariables = new HashMap<>(); for (int i = 0; i < values.size(); i++) { @@ -118,7 +118,7 @@ public void getOutputFieldValues() { } @Test - public void getPredictedValues() { + void getPredictedValues() { List values = getValues(); values.forEach(value -> { PMML4Result result = getPMML4Result(value); @@ -131,7 +131,7 @@ public void getPredictedValues() { } @Test - public void evaluate() { + void evaluate() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); DMNRuntime dmnRuntimeMock = mock(DMNRuntime.class); when(dmnRuntimeMock.getRootClassLoader()).thenReturn(classLoader); @@ -143,7 +143,7 @@ public void evaluate() { } @Test - public void compileFile() { + void compileFile() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Map retrieved = dmnKiePMMLTrustyInvocationEvaluator.compileFile(pmmlFileName, classLoader); assertThat(retrieved).isNotNull().isNotEmpty().containsKey("pmml"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/AnnotationsTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/AnnotationsTest.java index 240ea7fa1b2..9dfab41fb95 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/AnnotationsTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/AnnotationsTest.java @@ -28,7 +28,9 @@ import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -48,13 +50,11 @@ public class AnnotationsTest extends BaseVariantTest { public static final Logger LOG = LoggerFactory.getLogger(AnnotationsTest.class); private boolean strongly; - public AnnotationsTest(VariantTestConf testConfig) { - super(testConfig); + @ParameterizedTest + @MethodSource("params") + void nswe(VariantTestConf conf) throws Exception { + testConfig = conf; strongly = testConfig.isTypeSafe(); - } - - @Test - public void testNSWE() throws Exception { final DMNRuntime runtime = createRuntime("NSEW.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_FBA17BF4-BC04-4C16-9305-40E8B4B2FECB", "NSEW"); assertThat(dmnModel).isNotNull(); @@ -85,8 +85,11 @@ public void testNSWE() throws Exception { } } - @Test - public void testOneOfEachType() throws Exception { + @ParameterizedTest + @MethodSource("params") + void oneOfEachType(VariantTestConf conf) throws Exception { + testConfig = conf; + strongly = testConfig.isTypeSafe(); final DMNRuntime runtime = createRuntime("OneOfEachType.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_4f5608e9-4d74-4c22-a47e-ab657257fc9c", "OneOfEachType"); assertThat(dmnModel).isNotNull(); @@ -122,8 +125,11 @@ private void checkAnnOneOfEachType(Class inputSetClass, String fieldName, Str } } - @Test - public void testNextDays() throws Exception { + @ParameterizedTest + @MethodSource("params") + void nextDays(VariantTestConf conf) throws Exception { + testConfig = conf; + strongly = testConfig.isTypeSafe(); final DMNRuntime runtime = createRuntime("nextDays.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_8A1F9719-02AA-4517-97D4-5C4F5D22FE82", "nextDays"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNRuntimeTypesTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNRuntimeTypesTest.java index ae3c16546f8..452c6cd2709 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNRuntimeTypesTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNRuntimeTypesTest.java @@ -33,8 +33,9 @@ import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; - -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNDecisionResult.DecisionEvaluationStatus; import org.kie.dmn.api.core.DMNModel; @@ -63,12 +64,10 @@ public class DMNRuntimeTypesTest extends BaseVariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMNRuntimeTypesTest.class); - public DMNRuntimeTypesTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testOneOfEachType() throws Exception { + @ParameterizedTest + @MethodSource("params") + void oneOfEachType(VariantTestConf conf) throws Exception { + testConfig = conf; final DMNRuntime runtime = createRuntime("OneOfEachType.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_4f5608e9-4d74-4c22-a47e-ab657257fc9c", "OneOfEachType"); assertThat(dmnModel).isNotNull(); @@ -129,8 +128,10 @@ public void testOneOfEachType() throws Exception { } } - @Test - public void testJavaKeywords() { + @ParameterizedTest + @MethodSource("params") + void javaKeywords(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("javaKeywords.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_C41C1676-0DA9-47EA-90AD-F9BAA257129F", "A1B1A8AD-B0DC-453D-86A7-C9475450C982"); assertThat(dmnModel).isNotNull(); @@ -154,8 +155,10 @@ public void testJavaKeywords() { } } - @Test - public void testInnerComposite() { + @ParameterizedTest + @MethodSource("params") + void innerComposite(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("innerComposite.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_641BCEBF-8D10-4E08-B47F-A9181C737A82", "new-file"); assertThat(dmnModel).isNotNull(); @@ -187,8 +190,10 @@ public void testInnerComposite() { } } - @Test - public void testFixInnerComposite() { + @ParameterizedTest + @MethodSource("params") + void fixInnerComposite(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("fixInnerComposite.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_E82058C1-27D3-44F3-B1B3-4C02D17B7A05", "new-file"); assertThat(dmnModel).isNotNull(); @@ -211,8 +216,10 @@ public void testFixInnerComposite() { } } - @Test - public void testInnerCompositeCollection() { + @ParameterizedTest + @MethodSource("params") + void innerCompositeCollection(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("innerCompositeCollection.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_D8AE5AF4-1F9E-4423-873A-B8F3C3BE5FE5", "new-file"); assertThat(dmnModel).isNotNull(); @@ -238,8 +245,10 @@ public void testInnerCompositeCollection() { } } - @Test - public void testInputAny() { + @ParameterizedTest + @MethodSource("params") + void inputAny(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("inputAny.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_7D9140EF-DC52-4DC1-8983-9C2EC5B89BAE", "new-file"); assertThat(dmnModel).isNotNull(); @@ -260,8 +269,10 @@ public void testInputAny() { } } - @Test - public void testRecursiveEmployee() { + @ParameterizedTest + @MethodSource("params") + void recursiveEmployee(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("recursiveEmployee.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_d1e3d83e-230d-42fb-bc58-313463f7f40b", "Drawing 1"); @@ -300,8 +311,10 @@ public void testRecursiveEmployee() { } } - @Test - public void testListBasic() { + @ParameterizedTest + @MethodSource("params") + void listBasic(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("listBasic.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_B84B17F3-3E84-4DED-996E-AA630A6BF9C4", "new-file"); assertThat(dmnModel).isNotNull(); @@ -334,8 +347,10 @@ public void testListBasic() { } } - @Test - public void testListBasic_LOVerror() { + @ParameterizedTest + @MethodSource("params") + void listBasicLOVerror(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("listBasic.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_B84B17F3-3E84-4DED-996E-AA630A6BF9C4", "new-file"); assertThat(dmnModel).isNotNull(); @@ -368,8 +383,10 @@ public void testListBasic_LOVerror() { } } - @Test - public void testSameTypeNameMultiple() { + @ParameterizedTest + @MethodSource("params") + void sameTypeNameMultiple(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntimeWithAdditionalResources("class_imported.dmn", this.getClass(), "class_importing.dmn"); final DMNModel dmnModel0 = runtime.getModel("http://www.trisotech.com/definitions/_b3deed2b-245f-4cc4-a4bf-1e95cd240664", "imported"); assertThat(dmnModel0).isNotNull(); @@ -398,8 +415,10 @@ public void testSameTypeNameMultiple() { } } - @Test - public void testFieldCapitalization() { + @ParameterizedTest + @MethodSource("params") + void fieldCapitalization(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntimeWithAdditionalResources("Traffic Violation.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF", "Traffic Violation"); assertThat(dmnModel).isNotNull(); @@ -457,8 +476,10 @@ public void testFieldCapitalization() { } } - @Test - public void testDecisionService() { + @ParameterizedTest + @MethodSource("params") + void decisionService(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("DecisionServiceABC_DMN12.dmn", DMNDecisionServicesTest.class); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_2443d3f5-f178-47c6-a0c9-b1fd1c933f60", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -512,8 +533,10 @@ public void testDecisionService() { } } - @Test - public void testBKM() { + @ParameterizedTest + @MethodSource("params") + void bkm(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("0009-invocation-arithmetic.dmn", DMNRuntimeTest.class); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_cb28c255-91cd-4c01-ac7b-1a9cb1ecdb11", "literal invocation1"); assertThat(dmnModel).isNotNull(); @@ -552,8 +575,10 @@ public void testBKM() { } } - @Test - public void testCapitalLetterConflict() { + @ParameterizedTest + @MethodSource("params") + void capitalLetterConflict(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("capitalLetterConflict.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_B321C9B1-856E-45DE-B05D-5B4D4D301D37", "capitalLetterConflict"); assertThat(dmnModel).isNotNull(); @@ -593,8 +618,10 @@ public void testCapitalLetterConflict() { } } - @Test - public void testCapitalLetterConflictWithInputAndDecision() { + @ParameterizedTest + @MethodSource("params") + void capitalLetterConflictWithInputAndDecision(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("capitalLetterConflictWithInputAndDecision.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_EE9DAFC0-D50D-4D23-8676-FF8A40E02919", "capitalLetterConflictWithInputAndDecision"); assertThat(dmnModel).isNotNull(); @@ -623,8 +650,10 @@ public void testCapitalLetterConflictWithInputAndDecision() { } } - @Test - public void testCapitalLetterConflictItemDef() { + @ParameterizedTest + @MethodSource("params") + void capitalLetterConflictItemDef(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("capitalLetterConflictItemDef.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_DA986720-823F-4334-8AB5-5CBA76FD1B9E", "capitalLetterConflictItemDef"); assertThat(dmnModel).isNotNull(); @@ -654,8 +683,10 @@ public void testCapitalLetterConflictItemDef() { } } - @Test - public void testShareTypeForInputAndOutput() { + @ParameterizedTest + @MethodSource("params") + void shareTypeForInputAndOutput(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("shareTypeForInputAndOutput.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_DBEFBA7B-C568-4631-A89E-AA31F7C6564B", "shareTypeForInputAndOutput"); assertThat(dmnModel).isNotNull(); @@ -688,8 +719,10 @@ public void testShareTypeForInputAndOutput() { } } - @Test - public void testTopLevelTypeCollection() { + @ParameterizedTest + @MethodSource("params") + void topLevelTypeCollection(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("PersonListHelloBKM2.dmn", DMNRuntimeTest.class); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_7e41a76e-2df6-4899-bf81-ae098757a3b6", "PersonListHelloBKM2"); @@ -723,8 +756,10 @@ public void testTopLevelTypeCollection() { } } - @Test - public void testTopLevelCompositeCollection() { + @ParameterizedTest + @MethodSource("params") + void topLevelCompositeCollection(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("topLevelCompositeCollection.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel( "https://kiegroup.org/dmn/_3ED2F714-24F0-4764-88FA-04217901C05A", "topLevelCompositeCollection"); @@ -759,8 +794,10 @@ public void testTopLevelCompositeCollection() { } } - @Test - public void testComponentCollection() { + @ParameterizedTest + @MethodSource("params") + void componentCollection(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("collections.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_2A93F258-EF3B-4150-A202-1D02A893DF2B", "collections"); assertThat(dmnModel).isNotNull(); @@ -805,8 +842,10 @@ public void testComponentCollection() { } } - @Test - public void testComponentCollectionPassTypedObject() { + @ParameterizedTest + @MethodSource("params") + void componentCollectionPassTypedObject(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("collectionsPassTypedObject.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_10C4DB2B-1DCA-4B4F-A994-FA046AE5C7B0", "collectionsPassTypedObject"); assertThat(dmnModel).isNotNull(); @@ -852,8 +891,10 @@ public void testComponentCollectionPassTypedObject() { } } - @Test - public void testEvaluateByIdAndName() { + @ParameterizedTest + @MethodSource("params") + void evaluateByIdAndName(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntimeWithAdditionalResources("2decisions.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_6453A539-85B5-4A4E-800E-6721C50B6B55", "2decisions"); assertThat(dmnModel).isNotNull(); @@ -905,7 +946,8 @@ public void testEvaluateByIdAndName() { } } - public void testCollectionOfCollection() { + public void testCollectionOfCollection(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("topLevelColOfCol.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_74636626-ACB0-4A1F-9AD3-D4E0AFA1A24A", "topLevelColOfCol"); assertThat(dmnModel).isNotNull(); @@ -958,8 +1000,10 @@ private void assertPersonMapInCol(Map personMap) { assertThat(personMap.get("age")).isIn(coerceNumber(21), coerceNumber(22), coerceNumber(23), coerceNumber(24)); } - @Test - public void testCollectionOfCollectionOfCollection() { + @ParameterizedTest + @MethodSource("params") + void collectionOfCollectionOfCollection(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("topLevelColOfColOfCol.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_74636626-ACB0-4A1F-9AD3-D4E0AFA1A24A", "topLevelColOfColOfCol"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNTypeSafeTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNTypeSafeTest.java index 85585bd56e8..363fbf0371c 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNTypeSafeTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNTypeSafeTest.java @@ -23,9 +23,9 @@ import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -41,15 +41,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.assertj.core.api.Assertions.assertThat; import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.core.BaseVariantTest.VariantTestConf.KIE_API_TYPECHECK_TYPESAFE; import static org.kie.dmn.core.util.DynamicTypeUtils.entry; import static org.kie.dmn.core.util.DynamicTypeUtils.mapOf; public class DMNTypeSafeTest extends BaseVariantTest { - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{KIE_API_TYPECHECK_TYPESAFE}; } @@ -62,12 +61,8 @@ public static Object[] params() { private DMNTypeSafePackageName.ModelFactory modelFactory; - public DMNTypeSafeTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Before - public void setUp() { + @BeforeEach + void setUp() { runtime = DMNRuntimeUtil.createRuntime("a.dmn", this.getClass()); String namespace = "http://www.trisotech.com/definitions/_2ceee5b6-0f0d-41ef-890e-2cd6fb1adb10"; String modelName = "Drawing 1"; @@ -77,8 +72,10 @@ public void setUp() { packageName = modelFactory.create(dmnModel); } - @Test - public void test() throws Exception { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void test(VariantTestConf conf) throws Exception { + testConfig = conf; assertValidDmnModel(dmnModel); @@ -135,8 +132,10 @@ private FEELPropertyAccessible outputSet(Map> compile, FEELProp return feelPropertyAccessible; } - @Test - public void testDynamic() throws Exception { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void dynamic(VariantTestConf conf) throws Exception { + testConfig = conf; assertValidDmnModel(dmnModel); @@ -174,8 +173,10 @@ public void testDynamic() throws Exception { assertThat(dContext.get("the person")).isEqualTo(context.getFEELProperty("p").toOptional().get()); } - @Test - public void testMetadata() throws Exception { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void metadata(VariantTestConf conf) throws Exception { + testConfig = conf; assertValidDmnModel(dmnModel); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/JavadocTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/JavadocTest.java index e6c0af2648b..13270a3e738 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/JavadocTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/JavadocTest.java @@ -27,8 +27,8 @@ import com.github.javaparser.ast.body.FieldDeclaration; import com.github.javaparser.ast.comments.JavadocComment; import org.drools.util.StringUtils; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.BaseVariantTest; @@ -45,17 +45,14 @@ public class JavadocTest extends BaseVariantTest { public static final Logger LOG = LoggerFactory.getLogger(JavadocTest.class); - public JavadocTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{BUILDER_DEFAULT_NOCL_TYPECHECK_TYPESAFE, KIE_API_TYPECHECK_TYPESAFE}; } - @Test - public void testDateAndTime() throws Exception { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void dateAndTime(VariantTestConf conf) throws Exception { + testConfig = conf; final DMNRuntime runtime = createRuntime("0007-date-time.dmn", DMNRuntimeTest.class); runtime.addListener(DMNRuntimeUtil.createListener()); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/typeref/DMNTyperefTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/typeref/DMNTyperefTest.java index 2050c2a9938..98d71824033 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/typeref/DMNTyperefTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/typeref/DMNTyperefTest.java @@ -21,7 +21,9 @@ import java.math.BigDecimal; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -40,14 +42,12 @@ public class DMNTyperefTest extends BaseInterpretedVsCompiledTest { - public DMNTyperefTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - public static final Logger LOG = LoggerFactory.getLogger(DMNTyperefTest.class); - @Test - public void testCircular3() { + @ParameterizedTest + @MethodSource("params") + void circular3(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("circular3.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_EEE7FA5B-AF9C-4937-8870-D612D4D8D860", "new-file"); assertThat(dmnModel).isNotNull(); @@ -64,8 +64,10 @@ public void testCircular3() { assertThat(result.get("Decision-1")).isEqualTo("named John Doe age 40 ext age 41"); } - @Test - public void testGenFn1() { + @ParameterizedTest + @MethodSource("params") + void genFn1(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("wireGenFnType1.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_10795E58-CD3F-4203-B4D7-C80D9D8BE7BD", "wireGenFnType1"); assertThat(dmnModel).isNotNull(); @@ -83,36 +85,46 @@ public void testGenFn1() { assertThat(result.get("Decision-1")).isEqualTo("Hello, World!"); } - @Test - public void test_bkmWrongFnType() { + @ParameterizedTest + @MethodSource("params") + void bkm_wrong_fn_type(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("bkmWrongFnType.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.TYPEREF_MISMATCH))).isTrue(); } - @Test - public void test_bkmWrongFnType2() { + @ParameterizedTest + @MethodSource("params") + void bkm_wrong_fn_type2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("bkmWrongFnType2.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - @Test - public void test_bkmWrongFnType3() { + @ParameterizedTest + @MethodSource("params") + void bkm_wrong_fn_type3(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("bkmWrongFnType3.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - @Test - public void test_bkmWrongFnType4() { + @ParameterizedTest + @MethodSource("params") + void bkm_wrong_fn_type4(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("bkmWrongFnType4.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - @Test - public void testGenFn2() { + @ParameterizedTest + @MethodSource("params") + void genFn2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("wireGenFnType2.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_10795E58-CD3F-4203-B4D7-C80D9D8BE7BD", "wireGenFnType2"); assertThat(dmnModel).isNotNull(); @@ -130,8 +142,10 @@ public void testGenFn2() { assertThat(result.get("Decision-1")).isEqualTo("Hello, World!"); } - @Test - public void test_dsWrongFnType() { + @ParameterizedTest + @MethodSource("params") + void ds_wrong_fn_type(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("dsWrongFnType.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_10795E58-CD3F-4203-B4D7-C80D9D8BE7BD", "dsWrongFnType"); assertThat(dmnModel).isNotNull(); @@ -145,50 +159,64 @@ public void test_dsWrongFnType() { assertThat(dmnResult.getMessages()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isNotEmpty(); } - @Test - public void test_dsWrongFnType2() { + @ParameterizedTest + @MethodSource("params") + void ds_wrong_fn_type2(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("dsWrongFnType2.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - @Test - public void test_dsWrongFnType3() { + @ParameterizedTest + @MethodSource("params") + void ds_wrong_fn_type3(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("dsWrongFnType3.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - @Test - public void test_dsWrongFnType4() { + @ParameterizedTest + @MethodSource("params") + void ds_wrong_fn_type4(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("dsWrongFnType4.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - @Test - public void test_dsWrongFnType5() { + @ParameterizedTest + @MethodSource("params") + void ds_wrong_fn_type5(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("dsWrongFnType5.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.TYPEREF_MISMATCH))).isTrue(); } - @Test - public void test_dsWrongFnType6() { + @ParameterizedTest + @MethodSource("params") + void ds_wrong_fn_type6(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("dsWrongFnType6.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.TYPEREF_MISMATCH))).isTrue(); } - @Test - public void test_dsWrongFnType7() { + @ParameterizedTest + @MethodSource("params") + void ds_wrong_fn_type7(boolean useExecModelCompiler) { + init(useExecModelCompiler); final List messages = DMNRuntimeUtil.createExpectingDMNMessages("dsWrongFnType7.dmn", this.getClass()); assertThat(messages).isNotNull().isNotEmpty(); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.TYPEREF_MISMATCH))).isTrue(); } - @Test - public void testGenFn3() { + @ParameterizedTest + @MethodSource("params") + void genFn3(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("wireGenFnType3.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_10795E58-CD3F-4203-B4D7-C80D9D8BE7BD", "wireGenFnType3"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java index c2d829b9b00..51998a82d5a 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java @@ -6,17 +6,19 @@ import java.time.ZonedDateTime; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNType; import org.kie.dmn.core.impl.SimpleTypeImpl; import org.kie.dmn.feel.lang.types.BuiltInType; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class CoerceUtilTest { +class CoerceUtilTest { @Test - public void coerceValueCollectionToArrayConverted() { + void coerceValueCollectionToArrayConverted() { Object item = "TESTED_OBJECT"; Object value = Collections.singleton(item); DMNType requiredType = new SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/", @@ -33,7 +35,7 @@ public void coerceValueCollectionToArrayConverted() { } @Test - public void coerceValueCollectionToArrayNotConverted() { + void coerceValueCollectionToArrayNotConverted() { Object item = "TESTED_OBJECT"; Object value = Collections.singleton(item); DMNType requiredType = new SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/", @@ -80,7 +82,7 @@ public void coerceValueCollectionToArrayNotConverted() { } @Test - public void coerceValueDateToDateTimeConverted() { + void coerceValueDateToDateTimeConverted() { Object value = LocalDate.now(); DMNType requiredType = new SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/", "date and time", @@ -102,7 +104,7 @@ public void coerceValueDateToDateTimeConverted() { } @Test - public void coerceValueDateToDateTimeNotConverted() { + void coerceValueDateToDateTimeNotConverted() { Object value = "TEST_OBJECT"; DMNType requiredType = new SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/", "date and time", @@ -130,7 +132,7 @@ public void coerceValueDateToDateTimeNotConverted() { } @Test - public void actualCoerceValueCollectionToArray() { + void actualCoerceValueCollectionToArray() { Object item = "TESTED_OBJECT"; Object value = Collections.singleton(item); DMNType requiredType = new SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/", @@ -147,7 +149,7 @@ public void actualCoerceValueCollectionToArray() { } @Test - public void actualCoerceValueDateToDateTime() { + void actualCoerceValueDateToDateTime() { Object value = LocalDate.now(); DMNType requiredType = new SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/", "date and time", @@ -169,7 +171,7 @@ public void actualCoerceValueDateToDateTime() { } @Test - public void actualCoerceValueNotConverted() { + void actualCoerceValueNotConverted() { Object value = BigDecimal.valueOf(1L); DMNType requiredType = new SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/", "number", diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_2/DMN12specificTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_2/DMN12specificTest.java index 72f196e0a05..f7783892821 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_2/DMN12specificTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_2/DMN12specificTest.java @@ -25,7 +25,8 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -44,12 +45,10 @@ public class DMN12specificTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(DMN12specificTest.class); - public DMN12specificTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testDMN12typeAliases() { + @ParameterizedTest + @MethodSource("params") + void dmn12typeAliases(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS- final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("typeAliases.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_9f6be450-17c0-49d9-a67f-960ad04b046f", "Drawing 1"); @@ -67,8 +66,10 @@ public void testDMN12typeAliases() { assertThat(result.get("a decision")).isEqualTo(LocalDateTime.of(2018, 9, 28, 16, 7).plusDays(1)); } - @Test - public void testItemDefCollection() { + @ParameterizedTest + @MethodSource("params") + void itemDefCollection(boolean useExecModelCompiler) { + init(useExecModelCompiler); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-filter.dmn", getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_f52ca843-504b-4c3b-a6bc-4d377bffef7a", "filter01"); assertThat(dmnModel).isNotNull(); @@ -96,14 +97,18 @@ public void testItemDefCollection() { assertThat(dmnResult.getContext().get("filter01")).asList().containsExactly("Adams", "Ford"); } - @Test - public void testDMN12typeRefInformationItem() { + @ParameterizedTest + @MethodSource("params") + void dmn12typeRefInformationItem(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3544 check_testDMN12typeRefInformationItem("typeRefInformationItem_original.dmn"); } - @Test - public void testDMN12typeRefInformationItem_modified() { + @ParameterizedTest + @MethodSource("params") + void dmn12typeRefInformationItemModified(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-3544 check_testDMN12typeRefInformationItem("typeRefInformationItem_modified.dmn"); } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_2/DMNDecisionServicesTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_2/DMNDecisionServicesTest.java index 3303c49537e..7bee8b40e77 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_2/DMNDecisionServicesTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_2/DMNDecisionServicesTest.java @@ -18,7 +18,8 @@ */ package org.kie.dmn.core.v1_2; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.BaseInterpretedVsCompiledTest; @@ -32,12 +33,10 @@ public class DMNDecisionServicesTest extends BaseInterpretedVsCompiledTest { public static final Logger LOG = LoggerFactory.getLogger(DMNDecisionServicesTest.class); - public DMNDecisionServicesTest(final boolean useExecModelCompiler) { - super(useExecModelCompiler); - } - - @Test - public void testDecisionServiceCompiler20180830_DMN12() { + @ParameterizedTest + @MethodSource("params") + void decisionServiceCompiler20180830DMN12(boolean useExecModelCompiler) { + init(useExecModelCompiler); // DROOLS-2943 DMN DecisionServiceCompiler not correctly wired for DMNv1.2 format final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServiceABC_DMN12.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_2443d3f5-f178-47c6-a0c9-b1fd1c933f60", "Drawing 1"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_3/DMN13specificTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_3/DMN13specificTest.java index 3d3f4a227f0..d2b4194c3f2 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_3/DMN13specificTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_3/DMN13specificTest.java @@ -21,7 +21,8 @@ import java.math.BigDecimal; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage.Severity; import org.kie.dmn.api.core.DMNModel; @@ -43,12 +44,10 @@ public class DMN13specificTest extends BaseVariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMN13specificTest.class); - public DMN13specificTest(final BaseVariantTest.VariantTestConf conf) { - super(conf); - } - - @Test - public void testDMNv1_3_simple() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + void dMNv13Simple(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("simple.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_9d01a0c4-f529-4ad8-ad8e-ec5fb5d96ad4", "Chapter 11 Example"); assertThat(dmnModel).isNotNull(); @@ -71,8 +70,10 @@ public void testDMNv1_3_simple() { } } - @Test - public void testDMNv1_3_ch11() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + void dMNv13Ch11(VariantTestConf conf) { + testConfig = conf; testName = "testDMNv1_3_ch11"; final DMNRuntime runtime = createRuntimeWithAdditionalResources("Chapter 11 Example.dmn", this.getClass(), "Financial.dmn"); @@ -111,8 +112,10 @@ public void testDMNv1_3_ch11() { } } - @Test - public void testDMNv1_3_ch11_asSpecInputDataValues() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + void dMNv13Ch11AsSpecInputDataValues(VariantTestConf conf) { + testConfig = conf; testName = "testDMNv1_3_ch11_asSpecInputDataValues"; final DMNRuntime runtime = createRuntimeWithAdditionalResources("Chapter 11 Example.dmn", this.getClass(), "Financial.dmn"); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_9d01a0c4-f529-4ad8-ad8e-ec5fb5d96ad4", "Chapter 11 Example"); @@ -150,8 +153,10 @@ public void testDMNv1_3_ch11_asSpecInputDataValues() { } } - @Test - public void testBKMencapsulatedlogictyperef() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + void bKMencapsulatedlogictyperef(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("bkmELTyperef.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_a49df6fc-c936-467a-9762-9aa3c9a93c06", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -172,9 +177,11 @@ public void testBKMencapsulatedlogictyperef() { assertThat(allProperties.get("Decision1")).isEqualTo(new BigDecimal("3")); } } - - @Test - public void testBKMFnTypeVirtuous() { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + void bkmFnTypeVirtuous(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("bkmFnTypeVirtuous.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_563323ba-325e-4a3f-938f-369854010eaf", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -190,9 +197,11 @@ public void testBKMFnTypeVirtuous() { final DMNContext result = dmnResult.getContext(); assertThat(result.get("do greet the name")).isEqualTo("Hello, John"); } - - @Test - public void testBKMFnTypeWrongEL() { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + void bkmFnTypeWrongEL(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("bkmFnTypeWrongEL.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_563323ba-325e-4a3f-938f-369854010eaf", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -208,9 +217,11 @@ public void testBKMFnTypeWrongEL() { final DMNContext result = dmnResult.getContext(); assertThat(result.get("do greet the name")).isEqualTo("Hello, John"); } - - @Test - public void testBKMWrongELExpr() { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + void bkmWrongELExpr(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("bkmWrongELExprType.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_563323ba-325e-4a3f-938f-369854010eaf", "Drawing 1"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_3/DMN13specificTestNonTypesafe.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_3/DMN13specificTestNonTypesafe.java index 83da10019b5..4e4fbe544c1 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_3/DMN13specificTestNonTypesafe.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_3/DMN13specificTestNonTypesafe.java @@ -21,7 +21,8 @@ import java.math.BigDecimal; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -40,12 +41,10 @@ public class DMN13specificTestNonTypesafe extends BaseVariantNonTypeSafeTest { public static final Logger LOG = LoggerFactory.getLogger(DMN13specificTestNonTypesafe.class); - public DMN13specificTestNonTypesafe(final VariantTestConf conf) { - super(conf); - } - - @Test - public void testDMNv1_3_ch11_Example2() { + @ParameterizedTest + @MethodSource("params") + void dMNv13Ch11Example2(VariantTestConf conf) { + testConfig = conf; testName = "testDMNv1_3_ch11_Example2"; final DMNRuntime runtime = createRuntimeWithAdditionalResources("Recommended Loan Products.dmn", this.getClass(), "Loan info.dmn"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14ExpressionsTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14ExpressionsTest.java index f5566dd6e4a..b684c947a0e 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14ExpressionsTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14ExpressionsTest.java @@ -24,9 +24,9 @@ import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -47,26 +47,22 @@ public class DMN14ExpressionsTest extends BaseVariantTest { private DMNRuntime runtime; private DMNModel model; - public DMN14ExpressionsTest(final BaseVariantTest.VariantTestConf conf) { - super(conf); - } - - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{KIE_API_TYPECHECK, BUILDER_DEFAULT_NOCL_TYPECHECK}; // only variants needed until DMNv1.4 is actually published } - - - @Before - public void setup() { + + void setup() { runtime = createRuntime("dmn14expressions.dmn", DMN14ExpressionsTest.class); assertThat(runtime).isNotNull(); model = runtime.getModel("http://www.trisotech.com/definitions/_3404349f-5046-4ad3-ad15-7f1e27291ab5", "DMN 1.4 expressions"); assertThat(model).isNotNull(); } - @Test - public void testConditionalWithInput() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void conditionalWithInput(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Boolean Input", true)), "Conditional"); assertThat(results.getDecisionResultByName("Conditional").getResult()).isEqualTo("Conditional evaluated to TRUE"); @@ -78,16 +74,22 @@ public void testConditionalWithInput() throws Throwable { } - @Test - public void testConditionalNonBooleanIf() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void conditionalNonBooleanIf(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(), "Non boolean"); assertThat(results.getMessages()).hasSize(1); assertThat(results.getMessages().iterator().next().getMessageType()).isEqualTo(DMNMessageType.ERROR_EVAL_NODE); } - @Test - public void testIteratorFor() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorFor(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 1)), "Addition"); assertThat(results.getDecisionResultByName("Addition").getResult().toString()).isEqualTo(Arrays.asList(2, 3, 4, 5).toString()); @@ -95,36 +97,48 @@ public void testIteratorFor() throws Throwable { assertThat(results.getDecisionResultByName("Addition").getResult().toString()).isEqualTo(Arrays.asList(3, 4, 5, 6).toString()); } - @Test - public void testIteratorForPartial() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorForPartial(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 0)), "Addition Partial"); assertThat(results.getDecisionResultByName("Addition Partial").getResult().toString()).isEqualTo(Arrays.asList(1, 3, 6, 10).toString()); results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "Addition Partial"); assertThat(results.getDecisionResultByName("Addition Partial").getResult().toString()).isEqualTo(Arrays.asList(1, 8, 16, 25).toString()); } - - @Test - public void testIteratorForInRangeClose() throws Throwable { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorForInRangeClose(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 1)), "Addition Range Close"); assertThat(results.getDecisionResultByName("Addition Range Close").getResult().toString()).isEqualTo(Arrays.asList(3, 4).toString()); results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 2)), "Addition Range Close"); assertThat(results.getDecisionResultByName("Addition Range Close").getResult().toString()).isEqualTo(Arrays.asList(4, 5).toString()); - } + } - @Test - public void testIteratorForInRangeOpen() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorForInRangeOpen(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 1)), "Addition Range Open"); assertThat(results.getDecisionResultByName("Addition Range Open").getResult().toString()).isEqualTo(Arrays.asList(2, 3, 4, 5).toString()); results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 2)), "Addition Range Open"); assertThat(results.getDecisionResultByName("Addition Range Open").getResult().toString()).isEqualTo(Arrays.asList(3, 4, 5, 6).toString()); - } + } - - @Test - public void testIteratorSome() throws Throwable { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorSome(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "Number Greater Exists"); assertThat(((Boolean) results.getDecisionResultByName("Number Greater Exists").getResult()).booleanValue()).isTrue(); @@ -135,8 +149,11 @@ public void testIteratorSome() throws Throwable { assertThat(((Boolean) results.getDecisionResultByName("Number Greater Exists").getResult()).booleanValue()).isFalse(); } - @Test - public void testIteratorEvery() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorEvery(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "All Greater"); assertThat(((Boolean) results.getDecisionResultByName("All Greater").getResult()).booleanValue()).isFalse(); @@ -147,8 +164,11 @@ public void testIteratorEvery() throws Throwable { assertThat(((Boolean) results.getDecisionResultByName("All Greater").getResult()).booleanValue()).isFalse(); } - @Test - public void testFilterIndex() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void filterIndex(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "Match by index"); assertThat(results.getDecisionResultByName("Match by index").getResult()).isEqualTo(new BigDecimal(5)); @@ -160,8 +180,11 @@ public void testFilterIndex() throws Throwable { } - @Test - public void testFilterExpression() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void filterExpression(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; + setup(); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "Match by Fnct"); assertThat(results.getDecisionResultByName("Match by Fnct").getResult().toString()).isEqualTo(Arrays.asList(6, 7, 8, 9, 10).toString()); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14GenericSynthTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14GenericSynthTest.java index beacc0e039f..a9134471fad 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14GenericSynthTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14GenericSynthTest.java @@ -23,8 +23,8 @@ import java.util.Arrays; import java.util.Map; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -43,17 +43,14 @@ public class DMN14GenericSynthTest extends BaseVariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMN14GenericSynthTest.class); - public DMN14GenericSynthTest(final BaseVariantTest.VariantTestConf conf) { - super(conf); - } - - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{KIE_API_TYPECHECK, BUILDER_DEFAULT_NOCL_TYPECHECK}; // only variants needed until DMNv1.4 is actually published } - @Test - public void testFilterDatatype() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void filterDatatype(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; DMNRuntime runtime = createRuntime("filter-datatype.dmn", this.getClass()); assertThat(runtime).isNotNull(); DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_caa02430-93c6-4ba7-a646-81bbcef32978", "Drawing 1"); @@ -72,8 +69,10 @@ private void checkFilterDatatype(DMNRuntime runtime, DMNModel model) { assertThat(results.getDecisionResultByName("Decision").getResult()).isEqualTo(Arrays.asList(tc1, tc3)); } - @Test - public void testFilterDatatype2() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void filterDatatype2(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; DMNRuntime runtime = createRuntime("filter-datatype2.dmn", this.getClass()); assertThat(runtime).isNotNull(); DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_caa02430-93c6-4ba7-a646-81bbcef32978", "Drawing 1"); @@ -82,8 +81,10 @@ public void testFilterDatatype2() throws Throwable { checkFilterDatatype(runtime, model); } - @Test - public void testIteratorDatatype() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorDatatype(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; DMNRuntime runtime = createRuntime("iterator-datatype.dmn", this.getClass()); assertThat(runtime).isNotNull(); DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_caa02430-93c6-4ba7-a646-81bbcef32978", "Drawing 1"); @@ -102,8 +103,10 @@ private void checkIteratorDatatype(DMNRuntime runtime, DMNModel model) { assertThat(results.getDecisionResultByName("Decision").getResult()).isEqualTo(Arrays.asList("x", "y", "z")); } - @Test - public void testIteratorDatatype2() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorDatatype2(final BaseVariantTest.VariantTestConf conf) throws Throwable { + testConfig = conf; DMNRuntime runtime = createRuntime("iterator-datatype2.dmn", this.getClass()); assertThat(runtime).isNotNull(); DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_caa02430-93c6-4ba7-a646-81bbcef32978", "Drawing 1"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14specificTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14specificTest.java index 6cc366635f7..dfa36efbdf8 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14specificTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/v1_4/DMN14specificTest.java @@ -21,8 +21,8 @@ import java.math.BigDecimal; import java.util.Arrays; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -49,17 +49,14 @@ public class DMN14specificTest extends BaseVariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMN14specificTest.class); - public DMN14specificTest(final BaseVariantTest.VariantTestConf conf) { - super(conf); - } - - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{KIE_API_TYPECHECK, BUILDER_DEFAULT_NOCL_TYPECHECK}; // only variants needed until DMNv1.4 is actually published } - @Test - public void testDMNv1_4_put() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void dMNv14Put(final BaseVariantTest.VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("exampleContextPut.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("ns1", "examplePut"); assertThat(dmnModel).isNotNull(); @@ -75,8 +72,10 @@ public void testDMNv1_4_put() { assertThat(dmnResult.getDecisionResultByName("Processed Request").getResult()).hasFieldOrPropertyWithValue("priority", "Medium"); } - @Test - public void testDMNv1_4_putAll() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void dMNv14PutAll(final BaseVariantTest.VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("exampleContextMerge.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_864E9A62-12E5-41DC-A7A6-7F028822A067", "examplePutAll"); assertThat(dmnModel).isNotNull(); @@ -91,9 +90,11 @@ public void testDMNv1_4_putAll() { assertThat(dmnResult.getDecisionResultByName("Complete Person").getResult()).hasFieldOrPropertyWithValue("last name", "Doe") .hasFieldOrPropertyWithValue("age", new BigDecimal(47)); } - - @Test - public void test_simple() { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void simple(final BaseVariantTest.VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("simple.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_d9232146-7aaa-49a9-8668-261a01844ace", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -109,9 +110,11 @@ public void test_simple() { final DMNContext result = dmnResult.getContext(); assertThat(result.get("greet")).isEqualTo("Hello, John"); } - - @Test - public void testDMNv1_4_ch11() { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void dMNv14Ch11(final BaseVariantTest.VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntimeWithAdditionalResources("Chapter 11 Example.dmn", this.getClass(), "Financial.dmn"); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_9d01a0c4-f529-4ad8-ad8e-ec5fb5d96ad4", "Chapter 11 Example"); assertThat(dmnModel).isNotNull(); @@ -140,9 +143,11 @@ public void testDMNv1_4_ch11() { assertThat(result.get("Strategy")).isEqualTo("THROUGH"); assertThat(result.get("Routing")).isEqualTo("ACCEPT"); } - - @Test - public void testDMNv1_4_ch11_Example2() { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void dMNv14Ch11Example2(final BaseVariantTest.VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntimeWithAdditionalResources("Recommended Loan Products.dmn", this.getClass(), "Loan info.dmn"); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_736fa164-03d8-429f-8318-4913a548c3a6", "Recommended Loan Products"); assertThat(dmnModel).isNotNull(); @@ -253,8 +258,10 @@ public void testDMNv1_4_ch11_Example2() { entry("Recommendation", "Best"))); } - @Test - public void test_sampleFor() { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void sample_for(final BaseVariantTest.VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("sampleFor.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_5d7731f1-525d-4e75-a24a-39066f52ccdf", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -268,9 +275,11 @@ public void test_sampleFor() { final DMNContext result = dmnResult.getContext(); assertThat(result.get("sampleFor")).asList().containsExactly(new BigDecimal(2), new BigDecimal(3), new BigDecimal(4)); } - - @Test - public void test_sampleQuantified() { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void sample_quantified(final BaseVariantTest.VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("sampleQuantified.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_480411d5-e8b4-422f-9a76-1e8929930ead", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -285,9 +294,11 @@ public void test_sampleQuantified() { assertThat(result.get("sampleEvery")).isEqualTo(Boolean.TRUE); assertThat(result.get("sampleSome")).isEqualTo(Boolean.TRUE); } - - @Test - public void test_sampleConditional() { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void sample_conditional(final BaseVariantTest.VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("sampleConditional.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_da2ac43a-133b-483d-9c08-958d10024584", "Drawing 1"); assertThat(dmnModel).isNotNull(); @@ -301,9 +312,11 @@ public void test_sampleConditional() { final DMNContext result = dmnResult.getContext(); assertThat(result.get("sampleConditional")).isEqualTo("Hello World"); } - - @Test - public void test_sampleFilter() { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void sample_filter(final BaseVariantTest.VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("sampleFilter.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_e1291f4e-e828-4a47-86e8-474899d50185", "Drawing 1"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-feel/pom.xml b/kie-dmn/kie-dmn-feel/pom.xml index 19e72a32d2e..c0c9b9ecb92 100644 --- a/kie-dmn/kie-dmn-feel/pom.xml +++ b/kie-dmn/kie-dmn-feel/pom.xml @@ -97,13 +97,13 @@ - junit - junit + org.mockito + mockito-core test org.mockito - mockito-core + mockito-junit-jupiter test @@ -121,6 +121,11 @@ yasson test + + org.junit.jupiter + junit-jupiter + test + org.asciidoctor asciidoctorj @@ -135,11 +140,11 @@ ${project.basedir}/src/test/resources - ${project.basedir}/../ - - ref-dmn-feel-builtin-functions.adoc - - false + ${project.basedir}/../ + + ref-dmn-feel-builtin-functions.adoc + + false diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/DirectCompilerTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/DirectCompilerTest.java index edf20396a04..137a3c50db1 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/DirectCompilerTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/DirectCompilerTest.java @@ -22,7 +22,7 @@ import java.time.LocalDate; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.lang.FEELProperty; import org.kie.dmn.feel.lang.Type; @@ -47,17 +47,17 @@ public class DirectCompilerTest { @Test - public void test_FEEL_number() { + void feel_number() { assertThat(parseCompileEvaluate("10")).isEqualTo(BigDecimal.valueOf(10)); } - + @Test - public void test_FEEL_negative_number() { + void feel_negative_number() { assertThat(parseCompileEvaluate("-10")).isEqualTo(BigDecimal.valueOf(-10)); } - + @Test - public void test_FEEL_DROOLS_2143() { + void feel_drools_2143() { // DROOLS-2143: Allow ''--1' expression as per FEEL grammar rule 26 assertThat(parseCompileEvaluate("--10")).isEqualTo(BigDecimal.valueOf(10)); assertThat(parseCompileEvaluate("---10")).isEqualTo(BigDecimal.valueOf(-10)); @@ -65,24 +65,24 @@ public void test_FEEL_DROOLS_2143() { } @Test - public void test_FEEL_boolean() { + void feel_boolean() { assertThat(parseCompileEvaluate("false")).isEqualTo(Boolean.FALSE); assertThat(parseCompileEvaluate("true")).isEqualTo(Boolean.TRUE); assertThat(parseCompileEvaluate("null")).isNull(); } - + @Test - public void test_FEEL_null() { + void feel_null() { assertThat(parseCompileEvaluate("null")).isNull(); } - + @Test - public void test_FEEL_string() { + void feel_string() { assertThat(parseCompileEvaluate("\"some string\"")).isEqualTo("some string" ); } - + @Test - public void test_primary_parens() { + void primary_parens() { assertThat(parseCompileEvaluate("(\"some string\")")).isEqualTo("some string" ); assertThat(parseCompileEvaluate("(123)")).isEqualTo(BigDecimal.valueOf(123)); assertThat(parseCompileEvaluate("(-123)")).isEqualTo(BigDecimal.valueOf(-123)); @@ -90,12 +90,12 @@ public void test_primary_parens() { assertThat(parseCompileEvaluate("(false)")).isEqualTo(Boolean.FALSE); assertThat(parseCompileEvaluate("(true)")).isEqualTo(Boolean.TRUE); } - + /** * See {@link FEELTernaryLogicTest} */ @Test - public void test_ternary_logic() { + void ternary_logic() { assertThat(parseCompileEvaluate( "true and true")).isEqualTo(Boolean.TRUE); assertThat(parseCompileEvaluate( "true and false")).isEqualTo(Boolean.FALSE); assertThat(parseCompileEvaluate( "true and null")).isNull(); @@ -120,29 +120,29 @@ public void test_ternary_logic() { assertThat(parseCompileEvaluate( "true or false and false")).isEqualTo(Boolean.TRUE); assertThat(parseCompileEvaluate( "(true or false) and false")).isEqualTo(Boolean.FALSE); } - + /** * Partially from {@link FEELConditionsAndLoopsTest} */ @Test - public void test_if() { + void test_if() { assertThat(parseCompileEvaluate( "if true then 15 else 5")).isEqualTo(BigDecimal.valueOf( 15 )); assertThat(parseCompileEvaluate( "if false then 15 else 5")).isEqualTo(BigDecimal.valueOf( 5 )); assertThat(parseCompileEvaluate("if null then 15 else 5")).isEqualTo(BigDecimal.valueOf(5)); assertThat(parseCompileEvaluate("if \"hello\" then 15 else 5")).isEqualTo(BigDecimal.valueOf(5)); } - + @Test - public void test_additiveExpression() { + void additive_expression() { assertThat(parseCompileEvaluate( "1 + 2")).isEqualTo(BigDecimal.valueOf( 3 )); assertThat(parseCompileEvaluate( "1 + null")).isNull(); assertThat(parseCompileEvaluate( "1 - 2")).isEqualTo(BigDecimal.valueOf( -1 )); assertThat(parseCompileEvaluate( "1 - null")).isNull(); assertThat(parseCompileEvaluate( "\"Hello, \" + \"World\"")).isEqualTo("Hello, World"); } - + @Test - public void test_multiplicativeExpression() { + void multiplicative_expression() { assertThat(parseCompileEvaluate("3 * 5")).isEqualTo(BigDecimal.valueOf(15)); assertThat(parseCompileEvaluate("3 * null")).isNull(); assertThat(parseCompileEvaluate("10 / 2")).isEqualTo(BigDecimal.valueOf(5)); @@ -150,13 +150,13 @@ public void test_multiplicativeExpression() { } @Test - public void test_exponentiationExpression() { + void exponentiation_expression() { assertThat(parseCompileEvaluate("3 ** 3")).isEqualTo(BigDecimal.valueOf(27)); assertThat(parseCompileEvaluate("3 ** null")).isNull(); } @Test - public void test_logicalNegationExpression() { + void logical_negation_expression() { // this is all invalid syntax assertThat(parseCompileEvaluate("not true")).isNull(); assertThat(parseCompileEvaluate("not false")).isNull(); @@ -165,7 +165,7 @@ public void test_logicalNegationExpression() { } @Test - public void test_listExpression() { + void list_expression() { assertThat(parseCompileEvaluate("[]")).asList().isEmpty(); assertThat(parseCompileEvaluate("[ ]")).asList().isEmpty(); assertThat(parseCompileEvaluate("[1]")).asList().containsExactly(BigDecimal.valueOf(1)); @@ -173,7 +173,7 @@ public void test_listExpression() { } @Test - public void test_instanceOfExpression() { + void instance_of_expression() { assertThat(parseCompileEvaluate("123 instance of number")).isEqualTo(Boolean.TRUE); assertThat(parseCompileEvaluate("\"ciao\" instance of number")).isEqualTo(Boolean.FALSE); assertThat(parseCompileEvaluate("123 instance of string")).isEqualTo(Boolean.FALSE); @@ -181,7 +181,7 @@ public void test_instanceOfExpression() { } @Test - public void test_between() { + void between() { assertThat(parseCompileEvaluate("10 between 5 and 12")).isEqualTo(Boolean.TRUE); assertThat(parseCompileEvaluate("10 between 20 and 30")).isEqualTo(Boolean.FALSE); assertThat(parseCompileEvaluate("10 between 5 and \"foo\"")).isNull(); @@ -191,7 +191,7 @@ public void test_between() { } @Test - public void test_filterPath() { + void filter_path() { // Filtering by index assertThat(parseCompileEvaluate("[\"a\", \"b\", \"c\"][1]")).isEqualTo("a"); assertThat(parseCompileEvaluate("[\"a\", \"b\", \"c\"][2]")).isEqualTo("b"); @@ -218,7 +218,7 @@ public void test_filterPath() { } @Test - public void test_filterPath_tricky1() { + void filter_path_tricky1() { CompiledFEELExpression nameRef = parse( "[ {x:1, y:2}, {x:2, y:3} ][x]"); LOG.debug("{}", nameRef); @@ -231,7 +231,7 @@ public void test_filterPath_tricky1() { } @Test - public void test_filterPath_tricky2() { + void filter_path_tricky2() { CompiledFEELExpression nameRef = parse("[ {x:1, y:2}, {x:2, y:3} ][x]"); LOG.debug("{}", nameRef); @@ -244,7 +244,7 @@ public void test_filterPath_tricky2() { } @Test - public void test_filterPathSelection() { + void filter_path_selection() { // Selection assertThat(parseCompileEvaluate("[ {x:1, y:2}, {x:2, y:3} ].y")).asList().containsExactly(BigDecimal.valueOf(2), BigDecimal.valueOf(3)); assertThat(parseCompileEvaluate("[ {x:1, y:2}, {x:2} ].y")).asList().containsExactly(BigDecimal.valueOf(2), null); @@ -252,7 +252,7 @@ public void test_filterPathSelection() { } @Test - public void test_for() { + void test_for() { // for Object parseCompileEvaluate = parseCompileEvaluate("for x in [ 10, 20, 30 ], y in [ 1, 2, 3 ] return x * y"); assertThat(parseCompileEvaluate).asList(). @@ -266,7 +266,7 @@ public void test_for() { } @Test - public void test_quantifiedExpressions() { + void quantified_expressions() { // quantified expressions assertThat(parseCompileEvaluate("some price in [ 80, 11, 110 ] satisfies price > 100")).isEqualTo(Boolean.TRUE); assertThat(parseCompileEvaluate("some price in [ 80, 11, 90 ] satisfies price > 100")).isEqualTo(Boolean.FALSE); @@ -278,24 +278,24 @@ public void test_quantifiedExpressions() { } @Test - public void test_basicFunctionInvocation() { + void basic_function_invocation() { assertThat(parseCompileEvaluate("max(1, 2, 3)")).isEqualTo(new BigDecimal(3)); } @Test - public void test_basicFunctionDefinition() { + void basic_function_definition() { assertThat(parseCompileEvaluate("function (a, b) a + b")).isInstanceOf(CompiledCustomFEELFunction.class); assertThat(parseCompileEvaluate("{ s : function (a, b) a + b, x : 1, y : 2, r : s(x,y) }.r")).isEqualTo(new BigDecimal(3)); } @Test - public void test_namedFunctionInvocation() { + void named_function_invocation() { assertThat(parseCompileEvaluate("substring(start position: 2, string: \"FOOBAR\")")).isEqualTo("OOBAR"); assertThat(parseCompileEvaluate("ceiling( n : 1.5 )")).isEqualTo(new BigDecimal("2")); } @Test - public void test_Misc_fromOriginalFEELInterpretedTestSuite() { + void misc_from_original_feelinterpreted_test_suite() { assertThat(parseCompileEvaluate("if null then \"foo\" else \"bar\"")).isEqualTo("bar"); assertThat(parseCompileEvaluate("{ hello world : function() \"Hello World!\", message : hello world() }.message")).isEqualTo("Hello World!"); assertThat(parseCompileEvaluate("1 + if true then 1 else 2")).isEqualTo(new BigDecimal("2")); @@ -308,14 +308,14 @@ public void test_Misc_fromOriginalFEELInterpretedTestSuite() { } @Test - public void test_Benchmark_feelExpressions() { + void benchmark_feel_expressions() { assertThat(parseCompileEvaluate("{ full name: { first name: \"John\", last name: \"Doe\" } }.full name.last name")).isEqualTo("Doe"); assertThat(parseCompileEvaluate("some price in [ 80, 11, 110 ] satisfies price > 100")).isEqualTo(Boolean.TRUE); assertThat(parseCompileEvaluate("every price in [ 80, 11, 90 ] satisfies price > 10")).isEqualTo(Boolean.TRUE); } @Test - public void test_contextExpression() { + void context_expression() { assertThat(parseCompileEvaluate("{}")).isEqualTo(Collections.emptyMap()); assertThat(parseCompileEvaluate("{ }")).isEqualTo(Collections.emptyMap()); assertThat(parseCompileEvaluate("{ a : 1 }")).isEqualTo(mapOf(entry("a", new BigDecimal(1)))); @@ -326,23 +326,23 @@ public void test_contextExpression() { assertThat(parseCompileEvaluate("{ a : 1, b : a }")).isEqualTo(mapOf(entry("a", new BigDecimal(1)), entry("b", new BigDecimal(1)))); } - + /** * See {@link FEELParserTest} */ @Test - public void testContextWithMultipleEntries() { + void contextWithMultipleEntries() { String inputExpression = "{ \"a string key\" : 10," + "\n" + " a non-string key : 11," + "\n" + " a key.with + /' odd chars : 12 }"; assertThat(parseCompileEvaluate(inputExpression)).isEqualTo(mapOf(entry("a string key", new BigDecimal(10)), entry("a non-string key", new BigDecimal(11)), entry("a key.with + /' odd chars", new BigDecimal(12)))); } - + /** * See {@link FEELParserTest} */ @Test - public void testNestedContexts() { + void nestedContexts() { String inputExpression = "{ a value : 10," + "\n" + " an applicant : { " + "\n" + " first name : \"Edson\", " + "\n" @@ -368,7 +368,7 @@ public void testNestedContexts() { * See {@link FEELParserTest} */ @Test - public void testNestedContexts2() { + void nestedContexts2() { String complexContext = "{ an applicant : { \n" + " home address : { \n" + " street name: \"broadway st\", \n" + @@ -383,7 +383,7 @@ public void testNestedContexts2() { } @Test - public void testNameReference() { + void nameReference() { String inputExpression = "someSimpleName"; CompiledFEELExpression nameRef = parse( inputExpression, mapOf( entry("someSimpleName", BuiltInType.STRING) ) ); LOG.debug("{}", nameRef); @@ -395,9 +395,9 @@ public void testNameReference() { assertThat(result).isEqualTo(BigDecimal.valueOf(123)); } - + @Test - public void testQualifiedName() { + void qualifiedName() { String inputExpression = "My Person.Full Name"; Type personType = new MapBackedType("Person", mapOf( entry("Full Name", BuiltInType.STRING), entry("Age", BuiltInType.NUMBER) ) ); CompiledFEELExpression qualRef = parse( inputExpression, mapOf( entry("My Person", personType) ) ); @@ -426,8 +426,9 @@ public String getFullName() { return "John Doe"; } } + @Test - public void testQualifiedName2() { + void qualifiedName2() { String inputExpression = "My Person.Full Name"; Type personType = JavaBackedType.of(MyPerson.class); CompiledFEELExpression qualRef = parse( inputExpression, mapOf( entry("My Person", personType) ) ); @@ -442,7 +443,7 @@ public void testQualifiedName2() { } @Test - public void testQualifiedName3() { + void qualifiedName3() { String inputExpression = "a date.year"; Type dateType = BuiltInType.DATE; CompiledFEELExpression qualRef = parse(inputExpression, mapOf(entry("a date", dateType))); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/DirectCompilerUnaryTestsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/DirectCompilerUnaryTestsTest.java index 54a8778aa98..8e4feea77fd 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/DirectCompilerUnaryTestsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/DirectCompilerUnaryTestsTest.java @@ -25,7 +25,7 @@ import com.github.javaparser.ast.expr.Expression; import org.antlr.v4.runtime.tree.ParseTree; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.lang.Type; import org.kie.dmn.feel.lang.ast.BaseNode; @@ -64,13 +64,13 @@ private List parseCompileEvaluate(String feelLiteralExpression, Object } @Test - public void test_Dash() { + void dash() { assertThat(parseCompileEvaluate("-", 1)).containsExactly(Boolean.TRUE); assertThat(parseCompileEvaluate("-, -", 1)).isEmpty(); } - + @Test - public void test_positiveUnaryTestIneq() { + void positive_unary_test_ineq() { assertThat(parseCompileEvaluate("<47", 1)).containsExactly(Boolean.TRUE); assertThat(parseCompileEvaluate("<47, <100", 1)).containsExactly(Boolean.TRUE, Boolean.TRUE); assertThat(parseCompileEvaluate("<47, <100, <-47", 1)).containsExactly(Boolean.TRUE, Boolean.TRUE, Boolean.FALSE); @@ -82,9 +82,9 @@ public void test_positiveUnaryTestIneq() { assertThat(parseCompileEvaluate(">=1, >2, <3, <=4", 5)).containsExactly(Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE); assertThat(parseCompileEvaluate("!=1, !=42", 1)).containsExactly(Boolean.FALSE, Boolean.TRUE); } - + @Test - public void test_positiveUnaryTestIneq_forEQ() { + void positive_unary_test_ineq_for_eq() { assertThat(parseCompileEvaluate("<47, =1", 1)).containsExactly(Boolean.TRUE, Boolean.TRUE); assertThat(parseCompileEvaluate("<47, =47", 1)).containsExactly(Boolean.TRUE, Boolean.FALSE); assertThat(parseCompileEvaluate("<47, 1", 1)).containsExactly(Boolean.TRUE, Boolean.TRUE); @@ -92,12 +92,12 @@ public void test_positiveUnaryTestIneq_forEQ() { } @Test - public void test_not() { + void not() { assertThat(parseCompileEvaluate("not(=47), not(<1), not(!=1)", 1)).isEmpty(); } @Test - public void test_simpleUnaryTest_forRANGE() { + void simple_unary_test_for_range() { assertThat(parseCompileEvaluate("[1..2]", 1)).containsExactly(Boolean.TRUE); assertThat(parseCompileEvaluate("[1..2], [2..3]", 1)).containsExactly(Boolean.TRUE, Boolean.FALSE); assertThat(parseCompileEvaluate("(1..2], [2..3]", 1)).containsExactly(Boolean.FALSE, Boolean.FALSE); @@ -105,7 +105,7 @@ public void test_simpleUnaryTest_forRANGE() { } @Test - public void t2() { + void t2() { assertThat(parseCompileEvaluate("\"asd\"", "asd")).containsExactly(Boolean.TRUE); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualBasicFunctionInvocationTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualBasicFunctionInvocationTest.java index 630951a775e..5d2e34086ca 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualBasicFunctionInvocationTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualBasicFunctionInvocationTest.java @@ -21,7 +21,7 @@ import java.math.BigDecimal; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +49,7 @@ public Object apply(EvaluationContext feelExprCtx) { } @Test - public void testManualContext() { + void manualContext() { CompiledFEELExpression compiledExpression = new ManualFilterExpression(); LOG.debug("{}", compiledExpression); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualContextTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualContextTest.java index 9588fb487ef..1b79c12a6b1 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualContextTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualContextTest.java @@ -20,7 +20,7 @@ import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +56,7 @@ public Map apply(EvaluationContext feelExprCtx) { } @Test - public void testManualContext() { + void manualContext() { CompiledFEELExpression compiledExpression = new ManualContext(); LOG.debug("{}", compiledExpression); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualFilterTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualFilterTest.java index 0841dfdc1f0..f081a65da67 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualFilterTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualFilterTest.java @@ -20,7 +20,7 @@ import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,7 +57,7 @@ public Object apply(EvaluationContext feelExprCtx) { } @Test - public void testManualContext() { + void manualContext() { CompiledFEELExpression compiledExpression = new ManualFilterExpression(); LOG.debug("{}", compiledExpression); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualForTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualForTest.java index bce9de2f59a..d7ec805b62f 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualForTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualForTest.java @@ -21,7 +21,7 @@ import java.math.BigDecimal; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +58,7 @@ public Object apply(EvaluationContext feelExprCtx) { } @Test - public void testManualContext() { + void manualContext() { CompiledFEELExpression compiledExpression = new ManualFilterExpression(); LOG.debug("{}", compiledExpression); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualNamedFunctionInvocationTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualNamedFunctionInvocationTest.java index ed6a1a3bb43..d2d254e8f79 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualNamedFunctionInvocationTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualNamedFunctionInvocationTest.java @@ -20,7 +20,7 @@ import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.lang.impl.NamedParameter; import org.slf4j.Logger; @@ -49,7 +49,7 @@ public Object apply(EvaluationContext feelExprCtx) { } @Test - public void testManualContext() { + void manualContext() { CompiledFEELExpression compiledExpression = new NamedFunctionExample(); LOG.debug("{}", compiledExpression); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualQuantTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualQuantTest.java index f21d8e55744..7204f3e6417 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualQuantTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualQuantTest.java @@ -20,7 +20,7 @@ import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.lang.ast.QuantifiedExpressionNode.Quantifier; import org.slf4j.Logger; @@ -54,7 +54,7 @@ public Object apply(EvaluationContext feelExprCtx) { } @Test - public void testManualContext() { + void manualContext() { CompiledFEELExpression compiledExpression = new ManualFilterExpression(); LOG.debug("{}", compiledExpression); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualUnaryTestsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualUnaryTestsTest.java index bddfb273c13..02ae4687722 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualUnaryTestsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/codegen/feel11/ManualUnaryTestsTest.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.runtime.UnaryTest; import org.kie.dmn.feel.util.EvalHelper; @@ -52,7 +52,7 @@ public List getUnaryTests() { } @Test - public void testManualUnaryTests() { + void manualUnaryTests() { Object left = EvalHelper.coerceNumber(7); CompiledFEELUnaryTests compiledUnaryTests = new ManualImpl1(); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/documentation/ADocFEELExamplesTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/documentation/ADocFEELExamplesTest.java index 167057b6bd1..9570d44e762 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/documentation/ADocFEELExamplesTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/documentation/ADocFEELExamplesTest.java @@ -33,7 +33,7 @@ import org.asciidoctor.ast.Document; import org.asciidoctor.ast.ListItem; import org.asciidoctor.ast.StructuralNode; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.FEEL; import org.kie.dmn.feel.lang.FEELProfile; import org.kie.dmn.feel.parser.feel11.profiles.KieExtendedFEELProfile; @@ -42,13 +42,14 @@ import static org.assertj.core.api.Assertions.assertThat; -public class ADocFEELExamplesTest { +class ADocFEELExamplesTest { private static final Logger LOG = LoggerFactory.getLogger(ADocFEELExamplesTest.class); private static final List profiles = new ArrayList<>(); static { profiles.add(new KieExtendedFEELProfile()); } + private final FEEL feel = FEEL.newInstance(profiles); /** @@ -57,7 +58,7 @@ public class ADocFEELExamplesTest { * $ mvn test -Dtest=org.kie.dmn.feel.documentation.ADocFEELExamplesTest */ @Test - public void test() throws URISyntaxException { + void test() throws URISyntaxException { Asciidoctor asciidoctor = Asciidoctor.Factory.create(); URL resource = this.getClass().getResource("/ref-dmn-feel-builtin-functions.adoc"); URI uri = resource.toURI(); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/documentation/FromSpecificationNotInAdocTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/documentation/FromSpecificationNotInAdocTest.java index 0b76097c8c4..f4efed20eca 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/documentation/FromSpecificationNotInAdocTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/documentation/FromSpecificationNotInAdocTest.java @@ -20,7 +20,9 @@ import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.BaseFEELTest; /** @@ -29,8 +31,13 @@ */ public class FromSpecificationNotInAdocTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { {"substring(\"foobar\",3) = \"obar\"", Boolean.TRUE, null}, {"substring(\"foobar\",3,3) = \"oba\"", Boolean.TRUE, null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/jandex/AbstractJandexTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/jandex/AbstractJandexTest.java index 046555611e9..be3d2f5ad1d 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/jandex/AbstractJandexTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/jandex/AbstractJandexTest.java @@ -34,12 +34,11 @@ import jakarta.json.bind.Jsonb; import jakarta.json.bind.JsonbBuilder; import jakarta.json.bind.JsonbConfig; - import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; import org.jboss.jandex.Index; import org.jboss.jandex.Indexer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.FEELFunction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +55,7 @@ protected AbstractJandexTest(String moduleName) { } @Test - public void testReflectConfigJSON() throws Exception { + public void reflectConfigJSON() throws Exception { Indexer indexer = new Indexer(); InputStream stream = getClass().getClassLoader() .getResourceAsStream("org/kie/dmn/feel/runtime/FEELFunction.class"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/InfixOperatorTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/InfixOperatorTest.java index 080ff45e44c..91961be98fe 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/InfixOperatorTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/InfixOperatorTest.java @@ -18,21 +18,21 @@ */ package org.kie.dmn.feel.lang.ast; -import org.junit.Test; -import org.kie.dmn.feel.lang.EvaluationContext; - import java.time.Duration; import java.time.LocalDate; import java.time.temporal.ChronoUnit; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.lang.EvaluationContext; + import static java.time.temporal.ChronoUnit.DAYS; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -public class InfixOperatorTest { +class InfixOperatorTest { @Test - public void addLocalDateAndDuration() { + void addLocalDateAndDuration() { LocalDate left = LocalDate.of(2021, 1, 1); Duration right = Duration.of(-1, ChronoUnit.HOURS); LocalDate retrieved = (LocalDate) InfixOperator.ADD.evaluate(left, right, null); @@ -75,7 +75,7 @@ public void addLocalDateAndDuration() { } @Test - public void subLocalDateAndDuration() { + void subLocalDateAndDuration() { LocalDate left = LocalDate.of(2021, 1, 1); Duration right = Duration.of(-1, ChronoUnit.HOURS); LocalDate retrieved = (LocalDate) InfixOperator.SUB.evaluate(left, right, null); @@ -118,7 +118,7 @@ public void subLocalDateAndDuration() { } @Test - public void mulDurationAndDuration() { + void mulDurationAndDuration() { Object left = Duration.of(5, DAYS); Object right = Duration.of(5, DAYS); assertThat(InfixOperator.MULT.evaluate(left, right, mock(EvaluationContext.class))).isNull(); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/BigDecimalRangeIteratorTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/BigDecimalRangeIteratorTest.java index cffdd4615f1..7264767ff0a 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/BigDecimalRangeIteratorTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/BigDecimalRangeIteratorTest.java @@ -18,21 +18,21 @@ */ package org.kie.dmn.feel.lang.ast.forexpressioniterators; -import org.junit.Test; - import java.math.BigDecimal; import java.util.Arrays; import java.util.List; import java.util.stream.IntStream; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class BigDecimalRangeIteratorTest { +class BigDecimalRangeIteratorTest { @Test - public void hasNextAscendantTest() { + void hasNextAscendantTest() { BigDecimal start = BigDecimal.valueOf(1); BigDecimal end = BigDecimal.valueOf(3); BigDecimalRangeIterator iterator = new BigDecimalRangeIterator(start, end); @@ -46,7 +46,7 @@ public void hasNextAscendantTest() { } @Test - public void hasNextDescendantTest() { + void hasNextDescendantTest() { BigDecimal start = BigDecimal.valueOf(3); BigDecimal end = BigDecimal.valueOf(1); BigDecimalRangeIterator iterator = new BigDecimalRangeIterator(start, end); @@ -60,7 +60,7 @@ public void hasNextDescendantTest() { } @Test - public void nextAscendantTest() { + void nextAscendantTest() { BigDecimal start = BigDecimal.valueOf(1); BigDecimal end = BigDecimal.valueOf(3); List expected = Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3)); @@ -69,7 +69,7 @@ public void nextAscendantTest() { } @Test - public void nextDescendantTest() { + void nextDescendantTest() { BigDecimal start = BigDecimal.valueOf(3); BigDecimal end = BigDecimal.valueOf(1); List expected = Arrays.asList(BigDecimal.valueOf(3), BigDecimal.valueOf(2), BigDecimal.valueOf(1)); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationTest.java index 56512a3c425..509cbcfe25f 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationTest.java @@ -18,20 +18,22 @@ */ package org.kie.dmn.feel.lang.ast.forexpressioniterators; -import org.junit.Test; - import java.math.BigDecimal; import java.time.LocalDate; import java.util.Arrays; import java.util.List; import java.util.stream.IntStream; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class ForIterationTest { +class ForIterationTest { @Test - public void hasNextValueBigDecimalTest() { + void hasNextValueBigDecimalTest() { BigDecimal start = BigDecimal.valueOf(1); BigDecimal end = BigDecimal.valueOf(3); ForIteration iteration = new ForIteration("iteration", start, end); @@ -45,7 +47,7 @@ public void hasNextValueBigDecimalTest() { } @Test - public void hasNextValueLocalDateTest() { + void hasNextValueLocalDateTest() { LocalDate start = LocalDate.of(2021, 1, 1); LocalDate end = LocalDate.of(2021, 1, 3); ForIteration iteration = new ForIteration("iteration", start, end); @@ -59,7 +61,7 @@ public void hasNextValueLocalDateTest() { } @Test - public void getNextValueBigDecimalTest() { + void getNextValueBigDecimalTest() { BigDecimal start = BigDecimal.valueOf(1); BigDecimal end = BigDecimal.valueOf(3); List expected = Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3)); @@ -69,7 +71,7 @@ public void getNextValueBigDecimalTest() { } @Test - public void getNextValueLocalDateTest() { + void getNextValueLocalDateTest() { LocalDate start = LocalDate.of(2021, 1, 3); LocalDate end = LocalDate.of(2021, 1, 1); List expected = Arrays.asList(LocalDate.of(2021, 1, 3), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 1)); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationUtilsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationUtilsTest.java index bb50aca4146..0b4da928e6f 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationUtilsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationUtilsTest.java @@ -18,8 +18,11 @@ */ package org.kie.dmn.feel.lang.ast.forexpressioniterators; -import org.junit.Before; -import org.junit.Test; +import java.math.BigDecimal; +import java.time.LocalDate; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.api.feel.runtime.events.FEELEventListener; import org.kie.dmn.feel.exceptions.EndpointOfRangeNotValidTypeException; @@ -28,11 +31,8 @@ import org.kie.dmn.feel.lang.impl.FEELEventListenersManager; import org.mockito.ArgumentCaptor; -import java.math.BigDecimal; -import java.time.LocalDate; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.kie.dmn.feel.codegen.feel11.CodegenTestUtil.newEmptyEvaluationContext; import static org.kie.dmn.feel.lang.ast.forexpressioniterators.ForIterationUtils.getForIteration; import static org.kie.dmn.feel.lang.ast.forexpressioniterators.ForIterationUtils.validateValues; @@ -44,13 +44,13 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -public class ForIterationUtilsTest { +class ForIterationUtilsTest { private FEELEventListener listener; private EvaluationContext ctx; - @Before - public void setup() { + @BeforeEach + void setup() { final FEELEventListenersManager mngr = new FEELEventListenersManager(); listener = mock(FEELEventListener.class); mngr.addListener(listener); @@ -58,7 +58,7 @@ public void setup() { } @Test - public void getForIterationValidTest() { + void getForIterationValidTest() { ForIteration retrieved = getForIteration(ctx, "iteration", BigDecimal.valueOf(1), BigDecimal.valueOf(3)); assertNotNull(retrieved); verify(listener, never()).onEvent(any(FEELEvent.class)); @@ -68,7 +68,7 @@ public void getForIterationValidTest() { } @Test - public void getForIterationNotValidTest() { + void getForIterationNotValidTest() { try { getForIteration(ctx, "iteration", "NOT", "VALID"); } catch (Exception e) { @@ -96,7 +96,7 @@ public void getForIterationNotValidTest() { } @Test - public void valueMustBeValidTrueTest() { + void valueMustBeValidTrueTest() { valueMustBeValid(ctx, BigDecimal.valueOf(1)); verify(listener, never()).onEvent(any(FEELEvent.class)); valueMustBeValid(ctx, LocalDate.of(2021, 1, 3)); @@ -104,7 +104,7 @@ public void valueMustBeValidTrueTest() { } @Test - public void valueMustBeValidFalseTest() { + void valueMustBeValidFalseTest() { try { valueMustBeValid(ctx, "INVALID"); } catch (Exception e) { @@ -115,7 +115,7 @@ public void valueMustBeValidFalseTest() { } @Test - public void validateValuesTrueTest() { + void validateValuesTrueTest() { validateValues(ctx, BigDecimal.valueOf(1), BigDecimal.valueOf(3)); verify(listener, never()).onEvent(any(FEELEvent.class)); validateValues(ctx, LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 3)); @@ -123,7 +123,7 @@ public void validateValuesTrueTest() { } @Test - public void validateValuesFalseTest() { + void validateValuesFalseTest() { try { validateValues(ctx, "INVALID", "INVALID"); } catch (Exception e) { diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java index 6c40c0813f7..eaf378f26e7 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java @@ -18,31 +18,31 @@ */ package org.kie.dmn.feel.lang.ast.forexpressioniterators; -import org.junit.BeforeClass; -import org.junit.Test; - import java.time.LocalDate; import java.util.Arrays; import java.util.List; import java.util.stream.IntStream; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class LocalDateRangeIteratorTest { +class LocalDateRangeIteratorTest { private static LocalDate before; private static LocalDate after; - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { before = LocalDate.of(2021, 1, 1); after = LocalDate.of(2021, 1, 3); } @Test - public void hasNextAscendantTest() { + void hasNextAscendantTest() { LocalDateRangeIterator iterator = new LocalDateRangeIterator(before, after); assertTrue(iterator.hasNext()); LocalDate next = iterator.next(); @@ -54,7 +54,7 @@ public void hasNextAscendantTest() { } @Test - public void hasNextDescendantTest() { + void hasNextDescendantTest() { LocalDateRangeIterator iterator = new LocalDateRangeIterator(after, before); assertTrue(iterator.hasNext()); LocalDate next = iterator.next(); @@ -66,14 +66,14 @@ public void hasNextDescendantTest() { } @Test - public void nextAscendantTest() { + void nextAscendantTest() { List expected = Arrays.asList(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 3)); LocalDateRangeIterator iterator = new LocalDateRangeIterator(before, after); IntStream.range(0, 3).forEach(i -> assertEquals(expected.get(i), iterator.next())); } @Test - public void nextDescendantTest() { + void nextDescendantTest() { List expected = Arrays.asList(LocalDate.of(2021, 1, 3), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 1)); LocalDateRangeIterator iterator = new LocalDateRangeIterator(after, before); IntStream.range(0, 3).forEach(i -> assertEquals(expected.get(i), iterator.next())); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ZonedDateTimeRangeIteratorTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ZonedDateTimeRangeIteratorTest.java index fce2e1dda63..4f5e4d38116 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ZonedDateTimeRangeIteratorTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ZonedDateTimeRangeIteratorTest.java @@ -18,9 +18,6 @@ */ package org.kie.dmn.feel.lang.ast.forexpressioniterators; -import org.junit.BeforeClass; -import org.junit.Test; - import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -28,24 +25,27 @@ import java.util.List; import java.util.stream.IntStream; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class ZonedDateTimeRangeIteratorTest { +class ZonedDateTimeRangeIteratorTest { private static ZonedDateTime before; private static ZonedDateTime after; - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { // Tests using on those variables relies on the exact hour/minute, because the ZonedDateTimeRangeIterator is meant to iterate on a full-day base before = getZonedDateTime(2021, 1, 1, 10, 15); after = getZonedDateTime(2021, 1, 3, 10, 15); } @Test - public void hasNextAscendantTest() { + void hasNextAscendantTest() { ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(before, after); assertTrue(iterator.hasNext()); ZonedDateTime next = iterator.next(); @@ -57,7 +57,7 @@ public void hasNextAscendantTest() { } @Test - public void hasNextDescendantTest() { + void hasNextDescendantTest() { ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(after, before); assertTrue(iterator.hasNext()); ZonedDateTime next = iterator.next(); @@ -69,7 +69,7 @@ public void hasNextDescendantTest() { } @Test - public void nextAscendantTest() { + void nextAscendantTest() { List expected = Arrays.asList(getZonedDateTime(2021, 1, 1, 10, 15), getZonedDateTime(2021, 1, 2, 10, 15), getZonedDateTime(2021, 1, 3, 10, 15)); @@ -78,7 +78,7 @@ public void nextAscendantTest() { } @Test - public void nextDescendantTest() { + void nextDescendantTest() { List expected = Arrays.asList(getZonedDateTime(2021, 1, 3, 10, 15), getZonedDateTime(2021, 1, 2, 10, 15), getZonedDateTime(2021, 1, 1, 10, 15)); @@ -88,7 +88,7 @@ public void nextDescendantTest() { @Test - public void hasNotNextAscendantTest() { + void hasNotNextAscendantTest() { ZonedDateTime start = getZonedDateTime(2021, 1, 1, 10, 15); ZonedDateTime end = getZonedDateTime(2021, 1, 2, 10, 14); ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(start, end); @@ -96,8 +96,9 @@ public void hasNotNextAscendantTest() { assertEquals(start, retrieved); assertFalse(iterator.hasNext()); } + @Test - public void hasNotNextDescendantTest() { + void hasNotNextDescendantTest() { ZonedDateTime start = getZonedDateTime(2021, 1, 2, 10, 14); ZonedDateTime end = getZonedDateTime(2021, 1, 1, 10, 15); ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(start, end); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/infixexecutors/InfixExecutorUtilsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/infixexecutors/InfixExecutorUtilsTest.java index cce73e0cd5a..63f13b75ba7 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/infixexecutors/InfixExecutorUtilsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/infixexecutors/InfixExecutorUtilsTest.java @@ -18,11 +18,6 @@ */ package org.kie.dmn.feel.lang.ast.infixexecutors; -import ch.obermuhlner.math.big.BigDecimalMath; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.lang.EvaluationContext; - import java.math.BigDecimal; import java.math.MathContext; import java.time.Duration; @@ -32,19 +27,27 @@ import java.util.function.BinaryOperator; import java.util.function.Supplier; +import ch.obermuhlner.math.big.BigDecimalMath; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.lang.EvaluationContext; + import static java.time.temporal.ChronoUnit.DAYS; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.feel.lang.ast.infixexecutors.InfixExecutorUtils.isAllowedMultiplicationBasedOnSpec; import static org.kie.dmn.feel.lang.ast.infixexecutors.InfixExecutorUtils.math; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; -public class InfixExecutorUtilsTest { +class InfixExecutorUtilsTest { private static List> MATH_OPERATORS; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { MATH_OPERATORS = new ArrayList<>(); MATH_OPERATORS.add((l, r) -> l.add(r, MathContext.DECIMAL128)); MATH_OPERATORS.add((l, r) -> l.subtract(r, MathContext.DECIMAL128)); @@ -54,7 +57,7 @@ public void setUp() throws Exception { } @Test - public void math_BothNumbers() { + void math_BothNumbers() { final Random rnd = new Random(); MATH_OPERATORS.forEach(operator -> { BigDecimal left = BigDecimal.valueOf(rnd.nextDouble()); @@ -68,7 +71,7 @@ public void math_BothNumbers() { } @Test - public void math_NumberAndString() { + void math_NumberAndString() { final Random rnd = new Random(); MATH_OPERATORS.forEach(operator -> { BigDecimal left = BigDecimal.valueOf(rnd.nextDouble()); @@ -79,7 +82,7 @@ public void math_NumberAndString() { } @Test - public void isAllowedMultiplicationBasedOnSpecTest() { + void isAllowedMultiplicationBasedOnSpecTest() { EvaluationContext evaluationContext = mock(EvaluationContext.class); Object left = 23; Object right = 354.5; diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/examples/CompileEvaluateTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/examples/CompileEvaluateTest.java index d4826902590..4fa44777722 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/examples/CompileEvaluateTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/examples/CompileEvaluateTest.java @@ -19,14 +19,13 @@ package org.kie.dmn.feel.lang.examples; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.api.feel.runtime.events.FEELEventListener; @@ -43,7 +42,7 @@ import static org.kie.dmn.feel.util.DynamicTypeUtils.entry; import static org.kie.dmn.feel.util.DynamicTypeUtils.prototype; -public class CompileEvaluateTest { +class CompileEvaluateTest { private static final Logger LOG = LoggerFactory.getLogger(CompileEvaluateTest.class); private static final FEEL feel = FEEL.newInstance(); private List errors; @@ -66,21 +65,21 @@ public class CompileEvaluateTest { } } ); } - - @Before - public void before() { + + @BeforeEach + void before() { errors = new ArrayList<>(); errorsCountingListener = evt -> { if ( evt.getSeverity() == Severity.ERROR ) { errors.add(evt); } }; feel.addListener( errorsCountingListener ); } - - @After - public void after() { + + @AfterEach + void after() { feel.removeListener( errorsCountingListener ); } - + @Test - public void test_isDynamicResolution() { + void is_dynamic_resolution() { CompilerContext ctx = feel.newCompilerContext(); ctx.addInputVariableType( "Person List", BuiltInType.LIST); @@ -103,10 +102,10 @@ public void test_isDynamicResolution() { assertThat(result).isInstanceOf(List.class); assertThat((List) result).hasSize(1); assertThat(((Map) ((List) result).get(0)).get("Full Name")).isEqualTo("Edson Tirelli"); - } - + } + @Test - public void test2() { + void test2() { CompilerContext ctx = feel.newCompilerContext(); ctx.addInputVariableType( "MyPerson", new MapBackedType().addField( "FullName", BuiltInType.STRING ) ); @@ -123,7 +122,7 @@ public void test2() { } @Test - public void test2OK() { + void test2OK() { CompilerContext ctx = feel.newCompilerContext(); ctx.addInputVariableType( "MyPerson", new MapBackedType().addField( "FullName", BuiltInType.STRING ) ); @@ -136,9 +135,9 @@ public void test2OK() { assertThat(result).isEqualTo("John Doe"); } - + @Test - public void testHyphenInProperty() { + void hyphenInProperty() { CompilerContext ctx = feel.newCompilerContext(); ctx.addInputVariableType( "input", new MapBackedType().addField( "Primary-Key", BuiltInType.STRING ).addField( "Value", BuiltInType.STRING ) ); CompiledExpression compiledExpression = feel.compile( "input.Primary-Key", ctx ); @@ -150,9 +149,9 @@ public void testHyphenInProperty() { assertThat(result).isEqualTo("k987"); assertThat(errors).isEmpty(); } - + @Test - public void testHyphenInPropertyOfCollectionForProjection() { + void hyphenInPropertyOfCollectionForProjection() { MapBackedType compositeType = new MapBackedType().addField( "Primary-Key", BuiltInType.STRING ).addField( "Value", BuiltInType.STRING ); CompilerContext ctx = feel.newCompilerContext(); ctx.addInputVariableType( "input", new GenListType(compositeType) ); @@ -165,9 +164,9 @@ public void testHyphenInPropertyOfCollectionForProjection() { assertThat(result).asList().containsExactly("k987"); assertThat(errors).isEmpty(); } - + @Test - public void testHyphenInPropertyOfCollectionForAccessor() { + void hyphenInPropertyOfCollectionForAccessor() { MapBackedType compositeType = new MapBackedType().addField( "Primary-Key", BuiltInType.STRING ).addField( "Value", BuiltInType.STRING ); CompilerContext ctx = feel.newCompilerContext(); ctx.addInputVariableType( "my input", new GenListType(compositeType) ); @@ -180,25 +179,25 @@ public void testHyphenInPropertyOfCollectionForAccessor() { assertThat(result).isEqualTo("k987"); assertThat(errors).isEmpty(); } - + @Test - public void testExternalFnMissingClass() { + void externalFnMissingClass() { CompiledExpression compiledExpression = feel.compile( "{ maximum : function( v1, v2 ) external { java : { class : \"java.lang.Meth\", method signature: \"max(long,long)\" } }, the max : maximum( 10, 20 ) }.the max", feel.newCompilerContext() ); Object result = feel.evaluate(compiledExpression, new HashMap<>()); assertThat(errors).anyMatch(fe -> fe.getMessage().contains("java.lang.Meth")); } - + @Test - public void testExternalFnMissingMethod() { + void externalFnMissingMethod() { CompiledExpression compiledExpression = feel.compile( "{ maximum : function( v1, v2 ) external { java : { class : \""+Math.class.getCanonicalName()+"\", method signature: \"max(int,long)\" } }, the max : maximum( 10, 20 ) }.the max", feel.newCompilerContext() ); Object result = feel.evaluate(compiledExpression, new HashMap<>()); assertThat(errors).anyMatch(fe -> fe.getMessage().contains("max(int,int)") && fe.getMessage().contains("max(long,long)")); - } - + } + @Test - public void testExternalFnMissingMethodString() { + void externalFnMissingMethodString() { CompiledExpression compiledExpression = feel.compile( "{ fn : function( p1 ) external { java : { class : \""+SomeTestUtilClass.class.getCanonicalName()+"\", method signature: \"greet(String)\" } }, r : fn( \"John Doe\" ) }.r", feel.newCompilerContext() ); Object result = feel.evaluate(compiledExpression, new HashMap<>()); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/examples/ExamplesTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/examples/ExamplesTest.java index d70d13998a8..b05f68c5121 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/examples/ExamplesTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/examples/ExamplesTest.java @@ -18,18 +18,18 @@ */ package org.kie.dmn.feel.lang.examples; -import org.junit.BeforeClass; -import org.junit.Test; +import java.math.BigDecimal; +import java.util.Map; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.FEEL; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.math.BigDecimal; -import java.util.Map; - import static org.assertj.core.api.Assertions.assertThat; -public class ExamplesTest +class ExamplesTest extends ExamplesBaseTest { private static final Logger logger = LoggerFactory.getLogger( ExamplesTest.class ); @@ -37,15 +37,15 @@ public class ExamplesTest private static Map context; private static FEEL feel; - @BeforeClass - public static void setupTest() { + @BeforeAll + static void setupTest() { String expression = loadExpression( "example_10_6_1.feel" ); feel = FEEL.newInstance(); context = (Map) feel.evaluate( expression ); } @Test - public void testLoadApplicantContext() { + void loadApplicantContext() { String expression = loadExpression( "applicant.feel" ); Map applicant = (Map) feel.evaluate( expression ); System.out.println( printContext( applicant ) ); @@ -54,13 +54,13 @@ public void testLoadApplicantContext() { } @Test - public void testLoadExample_10_6_1() { + void loadExample1061() { System.out.println( printContext( context ) ); assertThat(context).hasSize(6); } @Test - public void testLoadExample_10_6_2() { + void loadExample1062() { Number yearlyIncome = (Number) feel.evaluate( "monthly income * 12", context ); System.out.println( "Yearly income = " + yearlyIncome ); @@ -69,7 +69,7 @@ public void testLoadExample_10_6_2() { } @Test - public void testLoadExample_10_6_3() { + void loadExample1063() { String expression = loadExpression( "example_10_6_3.feel" ); String maritalStatus = (String) feel.evaluate( expression, context ); @@ -80,7 +80,7 @@ public void testLoadExample_10_6_3() { } @Test - public void testLoadExample_10_6_4() { + void loadExample1064() { Number totalExpenses = (Number) feel.evaluate( "sum( monthly outgoings )", context ); System.out.println( "Monthly total expenses = " + totalExpenses ); @@ -89,7 +89,7 @@ public void testLoadExample_10_6_4() { } @Test - public void testLoadExample_10_6_5() { + void loadExample1065() { String expression = loadExpression( "example_10_6_5.feel" ); Number pmt = (Number) feel.evaluate( expression, context ); @@ -100,7 +100,7 @@ public void testLoadExample_10_6_5() { } @Test - public void testLoadExample_10_6_6() { + void loadExample1066() { String expression = loadExpression( "example_10_6_6.feel" ); Number total = (Number) feel.evaluate( expression, context ); @@ -111,7 +111,7 @@ public void testLoadExample_10_6_6() { } @Test - public void testLoadExample_10_6_7() { + void loadExample1067() { String expression = loadExpression( "example_10_6_7.feel" ); Boolean bankrupcy = (Boolean) feel.evaluate( expression, context ); @@ -122,7 +122,7 @@ public void testLoadExample_10_6_7() { } @Test - public void testJavaCall() { + void javaCall() { String expression = loadExpression( "javacall.feel" ); Map context = (Map) feel.evaluate( expression ); @@ -131,7 +131,7 @@ public void testJavaCall() { } @Test - public void testAdhocExpression() { + void adhocExpression() { String expression = loadExpression( "custom.feel" ); Object result = feel.evaluate( expression ); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/FEELProfileTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/FEELProfileTest.java index e4685eb7cf8..a091bf74237 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/FEELProfileTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/FEELProfileTest.java @@ -18,11 +18,10 @@ */ package org.kie.dmn.feel.lang.impl; -import java.util.Arrays; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.FEEL; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.lang.FEELProfile; @@ -34,10 +33,10 @@ import static org.kie.dmn.feel.util.DynamicTypeUtils.entry; import static org.kie.dmn.feel.util.DynamicTypeUtils.mapOf; -public class FEELProfileTest { +class FEELProfileTest { @Test - public void testFeelProfileFunctionsAndValues() { + void feelProfileFunctionsAndValues() { // Instantiate a new FEEL with the profile to try the method that uses the data cache FEEL feel = FEEL.newInstance(List.of(new TestFEELProfile())); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/JavaBackedTypeTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/JavaBackedTypeTest.java index 473b5a93aea..0cca02fa068 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/JavaBackedTypeTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/JavaBackedTypeTest.java @@ -20,17 +20,17 @@ import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.CompositeType; import org.kie.dmn.feel.lang.FEELType; import org.kie.dmn.feel.model.Person; import static org.assertj.core.api.Assertions.assertThat; -public class JavaBackedTypeTest { +class JavaBackedTypeTest { @Test - public void testPerson() { + void person() { CompositeType personType = (CompositeType) JavaBackedType.of( Person.class ); Set personProperties = personType.getFields().keySet(); @@ -72,9 +72,9 @@ private String getBPrivate() { return b; } } - + @Test - public void testMyPojoNoMethodAnn() { + void myPojoNoMethodAnn() { CompositeType personType = (CompositeType) JavaBackedType.of( MyPojoNoMethodAnn.class ); Set personProperties = personType.getFields().keySet(); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/MapBackedTypeTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/MapBackedTypeTest.java index b5500bc7295..590aeb87070 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/MapBackedTypeTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/MapBackedTypeTest.java @@ -18,18 +18,19 @@ */ package org.kie.dmn.feel.lang.impl; -import static org.kie.dmn.feel.util.DynamicTypeUtils.*; - import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.lang.types.BuiltInType; import static org.assertj.core.api.Assertions.assertThat; -import org.kie.dmn.feel.lang.types.BuiltInType; +import static org.kie.dmn.feel.util.DynamicTypeUtils.entry; +import static org.kie.dmn.feel.util.DynamicTypeUtils.mapOf; +import static org.kie.dmn.feel.util.DynamicTypeUtils.prototype; -public class MapBackedTypeTest { +class MapBackedTypeTest { @Test - public void testBasic() { + void basic() { MapBackedType personType = new MapBackedType( "Person" , mapOf( entry("First Name", BuiltInType.STRING), entry("Last Name", BuiltInType.STRING) )); Map aPerson = prototype( entry("First Name", "John"), entry("Last Name", "Doe") ); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/TemporalConstantFoldingParserTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/TemporalConstantFoldingParserTest.java index ef705a4f550..0e63e1eb269 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/TemporalConstantFoldingParserTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/impl/TemporalConstantFoldingParserTest.java @@ -21,10 +21,8 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.feel.FEEL; import org.kie.dmn.feel.codegen.feel11.ProcessedExpression; import org.kie.dmn.feel.lang.CompiledExpression; @@ -35,10 +33,8 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class TemporalConstantFoldingParserTest { - @Parameters(name = "{0}") public static Iterable data() { return Arrays.asList("date(\"2021-02-13\")", "date(2021, 2, 13)", @@ -48,15 +44,15 @@ public static Iterable data() { "duration(\"P1Y\")", "duration(\"P2DT20H14M\")"); } - - @Parameterized.Parameter(0) public String expression; static final FEEL FEEL_STRICT = FEEL.newInstance(); static final FEEL FEEL_KIE = FEEL.newInstance(List.of(new KieExtendedFEELProfile())); - @Test - public void testStrict() { + @MethodSource("data") + @ParameterizedTest(name = "{0}") + public void strict(String expression) { + initTemporalConstantFoldingParserTest(expression); CompilerContext ctx = FEEL_STRICT.newCompilerContext(); CompiledExpression compile = FEEL_STRICT.compile(expression, ctx); ASTNode ast = extractAST(compile); @@ -64,8 +60,10 @@ public void testStrict() { assertThat(((FunctionInvocationNode) ast).getTcFolded()).isNotNull(); } - @Test - public void testKie() { + @MethodSource("data") + @ParameterizedTest(name = "{0}") + public void kie(String expression) { + initTemporalConstantFoldingParserTest(expression); CompilerContext ctx = FEEL_KIE.newCompilerContext(); CompiledExpression compile = FEEL_KIE.compile(expression, ctx); ASTNode ast = extractAST(compile); @@ -77,4 +75,8 @@ private ASTNode extractAST(CompiledExpression compile) { return ((ProcessedExpression) compile).getInterpreted().getASTNode(); } + public void initTemporalConstantFoldingParserTest(String expression) { + this.expression = expression; + } + } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/types/impl/ImmutableFPAWrappingPOJOTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/types/impl/ImmutableFPAWrappingPOJOTest.java index 02d807d4096..72c54933499 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/types/impl/ImmutableFPAWrappingPOJOTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/types/impl/ImmutableFPAWrappingPOJOTest.java @@ -18,16 +18,16 @@ */ package org.kie.dmn.feel.lang.types.impl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.model.SupportRequest; import org.kie.dmn.feel.util.EvalHelper.PropertyValueResult; import static org.assertj.core.api.Assertions.assertThat; -public class ImmutableFPAWrappingPOJOTest { +class ImmutableFPAWrappingPOJOTest { @Test - public void testSupportRequest() { + void supportRequest() { ImmutableFPAWrappingPOJO fpa = new ImmutableFPAWrappingPOJO(new SupportRequest("John Doe", "47", "info@redhat.com", "+1", "somewhere", "tech", "app crashed", false)); assertThat(fpa.getFEELProperty("full name").toOptional()).contains("John Doe"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELCodeMarshallerTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELCodeMarshallerTest.java index c77a873b737..8b2adc20b4d 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELCodeMarshallerTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELCodeMarshallerTest.java @@ -18,26 +18,30 @@ */ package org.kie.dmn.feel.marshaller; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; -import org.kie.dmn.feel.runtime.Range; -import org.kie.dmn.feel.runtime.impl.RangeImpl; - import java.math.BigDecimal; -import java.time.*; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.Period; +import java.time.ZoneOffset; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashMap; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; +import org.kie.dmn.feel.runtime.Range; +import org.kie.dmn.feel.runtime.impl.RangeImpl; + import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class FEELCodeMarshallerTest { - @Parameterized.Parameters(name = "{index}: {0} ({1}) = {2}") - public static Collection data() { + private static Collection data() { final Object[][] cases = new Object[][] { // numbers { BigDecimal.valueOf( 2 ), "2" }, @@ -102,15 +106,13 @@ public static Collection data() { }; return Arrays.asList( cases ); } - - @Parameterized.Parameter(0) public Object value; - - @Parameterized.Parameter(1) public String result; - @Test - public void testExpression() { + @MethodSource("data") + @ParameterizedTest(name = "{index}: {0} ({1}) = {2}") + public void expression(Object value, String result) { + initFEELCodeMarshallerTest(value, result); assertResult( value, result ); } @@ -121,4 +123,9 @@ protected void assertResult( Object value, String result ) { assertThat(FEELCodeMarshaller.INSTANCE.marshall( value )).as("Marshalling: '" + value + "'").isEqualTo(result); } } + + public void initFEELCodeMarshallerTest(Object value, String result) { + this.value = value; + this.result = result; + } } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELCodeMarshallerUnmarshallTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELCodeMarshallerUnmarshallTest.java index 884fc43a663..aa2457b8362 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELCodeMarshallerUnmarshallTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELCodeMarshallerUnmarshallTest.java @@ -30,9 +30,8 @@ import java.util.Collection; import java.util.LinkedHashMap; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.feel.lang.Type; import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; @@ -41,11 +40,9 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class FEELCodeMarshallerUnmarshallTest { - @Parameterized.Parameters(name = "{index}: {0} ({1}) = {2}") - public static Collection data() { + private static Collection data() { final Object[][] cases = new Object[][] { // numbers { BuiltInType.UNKNOWN, "2", BigDecimal.valueOf( 2 ) }, @@ -104,18 +101,14 @@ public static Collection data() { }; return Arrays.asList( cases ); } - - @Parameterized.Parameter(0) public Type feelType; - - @Parameterized.Parameter(1) public String value; - - @Parameterized.Parameter(2) public Object result; - @Test - public void testExpression() { + @MethodSource("data") + @ParameterizedTest(name = "{index}: {0} ({1}) = {2}") + public void expression(Type feelType, String value, Object result) { + initFEELCodeMarshallerUnmarshallTest(feelType, value, result); assertResult( feelType, value, result ); } @@ -126,4 +119,10 @@ protected void assertResult(Type feelType, String value, Object result ) { assertThat(FEELCodeMarshaller.INSTANCE.unmarshall( feelType, value )).as("Unmarshalling: '" + value + "'").isEqualTo(result); } } + + public void initFEELCodeMarshallerUnmarshallTest(Type feelType, String value, Object result) { + this.feelType = feelType; + this.value = value; + this.result = result; + } } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELStringMarshallerTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELStringMarshallerTest.java index 746890ec8c6..5b0f619a050 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELStringMarshallerTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELStringMarshallerTest.java @@ -18,26 +18,30 @@ */ package org.kie.dmn.feel.marshaller; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; -import org.kie.dmn.feel.runtime.Range; -import org.kie.dmn.feel.runtime.impl.RangeImpl; - import java.math.BigDecimal; -import java.time.*; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.Period; +import java.time.ZoneOffset; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashMap; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; +import org.kie.dmn.feel.runtime.Range; +import org.kie.dmn.feel.runtime.impl.RangeImpl; + import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class FEELStringMarshallerTest { - @Parameterized.Parameters(name = "{index}: {0} ({1}) = {2}") - public static Collection data() { + private static Collection data() { final Object[][] cases = new Object[][] { // numbers { BigDecimal.valueOf( 2 ), "2" }, @@ -103,15 +107,13 @@ public static Collection data() { }; return Arrays.asList( cases ); } - - @Parameterized.Parameter(0) public Object value; - - @Parameterized.Parameter(1) public String result; - @Test - public void testExpression() { + @MethodSource("data") + @ParameterizedTest(name = "{index}: {0} ({1}) = {2}") + public void expression(Object value, String result) { + initFEELStringMarshallerTest(value, result); assertResult( value, result ); } @@ -122,4 +124,9 @@ protected void assertResult( Object value, String result ) { assertThat(FEELStringMarshaller.INSTANCE.marshall(value)).as("Marshalling: '" + value + "'").isEqualTo(result); } } + + public void initFEELStringMarshallerTest(Object value, String result) { + this.value = value; + this.result = result; + } } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELStringMarshallerUnmarshallTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELStringMarshallerUnmarshallTest.java index bd03420773b..578b7944a45 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELStringMarshallerUnmarshallTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/marshaller/FEELStringMarshallerUnmarshallTest.java @@ -29,20 +29,17 @@ import java.util.Arrays; import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.feel.lang.Type; import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class FEELStringMarshallerUnmarshallTest { - @Parameterized.Parameters(name = "{index}: {0} ({1}) = {2}") - public static Collection data() { + private static Collection data() { final Object[][] cases = new Object[][] { // numbers { BuiltInType.NUMBER, "2", BigDecimal.valueOf( 2 ) }, @@ -93,18 +90,14 @@ public static Collection data() { }; return Arrays.asList( cases ); } - - @Parameterized.Parameter(0) public Type feelType; - - @Parameterized.Parameter(1) public String value; - - @Parameterized.Parameter(2) public Object result; - @Test - public void testExpression() { + @MethodSource("data") + @ParameterizedTest(name = "{index}: {0} ({1}) = {2}") + public void expression(Type feelType, String value, Object result) { + initFEELStringMarshallerUnmarshallTest(feelType, value, result); assertResult( feelType, value, result ); } @@ -115,4 +108,10 @@ protected void assertResult(Type feelType, String value, Object result ) { assertThat(FEELStringMarshaller.INSTANCE.unmarshall( feelType, value )).as("Unmarshalling: '" + value + "'").isEqualTo(result); } } + + public void initFEELStringMarshallerUnmarshallTest(Type feelType, String value, Object result) { + this.feelType = feelType; + this.value = value; + this.result = result; + } } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/parser/feel11/FEELParserSeverityTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/parser/feel11/FEELParserSeverityTest.java index b2327d905d2..6f499898978 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/parser/feel11/FEELParserSeverityTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/parser/feel11/FEELParserSeverityTest.java @@ -20,7 +20,7 @@ import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.api.feel.runtime.events.FEELEventListener; import org.kie.dmn.feel.codegen.feel11.ProcessedExpression; @@ -44,12 +44,12 @@ import static org.mockito.Mockito.verify; -public class FEELParserSeverityTest { +class FEELParserSeverityTest { private static final Logger LOG = LoggerFactory.getLogger(FEELParserSeverityTest.class); @Test - public void testUnexistentOperatorGTGT() { + void unexistentOperatorGTGT() { // RHDM-1119 String inputExpression = "1 >> 2"; ASTNode number = parseSeverity(inputExpression, FEELEvent.Severity.WARN); @@ -60,7 +60,7 @@ public void testUnexistentOperatorGTGT() { } @Test - public void testUnexistentOperatorGTGTGT() { + void unexistentOperatorGTGTGT() { // RHDM-1119 String inputExpression = "1 >>> 2"; ASTNode number = parseSeverity(inputExpression, FEELEvent.Severity.WARN); @@ -71,7 +71,7 @@ public void testUnexistentOperatorGTGTGT() { } @Test - public void testUnexistentOperatorEQEQ() { + void unexistentOperatorEQEQ() { // RHDM-1119 String inputExpression = "1 == 2"; ASTNode number = parseSeverity(inputExpression, FEELEvent.Severity.WARN); @@ -82,7 +82,7 @@ public void testUnexistentOperatorEQEQ() { } @Test - public void testUnexistentOperatorInvokeLTLT() { + void unexistentOperatorInvokeLTLT() { // RHDM-1119 String inputExpression = "{ m: <<18 }.m(16)"; ASTNode number = parseSeverity(inputExpression, FEELEvent.Severity.WARN); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/parser/feel11/FEELParserTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/parser/feel11/FEELParserTest.java index 5206b3d4407..611e7ba3945 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/parser/feel11/FEELParserTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/parser/feel11/FEELParserTest.java @@ -23,10 +23,39 @@ import java.util.Map; import org.antlr.v4.runtime.tree.ParseTree; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.Type; -import org.kie.dmn.feel.lang.ast.*; +import org.kie.dmn.feel.lang.ast.ASTNode; +import org.kie.dmn.feel.lang.ast.AtLiteralNode; +import org.kie.dmn.feel.lang.ast.BaseNode; +import org.kie.dmn.feel.lang.ast.BetweenNode; +import org.kie.dmn.feel.lang.ast.BooleanNode; +import org.kie.dmn.feel.lang.ast.ContextEntryNode; +import org.kie.dmn.feel.lang.ast.ContextNode; +import org.kie.dmn.feel.lang.ast.FilterExpressionNode; +import org.kie.dmn.feel.lang.ast.ForExpressionNode; +import org.kie.dmn.feel.lang.ast.FunctionDefNode; +import org.kie.dmn.feel.lang.ast.FunctionInvocationNode; +import org.kie.dmn.feel.lang.ast.IfExpressionNode; +import org.kie.dmn.feel.lang.ast.InNode; +import org.kie.dmn.feel.lang.ast.InfixOpNode; +import org.kie.dmn.feel.lang.ast.InfixOperator; +import org.kie.dmn.feel.lang.ast.InstanceOfNode; +import org.kie.dmn.feel.lang.ast.IterationContextNode; +import org.kie.dmn.feel.lang.ast.ListNode; +import org.kie.dmn.feel.lang.ast.NameDefNode; +import org.kie.dmn.feel.lang.ast.NameRefNode; +import org.kie.dmn.feel.lang.ast.NamedParameterNode; +import org.kie.dmn.feel.lang.ast.NullNode; +import org.kie.dmn.feel.lang.ast.NumberNode; +import org.kie.dmn.feel.lang.ast.PathExpressionNode; +import org.kie.dmn.feel.lang.ast.QualifiedNameNode; +import org.kie.dmn.feel.lang.ast.QuantifiedExpressionNode; +import org.kie.dmn.feel.lang.ast.RangeNode; +import org.kie.dmn.feel.lang.ast.SignedUnaryNode; +import org.kie.dmn.feel.lang.ast.StringNode; +import org.kie.dmn.feel.lang.ast.TypeNode; import org.kie.dmn.feel.lang.impl.MapBackedType; import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.feel.util.Msg; @@ -38,7 +67,7 @@ public class FEELParserTest { @Test - public void testIntegerLiteral() { + void integerLiteral() { String inputExpression = "10"; BaseNode number = parse( inputExpression ); @@ -48,7 +77,7 @@ public void testIntegerLiteral() { } @Test - public void testNegativeIntegerLiteral() { + void negativeIntegerLiteral() { String inputExpression = "-10"; BaseNode number = parse( inputExpression ); @@ -63,7 +92,7 @@ public void testNegativeIntegerLiteral() { } @Test - public void testPositiveIntegerLiteral() { + void positiveIntegerLiteral() { String inputExpression = "+10"; BaseNode number = parse( inputExpression ); @@ -78,7 +107,7 @@ public void testPositiveIntegerLiteral() { } @Test - public void testFloatLiteral() { + void floatLiteral() { String inputExpression = "10.5"; BaseNode number = parse( inputExpression ); @@ -88,7 +117,7 @@ public void testFloatLiteral() { } @Test - public void testNegativeFloatLiteral() { + void negativeFloatLiteral() { String inputExpression = "-10.5"; BaseNode number = parse( inputExpression ); @@ -103,7 +132,7 @@ public void testNegativeFloatLiteral() { } @Test - public void testPositiveFloatLiteral() { + void positiveFloatLiteral() { String inputExpression = "+10.5"; BaseNode number = parse( inputExpression ); @@ -118,7 +147,7 @@ public void testPositiveFloatLiteral() { } @Test - public void testBooleanTrueLiteral() { + void booleanTrueLiteral() { String inputExpression = "true"; BaseNode bool = parse( inputExpression ); @@ -128,7 +157,7 @@ public void testBooleanTrueLiteral() { } @Test - public void testBooleanFalseLiteral() { + void booleanFalseLiteral() { String inputExpression = "false"; BaseNode bool = parse( inputExpression ); @@ -138,7 +167,7 @@ public void testBooleanFalseLiteral() { } @Test - public void testAtLiteralDate() { + void atLiteralDate() { String inputExpression = "@\"2016-07-29\""; BaseNode bool = parse(inputExpression); @@ -148,7 +177,7 @@ public void testAtLiteralDate() { } @Test - public void testAtLiteralTime() { + void atLiteralTime() { String inputExpression = "@\"23:59:00\""; BaseNode bool = parse(inputExpression); @@ -158,7 +187,7 @@ public void testAtLiteralTime() { } @Test - public void testAtLiteralDateAndTime() { + void atLiteralDateAndTime() { String inputExpression = "@\"2016-07-29T05:48:23\""; BaseNode bool = parse(inputExpression); @@ -168,7 +197,7 @@ public void testAtLiteralDateAndTime() { } @Test - public void testAtLiteralDuration() { + void atLiteralDuration() { String inputExpression = "@\"P2Y2M\""; BaseNode bool = parse(inputExpression); @@ -178,7 +207,7 @@ public void testAtLiteralDuration() { } @Test - public void testNullLiteral() { + void nullLiteral() { String inputExpression = "null"; BaseNode nullLit = parse( inputExpression ); @@ -188,7 +217,7 @@ public void testNullLiteral() { } @Test - public void testStringLiteral() { + void stringLiteral() { String inputExpression = "\"some string\""; BaseNode stringLit = parse( inputExpression ); @@ -199,7 +228,7 @@ public void testStringLiteral() { } @Test - public void testNameReference() { + void nameReference() { String inputExpression = "someSimpleName"; BaseNode nameRef = parse( inputExpression, mapOf( entry("someSimpleName", BuiltInType.STRING))); @@ -209,7 +238,7 @@ public void testNameReference() { } @Test - public void testQualifiedName() { + void qualifiedName() { String inputExpression = "My Person.Full Name"; MapBackedType personType = new MapBackedType("Person", mapOf( entry("Full Name", BuiltInType.STRING), entry("Age", BuiltInType.NUMBER))); BaseNode qualRef = parse( inputExpression, mapOf( entry("My Person", personType))); @@ -229,7 +258,7 @@ public void testQualifiedName() { } @Test - public void testParensWithLiteral() { + void parensWithLiteral() { String inputExpression = "(10.5 )"; BaseNode number = parse( inputExpression ); @@ -239,7 +268,7 @@ public void testParensWithLiteral() { } @Test - public void testLogicalNegation() { + void logicalNegation() { String inputExpression = "not ( true )"; BaseNode neg = parse( inputExpression ); @@ -254,7 +283,7 @@ public void testLogicalNegation() { } @Test - public void testMultiplication() { + void multiplication() { String inputExpression = "10 * x"; BaseNode infix = parse( inputExpression, mapOf(entry("x", BuiltInType.NUMBER)) ); @@ -273,7 +302,7 @@ public void testMultiplication() { } @Test - public void testDivision() { + void division() { String inputExpression = "y / 5 * ( x )"; BaseNode infix = parse( inputExpression, mapOf(entry("x", BuiltInType.NUMBER), entry("y", BuiltInType.NUMBER)) ); @@ -301,7 +330,7 @@ public void testDivision() { } @Test - public void testPower1() { + void power1() { String inputExpression = "y * 5 ** 3"; BaseNode infix = parse( inputExpression, mapOf(entry("y", BuiltInType.NUMBER)) ); @@ -329,7 +358,7 @@ public void testPower1() { } @Test - public void testPower2() { + void power2() { String inputExpression = "(y * 5) ** 3"; BaseNode infix = parse( inputExpression, mapOf(entry("y", BuiltInType.NUMBER)) ); @@ -357,7 +386,7 @@ public void testPower2() { } @Test - public void testPower3() { + void power3() { String inputExpression = "y ** 5 * 3"; BaseNode infix = parse( inputExpression, mapOf(entry("y", BuiltInType.NUMBER)) ); @@ -385,7 +414,7 @@ public void testPower3() { } @Test - public void testPower4() { + void power4() { String inputExpression = "y ** ( 5 * 3 )"; BaseNode infix = parse( inputExpression, mapOf(entry("y", BuiltInType.NUMBER)) ); @@ -413,7 +442,7 @@ public void testPower4() { } @Test - public void testAdd1() { + void add1() { String inputExpression = "y + 5 * 3"; BaseNode infix = parse( inputExpression, mapOf(entry("y", BuiltInType.NUMBER)) ); @@ -441,7 +470,7 @@ public void testAdd1() { } @Test - public void testSub1() { + void sub1() { String inputExpression = "(y - 5) ** 3"; BaseNode infix = parse( inputExpression, mapOf(entry("y", BuiltInType.NUMBER)) ); @@ -469,7 +498,7 @@ public void testSub1() { } @Test - public void testBetween() { + void between() { String inputExpression = "x between 10+y and 3**z"; BaseNode between = parse( inputExpression ); @@ -489,7 +518,7 @@ public void testBetween() { } @Test - public void testInValueList() { + void inValueList() { // TODO review this test might be wrong as list is not homogeneous String inputExpression = "x / 4 in ( 10+y, true, 80, someVar )"; BaseNode inNode = parse( inputExpression ); @@ -513,7 +542,7 @@ public void testInValueList() { } @Test - public void testInUnaryTestList() { + void inUnaryTestList() { String inputExpression = "x ** y in ( <=1000, >t, null, (2000..z[, ]z..2000], [(10+5)..(a*b)) )"; BaseNode inNode = parse( inputExpression ); @@ -565,7 +594,7 @@ public void testInUnaryTestList() { } @Test - public void testInUnaryTest() { + void inUnaryTest() { String inputExpression = "x - y in [(10+5)..(a*b))"; BaseNode inNode = parse( inputExpression ); @@ -582,7 +611,7 @@ public void testInUnaryTest() { } @Test - public void testInUnaryTestStrings() { + void inUnaryTestStrings() { final String inputExpression = "name in [\"A\"..\"Z...\")"; final BaseNode inNode = parse( inputExpression ); @@ -598,7 +627,7 @@ public void testInUnaryTestStrings() { } @Test - public void testComparisonInFixOp() { + void comparisonInFixOp() { String inputExpression = "foo >= bar * 10"; BaseNode infix = parse( inputExpression ); @@ -615,7 +644,7 @@ public void testComparisonInFixOp() { } @Test - public void testConditionalLogicalOp() { + void conditionalLogicalOp() { String inputExpression = "foo < 10 and bar = \"x\" or baz"; BaseNode infix = parse( inputExpression ); @@ -643,7 +672,7 @@ public void testConditionalLogicalOp() { } @Test - public void testEmptyList() { + void emptyList() { String inputExpression = "[]"; BaseNode list = parse( inputExpression ); @@ -656,7 +685,7 @@ public void testEmptyList() { } @Test - public void testExpressionList() { + void expressionList() { // TODO review this test is potentially wrong as the list is not homogeneous String inputExpression = "[ 10, foo * bar, true ]"; BaseNode list = parse( inputExpression ); @@ -673,7 +702,7 @@ public void testExpressionList() { } @Test - public void testEmptyContext() { + void emptyContext() { String inputExpression = "{}"; BaseNode context = parse( inputExpression ); @@ -685,7 +714,7 @@ public void testEmptyContext() { } @Test - public void testContextWithMultipleEntries() { + void contextWithMultipleEntries() { String inputExpression = "{ \"a string key\" : 10," + " a non-string key : foo+bar," + " a key.with + /' odd chars : [10..50] }"; @@ -728,7 +757,7 @@ public void testContextWithMultipleEntries() { } @Test - public void testVariableWithInKeyword() { + void variableWithInKeyword() { String inputExpression = "{ a variable with in keyword : 10, " + " another variable : a variable with in keyword + 20, " + " another in variable : an external in variable / 2 }"; @@ -772,7 +801,7 @@ public void testVariableWithInKeyword() { } @Test - public void testNestedContexts() { + void nestedContexts() { String inputExpression = "{ a value : 10," + " an applicant : { " + " first name : \"Edson\", " @@ -827,7 +856,7 @@ public void testNestedContexts() { } @Test - public void testNestedContexts2() { + void nestedContexts2() { String inputExpression = "{ an applicant : { " + " home address : {" + " street name: \"broadway st\"," @@ -857,7 +886,7 @@ public void testNestedContexts2() { } @Test - public void testFunctionDefinition() { + void functionDefinition() { String inputExpression = "{ is minor : function( person's age ) person's age < 21 }"; BaseNode ctxbase = parse( inputExpression ); @@ -882,7 +911,7 @@ public void testFunctionDefinition() { } @Test - public void testExternalFunctionDefinition() { + void externalFunctionDefinition() { String inputExpression = "{ trigonometric cosine : function( angle ) external {" + " java : {" + " class : \"java.lang.Math\"," @@ -932,7 +961,7 @@ public void testExternalFunctionDefinition() { } @Test - public void testForExpression() { + void forExpression() { String inputExpression = "for item in order.items return item.price * item.quantity"; BaseNode forbase = parse( inputExpression ); @@ -952,7 +981,7 @@ public void testForExpression() { } @Test - public void testIfExpression() { + void ifExpression() { String inputExpression = "if applicant.age < 18 then \"declined\" else \"accepted\""; BaseNode ifBase = parse( inputExpression ); @@ -967,7 +996,7 @@ public void testIfExpression() { } @Test - public void testQuantifiedExpressionSome() { + void quantifiedExpressionSome() { String inputExpression = "some item in order.items satisfies item.price > 100"; BaseNode someBase = parse( inputExpression ); @@ -983,7 +1012,7 @@ public void testQuantifiedExpressionSome() { } @Test - public void testQuantifiedExpressionEvery() { + void quantifiedExpressionEvery() { String inputExpression = "every item in order.items satisfies item.price > 100"; BaseNode everyBase = parse( inputExpression ); @@ -999,7 +1028,7 @@ public void testQuantifiedExpressionEvery() { } @Test - public void testInstanceOfExpression() { + void instanceOfExpression() { String inputExpression = "\"foo\" instance of string"; BaseNode instanceOfBase = parse( inputExpression ); @@ -1015,7 +1044,7 @@ public void testInstanceOfExpression() { } @Test - public void testInstanceOfExpressionAnd() { + void instanceOfExpressionAnd() { String inputExpression = "\"foo\" instance of string and 10 instance of number"; BaseNode andExpr = parse( inputExpression ); @@ -1046,7 +1075,7 @@ public void testInstanceOfExpressionAnd() { } @Test - public void testInstanceOfExpressionFunction() { + void instanceOfExpressionFunction() { String inputExpression = "duration instance of function"; BaseNode instanceOfBase = parse( inputExpression ); @@ -1062,7 +1091,7 @@ public void testInstanceOfExpressionFunction() { } @Test - public void testPathExpression() { + void pathExpression() { String inputExpression = "[ 10, 15 ].size"; BaseNode pathBase = parse( inputExpression ); @@ -1077,7 +1106,7 @@ public void testPathExpression() { } @Test - public void testFilterExpression() { + void filterExpression() { String inputExpression = "[ {x:1, y:2}, {x:2, y:3} ][ x=1 ]"; BaseNode filterBase = parse( inputExpression ); @@ -1092,7 +1121,7 @@ public void testFilterExpression() { } @Test - public void testFunctionInvocationNamedParams() { + void functionInvocationNamedParams() { String inputExpression = "my.test.Function( named parameter 1 : x+10, named parameter 2 : \"foo\" )"; BaseNode functionBase = parse( inputExpression ); @@ -1121,7 +1150,7 @@ public void testFunctionInvocationNamedParams() { } @Test - public void testFunctionInvocationPositionalParams() { + void functionInvocationPositionalParams() { String inputExpression = "my.test.Function( x+10, \"foo\" )"; BaseNode functionBase = parse( inputExpression ); @@ -1138,7 +1167,7 @@ public void testFunctionInvocationPositionalParams() { } @Test - public void testFunctionInvocationWithKeyword() { + void functionInvocationWithKeyword() { String inputExpression = "date and time( \"2016-07-29T19:47:53\" )"; BaseNode functionBase = parse( inputExpression ); @@ -1154,7 +1183,7 @@ public void testFunctionInvocationWithKeyword() { } @Test - public void testFunctionInvocationWithExpressionParameters() { + void functionInvocationWithExpressionParameters() { String inputExpression = "date and time( date(\"2016-07-29\"), time(\"19:47:53\") )"; BaseNode functionBase = parse( inputExpression ); @@ -1171,7 +1200,7 @@ public void testFunctionInvocationWithExpressionParameters() { } @Test - public void testFunctionInvocationEmptyParams() { + void functionInvocationEmptyParams() { String inputExpression = "my.test.Function()"; BaseNode functionBase = parse( inputExpression ); @@ -1185,9 +1214,9 @@ public void testFunctionInvocationEmptyParams() { assertThat( function.getParams().getElements()).isEmpty(); } - @Ignore("dropped since DMNv1.2") + @Disabled("dropped since DMNv1.2") @Test - public void testFunctionDecisionTableInvocation() { + void functionDecisionTableInvocation() { String inputExpression = "decision table( " + " outputs: \"Applicant Risk Rating\"," + " input expression list: [\"Applicant Age\", \"Medical History\"]," @@ -1255,7 +1284,7 @@ public void testFunctionDecisionTableInvocation() { } @Test - public void testContextPathExpression() { + void contextPathExpression() { String inputExpression = "{ x : \"foo\" }.x"; BaseNode pathBase = parse( inputExpression ); @@ -1271,7 +1300,7 @@ public void testContextPathExpression() { } @Test - public void testContextPathExpression2() { + void contextPathExpression2() { String inputExpression = "{ x : { y : \"foo\" } }.x.y"; BaseNode pathBase = parse( inputExpression ); @@ -1287,7 +1316,7 @@ public void testContextPathExpression2() { } @Test - public void testContextPathExpression3() { + void contextPathExpression3() { String inputExpression = "{ first name : \"bob\" }.first name"; BaseNode pathBase = parse( inputExpression ); @@ -1303,53 +1332,53 @@ public void testContextPathExpression3() { } @Test - public void testVariableName() { + void variableName() { String var = "valid variable name"; assertThat( FEELParser.isVariableNameValid( var )).isEqualTo(true); } @Test - public void testVariableNameWithValidCharacters() { + void variableNameWithValidCharacters() { String var = "?_873./-'+*valid"; assertThat( FEELParser.isVariableNameValid( var )).isEqualTo(true); } @Test - public void testVariableNameWithValidCharactersHorseEmoji() { + void variableNameWithValidCharactersHorseEmoji() { String var = "🐎"; assertThat(FEELParser.isVariableNameValid(var)).isEqualTo(true); } @Test - public void testVariableNameWithInvalidCharacterPercentSimplified() { + void variableNameWithInvalidCharacterPercentSimplified() { String var = "banana%mango"; assertThat(FEELParser.isVariableNameValid(var)).isEqualTo(false); assertThat(FEELParser.checkVariableName(var).get(0).getMessage()).isEqualTo(Msg.createMessage(Msg.INVALID_VARIABLE_NAME, "character", "%")); } @Test - public void testVariableNameWithInvalidCharacterPercent() { + void variableNameWithInvalidCharacterPercent() { String var = "?_873./-'%+*valid"; assertThat( FEELParser.isVariableNameValid( var )).isEqualTo(false); assertThat( FEELParser.checkVariableName( var ).get( 0 ).getMessage()).isEqualTo( Msg.createMessage(Msg.INVALID_VARIABLE_NAME, "character", "%")); } @Test - public void testVariableNameWithInvalidCharacterAt() { + void variableNameWithInvalidCharacterAt() { String var = "?_873./-'@+*valid"; assertThat(FEELParser.isVariableNameValid(var)).isEqualTo(false); assertThat(FEELParser.checkVariableName(var).get(0).getMessage()).isEqualTo(Msg.createMessage(Msg.INVALID_VARIABLE_NAME, "character", "@")); } @Test - public void testVariableNameInvalidStartCharacter() { + void variableNameInvalidStartCharacter() { String var = "5variable can't start with a number"; assertThat( FEELParser.isVariableNameValid( var )).isEqualTo(false); assertThat( FEELParser.checkVariableName( var ).get( 0 ).getMessage()).isEqualTo( Msg.createMessage(Msg.INVALID_VARIABLE_NAME_START, "character", "5")); } @Test - public void testVariableNameCantStartWithKeyword() { + void variableNameCantStartWithKeyword() { String var = "for keyword is an invalid start for a variable name"; assertThat( FEELParser.isVariableNameValid( var )).isEqualTo(false); assertThat( FEELParser.checkVariableName( var ).get( 0 ).getMessage()).isEqualTo( Msg.createMessage(Msg.INVALID_VARIABLE_NAME_START, "keyword", "for")); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/BaseFEELCompilerTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/BaseFEELCompilerTest.java index 9dfdc8ace40..5fd2f0b4557 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/BaseFEELCompilerTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/BaseFEELCompilerTest.java @@ -23,9 +23,6 @@ import java.util.List; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.dmn.feel.FEEL; import org.kie.dmn.feel.lang.CompiledExpression; import org.kie.dmn.feel.lang.CompilerContext; @@ -35,32 +32,34 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public abstract class BaseFEELCompilerTest { - @Parameterized.Parameter(4) public FEEL_TARGET testFEELTarget; private FEEL feel = null; // due to @Parameter injection by JUnit framework, need to defer FEEL init to actual instance method, to have the opportunity for the JUNit framework to initialize all the @Parameters - @Parameterized.Parameter(0) public String expression; - @Parameterized.Parameter(1) public Map inputTypes; - @Parameterized.Parameter(2) public Map inputValues; - @Parameterized.Parameter(3) public Object result; - @Test - public void testExpression() { + public void expression(String expression, Map inputTypes, Map inputValues, Object result, FEEL_TARGET testFEELTarget) { + this.expression = expression; + this.inputTypes = inputTypes; + this.inputValues =inputValues; + this.result = result; + this.testFEELTarget = testFEELTarget; + feel = (testFEELTarget == FEEL_TARGET.JAVA_TRANSLATED) ? FEEL.newInstance(Collections.singletonList(new DoCompileFEELProfile())) : FEEL.newInstance(); assertResult( expression, inputTypes, inputValues, result ); } + abstract protected void instanceTest(String expression, Map inputTypes, Map inputValues, Object result, FEEL_TARGET testFEELTarget); + + protected void assertResult(final String expression, final Map inputTypes, final Map inputValues, final Object result) { final CompilerContext ctx = feel.newCompilerContext(); inputTypes.forEach(ctx::addInputVariableType); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/BaseFEELTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/BaseFEELTest.java index 505939f0da8..0a8e5aac5a5 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/BaseFEELTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/BaseFEELTest.java @@ -21,9 +21,6 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.api.feel.runtime.events.FEELEventListener; import org.kie.dmn.feel.FEEL; @@ -39,7 +36,6 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public abstract class BaseFEELTest { public enum FEEL_TARGET { @@ -49,23 +45,24 @@ public enum FEEL_TARGET { private FEEL feel = null; // due to @Parameter injection by JUnit framework, need to defer FEEL init to actual instance method, to have the opportunity for the JUNit framework to initialize all the @Parameters - @Parameterized.Parameter(0) public String expression; - @Parameterized.Parameter(1) public Object result; - @Parameterized.Parameter(2) public FEELEvent.Severity severity; - @Parameterized.Parameter(3) public FEEL_TARGET testFEELTarget; - @Parameterized.Parameter(4) public boolean useExtendedProfile; - @Test - public void testExpression() { + public void expression(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, + Boolean useExtendedProfile) { + this.expression = expression; + this.result = result; + this.severity = severity; + this.testFEELTarget = testFEELTarget; + this.useExtendedProfile = useExtendedProfile; + final List profiles = getFEELProfilesForTests(); feel = FEEL.newInstance(profiles); final FEELEventListener listener = mock(FEELEventListener.class ); @@ -82,6 +79,9 @@ public void testExpression() { } } + protected abstract void instanceTest(String expression, Object result, FEELEvent.Severity severity, + FEEL_TARGET testFEELTarget, Boolean useExtendedProfile); + protected void assertResult(final String expression, final Object result ) { if( result == null ) { assertThat(feel.evaluate( expression )).as("Evaluating: '" + expression + "'").isNull(); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java index df581ad7781..ac46851950b 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java @@ -18,10 +18,6 @@ */ package org.kie.dmn.feel.runtime; -import org.junit.runners.Parameterized; -import org.kie.dmn.api.feel.runtime.events.FEELEvent; -import org.kie.dmn.feel.util.EvalHelper; - import java.math.BigDecimal; import java.time.LocalDate; import java.util.ArrayList; @@ -31,13 +27,23 @@ import java.util.stream.IntStream; import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.feel.runtime.events.FEELEvent; +import org.kie.dmn.feel.util.EvalHelper; + import static org.kie.dmn.feel.util.DynamicTypeUtils.entry; import static org.kie.dmn.feel.util.DynamicTypeUtils.mapOf; public class FEEL12ExtendedForLoopTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{index}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { //normal: {"for x in [1, 2, 3] return x+1", Stream.of(1, 2, 3 ).map(x -> BigDecimal.valueOf(x + 1 ) ).collect(Collectors.toList() ), null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedFunctionsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedFunctionsTest.java index f7b54c6c212..56f75ec1d62 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedFunctionsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedFunctionsTest.java @@ -23,13 +23,19 @@ import java.util.Collection; import java.util.List; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class FEEL12ExtendedFunctionsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{index}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { { "modulo( 4, 3 )", new BigDecimal( "1" ), null }, { "modulo( 12, 5 )", new BigDecimal( "2" ), null }, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELConditionsAndLoopsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELConditionsAndLoopsTest.java index a3d210b1d18..afaf6b4112d 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELConditionsAndLoopsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELConditionsAndLoopsTest.java @@ -23,12 +23,19 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class FEELConditionsAndLoopsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // if expressions { "if true then 10+5 else 10-5", BigDecimal.valueOf( 15 ) , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELContextsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELContextsTest.java index 55173c859d6..f077115a141 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELContextsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELContextsTest.java @@ -25,14 +25,20 @@ import java.util.HashMap; import java.util.List; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.impl.RangeImpl; public class FEELContextsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { { "{ first name : \"Bob\", birthday : date(\"1978-09-12\"), salutation : \"Hello \"+first name }", new HashMap() {{ diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java index ee2b27411f0..149db8271ce 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java @@ -31,14 +31,20 @@ import java.time.format.DateTimeFormatter; import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; public class FEELDateTimeDurationTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // date/time/duration function invocations { "date(\"2016-07-29\")", DateTimeFormatter.ISO_DATE.parse( "2016-07-29", LocalDate::from ) , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELErrorMessagesTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELErrorMessagesTest.java index 755d614f610..ba8f5161342 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELErrorMessagesTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELErrorMessagesTest.java @@ -18,7 +18,7 @@ */ package org.kie.dmn.feel.runtime; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.api.feel.runtime.events.FEELEventListener; import org.kie.dmn.feel.FEEL; @@ -33,11 +33,10 @@ import static org.mockito.Mockito.verify; - -public class FEELErrorMessagesTest { +class FEELErrorMessagesTest { @Test - public void unknownVariable() { + void unknownVariable() { final FEEL feel = FEEL.newInstance(); final FEELEventListener fel = Mockito.mock(FEELEventListener.class ); feel.addListener( fel ); @@ -54,7 +53,7 @@ public void unknownVariable() { } @Test - public void ifWithoutElse() { + void ifWithoutElse() { final FEEL feel = FEEL.newInstance(); final FEELEventListener fel = Mockito.mock(FEELEventListener.class); feel.addListener(fel); @@ -71,7 +70,7 @@ public void ifWithoutElse() { } @Test - public void ifWithoutElse2() { + void ifWithoutElse2() { final FEEL feel = FEEL.newInstance(); final FEELEventListener fel = Mockito.mock(FEELEventListener.class); feel.addListener(fel); @@ -88,7 +87,7 @@ public void ifWithoutElse2() { } @Test - public void ifWithoutThen() { + void ifWithoutThen() { final FEEL feel = FEEL.newInstance(); final FEELEventListener fel = Mockito.mock(FEELEventListener.class); feel.addListener(fel); @@ -105,7 +104,7 @@ public void ifWithoutThen() { } @Test - public void ifWithoutThen2() { + void ifWithoutThen2() { final FEEL feel = FEEL.newInstance(); final FEELEventListener fel = Mockito.mock(FEELEventListener.class); feel.addListener(fel); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELEventListenerTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELEventListenerTest.java index 4d6e6fea335..2f8d6cf918c 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELEventListenerTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELEventListenerTest.java @@ -18,14 +18,14 @@ */ package org.kie.dmn.feel.runtime; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity; import org.kie.dmn.feel.FEEL; import static org.assertj.core.api.Assertions.assertThat; -public class FEELEventListenerTest { +class FEELEventListenerTest { private static final String LISTENER_OUTPUT = "Listener output"; @@ -33,8 +33,8 @@ public class FEELEventListenerTest { private String testVariable; - @Before - public void setup() { + @BeforeEach + void setup() { testVariable = null; feel = FEEL.newInstance(); feel.addListener(event -> testVariable = LISTENER_OUTPUT); @@ -43,13 +43,13 @@ public void setup() { } @Test - public void testParserError() { + void parserError() { feel.evaluate( "10 + / 5" ); assertThat(testVariable).isEqualTo(LISTENER_OUTPUT); } - + @Test - public void testSomeBuiltinFunctions() { + void someBuiltinFunctions() { System.out.println( feel.evaluate("append( null, 1, 2 )") ); assertThat(testVariable).isEqualTo(LISTENER_OUTPUT); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELExpressionsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELExpressionsTest.java index d7eaf253b76..5138a41a643 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELExpressionsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELExpressionsTest.java @@ -22,13 +22,19 @@ import java.util.Collection; import java.util.List; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class FEELExpressionsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // quantified expressions { "some price in [ 80, 11, 110 ] satisfies price > 100", Boolean.TRUE , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELFunctionDefinitionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELFunctionDefinitionTest.java index d2dbdf18c2c..31e5e78a60e 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELFunctionDefinitionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELFunctionDefinitionTest.java @@ -21,13 +21,19 @@ import java.math.BigDecimal; import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class FEELFunctionDefinitionTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // function definition and invocation {"{ hello : function() \"Hello World!\"}.hello()", "Hello World!", null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELFunctionsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELFunctionsTest.java index a84998a33ca..0e47e64c852 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELFunctionsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELFunctionsTest.java @@ -25,14 +25,20 @@ import java.util.Collections; import java.util.List; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; public class FEELFunctionsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // constants { "string(1.1)", "1.1" , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELListsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELListsTest.java index e8b6951fb0e..5803738dffe 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELListsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELListsTest.java @@ -25,14 +25,20 @@ import java.util.Collections; import java.util.HashMap; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.impl.RangeImpl; public class FEELListsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { { "[ 5, 10+2, \"foo\"+\"bar\", true ]", Arrays.asList( BigDecimal.valueOf( 5 ), BigDecimal.valueOf( 12 ), "foobar", Boolean.TRUE ), null }, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELMathOperationsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELMathOperationsTest.java index 0baec2d7de1..3e3ad562a39 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELMathOperationsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELMathOperationsTest.java @@ -21,14 +21,20 @@ import java.math.BigDecimal; import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.util.EvalHelper; public class FEELMathOperationsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { { "10+5", BigDecimal.valueOf( 15 ) , null}, { "10+\"5\"", null, null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELNumberCoercionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELNumberCoercionTest.java index 38ac0869c61..de319bc84b1 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELNumberCoercionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELNumberCoercionTest.java @@ -23,14 +23,14 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.FEEL; import org.kie.dmn.feel.lang.ast.InfixOperator; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.feel.util.EvalHelper.getBigDecimalOrNull; -public class FEELNumberCoercionTest { +class FEELNumberCoercionTest { private final FEEL feel = FEEL.newInstance(); private Object evaluateInfix(final Object x, final InfixOperator op, final Object y) { @@ -41,9 +41,9 @@ private Object evaluateInfix(final Object x, final InfixOperator op, final Objec System.out.println(expression); return feel.evaluate(expression, inputVariables); } - + @Test - public void test() { + void test() { assertThat( evaluateInfix( 1 , InfixOperator.LT , 2d )).isEqualTo(Boolean.TRUE); assertThat( evaluateInfix( 2d , InfixOperator.LT , 1 )).isEqualTo(Boolean.FALSE); assertThat( evaluateInfix( 1 , InfixOperator.LTE , 2d )).isEqualTo(Boolean.TRUE); @@ -66,9 +66,9 @@ private final Object evaluate(final String expression, final Map.Entry var(final String name, final Object value) { return new SimpleEntry<>(name, value); } - + @Test - public void testOthers() { + void others() { assertThat( evaluate("ceiling( 1.01 )") ).isEqualTo(getBigDecimalOrNull( 2d ) ); assertThat( evaluate("ceiling( x )", var("x", 1.01d )) ).isEqualTo(getBigDecimalOrNull( 2d ) ); assertThat( ((Map) evaluate("{ myf : function( v1, v2 ) ceiling(v1), invoked: myf(v2: false, v1: x) }", var("x", 1.01d) )).get("invoked")).isEqualTo(getBigDecimalOrNull( 2d ) ); @@ -79,7 +79,7 @@ public void testOthers() { } @Test - public void testMethodGetBigDecimalOrNull() { + void methodGetBigDecimalOrNull() { assertThat( getBigDecimalOrNull((short) 1)).isEqualTo(BigDecimal.ONE); assertThat( getBigDecimalOrNull((byte) 1)).isEqualTo(BigDecimal.ONE); assertThat( getBigDecimalOrNull(1)).isEqualTo(BigDecimal.ONE); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELOperatorsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELOperatorsTest.java index e609b9978ef..9aba1fed6c6 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELOperatorsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELOperatorsTest.java @@ -20,13 +20,19 @@ import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class FEELOperatorsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // 'not' expression { "not( true )", Boolean.FALSE , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELRangesTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELRangesTest.java index f2d533e37cb..1eda8deb2f8 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELRangesTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELRangesTest.java @@ -25,15 +25,21 @@ import java.util.Collection; import java.util.HashMap; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.impl.RangeImpl; public class FEELRangesTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][]{ {"[1..2]", new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.CLOSED), null}, {"[2..1]", new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.valueOf(2), BigDecimal.ONE, Range.RangeBoundary.CLOSED), null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELStaticTypeTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELStaticTypeTest.java index d1007cb0d1a..c8437038342 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELStaticTypeTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELStaticTypeTest.java @@ -23,7 +23,8 @@ import java.util.HashMap; import java.util.Map; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.feel.lang.Type; import org.kie.dmn.feel.lang.impl.JavaBackedType; import org.kie.dmn.feel.lang.impl.MapBackedType; @@ -34,8 +35,13 @@ public class FEELStaticTypeTest extends BaseFEELCompilerTest { - @Parameterized.Parameters(name = "{4}: {0} ({1} | {2}) = {3}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Map inputTypes, Map inputValues, Object result, BaseFEELTest.FEEL_TARGET testFEELTarget) { + expression(expression, inputTypes, inputValues, result, testFEELTarget); + } + + private static Collection data() { final Object[][] cases = new Object[][] { { "{ name : first name + last name }", diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELStringOperationsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELStringOperationsTest.java index bbbdf9891e5..2efb19ebe63 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELStringOperationsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELStringOperationsTest.java @@ -20,7 +20,9 @@ import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class FEELStringOperationsTest extends BaseFEELTest { @@ -28,8 +30,13 @@ public class FEELStringOperationsTest extends BaseFEELTest { * WARNING: do not use as JUNit's @Parameters name the index {1} within this test class, as this would result in invalid character in the XML surefire-report * Original error was: An invalid XML character (Unicode: 0x8) was found in the value of attribute "name" and element is "testcase". */ - @Parameterized.Parameters(name = "{index}: {0} ") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // string concatenation { "\"foo\"+\"bar\"", "foobar" , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELTernaryLogicTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELTernaryLogicTest.java index c1e48175d7c..9cfe87923a4 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELTernaryLogicTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELTernaryLogicTest.java @@ -20,12 +20,19 @@ import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class FEELTernaryLogicTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // ternary logic operations as per the spec { "true and true", Boolean.TRUE , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELValuesComparisonTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELValuesComparisonTest.java index 706d93bd04b..dd12b33bc4f 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELValuesComparisonTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELValuesComparisonTest.java @@ -20,12 +20,19 @@ import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class FEELValuesComparisonTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // number comparisons { "10.4 < 20.6", Boolean.TRUE , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELValuesConstantsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELValuesConstantsTest.java index 8d53f03cb0f..db32eb69f81 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELValuesConstantsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELValuesConstantsTest.java @@ -21,13 +21,19 @@ import java.math.BigDecimal; import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class FEELValuesConstantsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { // constants { "null", null , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/KieFEELExtendedFunctionsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/KieFEELExtendedFunctionsTest.java index f9eaf317a49..b3e66fb6c6b 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/KieFEELExtendedFunctionsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/KieFEELExtendedFunctionsTest.java @@ -25,7 +25,8 @@ import java.time.ZonedDateTime; import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import static org.kie.dmn.feel.util.DynamicTypeUtils.entry; @@ -33,8 +34,13 @@ public class KieFEELExtendedFunctionsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{index}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { { "string(\"Happy %.0fth birthday, Mr %s!\", 38, \"Doe\")", "Happy 38th birthday, Mr Doe!", null}, { "now()", ZonedDateTime.class , null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/TCFoldNotTCFoldTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/TCFoldNotTCFoldTest.java index 2e369cc1313..c57037b6955 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/TCFoldNotTCFoldTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/TCFoldNotTCFoldTest.java @@ -22,12 +22,19 @@ import java.time.LocalDateTime; import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.feel.runtime.events.FEELEvent; public class TCFoldNotTCFoldTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{3}: {0} ({1}) = {2}, Kie-Extended: {4}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][]{ {"date(\"2021-02-12\")", LocalDate.of(2021, 2, 12), null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AbsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AbsFunctionTest.java index 101037556d9..cfe4768dee2 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AbsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AbsFunctionTest.java @@ -18,34 +18,34 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; - import java.math.BigDecimal; import java.time.Duration; import java.time.Period; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; + import static java.math.BigDecimal.valueOf; -public class AbsFunctionTest { +class AbsFunctionTest { private AbsFunction absFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { absFunction = AbsFunction.INSTANCE; } @Test - public void testAbsFunctionNumber() { + void absFunctionNumber() { FunctionTestUtil.assertResult(absFunction.invoke(valueOf(10)), valueOf(10)); FunctionTestUtil.assertResult(absFunction.invoke(valueOf(-10)), valueOf(10)); FunctionTestUtil.assertResultError(absFunction.invoke((BigDecimal) null), InvalidParametersEvent.class); } @Test - public void testAbsFunctionDuration() { + void absFunctionDuration() { FunctionTestUtil.assertResult(absFunction.invoke(Duration.ofSeconds(100, 50 )), Duration.ofSeconds(100, 50)); FunctionTestUtil.assertResult(absFunction.invoke(Duration.ofSeconds(-100, 50 )), @@ -59,7 +59,7 @@ public void testAbsFunctionDuration() { } @Test - public void testAbsFunctionPeriod() { + void absFunctionPeriod() { FunctionTestUtil.assertResult(absFunction.invoke(Period.of( 100, 50, 0 ) ), Period.of(100, 50, 0)); FunctionTestUtil.assertResult(absFunction.invoke(Period.of( -100, 50, 0 ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AllFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AllFunctionTest.java index a3fcd336f9f..721d7ac405e 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AllFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AllFunctionTest.java @@ -21,95 +21,96 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class AllFunctionTest { +class AllFunctionTest { private AllFunction allFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { allFunction = new AllFunction(); } @Test - public void invokeBooleanParamNull() { + void invokeBooleanParamNull() { FunctionTestUtil.assertResultNull(allFunction.invoke((Boolean) null)); } @Test - public void invokeBooleanParamTrue() { + void invokeBooleanParamTrue() { FunctionTestUtil.assertResult(allFunction.invoke(true), true); } @Test - public void invokeBooleanParamFalse() { + void invokeBooleanParamFalse() { FunctionTestUtil.assertResult(allFunction.invoke(false), false); } @Test - public void invokeArrayParamNull() { + void invokeArrayParamNull() { FunctionTestUtil.assertResultError(allFunction.invoke((Object[]) null), InvalidParametersEvent.class); } @Test - public void invokeArrayParamEmptyArray() { + void invokeArrayParamEmptyArray() { FunctionTestUtil.assertResult(allFunction.invoke(new Object[]{}), true); } @Test - public void invokeArrayParamReturnTrue() { + void invokeArrayParamReturnTrue() { FunctionTestUtil.assertResult(allFunction.invoke(new Object[]{Boolean.TRUE, Boolean.TRUE}), true); } @Test - public void invokeArrayParamReturnFalse() { + void invokeArrayParamReturnFalse() { FunctionTestUtil.assertResult(allFunction.invoke(new Object[]{Boolean.TRUE, Boolean.FALSE}), false); FunctionTestUtil.assertResult(allFunction.invoke(new Object[]{Boolean.TRUE, null, Boolean.FALSE}), false); } @Test - public void invokeArrayParamReturnNull() { + void invokeArrayParamReturnNull() { FunctionTestUtil.assertResultNull(allFunction.invoke(new Object[]{Boolean.TRUE, null, Boolean.TRUE})); } @Test - public void invokeArrayParamTypeHeterogenousArray() { + void invokeArrayParamTypeHeterogenousArray() { FunctionTestUtil.assertResultError(allFunction.invoke(new Object[]{Boolean.TRUE, 1}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(allFunction.invoke(new Object[]{Boolean.FALSE, 1}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(allFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), InvalidParametersEvent.class); } @Test - public void invokeListParamNull() { + void invokeListParamNull() { FunctionTestUtil.assertResultError(allFunction.invoke((List) null), InvalidParametersEvent.class); } @Test - public void invokeListParamEmptyList() { + void invokeListParamEmptyList() { FunctionTestUtil.assertResult(allFunction.invoke(Collections.emptyList()), true); } @Test - public void invokeListParamReturnTrue() { + void invokeListParamReturnTrue() { FunctionTestUtil.assertResult(allFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.TRUE)), true); } @Test - public void invokeListParamReturnFalse() { + void invokeListParamReturnFalse() { FunctionTestUtil.assertResult(allFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.FALSE)), false); FunctionTestUtil.assertResult(allFunction.invoke(Arrays.asList(Boolean.TRUE, null, Boolean.FALSE)), false); } @Test - public void invokeListParamReturnNull() { + void invokeListParamReturnNull() { FunctionTestUtil.assertResultNull(allFunction.invoke(Arrays.asList(Boolean.TRUE, null, Boolean.TRUE))); } @Test - public void invokeListParamTypeHeterogenousArray() { + void invokeListParamTypeHeterogenousArray() { FunctionTestUtil.assertResultError(allFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(allFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(allFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), InvalidParametersEvent.class); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AnyFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AnyFunctionTest.java index c1dd0664653..216b5c7fa83 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AnyFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AnyFunctionTest.java @@ -21,46 +21,47 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class AnyFunctionTest { +class AnyFunctionTest { private AnyFunction anyFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { anyFunction = new AnyFunction(); } @Test - public void invokeBooleanParamNull() { + void invokeBooleanParamNull() { FunctionTestUtil.assertResultNull(anyFunction.invoke((Boolean) null)); } @Test - public void invokeBooleanParamTrue() { + void invokeBooleanParamTrue() { FunctionTestUtil.assertResult(anyFunction.invoke(true), true); } @Test - public void invokeBooleanParamFalse() { + void invokeBooleanParamFalse() { FunctionTestUtil.assertResult(anyFunction.invoke(false), false); } @Test - public void invokeArrayParamNull() { + void invokeArrayParamNull() { FunctionTestUtil.assertResultError(anyFunction.invoke((Object[]) null), InvalidParametersEvent.class); } @Test - public void invokeArrayParamEmptyArray() { + void invokeArrayParamEmptyArray() { FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{}), false); } @Test - public void invokeArrayParamReturnTrue() { + void invokeArrayParamReturnTrue() { FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{Boolean.TRUE, Boolean.TRUE}), true); FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{Boolean.TRUE, Boolean.FALSE}), true); FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{Boolean.TRUE, null}), true); @@ -68,34 +69,34 @@ public void invokeArrayParamReturnTrue() { } @Test - public void invokeArrayParamReturnFalse() { + void invokeArrayParamReturnFalse() { FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{Boolean.FALSE, Boolean.FALSE}), false); } @Test - public void invokeArrayParamReturnNull() { + void invokeArrayParamReturnNull() { FunctionTestUtil.assertResultNull(anyFunction.invoke(new Object[]{Boolean.FALSE, null, Boolean.FALSE})); } @Test - public void invokeArrayParamTypeHeterogenousArray() { + void invokeArrayParamTypeHeterogenousArray() { FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.FALSE, 1}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.TRUE, 1}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), InvalidParametersEvent.class); } @Test - public void invokeListParamNull() { + void invokeListParamNull() { FunctionTestUtil.assertResultError(anyFunction.invoke((List) null), InvalidParametersEvent.class); } @Test - public void invokeListParamEmptyList() { + void invokeListParamEmptyList() { FunctionTestUtil.assertResult(anyFunction.invoke(Collections.emptyList()), false); } @Test - public void invokeListParamReturnTrue() { + void invokeListParamReturnTrue() { FunctionTestUtil.assertResult(anyFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.TRUE)), true); FunctionTestUtil.assertResult(anyFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.FALSE)), true); FunctionTestUtil.assertResult(anyFunction.invoke(Arrays.asList(Boolean.TRUE, null)), true); @@ -103,17 +104,17 @@ public void invokeListParamReturnTrue() { } @Test - public void invokeListParamReturnFalse() { + void invokeListParamReturnFalse() { FunctionTestUtil.assertResult(anyFunction.invoke(Arrays.asList(Boolean.FALSE, Boolean.FALSE)), false); } @Test - public void invokeListParamReturnNull() { + void invokeListParamReturnNull() { FunctionTestUtil.assertResultNull(anyFunction.invoke(Arrays.asList(Boolean.FALSE, null, Boolean.FALSE))); } @Test - public void invokeListParamTypeHeterogenousArray() { + void invokeListParamTypeHeterogenousArray() { FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), InvalidParametersEvent.class); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AppendFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AppendFunctionTest.java index 1367018a23d..2a94891f4fa 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AppendFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/AppendFunctionTest.java @@ -21,39 +21,40 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class AppendFunctionTest { +class AppendFunctionTest { private AppendFunction appendFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { appendFunction = new AppendFunction(); } @Test - public void invokeInvalidParams() { + void invokeInvalidParams() { FunctionTestUtil.assertResultError(appendFunction.invoke((List) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(appendFunction.invoke((List) null, new Object[]{}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(appendFunction.invoke(Collections.emptyList(), null), InvalidParametersEvent.class); } @Test - public void invokeEmptyParams() { + void invokeEmptyParams() { FunctionTestUtil.assertResultList(appendFunction.invoke(Collections.emptyList(), new Object[]{}), Collections.emptyList()); } @Test - public void invokeAppendNothing() { + void invokeAppendNothing() { FunctionTestUtil.assertResultList(appendFunction.invoke(List.of("test"), new Object[]{}), List.of("test")); FunctionTestUtil.assertResultList(appendFunction.invoke(Arrays.asList("test", "test2"), new Object[]{}), Arrays.asList("test", "test2")); } @Test - public void invokeAppendSomething() { + void invokeAppendSomething() { FunctionTestUtil.assertResultList(appendFunction.invoke(Collections.emptyList(), new Object[]{"test"}), List.of("test")); FunctionTestUtil.assertResultList(appendFunction.invoke(List.of("test"), new Object[]{"test2"}), Arrays.asList("test", "test2")); FunctionTestUtil.assertResultList(appendFunction.invoke(List.of("test"), new Object[]{"test2", "test3"}), Arrays.asList("test", "test2", "test3")); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctionsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctionsTest.java index c0e3b0a15f0..4f25dc1235f 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctionsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BuiltInFunctionsTest.java @@ -25,20 +25,20 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.lang.Symbol; import org.kie.dmn.feel.runtime.FEELFunction; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import static org.kie.dmn.feel.runtime.functions.BuiltInFunctions.FUNCTIONS; -public class BuiltInFunctionsTest { +class BuiltInFunctionsTest { @Test - public void getFunctions() { + void getFunctions() { // This test is aimed at verify that all the "INSTANCE" fields are correctly populated, referring to the same class they are defined in Set< Class> verifiedClasses = Stream.of(FUNCTIONS).map(this::validateFunction) .filter(Objects::nonNull) @@ -47,12 +47,12 @@ public void getFunctions() { } @Test - public void getFunctionsByClassFails() { + void getFunctionsByClassFails() { assertThrows(IllegalArgumentException.class, () -> BuiltInFunctions.getFunction(FakeFunction.class)); } @Test - public void getFunctionsByNameFails() { + void getFunctionsByNameFails() { assertThrows(IllegalArgumentException.class, () -> BuiltInFunctions.getFunction(FakeFunction.FAKE_NAME)); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CeilingFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CeilingFunctionTest.java index 0d8390cf87d..e53d8ebcff6 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CeilingFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CeilingFunctionTest.java @@ -19,36 +19,37 @@ package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class CeilingFunctionTest { +class CeilingFunctionTest { private CeilingFunction ceilingFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { ceilingFunction = new CeilingFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(ceilingFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeZero() { + void invokeZero() { FunctionTestUtil.assertResultBigDecimal(ceilingFunction.invoke(BigDecimal.ZERO), BigDecimal.ZERO); } @Test - public void invokePositive() { + void invokePositive() { FunctionTestUtil.assertResultBigDecimal(ceilingFunction.invoke(BigDecimal.valueOf(10.2)), BigDecimal.valueOf(11)); } @Test - public void invokeNegative() { + void invokeNegative() { FunctionTestUtil.assertResultBigDecimal(ceilingFunction.invoke(BigDecimal.valueOf(-10.2)), BigDecimal.valueOf(-10)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CodeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CodeFunctionTest.java index aab5d35d0e8..acafaed37eb 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CodeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CodeFunctionTest.java @@ -33,92 +33,92 @@ import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.functions.extended.CodeFunction; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class CodeFunctionTest { +class CodeFunctionTest { private CodeFunction codeFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { codeFunction = new CodeFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResult(codeFunction.invoke(null), "null"); } @Test - public void invokeString() { + void invokeString() { FunctionTestUtil.assertResult(codeFunction.invoke("test"), "\"test\""); } @Test - public void invokeBigDecimal() { + void invokeBigDecimal() { FunctionTestUtil.assertResult(codeFunction.invoke(BigDecimal.valueOf(10.7)), "10.7"); } @Test - public void invokeLocalDate() { + void invokeLocalDate() { final LocalDate localDate = LocalDate.now(); FunctionTestUtil.assertResult(codeFunction.invoke(localDate), "date( \"" + localDate.toString() + "\" )"); } @Test - public void invokeLocalTime() { + void invokeLocalTime() { final LocalTime localTime = LocalTime.now(); FunctionTestUtil.assertResult(codeFunction.invoke(localTime), "time( \"" + TimeFunction.FEEL_TIME.format(localTime) + "\" )"); } @Test - public void invokeOffsetTime() { + void invokeOffsetTime() { final OffsetTime offsetTime = OffsetTime.now(); FunctionTestUtil.assertResult(codeFunction.invoke(offsetTime), "time( \"" + TimeFunction.FEEL_TIME.format(offsetTime) + "\" )"); } @Test - public void invokeLocalDateTime() { + void invokeLocalDateTime() { final LocalDateTime localDateTime = LocalDateTime.now(); FunctionTestUtil.assertResult(codeFunction.invoke(localDateTime), "date and time( \"" + DateAndTimeFunction.FEEL_DATE_TIME.format(localDateTime) + "\" )"); } @Test - public void invokeOffsetDateTime() { + void invokeOffsetDateTime() { final OffsetDateTime offsetDateTime = OffsetDateTime.now(); FunctionTestUtil.assertResult(codeFunction.invoke(offsetDateTime), "date and time( \"" + DateAndTimeFunction.FEEL_DATE_TIME.format(offsetDateTime) + "\" )"); } @Test - public void invokeZonedDateTime() { + void invokeZonedDateTime() { final ZonedDateTime zonedDateTime = ZonedDateTime.now(); FunctionTestUtil.assertResult(codeFunction.invoke(zonedDateTime), "date and time( \"" + DateAndTimeFunction.REGION_DATETIME_FORMATTER.format(zonedDateTime) + "\" )"); } @Test - public void invokeDurationZero() { + void invokeDurationZero() { FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ZERO), "duration( \"PT0S\" )"); } @Test - public void invokeDurationDays() { + void invokeDurationDays() { FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofDays(9)), "duration( \"P9D\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofDays(-9)), "duration( \"-P9D\" )"); } @Test - public void invokeDurationHours() { + void invokeDurationHours() { FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofHours(9)), "duration( \"PT9H\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofHours(200)), "duration( \"P8DT8H\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofHours(-200)), "duration( \"-P8DT8H\" )"); } @Test - public void invokeDurationMinutes() { + void invokeDurationMinutes() { FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofMinutes(9)), "duration( \"PT9M\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofMinutes(200)), "duration( \"PT3H20M\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofMinutes(5000)), "duration( \"P3DT11H20M\" )"); @@ -126,7 +126,7 @@ public void invokeDurationMinutes() { } @Test - public void invokeDurationSeconds() { + void invokeDurationSeconds() { FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofSeconds(9)), "duration( \"PT9S\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofSeconds(200)), "duration( \"PT3M20S\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofSeconds(5000)), "duration( \"PT1H23M20S\" )"); @@ -135,7 +135,7 @@ public void invokeDurationSeconds() { } @Test - public void invokeDurationNanosMillis() { + void invokeDurationNanosMillis() { FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofNanos(25)), "duration( \"PT0.000000025S\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofNanos(10000)), "duration( \"PT0.00001S\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Duration.ofNanos(10025)), "duration( \"PT0.000010025S\" )"); @@ -145,30 +145,30 @@ public void invokeDurationNanosMillis() { } @Test - public void invokePeriodZero() { + void invokePeriodZero() { FunctionTestUtil.assertResult(codeFunction.invoke(Period.ZERO), "duration( \"P0M\" )"); } @Test - public void invokePeriodYears() { + void invokePeriodYears() { FunctionTestUtil.assertResult(codeFunction.invoke(Period.ofYears(24)), "duration( \"P24Y\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Period.ofYears(-24)), "duration( \"-P24Y\" )"); } @Test - public void invokePeriodMonths() { + void invokePeriodMonths() { FunctionTestUtil.assertResult(codeFunction.invoke(Period.ofMonths(2)), "duration( \"P2M\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Period.ofMonths(27)), "duration( \"P2Y3M\" )"); FunctionTestUtil.assertResult(codeFunction.invoke(Period.ofMonths(-27)), "duration( \"-P2Y3M\" )"); } @Test - public void invokeListEmpty() { + void invokeListEmpty() { FunctionTestUtil.assertResult(codeFunction.invoke(Collections.emptyList()), "[ ]"); } @Test - public void invokeListNonEmpty() { + void invokeListNonEmpty() { final List values = new ArrayList<>(); values.add(1); values.add(BigDecimal.valueOf(10.5)); @@ -177,40 +177,40 @@ public void invokeListNonEmpty() { } @Test - public void invokeRangeOpenOpen() { + void invokeRangeOpenOpen() { FunctionTestUtil.assertResult( codeFunction.invoke(new RangeImpl(Range.RangeBoundary.OPEN, 12, 15, Range.RangeBoundary.OPEN)), "( 12 .. 15 )"); } @Test - public void invokeRangeOpenClosed() { + void invokeRangeOpenClosed() { FunctionTestUtil.assertResult( codeFunction.invoke(new RangeImpl(Range.RangeBoundary.OPEN, 12, 15, Range.RangeBoundary.CLOSED)), "( 12 .. 15 ]"); } @Test - public void invokeRangeClosedOpen() { + void invokeRangeClosedOpen() { FunctionTestUtil.assertResult( codeFunction.invoke(new RangeImpl(Range.RangeBoundary.CLOSED, 12, 15, Range.RangeBoundary.OPEN)), "[ 12 .. 15 )"); } @Test - public void invokeRangeClosedClosed() { + void invokeRangeClosedClosed() { FunctionTestUtil.assertResult( codeFunction.invoke(new RangeImpl(Range.RangeBoundary.CLOSED, 12, 15, Range.RangeBoundary.CLOSED)), "[ 12 .. 15 ]"); } @Test - public void invokeContextEmpty() { + void invokeContextEmpty() { FunctionTestUtil.assertResult(codeFunction.invoke(new HashMap<>()), "{ }"); } @Test - public void invokeContextNonEmpty() { + void invokeContextNonEmpty() { final Map childContextMap = new HashMap<>(); childContextMap.put("childKey1", "childValue1"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ComposingDifferentFunctionsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ComposingDifferentFunctionsTest.java index 7f6846a051e..21821635e99 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ComposingDifferentFunctionsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ComposingDifferentFunctionsTest.java @@ -27,20 +27,20 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -public class ComposingDifferentFunctionsTest { +class ComposingDifferentFunctionsTest { private DateAndTimeFunction dateTimeFunction; private DateFunction dateFunction; private TimeFunction timeFunction; private StringFunction stringFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { dateTimeFunction = new DateAndTimeFunction(); dateFunction = new DateFunction(); timeFunction = new TimeFunction(); @@ -48,7 +48,7 @@ public void setUp() { } @Test - public void testComposite1() { + void composite1() { final FEELFnResult p1 = dateTimeFunction.invoke("2017-08-10T10:20:00+02:00"); final FEELFnResult p2 = timeFunction.invoke("23:59:01"); @@ -60,7 +60,7 @@ public void testComposite1() { } @Test - public void testComposite2() { + void composite2() { final FEELFnResult p1 = dateTimeFunction.invoke("-999999999-12-31T23:59:59.999999999+02:00"); FunctionTestUtil.assertResult(p1, ZonedDateTime.of(-999999999, 12, 31, 23, 59, 59, 999_999_999, ZoneOffset.of("+02:00"))); @@ -68,7 +68,7 @@ public void testComposite2() { } @Test - public void testComposite3() { + void composite3() { final FEELFnResult p1 = dateTimeFunction.invoke("-999999999-12-31T23:59:59.999999999@Europe/Paris"); FunctionTestUtil.assertResult(p1, ZonedDateTime.of(-999999999, 12, 31, 23, 59, 59, 999_999_999, ZoneId.of("Europe/Paris"))); @@ -76,7 +76,7 @@ public void testComposite3() { } @Test - public void testComposite4() { + void composite4() { final FEELFnResult p1 = dateFunction.invoke("2017-01-01"); final FEELFnResult p2 = timeFunction.invoke("23:59:01@Europe/Paris"); @@ -92,7 +92,7 @@ public void testComposite4() { } @Test - public void testComposite5() { + void composite5() { final FEELFnResult p1 = dateTimeFunction.invoke("2017-08-10T10:20:00@Europe/Paris"); FunctionTestUtil.assertResult(p1, ZonedDateTime.of(2017, 8, 10, 10, 20, 0, 0, ZoneId.of("Europe/Paris"))); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunctionTest.java index f91d5427db4..9687ba46580 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ConcatenateFunctionTest.java @@ -22,42 +22,42 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class ConcatenateFunctionTest { +class ConcatenateFunctionTest { private ConcatenateFunction concatenateFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { concatenateFunction = new ConcatenateFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(concatenateFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeEmptyArray() { + void invokeEmptyArray() { FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{}), Collections.emptyList()); } @Test - public void invokeArrayWithNull() { + void invokeArrayWithNull() { FunctionTestUtil.assertResultError(concatenateFunction.invoke(new Object[]{null}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(concatenateFunction.invoke(new Object[]{1, null}), InvalidParametersEvent.class); } @Test - public void invokeArrayWithList() { + void invokeArrayWithList() { FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{"test", 2, Arrays.asList(2, 3)}), Arrays.asList("test", 2, 2, 3)); } @Test - public void invokeArrayWithoutList() { + void invokeArrayWithoutList() { FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{"test", 2, BigDecimal.valueOf(25.3)}), Arrays.asList("test", 2, BigDecimal.valueOf(25.3))); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContainsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContainsFunctionTest.java index 329fd7acc15..23c0e182475 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContainsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ContainsFunctionTest.java @@ -18,35 +18,35 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class ContainsFunctionTest { +class ContainsFunctionTest { private ContainsFunction containsFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { containsFunction = new ContainsFunction(); } @Test - public void invokeParamsNull() { + void invokeParamsNull() { FunctionTestUtil.assertResultError(containsFunction.invoke((String) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(containsFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(containsFunction.invoke("test", null), InvalidParametersEvent.class); } @Test - public void invokeContains() { + void invokeContains() { FunctionTestUtil.assertResult(containsFunction.invoke("test", "es"), true); FunctionTestUtil.assertResult(containsFunction.invoke("test", "t"), true); FunctionTestUtil.assertResult(containsFunction.invoke("testy", "y"), true); } @Test - public void invokeNotContains() { + void invokeNotContains() { FunctionTestUtil.assertResult(containsFunction.invoke("test", "ex"), false); FunctionTestUtil.assertResult(containsFunction.invoke("test", "u"), false); FunctionTestUtil.assertResult(containsFunction.invoke("test", "esty"), false); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CountFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CountFunctionTest.java index e154ff925ef..b743b549e42 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CountFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/CountFunctionTest.java @@ -23,46 +23,46 @@ import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class CountFunctionTest { +class CountFunctionTest { private CountFunction countFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { countFunction = new CountFunction(); } @Test - public void invokeParamListNull() { + void invokeParamListNull() { FunctionTestUtil.assertResultError(countFunction.invoke((List) null), InvalidParametersEvent.class); } @Test - public void invokeParamListEmpty() { + void invokeParamListEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(Collections.emptyList()), BigDecimal.ZERO); } @Test - public void invokeParamListNonEmpty() { + void invokeParamListNonEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(Arrays.asList(1, 2, "test")), BigDecimal.valueOf(3)); } @Test - public void invokeParamArrayNull() { + void invokeParamArrayNull() { FunctionTestUtil.assertResultError(countFunction.invoke((Object[]) null), InvalidParametersEvent.class); } @Test - public void invokeParamArrayEmpty() { + void invokeParamArrayEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(new Object[]{}), BigDecimal.ZERO); } @Test - public void invokeParamArrayNonEmpty() { + void invokeParamArrayNonEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(new Object[]{1, 2, "test"}), BigDecimal.valueOf(3)); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateFunctionTest.java index e53b81f0187..db9ece6621b 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateFunctionTest.java @@ -22,38 +22,38 @@ import java.time.LocalDate; import java.time.temporal.TemporalAccessor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class DateFunctionTest { +class DateFunctionTest { private DateFunction dateFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { dateFunction = new DateFunction(); } @Test - public void invokeParamStringNull() { + void invokeParamStringNull() { FunctionTestUtil.assertResultError(dateFunction.invoke((String) null), InvalidParametersEvent.class); } @Test - public void invokeParamStringNotDateOrTime() { + void invokeParamStringNotDateOrTime() { FunctionTestUtil.assertResultError(dateFunction.invoke("test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateFunction.invoke("2017-09-test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateFunction.invoke("2017-09-89"), InvalidParametersEvent.class); } @Test - public void invokeParamStringDate() { + void invokeParamStringDate() { FunctionTestUtil.assertResult(dateFunction.invoke("2017-09-07"), LocalDate.of(2017, 9, 7)); } @Test - public void invokeParamStringPaddingYearsDate() { + void invokeParamStringPaddingYearsDate() { FunctionTestUtil.assertResult(dateFunction.invoke("0001-12-31"), LocalDate.of(1, 12, 31)); FunctionTestUtil.assertResult(dateFunction.invoke("0012-12-31"), LocalDate.of(12, 12, 31)); FunctionTestUtil.assertResult(dateFunction.invoke("0123-12-31"), LocalDate.of(123, 12, 31)); @@ -64,7 +64,7 @@ public void invokeParamStringPaddingYearsDate() { } @Test - public void invokeParamYearMonthDayNulls() { + void invokeParamYearMonthDayNulls() { FunctionTestUtil.assertResultError(dateFunction.invoke(null, null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateFunction.invoke(10, null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateFunction.invoke(null, 10, null), InvalidParametersEvent.class); @@ -75,29 +75,29 @@ public void invokeParamYearMonthDayNulls() { } @Test - public void invokeParamYearMonthDayInvalidDate() { + void invokeParamYearMonthDayInvalidDate() { FunctionTestUtil.assertResultError(dateFunction.invoke(2017, 6, 59), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateFunction.invoke(2017, 59, 12), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateFunction.invoke(Integer.MAX_VALUE, 6, 12), InvalidParametersEvent.class); } @Test - public void invokeParamYearMonthDay() { + void invokeParamYearMonthDay() { FunctionTestUtil.assertResult(dateFunction.invoke(2017, 6, 12), LocalDate.of(2017, 6, 12)); } @Test - public void invokeParamTemporalNull() { + void invokeParamTemporalNull() { FunctionTestUtil.assertResultError(dateFunction.invoke((TemporalAccessor) null), InvalidParametersEvent.class); } @Test - public void invokeParamTemporalWrongTemporal() { + void invokeParamTemporalWrongTemporal() { FunctionTestUtil.assertResultError(dateFunction.invoke(DayOfWeek.MONDAY), InvalidParametersEvent.class); } @Test - public void invokeParamTemporal() { + void invokeParamTemporal() { FunctionTestUtil.assertResult(dateFunction.invoke(LocalDate.of(2017, 6, 12)), LocalDate.of(2017, 6, 12)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java index c208530e954..f44aa68c5e0 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java @@ -27,64 +27,65 @@ import java.time.ZonedDateTime; import java.time.temporal.Temporal; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class DateTimeFunctionTest { +class DateTimeFunctionTest { private DateAndTimeFunction dateTimeFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { dateTimeFunction = new DateAndTimeFunction(); } @Test - public void invokeParamStringNull() { + void invokeParamStringNull() { FunctionTestUtil.assertResultError(dateTimeFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeParamStringNotDateOrTime() { + void invokeParamStringNotDateOrTime() { FunctionTestUtil.assertResultError(dateTimeFunction.invoke("test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateTimeFunction.invoke("2017-09-test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateTimeFunction.invoke("2017-09-T89"), InvalidParametersEvent.class); } @Test - public void invokeParamStringDateTime() { + void invokeParamStringDateTime() { FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-09-07T10:20:30"), LocalDateTime.of(2017, 9, 7, 10, 20, 30)); FunctionTestUtil.assertResult(dateTimeFunction.invoke("99999-12-31T11:22:33"), LocalDateTime.of(99999, 12, 31, 11, 22, 33)); } @Test - public void invokeParamStringDateTimeZoned() { + void invokeParamStringDateTimeZoned() { FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30@Europe/Paris"), ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 0, ZoneId.of("Europe/Paris"))); FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.987@Europe/Paris"), ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 987_000_000, ZoneId.of("Europe/Paris"))); FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.123456789@Europe/Paris"), ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 123_456_789, ZoneId.of("Europe/Paris"))); FunctionTestUtil.assertResult(dateTimeFunction.invoke("999999999-12-31T23:59:59.999999999@Europe/Paris"), ZonedDateTime.of(999999999, 12, 31, 23, 59, 59, 999_999_999, ZoneId.of("Europe/Paris"))); } + @Test - public void invokeParamStringDateOffset() { + void invokeParamStringDateOffset() { FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-12-31T23:59:59.999999999+02:00"), ZonedDateTime.of(2017, 12, 31, 23, 59, 59, 999_999_999, ZoneOffset.of("+02:00"))); FunctionTestUtil.assertResult(dateTimeFunction.invoke("-999999999-12-31T23:59:59.999999999+02:00"), ZonedDateTime.of(-999999999, 12, 31, 23, 59, 59, 999_999_999, ZoneOffset.of("+02:00"))); } @Test - public void invokeParamStringDate() { + void invokeParamStringDate() { FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-09-07"), LocalDateTime.of(2017, 9, 7, 0, 0, 0)); } @Test - public void invokeParamTemporalNulls() { + void invokeParamTemporalNulls() { FunctionTestUtil.assertResultError(dateTimeFunction.invoke((Temporal) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateTimeFunction.invoke(null, LocalTime.of(10, 6, 20)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(dateTimeFunction.invoke(LocalDate.of(2017, 6, 12), null), InvalidParametersEvent.class); } @Test - public void invokeParamTemporalWrongTemporal() { + void invokeParamTemporalWrongTemporal() { // reminder: 1st parameter accordingly to FEEL Spec Table 58 "date is a date or date time [...] creates a date time from the given date (ignoring any time component)" [that means ignoring any TZ from `date` parameter, too] FunctionTestUtil.assertResultError( dateTimeFunction.invoke( @@ -97,7 +98,7 @@ public void invokeParamTemporalWrongTemporal() { } @Test - public void invokeParamTemporalLocalTime() { + void invokeParamTemporalLocalTime() { FunctionTestUtil.assertResult( dateTimeFunction.invoke( LocalDate.of(2017, 6, 12), @@ -106,7 +107,7 @@ public void invokeParamTemporalLocalTime() { } @Test - public void invokeParamTemporalOffsetTime() { + void invokeParamTemporalOffsetTime() { FunctionTestUtil.assertResult( dateTimeFunction.invoke( LocalDate.of(2017, 6, 12), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DayOfWeekTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DayOfWeekTest.java index 3d81b1bfd00..403468d133b 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DayOfWeekTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DayOfWeekTest.java @@ -24,21 +24,21 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class DayOfWeekTest { +class DayOfWeekTest { private DayOfWeekFunction fut; - @Before - public void setUp() { + @BeforeEach + void setUp() { fut = DayOfWeekFunction.INSTANCE; } @Test - public void testDayOfWeekFunctionTemporalAccessor() { + void dayOfWeekFunctionTemporalAccessor() { FunctionTestUtil.assertResult(fut.invoke(LocalDate.of(2019, 9, 17)), "Tuesday"); FunctionTestUtil.assertResult(fut.invoke(LocalDateTime.of(2019, 9, 17, 0, 0, 0)), "Tuesday"); FunctionTestUtil.assertResult(fut.invoke(OffsetDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), "Tuesday"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DayOfYearTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DayOfYearTest.java index 2dd4fba44c1..1493b0bb801 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DayOfYearTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DayOfYearTest.java @@ -24,23 +24,23 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import static java.math.BigDecimal.valueOf; -public class DayOfYearTest { +class DayOfYearTest { private DayOfYearFunction fut; - @Before - public void setUp() { + @BeforeEach + void setUp() { fut = DayOfYearFunction.INSTANCE; } @Test - public void testDayOfYearFunctionTemporalAccessor() { + void dayOfYearFunctionTemporalAccessor() { FunctionTestUtil.assertResult(fut.invoke(LocalDate.of(2019, 9, 17)), valueOf(260)); FunctionTestUtil.assertResult(fut.invoke(LocalDateTime.of(2019, 9, 17, 0, 0, 0)), valueOf(260)); FunctionTestUtil.assertResult(fut.invoke(OffsetDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), valueOf(260)); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DecimalFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DecimalFunctionTest.java index ab3b9382be3..7078d6306cd 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DecimalFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DecimalFunctionTest.java @@ -19,48 +19,49 @@ package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class DecimalFunctionTest { +class DecimalFunctionTest { private DecimalFunction decimalFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { decimalFunction = new DecimalFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(decimalFunction.invoke((BigDecimal) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(decimalFunction.invoke(BigDecimal.ONE, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(decimalFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); } @Test - public void invokeRoundingUp() { + void invokeRoundingUp() { FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.27), BigDecimal.ONE), BigDecimal.valueOf(10.3)); } @Test - public void invokeRoundingDown() { + void invokeRoundingDown() { FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.24), BigDecimal.ONE), BigDecimal.valueOf(10.2)); } @Test - public void invokeRoundingEven() { + void invokeRoundingEven() { FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.25), BigDecimal.ONE), BigDecimal.valueOf(10.2)); } @Test - public void invokeRoundingOdd() { + void invokeRoundingOdd() { FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.35), BigDecimal.ONE), BigDecimal.valueOf(10.4)); } @Test - public void invokeLargerScale() { + void invokeLargerScale() { FunctionTestUtil.assertResult(decimalFunction.invoke(BigDecimal.valueOf(10.123456789), BigDecimal.valueOf(6)), BigDecimal.valueOf(10.123457)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunctionTest.java index 0027c7dc13b..5b3af9101c5 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DistinctValuesFunctionTest.java @@ -23,45 +23,45 @@ import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class DistinctValuesFunctionTest { +class DistinctValuesFunctionTest { private DistinctValuesFunction distinctValuesFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { distinctValuesFunction = new DistinctValuesFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(distinctValuesFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeParamNotCollection() { + void invokeParamNotCollection() { FunctionTestUtil.assertResultList( distinctValuesFunction.invoke(BigDecimal.valueOf(10.1)), Collections.singletonList(BigDecimal.valueOf(10.1))); } @Test - public void invokeParamArray() { + void invokeParamArray() { FunctionTestUtil.assertResultList( distinctValuesFunction.invoke(new Object[]{BigDecimal.valueOf(10.1)}), Collections.singletonList(new Object[]{BigDecimal.valueOf(10.1)})); } @Test - public void invokeEmptyList() { + void invokeEmptyList() { FunctionTestUtil.assertResultList(distinctValuesFunction.invoke(Collections.emptyList()), Collections.emptyList()); } @Test - public void invokeList() { + void invokeList() { final List testValues = Arrays.asList(1, BigDecimal.valueOf(10.1), "test", 1, "test", BigDecimal.valueOf(10.1)); FunctionTestUtil.assertResultList( distinctValuesFunction.invoke(testValues), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DurationFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DurationFunctionTest.java index 1dc3e5869b5..b2472333139 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DurationFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DurationFunctionTest.java @@ -22,27 +22,27 @@ import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAmount; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class DurationFunctionTest { +class DurationFunctionTest { private DurationFunction durationFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { durationFunction = new DurationFunction(); } @Test - public void invokeParamStringNull() { + void invokeParamStringNull() { FunctionTestUtil.assertResultError(durationFunction.invoke((String) null), InvalidParametersEvent.class); } @Test - public void invokeParamStringInvalid() { + void invokeParamStringInvalid() { FunctionTestUtil.assertResultError(durationFunction.invoke("test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(durationFunction.invoke("test HHH"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(durationFunction.invoke("testP2Y3D"), InvalidParametersEvent.class); @@ -54,7 +54,7 @@ public void invokeParamStringInvalid() { } @Test - public void invokeParamStringDuration() { + void invokeParamStringDuration() { FunctionTestUtil.assertResult(durationFunction.invoke("P2D"), Duration.of(2, ChronoUnit.DAYS)); FunctionTestUtil.assertResult(durationFunction.invoke("P2DT3H"), Duration.of(2, ChronoUnit.DAYS).plusHours(3)); FunctionTestUtil.assertResult( @@ -66,25 +66,25 @@ public void invokeParamStringDuration() { } @Test - public void invokeParamStringPeriod() { + void invokeParamStringPeriod() { FunctionTestUtil.assertResult(durationFunction.invoke("P2Y3M"), ComparablePeriod.of(2, 3, 0)); FunctionTestUtil.assertResult(durationFunction.invoke("P2Y3M4D"), ComparablePeriod.of(2, 3, 4)); } @Test - public void invokeParamTemporalAmountNull() { + void invokeParamTemporalAmountNull() { FunctionTestUtil.assertResultError(durationFunction.invoke((TemporalAmount) null), InvalidParametersEvent.class); } @Test - public void invokeParamTemporalDuration() { + void invokeParamTemporalDuration() { FunctionTestUtil.assertResult( durationFunction.invoke(Duration.parse("P2DT3H28M15S")), Duration.of(2, ChronoUnit.DAYS).plusHours(3).plusMinutes(28).plusSeconds(15)); } @Test - public void invokeParamTemporalPeriod() { + void invokeParamTemporalPeriod() { FunctionTestUtil.assertResult(durationFunction.invoke(ComparablePeriod.parse("P2Y3M4D")), ComparablePeriod.of(2, 3, 4)); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/EndsWithFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/EndsWithFunctionTest.java index 9b170b168a6..a5146d0a54d 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/EndsWithFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/EndsWithFunctionTest.java @@ -18,28 +18,28 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class EndsWithFunctionTest { +class EndsWithFunctionTest { private EndsWithFunction endsWithFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { endsWithFunction = new EndsWithFunction(); } @Test - public void invokeParamsNull() { + void invokeParamsNull() { FunctionTestUtil.assertResultError(endsWithFunction.invoke((String) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(endsWithFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(endsWithFunction.invoke("test", null), InvalidParametersEvent.class); } @Test - public void invokeEndsWith() { + void invokeEndsWith() { FunctionTestUtil.assertResult(endsWithFunction.invoke("test", "t"), true); FunctionTestUtil.assertResult(endsWithFunction.invoke("test", "st"), true); FunctionTestUtil.assertResult(endsWithFunction.invoke("test", "est"), true); @@ -47,7 +47,7 @@ public void invokeEndsWith() { } @Test - public void invokeNotEndsWith() { + void invokeNotEndsWith() { FunctionTestUtil.assertResult(endsWithFunction.invoke("test", "es"), false); FunctionTestUtil.assertResult(endsWithFunction.invoke("test", "ttttt"), false); FunctionTestUtil.assertResult(endsWithFunction.invoke("test", "estt"), false); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FlattenFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FlattenFunctionTest.java index 49bd5a1fd55..3b9056e65e9 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FlattenFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FlattenFunctionTest.java @@ -21,32 +21,33 @@ import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class FlattenFunctionTest { +class FlattenFunctionTest { private FlattenFunction flattenFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { flattenFunction = new FlattenFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(flattenFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeParamNotCollection() { + void invokeParamNotCollection() { FunctionTestUtil.assertResult(flattenFunction.invoke(BigDecimal.valueOf(10.2)), Collections.singletonList(BigDecimal.valueOf(10.2))); FunctionTestUtil.assertResult(flattenFunction.invoke("test"), Collections.singletonList("test")); } @Test - public void invokeParamCollection() { + void invokeParamCollection() { FunctionTestUtil.assertResult(flattenFunction.invoke(Arrays.asList("test", 1, 2)), Arrays.asList("test", 1, 2)); FunctionTestUtil.assertResult(flattenFunction.invoke(Arrays.asList("test", 1, 2, Arrays.asList(3, 4))), Arrays.asList("test", 1, 2, 3, 4)); FunctionTestUtil.assertResult(flattenFunction.invoke(Arrays.asList("test", 1, 2, Arrays.asList(1, 2))), Arrays.asList("test", 1, 2, 1, 2)); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FloorFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FloorFunctionTest.java index 1cc3c198bd8..615b0aa0c75 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FloorFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/FloorFunctionTest.java @@ -19,36 +19,37 @@ package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class FloorFunctionTest { +class FloorFunctionTest { private FloorFunction floorFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { floorFunction = new FloorFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(floorFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeZero() { + void invokeZero() { FunctionTestUtil.assertResultBigDecimal(floorFunction.invoke(BigDecimal.ZERO), BigDecimal.ZERO); } @Test - public void invokePositive() { + void invokePositive() { FunctionTestUtil.assertResultBigDecimal(floorFunction.invoke(BigDecimal.valueOf(10.2)), BigDecimal.valueOf(10)); } @Test - public void invokeNegative() { + void invokeNegative() { FunctionTestUtil.assertResultBigDecimal(floorFunction.invoke(BigDecimal.valueOf(-10.2)), BigDecimal.valueOf(-11)); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/IndexOfFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/IndexOfFunctionTest.java index 0154530e55e..3e5a9e00089 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/IndexOfFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/IndexOfFunctionTest.java @@ -23,27 +23,27 @@ import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class IndexOfFunctionTest { +class IndexOfFunctionTest { private IndexOfFunction indexOfFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { indexOfFunction = new IndexOfFunction(); } @Test - public void invokeListNull() { + void invokeListNull() { FunctionTestUtil.assertResultError(indexOfFunction.invoke((List) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(indexOfFunction.invoke(null, new Object()), InvalidParametersEvent.class); } @Test - public void invokeMatchNull() { + void invokeMatchNull() { FunctionTestUtil.assertResultList(indexOfFunction.invoke(Collections.emptyList(), null), Collections.emptyList()); FunctionTestUtil.assertResultList(indexOfFunction.invoke(Collections.singletonList("test"), null), Collections.emptyList()); FunctionTestUtil.assertResultList( @@ -61,7 +61,7 @@ public void invokeMatchNull() { } @Test - public void invokeBigDecimal() { + void invokeBigDecimal() { FunctionTestUtil.assertResult(indexOfFunction.invoke(Arrays.asList("test", null, 12), BigDecimal.valueOf(12)), Collections.emptyList()); FunctionTestUtil.assertResult( indexOfFunction.invoke(Arrays.asList("test", null, BigDecimal.valueOf(12)), BigDecimal.valueOf(12)), @@ -79,7 +79,7 @@ public void invokeBigDecimal() { } @Test - public void invokeMatchNotNull() { + void invokeMatchNotNull() { FunctionTestUtil.assertResult(indexOfFunction.invoke(Arrays.asList("test", null, 12), "testttt"), Collections.emptyList()); FunctionTestUtil.assertResult( indexOfFunction.invoke(Arrays.asList("test", null, BigDecimal.valueOf(12)), "test"), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunctionTest.java index f217e0783e1..a8ef326d606 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/InsertBeforeFunctionTest.java @@ -22,53 +22,53 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class InsertBeforeFunctionTest { +class InsertBeforeFunctionTest { private InsertBeforeFunction insertBeforeFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { insertBeforeFunction = new InsertBeforeFunction(); } @Test - public void invokeListNull() { + void invokeListNull() { FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(null, BigDecimal.ZERO, new Object()), InvalidParametersEvent.class); } @Test - public void invokePositionNull() { + void invokePositionNull() { FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), null, new Object()), InvalidParametersEvent.class); } @Test - public void invokeListPositionNull() { + void invokeListPositionNull() { FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(null, null, new Object()), InvalidParametersEvent.class); } @Test - public void invokePositionZero() { + void invokePositionZero() { FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.ZERO, new Object()), InvalidParametersEvent.class); } @Test - public void invokePositionOutsideListBounds() { + void invokePositionOutsideListBounds() { FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.ONE, new Object()), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.valueOf(-1), new Object()), InvalidParametersEvent.class); } @Test - public void invokeInsertIntoEmptyList() { + void invokeInsertIntoEmptyList() { // According to spec, inserting into empty list shouldn't be possible. For inserting into empty list, user should use append() function. FunctionTestUtil.assertResultError(insertBeforeFunction.invoke(Collections.emptyList(), BigDecimal.ONE, null), InvalidParametersEvent.class); } @Test - public void invokePositionPositive() { + void invokePositionPositive() { FunctionTestUtil.assertResult(insertBeforeFunction.invoke(Collections.singletonList("test"), BigDecimal.ONE, null), Arrays.asList(null, "test")); FunctionTestUtil.assertResult( insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(2), "testtt"), @@ -79,7 +79,7 @@ public void invokePositionPositive() { } @Test - public void invokePositionNegative() { + void invokePositionNegative() { FunctionTestUtil.assertResult(insertBeforeFunction.invoke(Collections.singletonList("test"), BigDecimal.valueOf(-1), null), Arrays.asList(null, "test")); FunctionTestUtil.assertResult( insertBeforeFunction.invoke(Arrays.asList("test", null, BigDecimal.ZERO), BigDecimal.valueOf(-2), "testtt"), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListContainsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListContainsFunctionTest.java index 74ca0e60300..318bac32367 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListContainsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListContainsFunctionTest.java @@ -23,48 +23,48 @@ import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class ListContainsFunctionTest { +class ListContainsFunctionTest { private ListContainsFunction listContainsFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { listContainsFunction = new ListContainsFunction(); } @Test - public void invokeListNull() { + void invokeListNull() { FunctionTestUtil.assertResultError(listContainsFunction.invoke((List) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(listContainsFunction.invoke(null, new Object()), InvalidParametersEvent.class); } @Test - public void invokeContainsNull() { + void invokeContainsNull() { FunctionTestUtil.assertResult(listContainsFunction.invoke(Collections.singletonList(null), null), true); FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, null), null), true); FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(null, 1), null), true); } @Test - public void invokeNotContainsNull() { + void invokeNotContainsNull() { FunctionTestUtil.assertResult(listContainsFunction.invoke(Collections.emptyList(), null), false); FunctionTestUtil.assertResult(listContainsFunction.invoke(Collections.singletonList(1), null), false); FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2), null), false); } @Test - public void invokeContains() { + void invokeContains() { FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), "test"), true); FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), 1), true); FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), BigDecimal.ONE), true); } @Test - public void invokeNotContains() { + void invokeNotContains() { FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), "testtt"), false); FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), 3), false); FunctionTestUtil.assertResult(listContainsFunction.invoke(Arrays.asList(1, 2, "test"), BigDecimal.valueOf(3)), false); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListReplaceFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListReplaceFunctionTest.java index ff85207cb06..72dfd91742c 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListReplaceFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ListReplaceFunctionTest.java @@ -25,34 +25,34 @@ import java.util.List; import java.util.stream.IntStream; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.feel.util.CompilerUtils.parseCompileEvaluate; -public class ListReplaceFunctionTest { +class ListReplaceFunctionTest { private ListReplaceFunction listReplaceFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { listReplaceFunction = ListReplaceFunction.INSTANCE; } @Test - public void invokeListNull() { + void invokeListNull() { FunctionTestUtil.assertResultError(listReplaceFunction.invoke(null, BigDecimal.ONE, ""), InvalidParametersEvent.class); } @Test - public void invokePositionNull() { + void invokePositionNull() { FunctionTestUtil.assertResultError(listReplaceFunction.invoke(new ArrayList(), (BigDecimal) null, ""), InvalidParametersEvent.class); } @Test - public void invokePositionInvalid() { + void invokePositionInvalid() { FunctionTestUtil.assertResultError(listReplaceFunction.invoke(Collections.emptyList(), BigDecimal.ONE, ""), InvalidParametersEvent.class); List list = getList(); FunctionTestUtil.assertResultError(listReplaceFunction.invoke(list, BigDecimal.ZERO, ""), InvalidParametersEvent.class); @@ -60,7 +60,7 @@ public void invokePositionInvalid() { } @Test - public void invokeReplaceByPositionWithNull() { + void invokeReplaceByPositionWithNull() { List list = getList(); List expected = new ArrayList<>(list); expected.set(1, null); @@ -68,7 +68,7 @@ public void invokeReplaceByPositionWithNull() { } @Test - public void invokeReplaceByNegativePositionWithNotNull() { + void invokeReplaceByNegativePositionWithNotNull() { List list = getList(); List expected = new ArrayList<>(list); expected.set(2, "test"); @@ -76,7 +76,7 @@ public void invokeReplaceByNegativePositionWithNotNull() { } @Test - public void invokeReplaceByNegativePositionWithNull() { + void invokeReplaceByNegativePositionWithNull() { List list = getList(); List expected = new ArrayList<>(list); expected.set(2, null); @@ -84,7 +84,7 @@ public void invokeReplaceByNegativePositionWithNull() { } @Test - public void invokeReplaceByPositionWithNotNull() { + void invokeReplaceByPositionWithNotNull() { List list = getList(); List expected = new ArrayList<>(list); expected.set(1, "test"); @@ -93,12 +93,12 @@ public void invokeReplaceByPositionWithNotNull() { @Test - public void invokeMatchNull() { + void invokeMatchNull() { FunctionTestUtil.assertResultError(listReplaceFunction.invoke(new ArrayList(), (AbstractCustomFEELFunction) null, ""), InvalidParametersEvent.class); } @Test - public void invokeMatchInvalid() { + void invokeMatchInvalid() { List list = Arrays.asList(2, 4, 7, 8); String validMatchFunction = "function(item, newItem) item + newItem"; Object expressionObject = parseCompileEvaluate(validMatchFunction); @@ -107,7 +107,7 @@ public void invokeMatchInvalid() { } @Test - public void invokeReplaceByMatchWithNull() { + void invokeReplaceByMatchWithNull() { List list = getList(); List expected = new ArrayList<>(list); expected.set(1, null); @@ -118,7 +118,7 @@ public void invokeReplaceByMatchWithNull() { } @Test - public void invokeReplaceByMatchWithNotNull() { + void invokeReplaceByMatchWithNotNull() { String validMatchFunction = "function(item, newItem) item < newItem"; Object expressionObject = parseCompileEvaluate(validMatchFunction); assertThat(expressionObject).isInstanceOf(AbstractCustomFEELFunction.class); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MatchesFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MatchesFunctionTest.java index 47f8de845aa..cdbbd3c6e24 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MatchesFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MatchesFunctionTest.java @@ -18,61 +18,61 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class MatchesFunctionTest { +class MatchesFunctionTest { private MatchesFunction matchesFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { matchesFunction = new MatchesFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(matchesFunction.invoke((String) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(matchesFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(matchesFunction.invoke("test", null), InvalidParametersEvent.class); } @Test - public void invokeUnsupportedFlags() { + void invokeUnsupportedFlags() { FunctionTestUtil.assertResult(matchesFunction.invoke("foobar", "fo.bar", "g"), true); } @Test - public void invokeWithoutFlagsMatch() { + void invokeWithoutFlagsMatch() { FunctionTestUtil.assertResult(matchesFunction.invoke("test", "test"), true); FunctionTestUtil.assertResult(matchesFunction.invoke("foobar", "^fo*b"), true); } @Test - public void invokeWithoutFlagsNotMatch() { + void invokeWithoutFlagsNotMatch() { FunctionTestUtil.assertResult(matchesFunction.invoke("test", "testt"), false); FunctionTestUtil.assertResult(matchesFunction.invoke("foobar", "^fo*bb"), false); FunctionTestUtil.assertResult(matchesFunction.invoke("fo\nbar", "fo.bar"), false); } @Test - public void invokeWithFlagDotAll() { + void invokeWithFlagDotAll() { FunctionTestUtil.assertResult(matchesFunction.invoke("fo\nbar", "fo.bar", "s"), true); } @Test - public void invokeWithFlagMultiline() { + void invokeWithFlagMultiline() { FunctionTestUtil.assertResult(matchesFunction.invoke("fo\nbar", "^bar", "m"), true); } @Test - public void invokeWithFlagCaseInsensitive() { + void invokeWithFlagCaseInsensitive() { FunctionTestUtil.assertResult(matchesFunction.invoke("foobar", "^Fo*bar", "i"), true); } @Test - public void invokeWithAllFlags() { + void invokeWithAllFlags() { FunctionTestUtil.assertResult(matchesFunction.invoke("fo\nbar", "Fo.^bar", "smi"), true); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MaxFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MaxFunctionTest.java index 30f922aca82..561074eb9c5 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MaxFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MaxFunctionTest.java @@ -27,37 +27,37 @@ import java.util.List; import java.util.function.Predicate; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class MaxFunctionTest { +class MaxFunctionTest { private MaxFunction maxFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { maxFunction = new MaxFunction(); } @Test - public void invokeNullList() { + void invokeNullList() { FunctionTestUtil.assertResultError(maxFunction.invoke((List) null), InvalidParametersEvent.class); } @Test - public void invokeEmptyList() { + void invokeEmptyList() { FunctionTestUtil.assertResultError(maxFunction.invoke(Collections.emptyList()), InvalidParametersEvent.class); } @Test - public void invokeListWithHeterogenousTypes() { + void invokeListWithHeterogenousTypes() { FunctionTestUtil.assertResultError(maxFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), InvalidParametersEvent.class); } @Test - public void invokeListOfIntegers() { + void invokeListOfIntegers() { FunctionTestUtil.assertResult(maxFunction.invoke(Collections.singletonList(1)), 1); FunctionTestUtil.assertResult(maxFunction.invoke(Arrays.asList(1, 2, 3)), 3); FunctionTestUtil.assertResult(maxFunction.invoke(Arrays.asList(1, 3, 2)), 3); @@ -65,7 +65,7 @@ public void invokeListOfIntegers() { } @Test - public void invokeListOfStrings() { + void invokeListOfStrings() { FunctionTestUtil.assertResult(maxFunction.invoke(Collections.singletonList("a")), "a"); FunctionTestUtil.assertResult(maxFunction.invoke(Arrays.asList("a", "b", "c")), "c"); FunctionTestUtil.assertResult(maxFunction.invoke(Arrays.asList("a", "c", "b")), "c"); @@ -73,7 +73,7 @@ public void invokeListOfStrings() { } @Test - public void invokeListOfChronoPeriods() { + void invokeListOfChronoPeriods() { final ChronoPeriod p1Period = Period.parse("P1Y"); final ChronoPeriod p1Comparable = ComparablePeriod.parse("P1Y"); final ChronoPeriod p2Period = Period.parse("P1M"); @@ -88,22 +88,22 @@ public void invokeListOfChronoPeriods() { } @Test - public void invokeNullArray() { + void invokeNullArray() { FunctionTestUtil.assertResultError(maxFunction.invoke((Object[]) null), InvalidParametersEvent.class); } @Test - public void invokeEmptyArray() { + void invokeEmptyArray() { FunctionTestUtil.assertResultError(maxFunction.invoke(new Object[]{}), InvalidParametersEvent.class); } @Test - public void invokeArrayWithHeterogenousTypes() { + void invokeArrayWithHeterogenousTypes() { FunctionTestUtil.assertResultError(maxFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), InvalidParametersEvent.class); } @Test - public void invokeArrayOfIntegers() { + void invokeArrayOfIntegers() { FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{1}), 1); FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{1, 2, 3}), 3); FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{1, 3, 2}), 3); @@ -111,7 +111,7 @@ public void invokeArrayOfIntegers() { } @Test - public void invokeArrayOfStrings() { + void invokeArrayOfStrings() { FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{"a"}), "a"); FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{"a", "b", "c"}), "c"); FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{"a", "c", "b"}), "c"); @@ -119,7 +119,7 @@ public void invokeArrayOfStrings() { } @Test - public void invokeArrayOfChronoPeriods() { + void invokeArrayOfChronoPeriods() { final ChronoPeriod p1Period = Period.parse("P1Y"); final ChronoPeriod p1Comparable = ComparablePeriod.parse("P1Y"); final ChronoPeriod p2Period = Period.parse("P1M"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MeanFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MeanFunctionTest.java index ec1f1cd299b..9a6892a6648 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MeanFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MeanFunctionTest.java @@ -22,108 +22,109 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class MeanFunctionTest { +class MeanFunctionTest { private MeanFunction meanFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { meanFunction = new MeanFunction(); } @Test - public void invokeNumberNull() { + void invokeNumberNull() { FunctionTestUtil.assertResultError(meanFunction.invoke((Number) null), InvalidParametersEvent.class); } @Test - public void invokeNumberBigDecimal() { + void invokeNumberBigDecimal() { FunctionTestUtil.assertResult(meanFunction.invoke(BigDecimal.TEN), BigDecimal.TEN); } @Test - public void invokeNumberInteger() { + void invokeNumberInteger() { FunctionTestUtil.assertResult(meanFunction.invoke(10), BigDecimal.TEN); } @Test - public void invokeNumberDoubleWithoutDecimalPart() { + void invokeNumberDoubleWithoutDecimalPart() { FunctionTestUtil.assertResult(meanFunction.invoke(10d), BigDecimal.valueOf(10)); } @Test - public void invokeNumberDoubleWithDecimalPart() { + void invokeNumberDoubleWithDecimalPart() { FunctionTestUtil.assertResult(meanFunction.invoke(10.1d), BigDecimal.valueOf(10.1)); } @Test - public void invokeNumberFloat() { + void invokeNumberFloat() { FunctionTestUtil.assertResult(meanFunction.invoke(10.1f), BigDecimal.valueOf(10.1)); } @Test - public void invokeUnconvertableNumber() { + void invokeUnconvertableNumber() { FunctionTestUtil.assertResultError(meanFunction.invoke(Double.POSITIVE_INFINITY), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(meanFunction.invoke(Double.NEGATIVE_INFINITY), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(meanFunction.invoke(Double.NaN), InvalidParametersEvent.class); } @Test - public void invokeListNull() { + void invokeListNull() { FunctionTestUtil.assertResultError(meanFunction.invoke((List) null), InvalidParametersEvent.class); } @Test - public void invokeListEmpty() { + void invokeListEmpty() { FunctionTestUtil.assertResultError(meanFunction.invoke(Collections.emptyList()), InvalidParametersEvent.class); } @Test - public void invokeListTypeHeterogenous() { + void invokeListTypeHeterogenous() { FunctionTestUtil.assertResultError(meanFunction.invoke(Arrays.asList(1, "test")), InvalidParametersEvent.class); } @Test - public void invokeListWithIntegers() { + void invokeListWithIntegers() { FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10, 20, 30)), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10, 20, 30, -10, -20, -30)), BigDecimal.ZERO); FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(0, 0, 1)), new BigDecimal("0.3333333333333333333333333333333333")); } @Test - public void invokeListWithDoubles() { + void invokeListWithDoubles() { FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.0d, 20.0d, 30.0d)), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.2d, 20.2d, 30.2d)), BigDecimal.valueOf(20.2)); } @Test - public void invokeArrayNull() { + void invokeArrayNull() { FunctionTestUtil.assertResultError(meanFunction.invoke((Object[]) null), InvalidParametersEvent.class); } @Test - public void invokeArrayEmpty() { + void invokeArrayEmpty() { FunctionTestUtil.assertResultError(meanFunction.invoke(new Object[]{}), InvalidParametersEvent.class); } @Test - public void invokeArrayTypeHeterogenous() { + void invokeArrayTypeHeterogenous() { FunctionTestUtil.assertResultError(meanFunction.invoke(new Object[]{1, "test"}), InvalidParametersEvent.class); } @Test - public void invokeArrayWithIntegers() { + void invokeArrayWithIntegers() { FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{10, 20, 30}), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{10, 20, 30, -10, -20, -30}), BigDecimal.ZERO); FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{0, 0, 1}), new BigDecimal("0.3333333333333333333333333333333333")); } @Test - public void invokeArrayWithDoubles() { + void invokeArrayWithDoubles() { FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{10.0d, 20.0d, 30.0d}), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{10.2d, 20.2d, 30.2d}), BigDecimal.valueOf(20.2)); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MinFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MinFunctionTest.java index fb177da227d..d41c0e2ccfa 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MinFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MinFunctionTest.java @@ -27,37 +27,37 @@ import java.util.List; import java.util.function.Predicate; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class MinFunctionTest { +class MinFunctionTest { private MinFunction minFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { minFunction = new MinFunction(); } @Test - public void invokeNullList() { + void invokeNullList() { FunctionTestUtil.assertResultError(minFunction.invoke((List) null), InvalidParametersEvent.class); } @Test - public void invokeEmptyList() { + void invokeEmptyList() { FunctionTestUtil.assertResultError(minFunction.invoke(Collections.emptyList()), InvalidParametersEvent.class); } @Test - public void invokeListWithHeterogenousTypes() { + void invokeListWithHeterogenousTypes() { FunctionTestUtil.assertResultError(minFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), InvalidParametersEvent.class); } @Test - public void invokeListOfIntegers() { + void invokeListOfIntegers() { FunctionTestUtil.assertResult(minFunction.invoke(Collections.singletonList(1)), 1); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList(1, 2, 3)), 1); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList(2, 1, 3)), 1); @@ -65,7 +65,7 @@ public void invokeListOfIntegers() { } @Test - public void invokeListOfStrings() { + void invokeListOfStrings() { FunctionTestUtil.assertResult(minFunction.invoke(Collections.singletonList("a")), "a"); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList("a", "b", "c")), "a"); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList("b", "a", "c")), "a"); @@ -73,7 +73,7 @@ public void invokeListOfStrings() { } @Test - public void invokeListOfChronoPeriods() { + void invokeListOfChronoPeriods() { final ChronoPeriod p1Period = Period.parse("P1Y"); final ChronoPeriod p1Comparable = ComparablePeriod.parse("P1Y"); final ChronoPeriod p2Period = Period.parse("P1M"); @@ -88,22 +88,22 @@ public void invokeListOfChronoPeriods() { } @Test - public void invokeNullArray() { + void invokeNullArray() { FunctionTestUtil.assertResultError(minFunction.invoke((Object[]) null), InvalidParametersEvent.class); } @Test - public void invokeEmptyArray() { + void invokeEmptyArray() { FunctionTestUtil.assertResultError(minFunction.invoke(new Object[]{}), InvalidParametersEvent.class); } @Test - public void invokeArrayWithHeterogenousTypes() { + void invokeArrayWithHeterogenousTypes() { FunctionTestUtil.assertResultError(minFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), InvalidParametersEvent.class); } @Test - public void invokeArrayOfIntegers() { + void invokeArrayOfIntegers() { FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{1}), 1); FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{1, 2, 3}), 1); FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{2, 1, 3}), 1); @@ -111,7 +111,7 @@ public void invokeArrayOfIntegers() { } @Test - public void invokeArrayOfStrings() { + void invokeArrayOfStrings() { FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{"a"}), "a"); FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{"a", "b", "c"}), "a"); FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{"b", "a", "c"}), "a"); @@ -119,7 +119,7 @@ public void invokeArrayOfStrings() { } @Test - public void invokeArrayOfChronoPeriods() { + void invokeArrayOfChronoPeriods() { final ChronoPeriod p1Period = Period.parse("P1Y"); final ChronoPeriod p1Comparable = ComparablePeriod.parse("P1Y"); final ChronoPeriod p2Period = Period.parse("P1M"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MonthOfYearTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MonthOfYearTest.java index d8a6939e64e..a837fce749a 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MonthOfYearTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/MonthOfYearTest.java @@ -24,21 +24,21 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class MonthOfYearTest { +class MonthOfYearTest { private MonthOfYearFunction fut; - @Before - public void setUp() { + @BeforeEach + void setUp() { fut = MonthOfYearFunction.INSTANCE; } @Test - public void testMonthOfYearFunctionTemporalAccessor() { + void monthOfYearFunctionTemporalAccessor() { FunctionTestUtil.assertResult(fut.invoke(LocalDate.of(2019, 9, 17)), "September"); FunctionTestUtil.assertResult(fut.invoke(LocalDateTime.of(2019, 9, 17, 0, 0, 0)), "September"); FunctionTestUtil.assertResult(fut.invoke(OffsetDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), "September"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NotFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NotFunctionTest.java index 4b9b80dc02d..1d5aef5cca4 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NotFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NotFunctionTest.java @@ -19,38 +19,39 @@ package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class NotFunctionTest { +class NotFunctionTest { private NotFunction notFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { notFunction = new NotFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultNull(notFunction.invoke(null)); } @Test - public void invokeWrongType() { + void invokeWrongType() { FunctionTestUtil.assertResultError(notFunction.invoke(1), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(notFunction.invoke("test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(notFunction.invoke(BigDecimal.ZERO), InvalidParametersEvent.class); } @Test - public void invokeTrue() { + void invokeTrue() { FunctionTestUtil.assertResult(notFunction.invoke(true), false); } @Test - public void invokeFalse() { + void invokeFalse() { FunctionTestUtil.assertResult(notFunction.invoke(false), true); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NowFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NowFunctionTest.java index acbc8fdd534..adaf8d74819 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NowFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NowFunctionTest.java @@ -21,24 +21,23 @@ import java.time.ZonedDateTime; import java.time.temporal.TemporalAccessor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.functions.extended.NowFunction; - import static org.assertj.core.api.Assertions.assertThat; -public class NowFunctionTest { +class NowFunctionTest { private NowFunction nowFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { nowFunction = new NowFunction(); } @Test - public void invoke() { + void invoke() { // The current time that we need to compare will almost never be the same as another one we get for comparison purposes, // because there is some execution between them, so the comparison assertion doesn't make sense. // Note: We cannot guarantee any part of the date to be the same. E.g. in case when the test is executed diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NumberFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NumberFunctionTest.java index cceb444263c..16c322489e3 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NumberFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/NumberFunctionTest.java @@ -20,21 +20,21 @@ import java.math.BigDecimal; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class NumberFunctionTest { +class NumberFunctionTest { private NumberFunction numberFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { numberFunction = new NumberFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(numberFunction.invoke(null, null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(numberFunction.invoke(null, " ", null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(numberFunction.invoke(null, null, "."), InvalidParametersEvent.class); @@ -42,87 +42,87 @@ public void invokeNull() { } @Test - public void invokeIllegalNumber() { + void invokeIllegalNumber() { FunctionTestUtil.assertResultError(numberFunction.invoke("test", null, null), InvalidParametersEvent.class); } @Test - public void invokeNumberWithLeadingZeros() { + void invokeNumberWithLeadingZeros() { FunctionTestUtil.assertResult(numberFunction.invoke("009876", null, null), BigDecimal.valueOf(9876)); } @Test - public void invokeNumberWithoutDecimalPart() { + void invokeNumberWithoutDecimalPart() { FunctionTestUtil.assertResult(numberFunction.invoke("9876", null, null), BigDecimal.valueOf(9876)); } @Test - public void invokeNumberWithGroupCharSpace() { + void invokeNumberWithGroupCharSpace() { FunctionTestUtil.assertResult(numberFunction.invoke("9 876", " ", null), BigDecimal.valueOf(9876)); FunctionTestUtil.assertResult(numberFunction.invoke("9 876 000", " ", null), BigDecimal.valueOf(9876000)); } @Test - public void invokeNumberWithGroupCharComma() { + void invokeNumberWithGroupCharComma() { FunctionTestUtil.assertResult(numberFunction.invoke("9,876", ",", null), BigDecimal.valueOf(9876)); FunctionTestUtil.assertResult(numberFunction.invoke("9,876,000", ",", null), BigDecimal.valueOf(9876000)); } @Test - public void invokeNumberWithGroupCharDot() { + void invokeNumberWithGroupCharDot() { FunctionTestUtil.assertResult(numberFunction.invoke("9.876", ".", null), BigDecimal.valueOf(9876)); FunctionTestUtil.assertResult(numberFunction.invoke("9.876.000", ".", null), BigDecimal.valueOf(9876000)); } @Test - public void invokeNumberWithDecimalCharComma() { + void invokeNumberWithDecimalCharComma() { FunctionTestUtil.assertResult(numberFunction.invoke("9,876", null, ","), BigDecimal.valueOf(9.876)); } @Test - public void invokeNumberWithDecimalCharDot() { + void invokeNumberWithDecimalCharDot() { FunctionTestUtil.assertResult(numberFunction.invoke("9.876", null, "."), BigDecimal.valueOf(9.876)); } @Test - public void invokeNumberWithGroupAndDecimalChar() { + void invokeNumberWithGroupAndDecimalChar() { FunctionTestUtil.assertResult(numberFunction.invoke("9 876.124", " ", "."), BigDecimal.valueOf(9876.124)); FunctionTestUtil.assertResult(numberFunction.invoke("9 876 000.124", " ", "."), BigDecimal.valueOf(9876000.124)); FunctionTestUtil.assertResult(numberFunction.invoke("9.876.000,124", ".", ","), BigDecimal.valueOf(9876000.124)); } @Test - public void invokeIncorrectGroup() { + void invokeIncorrectGroup() { FunctionTestUtil.assertResultError(numberFunction.invoke("1 000", ".", null), InvalidParametersEvent.class); } @Test - public void invokeInvalidGroup() { + void invokeInvalidGroup() { FunctionTestUtil.assertResultError(numberFunction.invoke("1 000", "test", null), InvalidParametersEvent.class); } @Test - public void invokeEmptyGroup() { + void invokeEmptyGroup() { FunctionTestUtil.assertResultError(numberFunction.invoke("1 000", "", null), InvalidParametersEvent.class); } @Test - public void invokeIncorrectDecimal() { + void invokeIncorrectDecimal() { FunctionTestUtil.assertResultError(numberFunction.invoke("1,1", null, "."), InvalidParametersEvent.class); } @Test - public void invokeInvalidDecimal() { + void invokeInvalidDecimal() { FunctionTestUtil.assertResultError(numberFunction.invoke("1.1", null, "test"), InvalidParametersEvent.class); } @Test - public void invokeEmptyDecimal() { + void invokeEmptyDecimal() { FunctionTestUtil.assertResultError(numberFunction.invoke("1.1", null, ""), InvalidParametersEvent.class); } @Test - public void invokeGroupEqualsDecimal() { + void invokeGroupEqualsDecimal() { FunctionTestUtil.assertResultError(numberFunction.invoke("1 000.1", ".", "."), InvalidParametersEvent.class); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RemoveFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RemoveFunctionTest.java index 5b7fccf78f6..a4f1b0def08 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RemoveFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/RemoveFunctionTest.java @@ -22,33 +22,34 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class RemoveFunctionTest { +class RemoveFunctionTest { private RemoveFunction removeFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { removeFunction = new RemoveFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(removeFunction.invoke((List) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(removeFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.emptyList(), null), InvalidParametersEvent.class); } @Test - public void invokePositionZero() { + void invokePositionZero() { FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.ZERO), InvalidParametersEvent.class); } @Test - public void invokePositionOutOfListBounds() { + void invokePositionOutOfListBounds() { FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(2)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(154)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(-2)), InvalidParametersEvent.class); @@ -56,7 +57,7 @@ public void invokePositionOutOfListBounds() { } @Test - public void invokePositionPositive() { + void invokePositionPositive() { FunctionTestUtil.assertResultList(removeFunction.invoke(Collections.singletonList(1), BigDecimal.ONE), Collections.emptyList()); FunctionTestUtil.assertResultList( removeFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(14)), BigDecimal.ONE), @@ -70,7 +71,7 @@ public void invokePositionPositive() { } @Test - public void invokePositionNegative() { + void invokePositionNegative() { FunctionTestUtil.assertResultList(removeFunction.invoke(Collections.singletonList(1), BigDecimal.valueOf(-1)), Collections.emptyList()); FunctionTestUtil.assertResultList( removeFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(14)), BigDecimal.valueOf(-1)), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReplaceFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReplaceFunctionTest.java index c4cfe15ea04..125914338de 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReplaceFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReplaceFunctionTest.java @@ -18,21 +18,21 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class ReplaceFunctionTest { +class ReplaceFunctionTest { private ReplaceFunction replaceFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { replaceFunction = new ReplaceFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", "test", null), InvalidParametersEvent.class); @@ -42,7 +42,7 @@ public void invokeNull() { } @Test - public void invokeNullWithFlags() { + void invokeNullWithFlags() { FunctionTestUtil.assertResultError(replaceFunction.invoke(null, null, null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", null, null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(replaceFunction.invoke("testString", "test", null, null), InvalidParametersEvent.class); @@ -59,34 +59,34 @@ public void invokeNullWithFlags() { } @Test - public void invokeWithoutFlagsPatternMatches() { + void invokeWithoutFlagsPatternMatches() { FunctionTestUtil.assertResult(replaceFunction.invoke("testString", "^test", "ttt"), "tttString"); FunctionTestUtil.assertResult(replaceFunction.invoke("testStringtest", "^test", "ttt"), "tttStringtest"); } @Test - public void invokeWithoutFlagsPatternNotMatches() { + void invokeWithoutFlagsPatternNotMatches() { FunctionTestUtil.assertResult(replaceFunction.invoke("testString", "ttest", "ttt"), "testString"); FunctionTestUtil.assertResult(replaceFunction.invoke("testString", "$test", "ttt"), "testString"); } @Test - public void invokeWithFlagDotAll() { + void invokeWithFlagDotAll() { FunctionTestUtil.assertResult(replaceFunction.invoke("fo\nbar", "o.b", "ttt", "s"), "ftttar"); } @Test - public void invokeWithFlagMultiline() { + void invokeWithFlagMultiline() { FunctionTestUtil.assertResult(replaceFunction.invoke("foo\nbar", "^b", "ttt", "m"), "foo\ntttar"); } @Test - public void invokeWithFlagCaseInsensitive() { + void invokeWithFlagCaseInsensitive() { FunctionTestUtil.assertResult(replaceFunction.invoke("foobar", "^fOO", "ttt", "i"), "tttbar"); } @Test - public void invokeWithAllFlags() { + void invokeWithAllFlags() { FunctionTestUtil.assertResult(replaceFunction.invoke("fo\nbar", "O.^b", "ttt", "smi"), "ftttar"); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReverseFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReverseFunctionTest.java index 4c1bf3084b8..b40e64c186d 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReverseFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/ReverseFunctionTest.java @@ -21,36 +21,37 @@ import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class ReverseFunctionTest { +class ReverseFunctionTest { private ReverseFunction reverseFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { reverseFunction = new ReverseFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(reverseFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeEmptyList() { + void invokeEmptyList() { FunctionTestUtil.assertResultList(reverseFunction.invoke(Collections.emptyList()), Collections.emptyList()); } @Test - public void invokeListTypeHomogenous() { + void invokeListTypeHomogenous() { FunctionTestUtil.assertResultList(reverseFunction.invoke(Arrays.asList(1, 2, 3, 4)), Arrays.asList(4, 3, 2, 1)); } @Test - public void invokeListTypeHeterogenous() { + void invokeListTypeHeterogenous() { FunctionTestUtil.assertResultList( reverseFunction.invoke(Arrays.asList(1, "test", BigDecimal.TEN, Collections.emptyList())), Arrays.asList(Collections.emptyList(), BigDecimal.TEN, "test", 1)); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SortFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SortFunctionTest.java index 50ad57f9744..ea35bba6cb1 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SortFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SortFunctionTest.java @@ -23,58 +23,58 @@ import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.EvaluationContext; import org.kie.dmn.feel.lang.Symbol; import org.kie.dmn.feel.runtime.FEELFunction; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class SortFunctionTest { +class SortFunctionTest { private SortFunction sortFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { sortFunction = new SortFunction(); } @Test - public void invokeListParamNull() { + void invokeListParamNull() { FunctionTestUtil.assertResultError(sortFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeListEmpty() { + void invokeListEmpty() { FunctionTestUtil.assertResultList(sortFunction.invoke(Collections.emptyList()), Collections.emptyList()); } @Test - public void invokeListSingleItem() { + void invokeListSingleItem() { FunctionTestUtil.assertResultList(sortFunction.invoke(Collections.singletonList(10)), Collections.singletonList(10)); } @Test - public void invokeListTypeHeterogenous() { + void invokeListTypeHeterogenous() { FunctionTestUtil.assertResultError( sortFunction.invoke(Arrays.asList(10, "test", BigDecimal.TEN)), InvalidParametersEvent.class); } @Test - public void invokeList() { + void invokeList() { FunctionTestUtil.assertResultList(sortFunction.invoke(Arrays.asList(10, 4, 5, 12)), Arrays.asList(4, 5, 10, 12)); FunctionTestUtil.assertResultList(sortFunction.invoke(Arrays.asList("a", "c", "b")), Arrays.asList("a", "b", "c")); } @Test - public void invokeWithSortFunctionNull() { + void invokeWithSortFunctionNull() { FunctionTestUtil.assertResultList( sortFunction.invoke(null, Arrays.asList(10, 4, 5, 12), null), Arrays.asList(4, 5, 10, 12)); } @Test - public void invokeWithSortFunction() { + void invokeWithSortFunction() { FunctionTestUtil.assertResultList( sortFunction.invoke(null, Arrays.asList(10, 4, 5, 12), getBooleanFunction(true)), Arrays.asList(12, 5, 4, 10)); FunctionTestUtil.assertResultList( @@ -82,7 +82,7 @@ public void invokeWithSortFunction() { } @Test - public void invokeExceptionInSortFunction() { + void invokeExceptionInSortFunction() { FunctionTestUtil.assertResultError( sortFunction.invoke(null, Arrays.asList(10, 4, 5, 12), getFunctionThrowingException()), InvalidParametersEvent.class); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StartsWithFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StartsWithFunctionTest.java index 27635fc039d..c4ff1ea5db2 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StartsWithFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StartsWithFunctionTest.java @@ -18,42 +18,42 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class StartsWithFunctionTest { +class StartsWithFunctionTest { private StartsWithFunction startsWithFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { startsWithFunction = new StartsWithFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(startsWithFunction.invoke((String) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(startsWithFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(startsWithFunction.invoke("test", null), InvalidParametersEvent.class); } @Test - public void invokeEmptyString() { + void invokeEmptyString() { FunctionTestUtil.assertResult(startsWithFunction.invoke("", ""), true); FunctionTestUtil.assertResult(startsWithFunction.invoke("", "test"), false); FunctionTestUtil.assertResult(startsWithFunction.invoke("test", ""), true); } @Test - public void invokeStartsWith() { + void invokeStartsWith() { FunctionTestUtil.assertResult(startsWithFunction.invoke("test", "te"), true); FunctionTestUtil.assertResult(startsWithFunction.invoke("test", "t"), true); FunctionTestUtil.assertResult(startsWithFunction.invoke("test", "test"), true); } @Test - public void invokeNotStartsWith() { + void invokeNotStartsWith() { FunctionTestUtil.assertResult(startsWithFunction.invoke("test", "tte"), false); FunctionTestUtil.assertResult(startsWithFunction.invoke("test", "tt"), false); FunctionTestUtil.assertResult(startsWithFunction.invoke("test", "ttest"), false); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringFunctionTest.java index dce9041aeea..8f36668a7c5 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringFunctionTest.java @@ -33,98 +33,98 @@ import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class StringFunctionTest { +class StringFunctionTest { private StringFunction stringFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { stringFunction = new StringFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResult(stringFunction.invoke(null), null); } @Test - public void invokeMaskNull() { + void invokeMaskNull() { FunctionTestUtil.assertResultError(stringFunction.invoke((String) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(stringFunction.invoke((String) null, new Object[]{}), InvalidParametersEvent.class); } @Test - public void invokeString() { + void invokeString() { FunctionTestUtil.assertResult(stringFunction.invoke("test"), "test"); } @Test - public void invokeBigDecimal() { + void invokeBigDecimal() { FunctionTestUtil.assertResult(stringFunction.invoke(BigDecimal.valueOf(10.7)), "10.7"); } @Test - public void invokeLocalDate() { + void invokeLocalDate() { final LocalDate localDate = LocalDate.now(); FunctionTestUtil.assertResult(stringFunction.invoke(localDate), localDate.toString()); } @Test - public void invokeLocalTime() { + void invokeLocalTime() { final LocalTime localTime = LocalTime.now(); FunctionTestUtil.assertResult(stringFunction.invoke(localTime), TimeFunction.FEEL_TIME.format(localTime)); } @Test - public void invokeOffsetTime() { + void invokeOffsetTime() { final OffsetTime offsetTime = OffsetTime.now(); FunctionTestUtil.assertResult(stringFunction.invoke(offsetTime), TimeFunction.FEEL_TIME.format(offsetTime)); } @Test - public void invokeLocalDateTime() { + void invokeLocalDateTime() { final LocalDateTime localDateTime = LocalDateTime.now(); FunctionTestUtil.assertResult(stringFunction.invoke(localDateTime), DateAndTimeFunction.FEEL_DATE_TIME.format(localDateTime)); } @Test - public void invokeOffsetDateTime() { + void invokeOffsetDateTime() { final OffsetDateTime offsetDateTime = OffsetDateTime.now(); FunctionTestUtil.assertResult(stringFunction.invoke(offsetDateTime), DateAndTimeFunction.FEEL_DATE_TIME.format(offsetDateTime)); } @Test - public void invokeZonedDateTime() { + void invokeZonedDateTime() { final ZonedDateTime zonedDateTime = ZonedDateTime.now(); FunctionTestUtil.assertResult(stringFunction.invoke(zonedDateTime), DateAndTimeFunction.REGION_DATETIME_FORMATTER.format(zonedDateTime)); } @Test - public void invokeDurationZero() { + void invokeDurationZero() { FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ZERO), "PT0S"); } @Test - public void invokeDurationDays() { + void invokeDurationDays() { FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofDays(9)), "P9D"); FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofDays(-9)), "-P9D"); } @Test - public void invokeDurationHours() { + void invokeDurationHours() { FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofHours(9)), "PT9H"); FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofHours(200)), "P8DT8H"); FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofHours(-200)), "-P8DT8H"); } @Test - public void invokeDurationMinutes() { + void invokeDurationMinutes() { FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofMinutes(9)), "PT9M"); FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofMinutes(200)), "PT3H20M"); FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofMinutes(5000)), "P3DT11H20M"); @@ -132,7 +132,7 @@ public void invokeDurationMinutes() { } @Test - public void invokeDurationSeconds() { + void invokeDurationSeconds() { FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofSeconds(9)), "PT9S"); FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofSeconds(200)), "PT3M20S"); FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofSeconds(5000)), "PT1H23M20S"); @@ -141,7 +141,7 @@ public void invokeDurationSeconds() { } @Test - public void invokeDurationNanosMillis() { + void invokeDurationNanosMillis() { FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofNanos(25)), "PT0.000000025S"); FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofNanos(10000)), "PT0.00001S"); FunctionTestUtil.assertResult(stringFunction.invoke(Duration.ofNanos(10025)), "PT0.000010025S"); @@ -151,30 +151,30 @@ public void invokeDurationNanosMillis() { } @Test - public void invokePeriodZero() { + void invokePeriodZero() { FunctionTestUtil.assertResult(stringFunction.invoke(Period.ZERO), "P0M"); } @Test - public void invokePeriodYears() { + void invokePeriodYears() { FunctionTestUtil.assertResult(stringFunction.invoke(Period.ofYears(24)), "P24Y"); FunctionTestUtil.assertResult(stringFunction.invoke(Period.ofYears(-24)), "-P24Y"); } @Test - public void invokePeriodMonths() { + void invokePeriodMonths() { FunctionTestUtil.assertResult(stringFunction.invoke(Period.ofMonths(2)), "P2M"); FunctionTestUtil.assertResult(stringFunction.invoke(Period.ofMonths(27)), "P2Y3M"); FunctionTestUtil.assertResult(stringFunction.invoke(Period.ofMonths(-27)), "-P2Y3M"); } @Test - public void invokeListEmpty() { + void invokeListEmpty() { FunctionTestUtil.assertResult(stringFunction.invoke(Collections.emptyList()), "[ ]"); } @Test - public void invokeListNonEmpty() { + void invokeListNonEmpty() { final List values = new ArrayList<>(); values.add(1); values.add(BigDecimal.valueOf(10.5)); @@ -183,40 +183,40 @@ public void invokeListNonEmpty() { } @Test - public void invokeRangeOpenOpen() { + void invokeRangeOpenOpen() { FunctionTestUtil.assertResult( stringFunction.invoke(new RangeImpl(Range.RangeBoundary.OPEN, 12, 15, Range.RangeBoundary.OPEN)), "( 12 .. 15 )"); } @Test - public void invokeRangeOpenClosed() { + void invokeRangeOpenClosed() { FunctionTestUtil.assertResult( stringFunction.invoke(new RangeImpl(Range.RangeBoundary.OPEN, 12, 15, Range.RangeBoundary.CLOSED)), "( 12 .. 15 ]"); } @Test - public void invokeRangeClosedOpen() { + void invokeRangeClosedOpen() { FunctionTestUtil.assertResult( stringFunction.invoke(new RangeImpl(Range.RangeBoundary.CLOSED, 12, 15, Range.RangeBoundary.OPEN)), "[ 12 .. 15 )"); } @Test - public void invokeRangeClosedClosed() { + void invokeRangeClosedClosed() { FunctionTestUtil.assertResult( stringFunction.invoke(new RangeImpl(Range.RangeBoundary.CLOSED, 12, 15, Range.RangeBoundary.CLOSED)), "[ 12 .. 15 ]"); } @Test - public void invokeContextEmpty() { + void invokeContextEmpty() { FunctionTestUtil.assertResult(stringFunction.invoke(new HashMap<>()), "{ }"); } @Test - public void invokeContextNonEmpty() { + void invokeContextNonEmpty() { final Map childContextMap = new HashMap<>(); childContextMap.put("childKey1", "childValue1"); @@ -228,7 +228,7 @@ public void invokeContextNonEmpty() { } @Test - public void invokeMaskedFormat() { + void invokeMaskedFormat() { FunctionTestUtil.assertResult(stringFunction.invoke("%s is here!", new Object[]{"Gorgonzola"}), "Gorgonzola is here!"); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLengthFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLengthFunctionTest.java index 47a2202334c..94eceadca52 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLengthFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLengthFunctionTest.java @@ -19,31 +19,32 @@ package org.kie.dmn.feel.runtime.functions; import java.math.BigDecimal; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class StringLengthFunctionTest { +class StringLengthFunctionTest { private StringLengthFunction stringLengthFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { stringLengthFunction = new StringLengthFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(stringLengthFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeEmptyString() { + void invokeEmptyString() { FunctionTestUtil.assertResult(stringLengthFunction.invoke(""), BigDecimal.ZERO); } @Test - public void invoke() { + void invoke() { FunctionTestUtil.assertResult(stringLengthFunction.invoke("testString"), BigDecimal.TEN); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunctionTest.java index c5889439eb0..7171cffa716 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringLowerCaseFunctionTest.java @@ -18,36 +18,36 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class StringLowerCaseFunctionTest { +class StringLowerCaseFunctionTest { private StringLowerCaseFunction stringLowerCaseFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { stringLowerCaseFunction = new StringLowerCaseFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(stringLowerCaseFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeLowercaseString() { + void invokeLowercaseString() { FunctionTestUtil.assertResult(stringLowerCaseFunction.invoke("teststring"), "teststring"); } @Test - public void invokeUppercaseString() { + void invokeUppercaseString() { FunctionTestUtil.assertResult(stringLowerCaseFunction.invoke("TESTSTRING"), "teststring"); } @Test - public void invokeMixedCaseString() { + void invokeMixedCaseString() { FunctionTestUtil.assertResult(stringLowerCaseFunction.invoke("testSTRing"), "teststring"); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunctionTest.java index ac70a911b87..8770234a7b4 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/StringUpperCaseFunctionTest.java @@ -18,36 +18,36 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class StringUpperCaseFunctionTest { +class StringUpperCaseFunctionTest { private StringUpperCaseFunction stringUpperCaseFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { stringUpperCaseFunction = new StringUpperCaseFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(stringUpperCaseFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeLowercaseString() { + void invokeLowercaseString() { FunctionTestUtil.assertResult(stringUpperCaseFunction.invoke("teststring"), "TESTSTRING"); } @Test - public void invokeUppercaseString() { + void invokeUppercaseString() { FunctionTestUtil.assertResult(stringUpperCaseFunction.invoke("TESTSTRING"), "TESTSTRING"); } @Test - public void invokeMixedCaseString() { + void invokeMixedCaseString() { FunctionTestUtil.assertResult(stringUpperCaseFunction.invoke("testSTRing"), "TESTSTRING"); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SublistFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SublistFunctionTest.java index 7df6f65a374..ac0f4cfdfc3 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SublistFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SublistFunctionTest.java @@ -22,57 +22,58 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class SublistFunctionTest { +class SublistFunctionTest { private SublistFunction sublistFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { sublistFunction = new SublistFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(sublistFunction.invoke((List) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(sublistFunction.invoke(null, BigDecimal.ONE), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(sublistFunction.invoke(Collections.emptyList(), null), InvalidParametersEvent.class); } @Test - public void invokeStartZero() { + void invokeStartZero() { FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.ZERO), InvalidParametersEvent.class); } @Test - public void invokeStartOutOfListBounds() { + void invokeStartOutOfListBounds() { FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.TEN), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.valueOf(-10)), InvalidParametersEvent.class); } @Test - public void invokeLengthNegative() { + void invokeLengthNegative() { FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.valueOf(1), BigDecimal.valueOf(-3)), InvalidParametersEvent.class); } @Test - public void invokeLengthOutOfListBounds() { + void invokeLengthOutOfListBounds() { FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.ONE, BigDecimal.valueOf(3)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(sublistFunction.invoke(Arrays.asList(1, 2), BigDecimal.valueOf(-1), BigDecimal.valueOf(3)), InvalidParametersEvent.class); } @Test - public void invokeStartPositive() { + void invokeStartPositive() { FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, 2, 3), BigDecimal.valueOf(2)), Arrays.asList(2, 3)); FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(2)), Arrays.asList("test", 3)); FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(2), BigDecimal.ONE), Collections.singletonList("test")); } @Test - public void invokeStartNegative() { + void invokeStartNegative() { FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, 2, 3), BigDecimal.valueOf(-2)), Arrays.asList(2, 3)); FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(-2)), Arrays.asList("test", 3)); FunctionTestUtil.assertResult(sublistFunction.invoke(Arrays.asList(1, "test", 3), BigDecimal.valueOf(-2), BigDecimal.ONE), Collections.singletonList("test")); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunctionTest.java index 7abae3f499e..8aae3b448d1 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringAfterFunctionTest.java @@ -18,34 +18,34 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class SubstringAfterFunctionTest { +class SubstringAfterFunctionTest { private SubstringAfterFunction substringAfterFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { substringAfterFunction = new SubstringAfterFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(substringAfterFunction.invoke((String) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringAfterFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringAfterFunction.invoke("test", null), InvalidParametersEvent.class); } @Test - public void invokeMatchExists() { + void invokeMatchExists() { FunctionTestUtil.assertResult(substringAfterFunction.invoke("foobar", "ob"), "ar"); FunctionTestUtil.assertResult(substringAfterFunction.invoke("foobar", "o"), "obar"); } @Test - public void invokeMatchNotExists() { + void invokeMatchNotExists() { FunctionTestUtil.assertResult(substringAfterFunction.invoke("foobar", "oook"), ""); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunctionTest.java index d47c8ed8877..8b4b9fb1ec7 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringBeforeFunctionTest.java @@ -18,34 +18,34 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class SubstringBeforeFunctionTest { +class SubstringBeforeFunctionTest { private SubstringBeforeFunction substringBeforeFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { substringBeforeFunction = new SubstringBeforeFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(substringBeforeFunction.invoke((String) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringBeforeFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringBeforeFunction.invoke("test", null), InvalidParametersEvent.class); } @Test - public void invokeMatchExists() { + void invokeMatchExists() { FunctionTestUtil.assertResult(substringBeforeFunction.invoke("foobar", "ob"), "fo"); FunctionTestUtil.assertResult(substringBeforeFunction.invoke("foobar", "o"), "f"); } @Test - public void invokeMatchNotExists() { + void invokeMatchNotExists() { FunctionTestUtil.assertResult(substringBeforeFunction.invoke("foobar", "oook"), ""); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringFunctionTest.java index 81f8f1aba37..c9f31216961 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SubstringFunctionTest.java @@ -18,28 +18,28 @@ */ package org.kie.dmn.feel.runtime.functions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class SubstringFunctionTest { +class SubstringFunctionTest { private SubstringFunction substringFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { substringFunction = new SubstringFunction(); } @Test - public void invokeNull2ParamsMethod() { + void invokeNull2ParamsMethod() { FunctionTestUtil.assertResultError(substringFunction.invoke((String) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringFunction.invoke("test", null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringFunction.invoke(null, 0), InvalidParametersEvent.class); } @Test - public void invokeNull3ParamsMethod() { + void invokeNull3ParamsMethod() { FunctionTestUtil.assertResultError(substringFunction.invoke(null, null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringFunction.invoke("test", null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringFunction.invoke("test", null, 2), InvalidParametersEvent.class); @@ -49,13 +49,13 @@ public void invokeNull3ParamsMethod() { } @Test - public void invokeStartZero() { + void invokeStartZero() { FunctionTestUtil.assertResultError(substringFunction.invoke("test", 0), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringFunction.invoke("test", 0, null), InvalidParametersEvent.class); } @Test - public void invokeStartOutOfListBounds() { + void invokeStartOutOfListBounds() { FunctionTestUtil.assertResultError(substringFunction.invoke("test", 10), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringFunction.invoke("test", 10, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(substringFunction.invoke("test", -10), InvalidParametersEvent.class); @@ -63,18 +63,18 @@ public void invokeStartOutOfListBounds() { } @Test - public void invokeLengthNegative() { + void invokeLengthNegative() { FunctionTestUtil.assertResultError(substringFunction.invoke("test", 1, -3), InvalidParametersEvent.class); } @Test - public void invokeLengthOutOfListBounds() { + void invokeLengthOutOfListBounds() { FunctionTestUtil.assertResult(substringFunction.invoke("test", 2, 3), "est"); FunctionTestUtil.assertResult(substringFunction.invoke("test", -3, 3), "est"); } @Test - public void invokeStartPositive() { + void invokeStartPositive() { FunctionTestUtil.assertResult(substringFunction.invoke("test", 1), "test"); FunctionTestUtil.assertResult(substringFunction.invoke("test", 2), "est"); FunctionTestUtil.assertResult(substringFunction.invoke("test", 4), "t"); @@ -84,7 +84,7 @@ public void invokeStartPositive() { } @Test - public void invokeStartNegative() { + void invokeStartNegative() { FunctionTestUtil.assertResult(substringFunction.invoke("test", -1), "t"); FunctionTestUtil.assertResult(substringFunction.invoke("test", -2), "st"); FunctionTestUtil.assertResult(substringFunction.invoke("test", -4), "test"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SumFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SumFunctionTest.java index fc146814ccd..e701404a614 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SumFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/SumFunctionTest.java @@ -21,31 +21,32 @@ import java.math.BigDecimal; import java.util.Arrays; import java.util.List; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class SumFunctionTest { +class SumFunctionTest { private SumFunction sumFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { sumFunction = new SumFunction(); } @Test - public void invokeNumberParamNull() { + void invokeNumberParamNull() { FunctionTestUtil.assertResultError(sumFunction.invoke((Number) null), InvalidParametersEvent.class); } @Test - public void invokeNumberParamUnsupportedNumber() { + void invokeNumberParamUnsupportedNumber() { FunctionTestUtil.assertResultError(sumFunction.invoke(Double.NaN), InvalidParametersEvent.class); } @Test - public void invokeNumberParamSupportedNumber() { + void invokeNumberParamSupportedNumber() { FunctionTestUtil.assertResult(sumFunction.invoke(BigDecimal.TEN), BigDecimal.TEN); FunctionTestUtil.assertResult(sumFunction.invoke(10), BigDecimal.TEN); FunctionTestUtil.assertResult(sumFunction.invoke(-10), BigDecimal.valueOf(-10)); @@ -53,42 +54,42 @@ public void invokeNumberParamSupportedNumber() { } @Test - public void invokeListParam() { + void invokeListParam() { FunctionTestUtil.assertResultError(sumFunction.invoke((List) null), InvalidParametersEvent.class); } @Test - public void invokeListParamContainsUnsupportedNumber() { + void invokeListParamContainsUnsupportedNumber() { FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, 2, Double.NaN)), InvalidParametersEvent.class); } @Test - public void invokeListParamContainsUnsupportedType() { + void invokeListParamContainsUnsupportedType() { FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, "test", 2)), InvalidParametersEvent.class); } @Test - public void invokeListParamSupportedTypes() { + void invokeListParamSupportedTypes() { FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, (long) 5, BigDecimal.TEN)), BigDecimal.valueOf(30.1)); } @Test - public void invokeArrayParam() { + void invokeArrayParam() { FunctionTestUtil.assertResultError(sumFunction.invoke((Object[]) null), InvalidParametersEvent.class); } @Test - public void invokeArrayParamContainsUnsupportedNumber() { + void invokeArrayParamContainsUnsupportedNumber() { FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, 2, Double.NaN}), InvalidParametersEvent.class); } @Test - public void invokeArrayParamContainsUnsupportedType() { + void invokeArrayParamContainsUnsupportedType() { FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, "test", 2}), InvalidParametersEvent.class); } @Test - public void invokeArrayParamSupportedTypes() { + void invokeArrayParamSupportedTypes() { FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, 12.1, (long) 5, BigDecimal.TEN}), BigDecimal.valueOf(30.1)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TimeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TimeFunctionTest.java index 9efa20d4105..7f0ba0729b4 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TimeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TimeFunctionTest.java @@ -30,93 +30,93 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class TimeFunctionTest { +class TimeFunctionTest { private TimeFunction timeFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { timeFunction = new TimeFunction(); } @Test - public void invokeStringParamNull() { + void invokeStringParamNull() { FunctionTestUtil.assertResultError(timeFunction.invoke((String) null), InvalidParametersEvent.class); } @Test - public void invokeStringParamNotDateOrTime() { + void invokeStringParamNotDateOrTime() { FunctionTestUtil.assertResultError(timeFunction.invoke("test"), InvalidParametersEvent.class); } @Test - public void invokeStringParamTimeWrongFormat() { + void invokeStringParamTimeWrongFormat() { FunctionTestUtil.assertResultError(timeFunction.invoke("10-15:06"), InvalidParametersEvent.class); } @Test - public void invokeStringParamNoOffset() { + void invokeStringParamNoOffset() { FunctionTestUtil.assertResult(timeFunction.invoke("10:15:06"), LocalTime.of(10,15,6)); } @Test - public void invokeStringParamWithOffset() { + void invokeStringParamWithOffset() { FunctionTestUtil.assertResult(timeFunction.invoke("10:15:06+01:00"), OffsetTime.of(10,15,6, 0, ZoneOffset.ofHours(1))); FunctionTestUtil.assertResult(timeFunction.invoke("10:15:06-01:00"), OffsetTime.of(10,15,6, 0, ZoneOffset.ofHours(-1))); } @Test - public void parseWithZone() { + void parseWithZone() { final TemporalAccessor parsedResult = timeFunction.invoke("00:01:00@Etc/UTC").getOrElse(null); assertThat(parsedResult.query(TemporalQueries.localTime())).isEqualTo(LocalTime.of(0, 1, 0)); assertThat(parsedResult.query(TemporalQueries.zone())).isEqualTo(ZoneId.of("Etc/UTC")); } @Test - public void parseWithZoneIANA() { + void parseWithZoneIANA() { final TemporalAccessor parsedResult = timeFunction.invoke("00:01:00@Europe/Paris").getOrElse(null); assertThat(parsedResult.query(TemporalQueries.localTime())).isEqualTo(LocalTime.of(0, 1, 0)); assertThat(parsedResult.query(TemporalQueries.zone())).isEqualTo(ZoneId.of("Europe/Paris")); } @Test - public void invokeWrongIANAformat() { + void invokeWrongIANAformat() { FunctionTestUtil.assertResultError(timeFunction.invoke("13:20:00+02:00@Europe/Paris"), InvalidParametersEvent.class); } @Test - public void invokeTemporalAccessorParamNull() { + void invokeTemporalAccessorParamNull() { FunctionTestUtil.assertResultError(timeFunction.invoke((TemporalAccessor) null), InvalidParametersEvent.class); } @Test - public void invokeTemporalAccessorParamUnsupportedAccessor() { + void invokeTemporalAccessorParamUnsupportedAccessor() { FunctionTestUtil.assertResultError(timeFunction.invoke(DayOfWeek.MONDAY), InvalidParametersEvent.class); } @Test - public void invokeTemporalAccessorParamDate() { + void invokeTemporalAccessorParamDate() { FunctionTestUtil.assertResult(timeFunction.invoke(LocalDate.of(2017, 6, 12)), OffsetTime.of(0, 0, 0, 0, ZoneOffset.UTC)); } @Test - public void invokeTemporalAccessorParamTime() { + void invokeTemporalAccessorParamTime() { FunctionTestUtil.assertResult(timeFunction.invoke(LocalTime.of(11, 43)), LocalTime.of(11, 43, 0)); } @Test - public void invokeTemporalAccessorParamDateTime() { + void invokeTemporalAccessorParamDateTime() { FunctionTestUtil.assertResult(timeFunction.invoke(LocalDateTime.of(2017, 6, 12, 11, 43)), LocalTime.of(11, 43, 0)); } @Test - public void invokeTimeUnitsParamsNull() { + void invokeTimeUnitsParamsNull() { FunctionTestUtil.assertResultError(timeFunction.invoke(null, null, null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(timeFunction.invoke(null, null, 1, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(timeFunction.invoke(null, 1, null, null), InvalidParametersEvent.class); @@ -127,7 +127,7 @@ public void invokeTimeUnitsParamsNull() { } @Test - public void invokeTimeUnitsParamsUnsupportedNumber() { + void invokeTimeUnitsParamsUnsupportedNumber() { FunctionTestUtil.assertResultError(timeFunction.invoke(Double.POSITIVE_INFINITY, 1, 1, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(timeFunction.invoke(Double.NEGATIVE_INFINITY, 1, 1, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(timeFunction.invoke(1, Double.POSITIVE_INFINITY, 1, null), InvalidParametersEvent.class); @@ -137,35 +137,35 @@ public void invokeTimeUnitsParamsUnsupportedNumber() { } @Test - public void invokeTimeUnitsParamsOutOfBounds() { + void invokeTimeUnitsParamsOutOfBounds() { FunctionTestUtil.assertResultError(timeFunction.invoke(40, 1, 1, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(timeFunction.invoke(1, 900, 1, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(timeFunction.invoke(1, 1, 900, null), InvalidParametersEvent.class); } @Test - public void invokeTimeUnitsParamsNoOffset() { + void invokeTimeUnitsParamsNoOffset() { FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, 15, null), LocalTime.of(10, 43, 15)); } @Test - public void invokeTimeUnitsParamsNoOffsetWithNanoseconds() { + void invokeTimeUnitsParamsNoOffsetWithNanoseconds() { FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, BigDecimal.valueOf(15.154), null), LocalTime.of(10, 43, 15, 154000000)); } @Test - public void invokeTimeUnitsParamsWithOffset() { + void invokeTimeUnitsParamsWithOffset() { FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, 15, Duration.ofHours(1)), OffsetTime.of(10, 43, 15, 0, ZoneOffset.ofHours(1))); FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, 15, Duration.ofHours(-1)), OffsetTime.of(10, 43, 15, 0, ZoneOffset.ofHours(-1))); } @Test - public void invokeTimeUnitsParamsWithNoOffset() { + void invokeTimeUnitsParamsWithNoOffset() { FunctionTestUtil.assertResult(timeFunction.invoke(10, 43, 15), LocalTime.of(10, 43, 15)); } @Test - public void invokeTimeUnitsParamsWithOffsetWithNanoseconds() { + void invokeTimeUnitsParamsWithOffsetWithNanoseconds() { FunctionTestUtil.assertResult( timeFunction.invoke(10, 43, BigDecimal.valueOf(15.154), Duration.ofHours(1)), OffsetTime.of(10, 43, 15, 154000000, ZoneOffset.ofHours(1))); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TodayFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TodayFunctionTest.java index ff1624f3d38..161c4b98d60 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TodayFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/TodayFunctionTest.java @@ -20,21 +20,21 @@ import java.time.LocalDate; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.functions.extended.TodayFunction; -public class TodayFunctionTest { +class TodayFunctionTest { private TodayFunction todayFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { todayFunction = new TodayFunction(); } @Test - public void invoke() { + void invoke() { FunctionTestUtil.assertResult(todayFunction.invoke(), LocalDate.now()); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/UnionFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/UnionFunctionTest.java index e04edb6866b..cc99800a7a7 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/UnionFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/UnionFunctionTest.java @@ -21,85 +21,86 @@ import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class UnionFunctionTest { +class UnionFunctionTest { private UnionFunction unionFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { unionFunction = new UnionFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(unionFunction.invoke(null), InvalidParametersEvent.class); } @Test - public void invokeEmptyArray() { + void invokeEmptyArray() { FunctionTestUtil.assertResultList(unionFunction.invoke(new Object[]{}), Collections.emptyList()); } @Test - public void invokeSingleObject() { + void invokeSingleObject() { FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{10}), Collections.singletonList(10)); } @Test - public void invokeSingleObjectInAList() { + void invokeSingleObjectInAList() { FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{Collections.singletonList(10)}), Collections.singletonList(10)); } @Test - public void invokeSingleObjectInAnArray() { + void invokeSingleObjectInAnArray() { final int[] testArray = new int[]{10}; FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{testArray}), Collections.singletonList(testArray)); } @Test - public void invokeListIsNull() { + void invokeListIsNull() { FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{null}), Collections.singletonList(null)); } @Test - public void invokeListContainsNull() { + void invokeListContainsNull() { FunctionTestUtil.assertResult(unionFunction.invoke(new Object[]{Arrays.asList(null, 10, null)}), Arrays.asList(null, 10)); } @Test - public void invokeListsNoDuplicates() { + void invokeListsNoDuplicates() { final Object[] params = new Object[]{Arrays.asList(10, 8, 3), Arrays.asList(1, 15, 2)}; FunctionTestUtil.assertResultList(unionFunction.invoke(params), Arrays.asList(10, 8, 3, 1, 15, 2)); } @Test - public void invokeListsSomeDuplicates() { + void invokeListsSomeDuplicates() { final Object[] params = new Object[]{Arrays.asList(10, 8, 3), Arrays.asList(1, 10, 2), Arrays.asList(10, 3, 2, 5)}; FunctionTestUtil.assertResultList(unionFunction.invoke(params), Arrays.asList(10, 8, 3, 1, 2, 5)); } @Test - public void invokeListsAllDuplicates() { + void invokeListsAllDuplicates() { final Object[] params = new Object[]{Arrays.asList(10, 8, 3), Arrays.asList(10, 8, 3), Arrays.asList(3, 10, 8)}; FunctionTestUtil.assertResultList(unionFunction.invoke(params), Arrays.asList(10, 8, 3)); } @Test - public void invokeListAndSingleObject() { + void invokeListAndSingleObject() { FunctionTestUtil.assertResultList(unionFunction.invoke(new Object[]{Arrays.asList(10, 4, 5), 1}), Arrays.asList(10, 4, 5, 1)); } @Test - public void invokeListAndSingleObjectWithDuplicates() { + void invokeListAndSingleObjectWithDuplicates() { FunctionTestUtil.assertResultList(unionFunction.invoke(new Object[]{5, Arrays.asList(10, 4, 5), 10}), Arrays.asList(5, 10, 4)); } @Test - public void invokeMixedTypes() { + void invokeMixedTypes() { FunctionTestUtil.assertResultList( unionFunction.invoke(new Object[]{"test", Arrays.asList(10, "test", 5), BigDecimal.TEN}), Arrays.asList("test", 10, 5, BigDecimal.TEN)); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/WeekOfYearTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/WeekOfYearTest.java index 97489485097..d6ca2314cfe 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/WeekOfYearTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/WeekOfYearTest.java @@ -24,23 +24,23 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import static java.math.BigDecimal.valueOf; -public class WeekOfYearTest { +class WeekOfYearTest { private WeekOfYearFunction fut; - @Before - public void setUp() { + @BeforeEach + void setUp() { fut = WeekOfYearFunction.INSTANCE; } @Test - public void testWeekOfYearFunctionTemporalAccessor() { + void weekOfYearFunctionTemporalAccessor() { FunctionTestUtil.assertResult(fut.invoke(LocalDate.of(2019, 9, 17)), valueOf(38)); FunctionTestUtil.assertResult(fut.invoke(LocalDateTime.of(2019, 9, 17, 0, 0, 0)), valueOf(38)); FunctionTestUtil.assertResult(fut.invoke(OffsetDateTime.of(2019, 9, 17, 0, 0, 0, 0, ZoneOffset.UTC)), valueOf(38)); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunctionTest.java index abfd318aeff..57c36ee134f 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/YearsAndMonthsFunctionTest.java @@ -25,41 +25,41 @@ import java.time.YearMonth; import java.time.temporal.Temporal; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -public class YearsAndMonthsFunctionTest { +class YearsAndMonthsFunctionTest { private YearsAndMonthsFunction yamFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { yamFunction = new YearsAndMonthsFunction(); } @Test - public void invokeNull() { + void invokeNull() { FunctionTestUtil.assertResultError(yamFunction.invoke((Temporal) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(yamFunction.invoke(null, LocalDate.now()), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(yamFunction.invoke(LocalDate.now(), null), InvalidParametersEvent.class); } @Test - public void invokeUnsupportedTemporal() { + void invokeUnsupportedTemporal() { FunctionTestUtil.assertResultError(yamFunction.invoke(Instant.EPOCH, Instant.EPOCH), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(yamFunction.invoke(LocalDate.of(2017, 1, 1), Instant.EPOCH), InvalidParametersEvent.class); } @Test - public void invokeYear() { + void invokeYear() { FunctionTestUtil.assertResult(yamFunction.invoke(Year.of(2017), Year.of(2020)), ComparablePeriod.of(3, 0, 0)); FunctionTestUtil.assertResult(yamFunction.invoke(Year.of(2017), Year.of(2014)), ComparablePeriod.of(-3, 0, 0)); } @Test - public void invokeYearMonth() { + void invokeYearMonth() { FunctionTestUtil.assertResult( yamFunction.invoke(YearMonth.of(2017, 6), Year.of(2020)), ComparablePeriod.of(2, 7, 0)); @@ -69,14 +69,14 @@ public void invokeYearMonth() { } @Test - public void invokeYearLocalDate() { + void invokeYearLocalDate() { FunctionTestUtil.assertResult( yamFunction.invoke(LocalDate.of(2017, 6, 12), Year.of(2020)), ComparablePeriod.of(2, 6, 0)); } @Test - public void invokeYearMonthLocalDate() { + void invokeYearMonthLocalDate() { FunctionTestUtil.assertResult( yamFunction.invoke( LocalDate.of(2017, 6, 12), @@ -85,7 +85,7 @@ public void invokeYearMonthLocalDate() { } @Test - public void testYearsAndMonthsFunction_invokeLocalDateTime() { + void yearsAndMonthsFunctionInvokeLocalDateTime() { FunctionTestUtil.assertResult( yamFunction.invoke( LocalDateTime.of(2017, 6, 12, 12, 43), @@ -94,7 +94,7 @@ public void testYearsAndMonthsFunction_invokeLocalDateTime() { } @Test - public void invokeLocalDateLocalDate() { + void invokeLocalDateLocalDate() { FunctionTestUtil.assertResult( yamFunction.invoke( LocalDate.of(2017, 6, 12), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunctionTest.java index f3b6c0df873..3fea8c48bdb 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/extended/RangeFunctionTest.java @@ -18,9 +18,26 @@ */ package org.kie.dmn.feel.runtime.functions.extended; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.lang.ast.*; +import java.math.BigDecimal; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Period; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.lang.ast.AtLiteralNode; +import org.kie.dmn.feel.lang.ast.BaseNode; +import org.kie.dmn.feel.lang.ast.BooleanNode; +import org.kie.dmn.feel.lang.ast.FunctionInvocationNode; +import org.kie.dmn.feel.lang.ast.NullNode; +import org.kie.dmn.feel.lang.ast.NumberNode; +import org.kie.dmn.feel.lang.ast.StringNode; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; @@ -28,32 +45,25 @@ import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -import java.math.BigDecimal; -import java.time.*; -import java.time.format.DateTimeFormatter; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import static org.assertj.core.api.Assertions.assertThat; -public class RangeFunctionTest { +class RangeFunctionTest { private RangeFunction rangeFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { rangeFunction = new RangeFunction(); } @Test - public void invokeNull() { + void invokeNull() { List from = Arrays.asList(null, " ", "", "[..]"); from.forEach(it -> FunctionTestUtil.assertResultError(rangeFunction.invoke(it), InvalidParametersEvent.class, it)); } @Test - public void invokeDifferentTypes() { + void invokeDifferentTypes() { List from = Arrays.asList("[1..\"cheese\"]", "[1..date(\"1978-09-12\")]", "[1..date(\"1978-09-12\")]", @@ -62,13 +72,13 @@ public void invokeDifferentTypes() { } @Test - public void invokeInvalidTypes() { + void invokeInvalidTypes() { String from = "[if(false)..if(true)]"; FunctionTestUtil.assertResultError(rangeFunction.invoke(from), InvalidParametersEvent.class, from); } @Test - public void invoke_LeftNull() { + void invoke_LeftNull() { String from = "(..2)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), new RangeImpl(Range.RangeBoundary.OPEN, null, BigDecimal.valueOf(2), Range.RangeBoundary.OPEN), @@ -99,7 +109,7 @@ public void invoke_LeftNull() { } @Test - public void invoke_RightNull() { + void invoke_RightNull() { String from = "(1..)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, null, Range.RangeBoundary.OPEN), @@ -130,7 +140,7 @@ public void invoke_RightNull() { } @Test - public void invoke_OpenOpenBoundaries() { + void invoke_OpenOpenBoundaries() { String from = "(1..2)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.OPEN), @@ -161,7 +171,7 @@ public void invoke_OpenOpenBoundaries() { } @Test - public void invoke_OpenClosedBoundaries() { + void invoke_OpenClosedBoundaries() { String from = "(1..2]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.CLOSED), @@ -181,7 +191,7 @@ public void invoke_OpenClosedBoundaries() { } @Test - public void invoke_ClosedOpenBoundaries() { + void invoke_ClosedOpenBoundaries() { String from = "[1..2)"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.OPEN), @@ -201,7 +211,7 @@ public void invoke_ClosedOpenBoundaries() { } @Test - public void invoke_ClosedClosedBoundaries() { + void invoke_ClosedClosedBoundaries() { String from = "[1..2)"; FunctionTestUtil.assertResult(rangeFunction.invoke("[1..2]"), new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.CLOSED), @@ -225,7 +235,7 @@ public void invoke_ClosedClosedBoundaries() { } @Test - public void invoke_WithOneFunctionNode() { + void invoke_WithOneFunctionNode() { String from = "[number(\"1\", \",\", \".\")\"..2]"; FunctionTestUtil.assertResult(rangeFunction.invoke(from), new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.valueOf(2), Range.RangeBoundary.CLOSED), @@ -237,7 +247,7 @@ public void invoke_WithOneFunctionNode() { } @Test - public void nodeIsAllowed_True() { + void nodeIsAllowed_True() { BaseNode node = rangeFunction.getNullNode(); assertThat(rangeFunction.nodeIsAllowed(node)).withFailMessage(node.getText()).isTrue(); node = getNumberNode(); @@ -251,7 +261,7 @@ public void nodeIsAllowed_True() { } @Test - public void nodeIsAllowed_False() { + void nodeIsAllowed_False() { BaseNode node = rangeFunction.parse("if(true)"); assertThat(rangeFunction.nodeIsAllowed(node)).withFailMessage(node.getText()).isFalse(); node = getBooleanNode(); @@ -259,7 +269,7 @@ public void nodeIsAllowed_False() { } @Test - public void nodeValueIsAllowed_True() { + void nodeValueIsAllowed_True() { Object value = null; assertThat(rangeFunction.nodeValueIsAllowed(value)) .withFailMessage(String.format("%s", value)).isTrue(); @@ -284,7 +294,7 @@ public void nodeValueIsAllowed_True() { } @Test - public void nodeValueIsAllowed_False() { + void nodeValueIsAllowed_False() { Object value = Boolean.TRUE; assertThat(rangeFunction.nodeValueIsAllowed(value)) .withFailMessage(String.format("%s", value)).isFalse(); @@ -297,7 +307,7 @@ public void nodeValueIsAllowed_False() { } @Test - public void nodesReturnsSameType_True() { + void nodesReturnsSameType_True() { assertThat(rangeFunction.nodesReturnsSameType(null, null)) .withFailMessage("null - null") .isTrue(); @@ -313,14 +323,14 @@ public void nodesReturnsSameType_True() { } @Test - public void nodesReturnsSameType_False() { + void nodesReturnsSameType_False() { assertThat(rangeFunction.nodesReturnsSameType("1", 1)) .withFailMessage("\"1\" - 1") .isFalse(); } @Test - public void evaluateWithValidFunctionInvocationNode() { + void evaluateWithValidFunctionInvocationNode() { Object[][] data = validFunctionInvocationNodeData(); Arrays.stream(data).forEach(objects -> { String expression = String.format("[%1$s..%1$s]", objects[0]); @@ -332,7 +342,7 @@ public void evaluateWithValidFunctionInvocationNode() { } @Test - public void evaluateWithInvalidFunctionInvocationNode() { + void evaluateWithInvalidFunctionInvocationNode() { Object[][] data = invalidFunctionInvocationNodeData(); Arrays.stream(data).forEach(objects -> { String expression = String.format("[%1$s..%1$s]", objects[0]); @@ -344,7 +354,7 @@ public void evaluateWithInvalidFunctionInvocationNode() { } @Test - public void parse_NotEmptyString() { + void parse_NotEmptyString() { String input = ""; assertThat(rangeFunction.parse(input)) .withFailMessage(String.format("Check `%s`", input)) @@ -366,13 +376,14 @@ public void parse_NotEmptyString() { input = "duration(\"P2DT20H14M\")"; assertThat(rangeFunction.parse(input)).withFailMessage(String.format("Check `%s`", input)).isInstanceOf(FunctionInvocationNode.class); } + @Test - public void parse_emptyString() { + void parse_emptyString() { assertThat(rangeFunction.parse("")).withFailMessage("Check ``").isInstanceOf(NullNode.class); } @Test - public void getNullNode() { + void getNullNode() { assertThat(rangeFunction.getNullNode()).isInstanceOf(NullNode.class); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/AfterFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/AfterFunctionTest.java index 9944383934b..d147526bfb0 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/AfterFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/AfterFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import java.math.BigDecimal; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -import java.math.BigDecimal; - -public class AfterFunctionTest { +class AfterFunctionTest { private AfterFunction afterFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { afterFunction = AfterFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(afterFunction.invoke((Comparable) null, "b"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(afterFunction.invoke("a", (Comparable) null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( afterFunction.invoke("a", BigDecimal.valueOf(2) ), InvalidParametersEvent.class ); } @Test - public void invokeParamSingles() { + void invokeParamSingles() { FunctionTestUtil.assertResult( afterFunction.invoke( "a", "b" ), Boolean.FALSE ); FunctionTestUtil.assertResult( afterFunction.invoke( "a", "a" ), Boolean.FALSE ); FunctionTestUtil.assertResult( afterFunction.invoke( "b", "a" ), Boolean.TRUE ); @@ -58,7 +58,7 @@ public void invokeParamSingles() { } @Test - public void invokeParamSingleAndRange() { + void invokeParamSingleAndRange() { FunctionTestUtil.assertResult( afterFunction.invoke( "a", new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED )), Boolean.FALSE ); @@ -74,7 +74,7 @@ public void invokeParamSingleAndRange() { } @Test - public void invokeParamRangeAndSingle() { + void invokeParamRangeAndSingle() { FunctionTestUtil.assertResult( afterFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), "f" ), @@ -94,7 +94,7 @@ public void invokeParamRangeAndSingle() { } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( afterFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/BeforeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/BeforeFunctionTest.java index 388889028a5..26db60252c0 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/BeforeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/BeforeFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import java.math.BigDecimal; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -import java.math.BigDecimal; - -public class BeforeFunctionTest { +class BeforeFunctionTest { private BeforeFunction beforeFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { beforeFunction = BeforeFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(beforeFunction.invoke((Comparable) null, "b"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(beforeFunction.invoke("a", (Comparable) null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( beforeFunction.invoke("a", BigDecimal.valueOf(2) ), InvalidParametersEvent.class ); } @Test - public void invokeParamSingles() { + void invokeParamSingles() { FunctionTestUtil.assertResult( beforeFunction.invoke( "a", "b" ), Boolean.TRUE ); FunctionTestUtil.assertResult( beforeFunction.invoke( "a", "a" ), Boolean.FALSE ); FunctionTestUtil.assertResult( beforeFunction.invoke( "b", "a" ), Boolean.FALSE ); @@ -58,7 +58,7 @@ public void invokeParamSingles() { } @Test - public void invokeParamSingleAndRange() { + void invokeParamSingleAndRange() { FunctionTestUtil.assertResult( beforeFunction.invoke( "a", new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED )), Boolean.FALSE ); @@ -74,7 +74,7 @@ public void invokeParamSingleAndRange() { } @Test - public void invokeParamRangeAndSingle() { + void invokeParamRangeAndSingle() { FunctionTestUtil.assertResult( beforeFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), "f" ), @@ -94,7 +94,7 @@ public void invokeParamRangeAndSingle() { } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( beforeFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/CoincidesFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/CoincidesFunctionTest.java index 2bdb9c29276..ce07c97068d 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/CoincidesFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/CoincidesFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import java.math.BigDecimal; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -import java.math.BigDecimal; - -public class CoincidesFunctionTest { +class CoincidesFunctionTest { private CoincidesFunction coincidesFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { coincidesFunction = CoincidesFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(coincidesFunction.invoke(null, "b"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(coincidesFunction.invoke("a", null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( coincidesFunction.invoke("a", BigDecimal.valueOf(2) ), InvalidParametersEvent.class ); } @Test - public void invokeParamSingles() { + void invokeParamSingles() { FunctionTestUtil.assertResult( coincidesFunction.invoke( "a", "b" ), Boolean.FALSE ); FunctionTestUtil.assertResult( coincidesFunction.invoke( "a", "a" ), Boolean.TRUE ); FunctionTestUtil.assertResult( coincidesFunction.invoke( "b", "a" ), Boolean.FALSE ); @@ -58,7 +58,7 @@ public void invokeParamSingles() { } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( coincidesFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/DuringFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/DuringFunctionTest.java index be65116e078..596b7c29c2e 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/DuringFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/DuringFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class DuringFunctionTest { +class DuringFunctionTest { private DuringFunction duringFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { duringFunction = DuringFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(duringFunction.invoke((Comparable) null, new RangeImpl()), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(duringFunction.invoke("a", null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( duringFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, 1, 2, Range.RangeBoundary.CLOSED ) ), InvalidParametersEvent.class ); } @Test - public void invokeParamSingleAndRange() { + void invokeParamSingleAndRange() { FunctionTestUtil.assertResult( duringFunction.invoke( "c", new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED )), Boolean.TRUE ); @@ -64,7 +64,7 @@ public void invokeParamSingleAndRange() { } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( duringFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FEELTemporalFunctionsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FEELTemporalFunctionsTest.java index e63fd109a8f..0794d4a1e3c 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FEELTemporalFunctionsTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FEELTemporalFunctionsTest.java @@ -20,13 +20,20 @@ import java.util.Collection; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.runtime.BaseFEELTest; public class FEELTemporalFunctionsTest extends BaseFEELTest { - @Parameterized.Parameters(name = "{index}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity, FEEL_TARGET testFEELTarget, Boolean useExtendedProfile) { + expression( expression, result, severity, testFEELTarget, useExtendedProfile); + } + + private static Collection data() { final Object[][] cases = new Object[][] { { "before( 1, 10 )", true, null }, { "before( 10, 1 )", false, null }, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FinishedByFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FinishedByFunctionTest.java index 13495ad48b1..e8b8baab427 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FinishedByFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FinishedByFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class FinishedByFunctionTest { +class FinishedByFunctionTest { private FinishedByFunction finishedByFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { finishedByFunction = FinishedByFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(finishedByFunction.invoke(null, "b"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(finishedByFunction.invoke(new RangeImpl(), (Comparable) null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( finishedByFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, 1, 2, Range.RangeBoundary.CLOSED ) ), InvalidParametersEvent.class ); } @Test - public void invokeParamRangeAndSingle() { + void invokeParamRangeAndSingle() { FunctionTestUtil.assertResult( finishedByFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), "f" ), @@ -68,7 +68,7 @@ public void invokeParamRangeAndSingle() { } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( finishedByFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FinishesFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FinishesFunctionTest.java index 45a980cd46b..29e1cc1b3f0 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FinishesFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FinishesFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class FinishesFunctionTest { +class FinishesFunctionTest { private FinishesFunction finishesFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { finishesFunction = FinishesFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(finishesFunction.invoke((Comparable) null, new RangeImpl()), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(finishesFunction.invoke("a", null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( finishesFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, 1, 2, Range.RangeBoundary.CLOSED ) ), InvalidParametersEvent.class ); } @Test - public void invokeParamSingleAndRange() { + void invokeParamSingleAndRange() { FunctionTestUtil.assertResult( finishesFunction.invoke( "f", new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED )), Boolean.TRUE ); @@ -64,7 +64,7 @@ public void invokeParamSingleAndRange() { } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( finishesFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FormulasTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FormulasTest.java index 624bf252e27..15a186b3f2b 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FormulasTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/FormulasTest.java @@ -18,12 +18,12 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; // ScratchPad to support discussion on https://issues.omg.org/browse/DMN14-125 -public class FormulasTest { +class FormulasTest { private static class R { public int start; @@ -81,7 +81,7 @@ static boolean overlapsBefore(R range1, R range2) { } @Test - public void testOverlapsBeforeFormula() { + void overlapsBeforeFormula() { assertThat(overlapsBefore(new R(true, 1, 5, true), new R(true, 3, 8, true))).isEqualTo(true); assertThat(overlapsBefore(new R(true, 1, 5, true), new R(true, 6, 8, true))).isEqualTo(false); assertThat(overlapsBefore(new R(true, 1, 5, true), new R(true, 5, 8, true))).isEqualTo(true); @@ -115,7 +115,7 @@ static boolean overlaps(R range1, R range2) { } @Test - public void testOverlapsFormula() { + void overlapsFormula() { assertThat( overlaps( new R(true, 1, 5, true ), new R( true, 3, 8, true ) ) ).isEqualTo( true ); assertThat( overlaps( new R(true, 3, 8, true ), new R( true, 1, 5, true ) ) ).isEqualTo( true ); assertThat( overlaps( new R(true, 1, 8, true ), new R( true, 3, 5, true ) ) ).isEqualTo( true ); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/IncludesFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/IncludesFunctionTest.java index b238e0d816d..5381fcf8248 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/IncludesFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/IncludesFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class IncludesFunctionTest { +class IncludesFunctionTest { private IncludesFunction includesFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { includesFunction = IncludesFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(includesFunction.invoke(null, "b"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(includesFunction.invoke(new RangeImpl(), (Comparable) null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( includesFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, 1, 2, Range.RangeBoundary.CLOSED ) ), InvalidParametersEvent.class ); } @Test - public void invokeParamRangeAndSingle() { + void invokeParamRangeAndSingle() { FunctionTestUtil.assertResult( includesFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), "c" ), @@ -68,7 +68,7 @@ public void invokeParamRangeAndSingle() { } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( includesFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/MeetsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/MeetsFunctionTest.java index 8e4b894f1e1..e0a49c4da82 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/MeetsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/MeetsFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class MeetsFunctionTest { +class MeetsFunctionTest { private MeetsFunction meetsFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { meetsFunction = MeetsFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(meetsFunction.invoke(null, new RangeImpl()), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(meetsFunction.invoke(new RangeImpl(), null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( meetsFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, 1, 2, Range.RangeBoundary.CLOSED ) ), InvalidParametersEvent.class ); } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( meetsFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/MetByFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/MetByFunctionTest.java index ae09d233914..f3b9ff4acea 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/MetByFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/MetByFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class MetByFunctionTest { +class MetByFunctionTest { private MetByFunction metByFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { metByFunction = MetByFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(metByFunction.invoke(null, new RangeImpl()), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(metByFunction.invoke(new RangeImpl(), null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( metByFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, 1, 2, Range.RangeBoundary.CLOSED ) ), InvalidParametersEvent.class ); } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( metByFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsFunctionTest.java index d9eca7f6345..699944dd85e 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/OverlapsFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class OverlapsFunctionTest { +class OverlapsFunctionTest { private OverlapsFunction overlapsFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { overlapsFunction = OverlapsFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(overlapsFunction.invoke(null, new RangeImpl()), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(overlapsFunction.invoke(new RangeImpl(), null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( overlapsFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, 1, 2, Range.RangeBoundary.CLOSED ) ), InvalidParametersEvent.class ); } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( overlapsFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/StartedByFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/StartedByFunctionTest.java index 9286ea0b0c9..32fd7c12d4c 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/StartedByFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/StartedByFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class StartedByFunctionTest { +class StartedByFunctionTest { private StartedByFunction startedByFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { startedByFunction = StartedByFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(startedByFunction.invoke(null, "b"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(startedByFunction.invoke(new RangeImpl(), (Comparable) null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( startedByFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, 1, 2, Range.RangeBoundary.CLOSED ) ), InvalidParametersEvent.class ); } @Test - public void invokeParamRangeAndSingle() { + void invokeParamRangeAndSingle() { FunctionTestUtil.assertResult( startedByFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), "f" ), @@ -68,7 +68,7 @@ public void invokeParamRangeAndSingle() { } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( startedByFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/StartsFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/StartsFunctionTest.java index 984558963e9..eb42fd4ce47 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/StartsFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/interval/StartsFunctionTest.java @@ -18,37 +18,37 @@ */ package org.kie.dmn.feel.runtime.functions.interval; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; import org.kie.dmn.feel.runtime.impl.RangeImpl; -public class StartsFunctionTest { +class StartsFunctionTest { private StartsFunction startsFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { startsFunction = StartsFunction.INSTANCE; } @Test - public void invokeParamIsNull() { + void invokeParamIsNull() { FunctionTestUtil.assertResultError(startsFunction.invoke((Comparable) null, new RangeImpl()), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(startsFunction.invoke("a", null), InvalidParametersEvent.class); } @Test - public void invokeParamsCantBeCompared() { + void invokeParamsCantBeCompared() { FunctionTestUtil.assertResultError( startsFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, 1, 2, Range.RangeBoundary.CLOSED ) ), InvalidParametersEvent.class ); } @Test - public void invokeParamSingleAndRange() { + void invokeParamSingleAndRange() { FunctionTestUtil.assertResult( startsFunction.invoke( "a", new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED )), Boolean.TRUE ); @@ -64,7 +64,7 @@ public void invokeParamSingleAndRange() { } @Test - public void invokeParamRangeAndRange() { + void invokeParamRangeAndRange() { FunctionTestUtil.assertResult( startsFunction.invoke( new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ), new RangeImpl( Range.RangeBoundary.CLOSED, "a", "f", Range.RangeBoundary.CLOSED ) ), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/CountFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/CountFunctionTest.java index f3e930b57c3..344ff641169 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/CountFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/CountFunctionTest.java @@ -18,51 +18,51 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.List; -public class CountFunctionTest { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; + +class CountFunctionTest { private NNCountFunction countFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { countFunction = new NNCountFunction(); } @Test - public void invokeParamListNull() { + void invokeParamListNull() { FunctionTestUtil.assertResult(countFunction.invoke((List) null), BigDecimal.ZERO); } @Test - public void invokeParamListEmpty() { + void invokeParamListEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(Collections.emptyList()), BigDecimal.ZERO); } @Test - public void invokeParamListNonEmpty() { + void invokeParamListNonEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(Arrays.asList(1, 2, "test")), BigDecimal.valueOf(3)); } @Test - public void invokeParamArrayNull() { + void invokeParamArrayNull() { FunctionTestUtil.assertResult(countFunction.invoke((Object[]) null), BigDecimal.ZERO); } @Test - public void invokeParamArrayEmpty() { + void invokeParamArrayEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(new Object[]{}), BigDecimal.ZERO); } @Test - public void invokeParamArrayNonEmpty() { + void invokeParamArrayNonEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(new Object[]{1, 2, "test"}), BigDecimal.valueOf(3)); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MaxFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MaxFunctionTest.java index 5465582c733..499b7b5e339 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MaxFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MaxFunctionTest.java @@ -18,42 +18,42 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.List; -public class MaxFunctionTest { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; +import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; + +class MaxFunctionTest { private NNMaxFunction maxFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { maxFunction = new NNMaxFunction(); } @Test - public void invokeNullList() { + void invokeNullList() { FunctionTestUtil.assertResult(maxFunction.invoke((List) null), null); } @Test - public void invokeEmptyList() { + void invokeEmptyList() { FunctionTestUtil.assertResult(maxFunction.invoke(Collections.emptyList()), null); } @Test - public void invokeListWithHeterogenousTypes() { + void invokeListWithHeterogenousTypes() { FunctionTestUtil.assertResultError(maxFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), InvalidParametersEvent.class); } @Test - public void invokeListOfIntegers() { + void invokeListOfIntegers() { FunctionTestUtil.assertResult(maxFunction.invoke(Collections.singletonList(1)), 1); FunctionTestUtil.assertResult(maxFunction.invoke(Arrays.asList(1, 2, 3)), 3); FunctionTestUtil.assertResult(maxFunction.invoke(Arrays.asList(1, 3, 2)), 3); @@ -61,7 +61,7 @@ public void invokeListOfIntegers() { } @Test - public void invokeListOfStrings() { + void invokeListOfStrings() { FunctionTestUtil.assertResult(maxFunction.invoke(Collections.singletonList("a")), "a"); FunctionTestUtil.assertResult(maxFunction.invoke(Arrays.asList("a", "b", "c")), "c"); FunctionTestUtil.assertResult(maxFunction.invoke(Arrays.asList("a", "c", "b")), "c"); @@ -69,22 +69,22 @@ public void invokeListOfStrings() { } @Test - public void invokeNullArray() { + void invokeNullArray() { FunctionTestUtil.assertResult(maxFunction.invoke((Object[]) null), null); } @Test - public void invokeEmptyArray() { + void invokeEmptyArray() { FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{}), null); } @Test - public void invokeArrayWithHeterogenousTypes() { + void invokeArrayWithHeterogenousTypes() { FunctionTestUtil.assertResultError(maxFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), InvalidParametersEvent.class); } @Test - public void invokeArrayOfIntegers() { + void invokeArrayOfIntegers() { FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{1}), 1); FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{null, 1, 2, 3}), 3); FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{1, 3, null, 2}), 3); @@ -92,7 +92,7 @@ public void invokeArrayOfIntegers() { } @Test - public void invokeArrayOfStrings() { + void invokeArrayOfStrings() { FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{"a"}), "a"); FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{null, "a", "b", "c"}), "c"); FunctionTestUtil.assertResult(maxFunction.invoke(new Object[]{"a", null, "c", "b"}), "c"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MeanFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MeanFunctionTest.java index fa077a37f80..6170103b523 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MeanFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MeanFunctionTest.java @@ -18,125 +18,125 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.List; -public class MeanFunctionTest { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; +import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; + +class MeanFunctionTest { private NNMeanFunction meanFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { meanFunction = new NNMeanFunction(); } @Test - public void invokeNumberNull() { + void invokeNumberNull() { FunctionTestUtil.assertResult(meanFunction.invoke((Number) null), null); } @Test - public void invokeNumberBigDecimal() { + void invokeNumberBigDecimal() { FunctionTestUtil.assertResult(meanFunction.invoke(BigDecimal.TEN), BigDecimal.TEN); } @Test - public void invokeNumberInteger() { + void invokeNumberInteger() { FunctionTestUtil.assertResult(meanFunction.invoke(10), BigDecimal.TEN); } @Test - public void invokeNumberDoubleWithoutDecimalPart() { + void invokeNumberDoubleWithoutDecimalPart() { FunctionTestUtil.assertResult(meanFunction.invoke(10d), BigDecimal.valueOf(10)); } @Test - public void invokeNumberDoubleWithDecimalPart() { + void invokeNumberDoubleWithDecimalPart() { FunctionTestUtil.assertResult(meanFunction.invoke(10.1d), BigDecimal.valueOf(10.1)); } @Test - public void invokeNumberFloat() { + void invokeNumberFloat() { FunctionTestUtil.assertResult(meanFunction.invoke(10.1f), BigDecimal.valueOf(10.1)); } @Test - public void invokeUnconvertableNumber() { + void invokeUnconvertableNumber() { FunctionTestUtil.assertResultError(meanFunction.invoke(Double.POSITIVE_INFINITY), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(meanFunction.invoke(Double.NEGATIVE_INFINITY), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(meanFunction.invoke(Double.NaN), InvalidParametersEvent.class); } @Test - public void invokeListNull() { + void invokeListNull() { FunctionTestUtil.assertResult(meanFunction.invoke((List) null), null); } @Test - public void invokeListEmpty() { + void invokeListEmpty() { FunctionTestUtil.assertResult(meanFunction.invoke(Collections.emptyList()), null); } @Test - public void invokeListTypeHeterogenous() { + void invokeListTypeHeterogenous() { FunctionTestUtil.assertResultError(meanFunction.invoke(Arrays.asList(1, "test")), InvalidParametersEvent.class); } @Test - public void invokeListParamSupportedTypesWithNull() { + void invokeListParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(20, 30, null, (long) 40, null, BigDecimal.TEN)), BigDecimal.valueOf(25)); } @Test - public void invokeListWithIntegers() { + void invokeListWithIntegers() { FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10, 20, 30)), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10, 20, 30, -10, -20, -30)), BigDecimal.ZERO); FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(0, 0, 1)), new BigDecimal("0.3333333333333333333333333333333333")); } @Test - public void invokeListWithDoubles() { + void invokeListWithDoubles() { FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.0d, 20.0d, 30.0d)), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(meanFunction.invoke(Arrays.asList(10.2d, 20.2d, 30.2d)), BigDecimal.valueOf(20.2)); } @Test - public void invokeArrayNull() { + void invokeArrayNull() { FunctionTestUtil.assertResult(meanFunction.invoke((Object[]) null), null); } @Test - public void invokeArrayEmpty() { + void invokeArrayEmpty() { FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{}), null); } @Test - public void invokeArrayTypeHeterogenous() { + void invokeArrayTypeHeterogenous() { FunctionTestUtil.assertResultError(meanFunction.invoke(new Object[]{1, "test"}), InvalidParametersEvent.class); } @Test - public void invokeArrayWithIntegers() { + void invokeArrayWithIntegers() { FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{10, 20, 30}), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{10, 20, 30, -10, -20, -30}), BigDecimal.ZERO); FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{0, 0, 1}), new BigDecimal("0.3333333333333333333333333333333333")); } @Test - public void invokeArrayWithDoubles() { + void invokeArrayWithDoubles() { FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{10.0d, 20.0d, 30.0d}), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{10.2d, 20.2d, 30.2d}), BigDecimal.valueOf(20.2)); } @Test - public void invokeArrayParamSupportedTypesWithNull() { + void invokeArrayParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(meanFunction.invoke(new Object[]{20, 30, null, (long) 40, null, BigDecimal.TEN}), BigDecimal.valueOf(25)); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MedianFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MedianFunctionTest.java index 1a2e1519e07..f090ca467b0 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MedianFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MedianFunctionTest.java @@ -18,88 +18,88 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.List; -public class MedianFunctionTest { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; +import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; + +class MedianFunctionTest { private NNMedianFunction medianFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { medianFunction = NNMedianFunction.INSTANCE; } @Test - public void invokeListNull() { + void invokeListNull() { FunctionTestUtil.assertResult(medianFunction.invoke((List) null), null); } @Test - public void invokeListEmpty() { + void invokeListEmpty() { FunctionTestUtil.assertResult(medianFunction.invoke(Collections.emptyList()), null); } @Test - public void invokeListTypeHeterogenous() { + void invokeListTypeHeterogenous() { FunctionTestUtil.assertResultError(medianFunction.invoke(Arrays.asList(1, "test")), InvalidParametersEvent.class); } @Test - public void invokeListParamSupportedTypesWithNull() { + void invokeListParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(medianFunction.invoke(Arrays.asList(20, 30, null, (long) 40, null, BigDecimal.TEN)), BigDecimal.valueOf(25)); } @Test - public void invokeListWithIntegers() { + void invokeListWithIntegers() { FunctionTestUtil.assertResult(medianFunction.invoke(Arrays.asList(10, 20, 30)), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(medianFunction.invoke(Arrays.asList(10, 20, 30, -10, -20, -30)), BigDecimal.ZERO); FunctionTestUtil.assertResult(medianFunction.invoke(Arrays.asList(0, 0, 1)), BigDecimal.ZERO); } @Test - public void invokeListWithDoubles() { + void invokeListWithDoubles() { FunctionTestUtil.assertResult(medianFunction.invoke(Arrays.asList(10.0d, 20.0d, 30.0d)), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(medianFunction.invoke(Arrays.asList(10.2d, 20.2d, 30.2d)), BigDecimal.valueOf(20.2)); } @Test - public void invokeArrayNull() { + void invokeArrayNull() { FunctionTestUtil.assertResult(medianFunction.invoke((Object[]) null), null); } @Test - public void invokeArrayEmpty() { + void invokeArrayEmpty() { FunctionTestUtil.assertResult(medianFunction.invoke(new Object[]{}), null); } @Test - public void invokeArrayTypeHeterogenous() { + void invokeArrayTypeHeterogenous() { FunctionTestUtil.assertResultError(medianFunction.invoke(new Object[]{1, "test"}), InvalidParametersEvent.class); } @Test - public void invokeArrayWithIntegers() { + void invokeArrayWithIntegers() { FunctionTestUtil.assertResult(medianFunction.invoke(new Object[]{10, 20, 30}), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(medianFunction.invoke(new Object[]{10, 20, 30, -10, -20, -30}), BigDecimal.ZERO); FunctionTestUtil.assertResult(medianFunction.invoke(new Object[]{0, 0, 1}), BigDecimal.ZERO); } @Test - public void invokeArrayWithDoubles() { + void invokeArrayWithDoubles() { FunctionTestUtil.assertResult(medianFunction.invoke(new Object[]{10.0d, 20.0d, 30.0d}), BigDecimal.valueOf(20)); FunctionTestUtil.assertResult(medianFunction.invoke(new Object[]{10.2d, 20.2d, 30.2d}), BigDecimal.valueOf(20.2)); } @Test - public void invokeArrayParamSupportedTypesWithNull() { + void invokeArrayParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(medianFunction.invoke(new Object[]{20, 30, null, (long) 40, null, BigDecimal.TEN}), BigDecimal.valueOf(25)); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MinFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MinFunctionTest.java index 383a642d848..cace72fa8e9 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MinFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/MinFunctionTest.java @@ -18,42 +18,42 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.List; -public class MinFunctionTest { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; +import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; + +class MinFunctionTest { private NNMinFunction minFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { minFunction = new NNMinFunction(); } @Test - public void invokeNullList() { + void invokeNullList() { FunctionTestUtil.assertResult(minFunction.invoke((List) null), null); } @Test - public void invokeEmptyList() { + void invokeEmptyList() { FunctionTestUtil.assertResult(minFunction.invoke(Collections.emptyList()), null); } @Test - public void invokeListWithHeterogenousTypes() { + void invokeListWithHeterogenousTypes() { FunctionTestUtil.assertResultError(minFunction.invoke(Arrays.asList(1, "test", BigDecimal.valueOf(10.2))), InvalidParametersEvent.class); } @Test - public void invokeListOfIntegers() { + void invokeListOfIntegers() { FunctionTestUtil.assertResult(minFunction.invoke(Collections.singletonList(1)), 1); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList(null, 1, 2, 3)), 1); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList(2, null, 1, 3)), 1); @@ -61,7 +61,7 @@ public void invokeListOfIntegers() { } @Test - public void invokeListOfStrings() { + void invokeListOfStrings() { FunctionTestUtil.assertResult(minFunction.invoke(Collections.singletonList("a")), "a"); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList(null, "a", "b", "c")), "a"); FunctionTestUtil.assertResult(minFunction.invoke(Arrays.asList("b", "a", null, "c")), "a"); @@ -69,22 +69,22 @@ public void invokeListOfStrings() { } @Test - public void invokeNullArray() { + void invokeNullArray() { FunctionTestUtil.assertResult(minFunction.invoke((Object[]) null), null); } @Test - public void invokeEmptyArray() { + void invokeEmptyArray() { FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{}), null); } @Test - public void invokeArrayWithHeterogenousTypes() { + void invokeArrayWithHeterogenousTypes() { FunctionTestUtil.assertResultError(minFunction.invoke(new Object[]{1, "test", BigDecimal.valueOf(10.2)}), InvalidParametersEvent.class); } @Test - public void invokeArrayOfIntegers() { + void invokeArrayOfIntegers() { FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{1}), 1); FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{1, 2, 3}), 1); FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{2, 1, 3}), 1); @@ -92,7 +92,7 @@ public void invokeArrayOfIntegers() { } @Test - public void invokeArrayOfStrings() { + void invokeArrayOfStrings() { FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{"a"}), "a"); FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{"a", "b", "c"}), "a"); FunctionTestUtil.assertResult(minFunction.invoke(new Object[]{"b", "a", "c"}), "a"); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/ModeFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/ModeFunctionTest.java index b09c36617c2..277a17c8ae4 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/ModeFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/ModeFunctionTest.java @@ -18,42 +18,42 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.List; -public class ModeFunctionTest { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; +import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; + +class ModeFunctionTest { private NNModeFunction modeFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { modeFunction = NNModeFunction.INSTANCE; } @Test - public void invokeListNull() { + void invokeListNull() { FunctionTestUtil.assertResult(modeFunction.invoke((List) null), null); } @Test - public void invokeListEmpty() { + void invokeListEmpty() { FunctionTestUtil.assertResult(modeFunction.invoke(Collections.emptyList()), null); } @Test - public void invokeListTypeHeterogenous() { + void invokeListTypeHeterogenous() { FunctionTestUtil.assertResultError(modeFunction.invoke(Arrays.asList(1, "test")), InvalidParametersEvent.class); } @Test - public void invokeListParamSupportedTypesWithNull() { + void invokeListParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(modeFunction.invoke(Arrays.asList(20, 30, null, (long) 20, null, BigDecimal.TEN)), List.of(BigDecimal.valueOf(20))); FunctionTestUtil.assertResult(modeFunction.invoke(Arrays.asList(20, 30, null, (long) 20, 30, BigDecimal.TEN)), @@ -63,22 +63,22 @@ public void invokeListParamSupportedTypesWithNull() { } @Test - public void invokeArrayNull() { + void invokeArrayNull() { FunctionTestUtil.assertResult(modeFunction.invoke((Object[]) null), null); } @Test - public void invokeArrayEmpty() { + void invokeArrayEmpty() { FunctionTestUtil.assertResult(modeFunction.invoke(new Object[]{}), null); } @Test - public void invokeArrayTypeHeterogenous() { + void invokeArrayTypeHeterogenous() { FunctionTestUtil.assertResultError(modeFunction.invoke(new Object[]{1, "test"}), InvalidParametersEvent.class); } @Test - public void invokeArrayParamSupportedTypesWithNull() { + void invokeArrayParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(modeFunction.invoke(Arrays.asList(20, 30, null, (long) 20, null, BigDecimal.TEN)), List.of(BigDecimal.valueOf(20))); FunctionTestUtil.assertResult(modeFunction.invoke(Arrays.asList(20, 30, null, (long) 20, 30, BigDecimal.TEN)), diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunctionTest.java index 294bb9f4ec6..68919aee554 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAllFunctionTest.java @@ -18,100 +18,100 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - import java.util.Arrays; import java.util.Collections; import java.util.List; -public class NNAllFunctionTest { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; +import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; + +class NNAllFunctionTest { private NNAllFunction NNAllFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { NNAllFunction = new NNAllFunction(); } @Test - public void invokeBooleanParamNull() { + void invokeBooleanParamNull() { FunctionTestUtil.assertResult(NNAllFunction.invoke((Boolean) null), true); } @Test - public void invokeBooleanParamTrue() { + void invokeBooleanParamTrue() { FunctionTestUtil.assertResult(NNAllFunction.invoke(true), true); } @Test - public void invokeBooleanParamFalse() { + void invokeBooleanParamFalse() { FunctionTestUtil.assertResult(NNAllFunction.invoke(false), false); } @Test - public void invokeArrayParamNull() { + void invokeArrayParamNull() { FunctionTestUtil.assertResult(NNAllFunction.invoke((Object[]) null), true); } @Test - public void invokeArrayParamEmptyArray() { + void invokeArrayParamEmptyArray() { FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{}), true); } @Test - public void invokeArrayParamReturnTrue() { + void invokeArrayParamReturnTrue() { FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{Boolean.TRUE, Boolean.TRUE}), true); } @Test - public void invokeArrayParamReturnFalse() { + void invokeArrayParamReturnFalse() { FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{Boolean.TRUE, Boolean.FALSE}), false); FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{Boolean.TRUE, null, Boolean.FALSE}), false); } @Test - public void invokeArrayParamReturnNull() { + void invokeArrayParamReturnNull() { FunctionTestUtil.assertResult(NNAllFunction.invoke(new Object[]{Boolean.TRUE, null, Boolean.TRUE}), true); } @Test - public void invokeArrayParamTypeHeterogenousArray() { + void invokeArrayParamTypeHeterogenousArray() { FunctionTestUtil.assertResultError(NNAllFunction.invoke(new Object[]{Boolean.TRUE, 1}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(NNAllFunction.invoke(new Object[]{Boolean.FALSE, 1}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(NNAllFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), InvalidParametersEvent.class); } @Test - public void invokeListParamNull() { + void invokeListParamNull() { FunctionTestUtil.assertResult(NNAllFunction.invoke((List) null), true); } @Test - public void invokeListParamEmptyList() { + void invokeListParamEmptyList() { FunctionTestUtil.assertResult(NNAllFunction.invoke(Collections.emptyList()), true); } @Test - public void invokeListParamReturnTrue() { + void invokeListParamReturnTrue() { FunctionTestUtil.assertResult(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.TRUE)), true); } @Test - public void invokeListParamReturnFalse() { + void invokeListParamReturnFalse() { FunctionTestUtil.assertResult(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.FALSE)), false); FunctionTestUtil.assertResult(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, null, Boolean.FALSE)), false); } @Test - public void invokeListParamReturnNull() { + void invokeListParamReturnNull() { FunctionTestUtil.assertResult(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, null, Boolean.TRUE)), true); } @Test - public void invokeListParamTypeHeterogenousArray() { + void invokeListParamTypeHeterogenousArray() { FunctionTestUtil.assertResultError(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(NNAllFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(NNAllFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), InvalidParametersEvent.class); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunctionTest.java index 59f3d1aa95c..ef3453b7d6e 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/NNAnyFunctionTest.java @@ -21,47 +21,48 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; -public class NNAnyFunctionTest { +class NNAnyFunctionTest { private NNAnyFunction anyFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { anyFunction = new NNAnyFunction(); } @Test - public void invokeBooleanParamNull() { + void invokeBooleanParamNull() { FunctionTestUtil.assertResult(anyFunction.invoke((Boolean) null), false); } @Test - public void invokeBooleanParamTrue() { + void invokeBooleanParamTrue() { FunctionTestUtil.assertResult(anyFunction.invoke(true), true); } @Test - public void invokeBooleanParamFalse() { + void invokeBooleanParamFalse() { FunctionTestUtil.assertResult(anyFunction.invoke(false), false); } @Test - public void invokeArrayParamNull() { + void invokeArrayParamNull() { FunctionTestUtil.assertResult(anyFunction.invoke((Object[]) null), false); } @Test - public void invokeArrayParamEmptyArray() { + void invokeArrayParamEmptyArray() { FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{}), false); } @Test - public void invokeArrayParamReturnTrue() { + void invokeArrayParamReturnTrue() { FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{Boolean.TRUE, Boolean.TRUE}), true); FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{Boolean.TRUE, Boolean.FALSE}), true); FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{Boolean.TRUE, null}), true); @@ -69,34 +70,34 @@ public void invokeArrayParamReturnTrue() { } @Test - public void invokeArrayParamReturnFalse() { + void invokeArrayParamReturnFalse() { FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{Boolean.FALSE, Boolean.FALSE}), false); } @Test - public void invokeArrayParamReturnNull() { + void invokeArrayParamReturnNull() { FunctionTestUtil.assertResult(anyFunction.invoke(new Object[]{Boolean.FALSE, null, Boolean.FALSE}), false); } @Test - public void invokeArrayParamTypeHeterogenousArray() { + void invokeArrayParamTypeHeterogenousArray() { FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.FALSE, 1}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.TRUE, 1}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(anyFunction.invoke(new Object[]{Boolean.TRUE, null, 1}), InvalidParametersEvent.class); } @Test - public void invokeListParamNull() { + void invokeListParamNull() { FunctionTestUtil.assertResult(anyFunction.invoke((List) null), false); } @Test - public void invokeListParamEmptyList() { + void invokeListParamEmptyList() { FunctionTestUtil.assertResult(anyFunction.invoke(Collections.emptyList()), false); } @Test - public void invokeListParamReturnTrue() { + void invokeListParamReturnTrue() { FunctionTestUtil.assertResult(anyFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.TRUE)), true); FunctionTestUtil.assertResult(anyFunction.invoke(Arrays.asList(Boolean.TRUE, Boolean.FALSE)), true); FunctionTestUtil.assertResult(anyFunction.invoke(Arrays.asList(Boolean.TRUE, null)), true); @@ -104,17 +105,17 @@ public void invokeListParamReturnTrue() { } @Test - public void invokeListParamReturnFalse() { + void invokeListParamReturnFalse() { FunctionTestUtil.assertResult(anyFunction.invoke(Arrays.asList(Boolean.FALSE, Boolean.FALSE)), false); } @Test - public void invokeListParamReturnNull() { + void invokeListParamReturnNull() { FunctionTestUtil.assertResult(anyFunction.invoke(Arrays.asList(Boolean.FALSE, null, Boolean.FALSE)), false); } @Test - public void invokeListParamTypeHeterogenousArray() { + void invokeListParamTypeHeterogenousArray() { FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.FALSE, 1)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.TRUE, 1)), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(anyFunction.invoke(Arrays.asList(Boolean.TRUE, null, 1)), InvalidParametersEvent.class); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/StddevFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/StddevFunctionTest.java index 3685c065b7a..1e1066f4a28 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/StddevFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/StddevFunctionTest.java @@ -24,27 +24,27 @@ import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; -public class StddevFunctionTest { +class StddevFunctionTest { private NNStddevFunction stddevFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { stddevFunction = NNStddevFunction.INSTANCE; } @Test - public void invokeNumberNull() { + void invokeNumberNull() { FunctionTestUtil.assertResult(stddevFunction.invoke((Number) null), null); } @Test - public void invokeSingleNumber() { + void invokeSingleNumber() { FunctionTestUtil.assertResultError(stddevFunction.invoke(BigDecimal.TEN), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(stddevFunction.invoke(10), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(stddevFunction.invoke(10d), InvalidParametersEvent.class); @@ -53,74 +53,74 @@ public void invokeSingleNumber() { } @Test - public void invokeUnconvertableNumber() { + void invokeUnconvertableNumber() { FunctionTestUtil.assertResultError(stddevFunction.invoke(Double.POSITIVE_INFINITY), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(stddevFunction.invoke(Double.NEGATIVE_INFINITY), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(stddevFunction.invoke(Double.NaN), InvalidParametersEvent.class); } @Test - public void invokeListNull() { + void invokeListNull() { FunctionTestUtil.assertResult(stddevFunction.invoke((List) null), null); } @Test - public void invokeListEmpty() { + void invokeListEmpty() { FunctionTestUtil.assertResult(stddevFunction.invoke(Collections.emptyList()), null); } @Test - public void invokeListTypeHeterogenous() { + void invokeListTypeHeterogenous() { FunctionTestUtil.assertResultError(stddevFunction.invoke(Arrays.asList(1, "test")), InvalidParametersEvent.class); } @Test - public void invokeListParamSupportedTypesWithNull() { + void invokeListParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(stddevFunction.invoke(Arrays.asList(20, 30, null, (long) 40, null, BigDecimal.TEN)), new BigDecimal("12.90994448735805628393088466594133", MathContext.DECIMAL128)); } @Test - public void invokeListWithIntegers() { + void invokeListWithIntegers() { FunctionTestUtil.assertResult(stddevFunction.invoke(Arrays.asList(10, 20, 30, 40)), new BigDecimal("12.90994448735805628393088466594133", MathContext.DECIMAL128)); } @Test - public void invokeListWithDoubles() { + void invokeListWithDoubles() { FunctionTestUtil.assertResult(stddevFunction.invoke(Arrays.asList(10.0d, 20.0d, 30.0d, 40.0d)), new BigDecimal("12.90994448735805628393088466594133", MathContext.DECIMAL128)); } @Test - public void invokeArrayNull() { + void invokeArrayNull() { FunctionTestUtil.assertResult(stddevFunction.invoke((Object[]) null), null); } @Test - public void invokeArrayEmpty() { + void invokeArrayEmpty() { FunctionTestUtil.assertResult(stddevFunction.invoke(new Object[]{}), null); } @Test - public void invokeArrayTypeHeterogenous() { + void invokeArrayTypeHeterogenous() { FunctionTestUtil.assertResultError(stddevFunction.invoke(new Object[]{1, "test"}), InvalidParametersEvent.class); } @Test - public void invokeArrayWithIntegers() { + void invokeArrayWithIntegers() { FunctionTestUtil.assertResult(stddevFunction.invoke(new Object[]{10, 20, 30, 40}), new BigDecimal("12.90994448735805628393088466594133", MathContext.DECIMAL128)); } @Test - public void invokeArrayWithDoubles() { + void invokeArrayWithDoubles() { FunctionTestUtil.assertResult(stddevFunction.invoke(new Object[]{10.0d, 20.0d, 30.0d, 40.0d}), new BigDecimal("12.90994448735805628393088466594133", MathContext.DECIMAL128)); } @Test - public void invokeArrayParamSupportedTypesWithNull() { + void invokeArrayParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(stddevFunction.invoke(new Object[]{20, 30, null, (long) 40, null, BigDecimal.TEN}), new BigDecimal("12.90994448735805628393088466594133", MathContext.DECIMAL128)); } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/SumFunctionTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/SumFunctionTest.java index 19197b15e5d..4b08bd0200d 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/SumFunctionTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/twovaluelogic/SumFunctionTest.java @@ -18,36 +18,36 @@ */ package org.kie.dmn.feel.runtime.functions.twovaluelogic; -import org.junit.Before; -import org.junit.Test; -import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; -import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; - import java.math.BigDecimal; import java.util.Arrays; import java.util.List; -public class SumFunctionTest { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.dmn.feel.runtime.events.InvalidParametersEvent; +import org.kie.dmn.feel.runtime.functions.FunctionTestUtil; + +class SumFunctionTest { private NNSumFunction sumFunction; - @Before - public void setUp() { + @BeforeEach + void setUp() { sumFunction = new NNSumFunction(); } @Test - public void invokeNumberParamNull() { + void invokeNumberParamNull() { FunctionTestUtil.assertResult(sumFunction.invoke((Number) null), null); } @Test - public void invokeNumberParamUnsupportedNumber() { + void invokeNumberParamUnsupportedNumber() { FunctionTestUtil.assertResultError(sumFunction.invoke(Double.NaN), InvalidParametersEvent.class); } @Test - public void invokeNumberParamSupportedNumber() { + void invokeNumberParamSupportedNumber() { FunctionTestUtil.assertResult(sumFunction.invoke(BigDecimal.TEN), BigDecimal.TEN); FunctionTestUtil.assertResult(sumFunction.invoke(10), BigDecimal.TEN); FunctionTestUtil.assertResult(sumFunction.invoke(-10), BigDecimal.valueOf(-10)); @@ -55,52 +55,52 @@ public void invokeNumberParamSupportedNumber() { } @Test - public void invokeListParam() { + void invokeListParam() { FunctionTestUtil.assertResult(sumFunction.invoke((List) null), null); } @Test - public void invokeListParamContainsUnsupportedNumber() { + void invokeListParamContainsUnsupportedNumber() { FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, 2, Double.NaN)), InvalidParametersEvent.class); } @Test - public void invokeListParamContainsUnsupportedType() { + void invokeListParamContainsUnsupportedType() { FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, "test", 2)), InvalidParametersEvent.class); } @Test - public void invokeListParamSupportedTypes() { + void invokeListParamSupportedTypes() { FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, (long) 5, BigDecimal.TEN)), BigDecimal.valueOf(30.1)); } @Test - public void invokeListParamSupportedTypesWithNull() { + void invokeListParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, null, (long) 5, null, BigDecimal.TEN)), BigDecimal.valueOf(30.1)); } @Test - public void invokeArrayParam() { + void invokeArrayParam() { FunctionTestUtil.assertResult(sumFunction.invoke((Object[]) null), null); } @Test - public void invokeArrayParamContainsUnsupportedNumber() { + void invokeArrayParamContainsUnsupportedNumber() { FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, 2, Double.NaN}), InvalidParametersEvent.class); } @Test - public void invokeArrayParamContainsUnsupportedType() { + void invokeArrayParamContainsUnsupportedType() { FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, "test", 2}), InvalidParametersEvent.class); } @Test - public void invokeArrayParamSupportedTypes() { + void invokeArrayParamSupportedTypes() { FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, 12.1, (long) 5, BigDecimal.TEN}), BigDecimal.valueOf(30.1)); } @Test - public void invokeArrayParamSupportedTypesWithNull() { + void invokeArrayParamSupportedTypesWithNull() { FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, null, 12.1, (long) 5, null, BigDecimal.TEN, null}), BigDecimal.valueOf(30.1)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/impl/RangeImplTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/impl/RangeImplTest.java index 3e4e252ecf9..6201fe90b12 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/impl/RangeImplTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/impl/RangeImplTest.java @@ -18,43 +18,43 @@ */ package org.kie.dmn.feel.runtime.impl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import static org.assertj.core.api.Assertions.assertThat; -public class RangeImplTest { +class RangeImplTest { @Test - public void getLowBoundary() { + void getLowBoundary() { final Range.RangeBoundary lowBoundary = Range.RangeBoundary.CLOSED; final RangeImpl rangeImpl = new RangeImpl(lowBoundary, 10, 15, Range.RangeBoundary.OPEN); assertThat(rangeImpl.getLowBoundary()).isEqualTo(lowBoundary); } @Test - public void getLowEndPoint() { + void getLowEndPoint() { final Integer lowEndPoint = 1; final RangeImpl rangeImpl = new RangeImpl(Range.RangeBoundary.OPEN, lowEndPoint, 15, Range.RangeBoundary.CLOSED); assertThat(rangeImpl.getLowEndPoint()).isEqualTo(lowEndPoint); } @Test - public void getHighEndPoint() { + void getHighEndPoint() { final Integer highEndPoint = 15; final RangeImpl rangeImpl = new RangeImpl(Range.RangeBoundary.OPEN, 1, highEndPoint, Range.RangeBoundary.CLOSED); assertThat(rangeImpl.getHighEndPoint()).isEqualTo(highEndPoint); } @Test - public void getHighBoundary() { + void getHighBoundary() { final Range.RangeBoundary highBoundary = Range.RangeBoundary.CLOSED; final RangeImpl rangeImpl = new RangeImpl(Range.RangeBoundary.OPEN, 10, 15, highBoundary); assertThat(rangeImpl.getHighBoundary()).isEqualTo(highBoundary); } @Test - public void includes() { + void includes() { RangeImpl rangeImpl = new RangeImpl(Range.RangeBoundary.OPEN, 10, 15, Range.RangeBoundary.OPEN); assertThat(rangeImpl.includes(-15)).isFalse(); assertThat(rangeImpl.includes(5)).isFalse(); @@ -80,7 +80,7 @@ public void includes() { } @Test - public void equals() { + void equals() { RangeImpl rangeImpl = new RangeImpl(Range.RangeBoundary.OPEN, 10, 15, Range.RangeBoundary.OPEN); assertThat(rangeImpl).isEqualTo(rangeImpl); @@ -103,7 +103,7 @@ public void equals() { } @Test - public void hashCodeTest() { + void hashCodeTest() { final RangeImpl rangeImpl = new RangeImpl(Range.RangeBoundary.OPEN, 10, 15, Range.RangeBoundary.OPEN); assertThat(rangeImpl.hashCode()).isEqualTo(rangeImpl.hashCode()); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/CoerceUtilTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/CoerceUtilTest.java index 28413e6d1ab..904f5ae0c89 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/CoerceUtilTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/CoerceUtilTest.java @@ -8,17 +8,17 @@ import java.util.Optional; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.types.BuiltInType; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class CoerceUtilTest { +class CoerceUtilTest { @Test - public void coerceParameterDateToDateTimeConverted() { + void coerceParameterDateToDateTimeConverted() { Object value = LocalDate.now(); Object retrieved = CoerceUtil.coerceParameter(BuiltInType.DATE_TIME, value); assertNotNull(retrieved); @@ -32,7 +32,7 @@ public void coerceParameterDateToDateTimeConverted() { } @Test - public void coerceParameterDateToDateTimeNotConverted() { + void coerceParameterDateToDateTimeNotConverted() { Object value = "TEST_OBJECT"; Object retrieved = CoerceUtil.coerceParameter(null, value); assertEquals(value, retrieved); @@ -43,7 +43,7 @@ public void coerceParameterDateToDateTimeNotConverted() { } @Test - public void coerceParamsCollectionToArrayConverted() { + void coerceParamsCollectionToArrayConverted() { Object item = "TESTED_OBJECT"; Object value = Collections.singleton(item); Object[] actualParams1 = {value, "NOT_DATE"}; @@ -73,7 +73,7 @@ public void coerceParamsCollectionToArrayConverted() { } @Test - public void coerceParamsToDateTimeConverted() { + void coerceParamsToDateTimeConverted() { Object value = LocalDate.now(); Object[] actualParams = {value, "NOT_DATE"}; Optional retrieved = CoerceUtil.coerceParams(LocalDate.class, ZonedDateTime.class, actualParams, 0); @@ -91,7 +91,7 @@ public void coerceParamsToDateTimeConverted() { } @Test - public void coerceParamsNotConverted() { + void coerceParamsNotConverted() { Object item = "TESTED_OBJECT"; Object value = Collections.singleton(item); Object[] actualParams1 = {value, "NOT_DATE"}; @@ -107,7 +107,7 @@ public void coerceParamsNotConverted() { } @Test - public void actualCoerceParameterToDateTimeConverted() { + void actualCoerceParameterToDateTimeConverted() { Object value = LocalDate.now(); Object retrieved = CoerceUtil.actualCoerceParameter(BuiltInType.DATE_TIME, value); assertNotNull(retrieved); @@ -121,7 +121,7 @@ public void actualCoerceParameterToDateTimeConverted() { } @Test - public void actualCoerceParameterNotConverted() { + void actualCoerceParameterNotConverted() { Object value = "TEST_OBJECT"; Object retrieved = CoerceUtil.actualCoerceParameter(BuiltInType.DATE_TIME, value); assertNotNull(retrieved); @@ -134,7 +134,7 @@ public void actualCoerceParameterNotConverted() { } @Test - public void actualCoerceParams() { + void actualCoerceParams() { Object value = LocalDate.now(); Object[] actualParams = {value, "NOT_DATE"}; Object coercedValue = BigDecimal.valueOf(1L); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/EvalHelperTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/EvalHelperTest.java index 3d7791ad654..bc1c0fd9f94 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/EvalHelperTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/EvalHelperTest.java @@ -22,17 +22,16 @@ import java.math.BigDecimal; import java.math.BigInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.FEELProperty; import static org.assertj.core.api.Assertions.assertThat; -import static org.kie.dmn.feel.util.EvalHelper.getBigDecimalOrNull; import static org.kie.dmn.feel.util.EvalHelper.normalizeVariableName; -public class EvalHelperTest { +class EvalHelperTest { @Test - public void testNormalizeSpace() { + void normalizeSpace() { assertThat(normalizeVariableName(null)).isNull(); assertThat(normalizeVariableName("")).isEqualTo(""); assertThat(normalizeVariableName(" ")).isEqualTo(""); @@ -58,14 +57,14 @@ public void testNormalizeSpace() { } @Test - public void testGetBigDecimalOrNull() { - assertThat(getBigDecimalOrNull(10d)).isEqualTo(new BigDecimal("10")); - assertThat(getBigDecimalOrNull(10.00000000D)).isEqualTo(new BigDecimal("10")); - assertThat(getBigDecimalOrNull(10000000000.5D)).isEqualTo(new BigDecimal("10000000000.5")); + void getBigDecimalOrNull() { + assertThat(EvalHelper.getBigDecimalOrNull(10d)).isEqualTo(new BigDecimal("10")); + assertThat(EvalHelper.getBigDecimalOrNull(10.00000000D)).isEqualTo(new BigDecimal("10")); + assertThat(EvalHelper.getBigDecimalOrNull(10000000000.5D)).isEqualTo(new BigDecimal("10000000000.5")); } @Test - public void testGetGenericAccessor() throws NoSuchMethodException { + void getGenericAccessor() throws NoSuchMethodException { Method expectedAccessor = TestPojo.class.getMethod("getAProperty"); assertThat(EvalHelper.getGenericAccessor(TestPojo.class, "aProperty")).as("getGenericAccessor should work on Java bean accessors.").isEqualTo(expectedAccessor); @@ -74,7 +73,7 @@ public void testGetGenericAccessor() throws NoSuchMethodException { } @Test - public void testNumericValuesComparative() { + void numericValuesComparative() { assertThat(EvalHelper.compare(BigDecimal.valueOf(1), BigDecimal.valueOf(2), null, (l, r) -> l.compareTo(r) < 0)).isTrue(); assertThat(EvalHelper.compare(1.0, 2.0, null, (l, r) -> l.compareTo(r) < 0)).isTrue(); assertThat(EvalHelper.compare(1, 2, null, (l, r) -> l.compareTo(r) > 0)).isFalse(); diff --git a/kie-dmn/kie-dmn-legacy-tests/pom.xml b/kie-dmn/kie-dmn-legacy-tests/pom.xml index 7f60fcd8fe1..57258c6b2c1 100644 --- a/kie-dmn/kie-dmn-legacy-tests/pom.xml +++ b/kie-dmn/kie-dmn-legacy-tests/pom.xml @@ -58,7 +58,7 @@ - + org.kie @@ -92,8 +92,8 @@ slf4j-api - junit - junit + org.junit.jupiter + junit-jupiter test @@ -101,6 +101,11 @@ mockito-core test + + org.mockito + mockito-junit-jupiter + test + ch.qos.logback logback-classic diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/BaseDMN1_1VariantTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/BaseDMN1_1VariantTest.java index d15906127ea..999bb5a183c 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/BaseDMN1_1VariantTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/BaseDMN1_1VariantTest.java @@ -18,18 +18,12 @@ */ package org.kie.dmn.legacy.tests.core.v1_1; -import org.junit.runners.Parameterized; import org.kie.dmn.core.BaseVariantTest; import static org.kie.dmn.core.BaseVariantTest.VariantTestConf.KIE_API_TYPECHECK; public abstract class BaseDMN1_1VariantTest extends BaseVariantTest { - public BaseDMN1_1VariantTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{KIE_API_TYPECHECK}; } diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNAssemblerTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNAssemblerTest.java index 8b67e940040..bc7960c4b58 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNAssemblerTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNAssemblerTest.java @@ -21,8 +21,10 @@ import java.time.OffsetTime; import java.time.format.DateTimeFormatter; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieFileSystem; import org.kie.api.builder.Message.Level; @@ -41,13 +43,11 @@ public class DMNAssemblerTest extends BaseDMN1_1VariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMNAssemblerTest.class); - - public DMNAssemblerTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testDuplicateModel() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void duplicateModel(VariantTestConf conf) { + testConfig = conf; final KieServices ks = KieServices.Factory.get(); final KieFileSystem kfs = ks.newKieFileSystem(); @@ -62,8 +62,10 @@ public void testDuplicateModel() { assertThat(results.getMessages(Level.ERROR)).hasSizeGreaterThan(0); } - @Test - public void testExtendedMode() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void extendedMode(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("strictMode.dmn", this.getClass() ); final DMNModel model = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ecf4ea54-2abc-4e2f-a101-4fe14e356a46", "strictMode" ); final DMNContext ctx = runtime.newContext(); @@ -72,8 +74,10 @@ public void testExtendedMode() { assertThat(result.getDecisionResultByName("time").getResult()).isEqualTo(DateTimeFormatter.ISO_TIME.parse("14:30:22z", OffsetTime::from)); } - @Test - public void testStrictMode() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void strictMode(VariantTestConf conf) { + testConfig = conf; System.setProperty("org.kie.dmn.strictConformance", "true"); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("strictMode.dmn", this.getClass() ); final DMNModel model = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ecf4ea54-2abc-4e2f-a101-4fe14e356a46", "strictMode" ); @@ -83,8 +87,10 @@ public void testStrictMode() { assertThat(result.getDecisionResultByName("time").getResult()).isNull(); } - @Test - public void testStrictModeProp() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void strictModeProp(VariantTestConf conf) { + testConfig = conf; final KieServices services = KieServices.Factory.get(); final KieFileSystem fileSystem = services.newKieFileSystem(); final KieModuleModel moduleModel = services.newKieModuleModel(); @@ -101,8 +107,8 @@ public void testStrictModeProp() { assertThat(result.getDecisionResultByName("time").getResult()).isNull(); } - @After - public void clearSystemProperty() { + @AfterEach + void clearSystemProperty() { System.clearProperty("org.kie.dmn.strictConformance"); } } diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNCompilerTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNCompilerTest.java index d816a7b840b..e522c4ad8c9 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNCompilerTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNCompilerTest.java @@ -18,7 +18,8 @@ */ package org.kie.dmn.legacy.tests.core.v1_1; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNModel; @@ -46,12 +47,10 @@ public class DMNCompilerTest extends BaseDMN1_1VariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMNCompilerTest.class); - public DMNCompilerTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testItemDefAllowedValuesString() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void itemDefAllowedValuesString(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("0003-input-data-string-allowed-values.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0003-input-data-string-allowed-values" ); assertThat(dmnModel).isNotNull(); @@ -80,8 +79,10 @@ public void testItemDefAllowedValuesString() { assertThat(feelType.getAllowedValuesFEEL().get( 3 ).apply( ctx, "STUDENT" )).isEqualTo(true); } - @Test - public void testCompositeItemDefinition() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void compositeItemDefinition(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntime("0008-LX-arithmetic.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0008-LX-arithmetic" ); assertThat(dmnModel).isNotNull(); @@ -117,8 +118,10 @@ public void testCompositeItemDefinition() { assertThat(((SimpleTypeImpl)termMonths).getFeelType()).isEqualTo(BuiltInType.NUMBER); } - @Test - public void testCompilationThrowsNPE() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void compilationThrowsNPE(VariantTestConf conf) { + testConfig = conf; try { createRuntime("compilationThrowsNPE.dmn", this.getClass()); fail("shouldn't have reached here."); @@ -127,8 +130,10 @@ public void testCompilationThrowsNPE() { } } - @Test - public void testRecursiveFunctions() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void recursiveFunctions(VariantTestConf conf) { + testConfig = conf; // DROOLS-2161 final DMNRuntime runtime = createRuntime("Recursive.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "Recursive" ); @@ -136,8 +141,10 @@ public void testRecursiveFunctions() { assertThat(evaluateModel(runtime, dmnModel, DMNFactory.newContext()).hasErrors()).isFalse(); } - @Test - public void testImport() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void testImport(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = createRuntimeWithAdditionalResources("Importing_Model.dmn", this.getClass(), "Imported_Model.dmn"); diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableHitPolicyTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableHitPolicyTest.java index 87f98e5b3aa..5b979395a20 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableHitPolicyTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableHitPolicyTest.java @@ -22,7 +22,8 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNModel; @@ -41,12 +42,10 @@ public class DMNDecisionTableHitPolicyTest extends BaseDMN1_1VariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMNDecisionTableHitPolicyTest.class); - public DMNDecisionTableHitPolicyTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testSimpleDecisionTableHitPolicyUnique() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyUnique(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-U.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-U"); assertThat(dmnModel).isNotNull(); @@ -56,8 +55,10 @@ public void testSimpleDecisionTableHitPolicyUnique() { assertThat(result.get("Approval Status")).isEqualTo("Approved"); } - @Test - public void testSimpleDecisionTableHitPolicyUniqueSatisfies() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyUniqueSatisfies(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-U.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-U"); assertThat(dmnModel).isNotNull(); @@ -70,8 +71,10 @@ public void testSimpleDecisionTableHitPolicyUniqueSatisfies() { assertThat(dmnResult.getMessages()).hasSizeGreaterThan(0); } - @Test - public void testSimpleDecisionTableHitPolicyUniqueNullWarn() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyUniqueNullWarn(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-U-noinputvalues.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-U-noinputvalues"); assertThat(dmnModel).isNotNull(); @@ -89,8 +92,10 @@ private void check_testSimpleDecisionTableHitPolicyUniqueNullWarn(DMNRuntime run assertThat(dmnResult.getMessages().stream().anyMatch(dm -> dm.getSeverity().equals(DMNMessage.Severity.WARN) && dm.getFeelEvent() instanceof HitPolicyViolationEvent && dm.getFeelEvent().getSeverity().equals(FEELEvent.Severity.WARN))).isTrue(); } - @Test - public void testSimpleDecisionTableHitPolicyUniqueNullWarn_ctxe() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyUniqueNullWarnCtxe(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-U-noinputvalues-ctxe.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-U-noinputvalues"); assertThat(dmnModel).isNotNull(); @@ -98,8 +103,10 @@ public void testSimpleDecisionTableHitPolicyUniqueNullWarn_ctxe() { check_testSimpleDecisionTableHitPolicyUniqueNullWarn(runtime, dmnModel); } - @Test - public void testSimpleDecisionTableHitPolicyUniqueNullWarn_ctxr() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyUniqueNullWarnCtxr(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-U-noinputvalues-ctxr.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-U-noinputvalues"); assertThat(dmnModel).isNotNull(); @@ -107,8 +114,10 @@ public void testSimpleDecisionTableHitPolicyUniqueNullWarn_ctxr() { check_testSimpleDecisionTableHitPolicyUniqueNullWarn(runtime, dmnModel); } - @Test - public void testDecisionTableHitPolicyUnique() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableHitPolicyUnique(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("BranchDistribution.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_cdf29af2-959b-4004-8271-82a9f5a62147", "Dessin 1"); assertThat(dmnModel).isNotNull(); @@ -124,8 +133,10 @@ public void testDecisionTableHitPolicyUnique() { assertThat(result.get("Branches distribution")).isEqualTo("Medium"); } - @Test - public void testSimpleDecisionTableHitPolicyFirst() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyFirst(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-F.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-F"); assertThat(dmnModel).isNotNull(); @@ -138,13 +149,17 @@ public void testSimpleDecisionTableHitPolicyFirst() { assertThat(decisionResult).containsEntry("Decision Review", "Decision final"); } - @Test - public void testSimpleDecisionTableHitPolicyAnyEqualRules() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyAnyEqualRules(VariantTestConf conf) { + testConfig = conf; testSimpleDecisionTableHitPolicyAny("0004-simpletable-A.dmn", "0004-simpletable-A", true); } - @Test - public void testSimpleDecisionTableHitPolicyAnyNonEqualRules() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyAnyNonEqualRules(VariantTestConf conf) { + testConfig = conf; testSimpleDecisionTableHitPolicyAny("0004-simpletable-A-non-equal.dmn", "0004-simpletable-A-non-equal", false); } @@ -164,8 +179,10 @@ private void testSimpleDecisionTableHitPolicyAny(final String resurceName, final } } - @Test - public void testSimpleDecisionTableHitPolicyPriority() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyPriority(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-P.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-P"); assertThat(dmnModel).isNotNull(); @@ -175,8 +192,10 @@ public void testSimpleDecisionTableHitPolicyPriority() { assertThat(result.get("Approval Status")).isEqualTo("Declined"); } - @Test - public void testSimpleDecisionTableHitPolicyPriorityMultipleOutputs() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyPriorityMultipleOutputs(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-P-multiple-outputs.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-P-multiple-outputs"); assertThat(dmnModel).isNotNull(); @@ -189,8 +208,10 @@ public void testSimpleDecisionTableHitPolicyPriorityMultipleOutputs() { assertThat(decisionResult).containsEntry("Decision Review", "Needs verification"); } - @Test - public void testSimpleDecisionTableHitPolicyOutputOrder() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyOutputOrder(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-O.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-O"); assertThat(dmnModel).isNotNull(); @@ -202,8 +223,10 @@ public void testSimpleDecisionTableHitPolicyOutputOrder() { assertThat(decisionResults).contains("Declined", "Declined", "Approved"); } - @Test - public void testSimpleDecisionTableHitPolicyOutputOrderMultipleOutputs() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyOutputOrderMultipleOutputs(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-O-multiple-outputs.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-O-multiple-outputs"); assertThat(dmnModel).isNotNull(); @@ -225,8 +248,10 @@ private void checkMultipleOutputResult(final Map outputResult, assertThat(outputResult).containsEntry("Decision Review", expectedDecisionReview); } - @Test - public void testSimpleDecisionTableHitPolicyRuleOrder() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyRuleOrder(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-R.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-R"); assertThat(dmnModel).isNotNull(); @@ -238,15 +263,19 @@ public void testSimpleDecisionTableHitPolicyRuleOrder() { assertThat(decisionResults).contains("Approved", "Needs review", "Declined"); } - @Test - public void testSimpleDecisionTableHitPolicyCollect() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyCollect(VariantTestConf conf) { + testConfig = conf; final List decisionResults = executeTestDecisionTableHitPolicyCollect(getSimpleTableContext(BigDecimal.valueOf(70 ), "Medium", true)); assertThat(decisionResults).hasSize(3); assertThat(decisionResults).contains(BigDecimal.valueOf(10), BigDecimal.valueOf(25), BigDecimal.valueOf(13)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectNoHits() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectNoHits(VariantTestConf conf) { + testConfig = conf; final List decisionResults = executeTestDecisionTableHitPolicyCollect(getSimpleTableContext(BigDecimal.valueOf(5 ), "Medium", true)); assertThat(decisionResults).hasSize(0); } @@ -261,15 +290,19 @@ private List executeTestDecisionTableHitPolicyCollect(final DMNConte return (List) result.get( "Status number"); } - @Test - public void testSimpleDecisionTableHitPolicyCollectSum() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectSum(VariantTestConf conf) { + testConfig = conf; testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-sum.dmn", "0004-simpletable-C-sum", BigDecimal.valueOf(48), getSimpleTableContext(BigDecimal.valueOf(70), "Medium", true)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectSumMultipleOutputs() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectSumMultipleOutputs(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-C-sum-multiple-outputs.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-C-sum-multiple-outputs"); @@ -285,29 +318,37 @@ public void testSimpleDecisionTableHitPolicyCollectSumMultipleOutputs() { assertThat(decisionResult).containsEntry("Value2", BigDecimal.valueOf(32)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectMin() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectMin(VariantTestConf conf) { + testConfig = conf; testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-min.dmn", "0004-simpletable-C-min", BigDecimal.valueOf(10), getSimpleTableContext(BigDecimal.valueOf(70), "Medium", true)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectMax() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectMax(VariantTestConf conf) { + testConfig = conf; testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-max.dmn", "0004-simpletable-C-max", BigDecimal.valueOf(25), getSimpleTableContext(BigDecimal.valueOf(70), "Medium", true)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectCount() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectCount(VariantTestConf conf) { + testConfig = conf; testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-count.dmn", "0004-simpletable-C-count", BigDecimal.valueOf(3), getSimpleTableContext(BigDecimal.valueOf(70), "Medium", true)); } - @Test - public void testSimpleDecisionTableHitPolicyCollectCountNoHits() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableHitPolicyCollectCountNoHits(VariantTestConf conf) { + testConfig = conf; testSimpleDecisionTableHitPolicyCollectAggregateFunction( "0004-simpletable-C-count.dmn", "0004-simpletable-C-count", BigDecimal.valueOf(0), getSimpleTableContext(BigDecimal.valueOf(5), "Medium", true)); @@ -336,8 +377,10 @@ private DMNContext getSimpleTableContext(final BigDecimal age, final String risk return context; } - @Test - public void testDecisionTableHitPolicyCollect() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableHitPolicyCollect(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Collect_Hit_Policy.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_da1a4dcb-01bf-4dee-9be8-f498bc68178c", "Collect Hit Policy"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableRuntimeTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableRuntimeTest.java index ebed0c95e4b..e5a15bcdaab 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableRuntimeTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableRuntimeTest.java @@ -27,8 +27,12 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; import org.kie.dmn.api.core.DMNContext; @@ -53,12 +57,10 @@ public class DMNDecisionTableRuntimeTest extends BaseDMN1_1VariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMNDecisionTableRuntimeTest.class); - public DMNDecisionTableRuntimeTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testDecisionTableWithCalculatedResult() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableWithCalculatedResult(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "calculation1.dmn", this.getClass() ); checkDecisionTableWithCalculatedResult(runtime); } @@ -78,9 +80,11 @@ private void checkDecisionTableWithCalculatedResult(final DMNRuntime runtime) { final DMNContext result = dmnResult.getContext(); assertThat( ((BigDecimal) result.get( "Logique de décision 1" )).setScale( 1, RoundingMode.CEILING )).isEqualTo(BigDecimal.valueOf( 0.5 ) ); } - - @Test(timeout = 30_000L) - public void testDecisionTableWithCalculatedResult_parallel() throws Throwable { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + @Timeout(value = 30_000L, unit = TimeUnit.MILLISECONDS) + void decisionTableWithCalculatedResultParallel() throws Throwable { final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "calculation1.dmn", this.getClass() ); final Runnable task = () -> checkDecisionTableWithCalculatedResult(runtime); final List problems = Collections.synchronizedList(new ArrayList<>()); @@ -97,8 +101,10 @@ public void testDecisionTableWithCalculatedResult_parallel() throws Throwable { } } - @Test - public void testDecisionTableMultipleResults() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableMultipleResults(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "car_damage_responsibility.dmn", this.getClass() ); final DMNRuntimeEventListener listener = Mockito.mock( DMNRuntimeEventListener.class ); runtime.addListener( listener ); @@ -131,8 +137,10 @@ public void testDecisionTableMultipleResults() { assertThat( second.getSelected()).containsExactly(3); } - @Test - public void testSimpleDecisionTableMultipleOutputWrongOutputType() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleDecisionTableMultipleOutputWrongOutputType(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0004-simpletable-P-multiple-outputs-wrong-output.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", "0004-simpletable-P-multiple-outputs-wrong-output" ); assertThat(dmnModel).isNotNull(); @@ -148,8 +156,10 @@ public void testSimpleDecisionTableMultipleOutputWrongOutputType() { message -> message.getFeelEvent().getSourceException() instanceof NullPointerException ).count()).isEqualTo(0L ); } - @Test - public void testDecisionTableInvalidInputErrorMessage() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableInvalidInputErrorMessage(VariantTestConf conf) { + testConfig = conf; final DMNContext context = DMNFactory.newContext(); context.set( "Branches dispersion", "Province" ); context.set( "Number of Branches", BigDecimal.valueOf( 10 ) ); @@ -157,8 +167,10 @@ public void testDecisionTableInvalidInputErrorMessage() { testDecisionTableInvalidInput( context ); } - @Test - public void testDecisionTableInvalidInputTypeErrorMessage() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableInvalidInputTypeErrorMessage(VariantTestConf conf) { + testConfig = conf; final DMNContext context = DMNFactory.newContext(); context.set( "Branches dispersion", 1 ); context.set( "Number of Branches", BigDecimal.valueOf( 10 ) ); @@ -166,8 +178,10 @@ public void testDecisionTableInvalidInputTypeErrorMessage() { testDecisionTableInvalidInput( context ); } - @Test - public void testDecisionTableNonexistingInputErrorMessage() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableNonexistingInputErrorMessage(VariantTestConf conf) { + testConfig = conf; final DMNContext context = DMNFactory.newContext(); context.set( "Not exists", "Province" ); context.set( "Number of Branches", BigDecimal.valueOf( 10 ) ); @@ -187,8 +201,10 @@ private void testDecisionTableInvalidInput(final DMNContext inputContext) { assertThat(result.isDefined( "Branches distribution")).isEqualTo(Boolean.FALSE); } - @Test - public void testDecisionTableDefaultValue() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableDefaultValue(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "decisiontable-default-value.dmn", this.getClass() ); final DMNRuntimeEventListener listener = Mockito.mock( DMNRuntimeEventListener.class ); runtime.addListener( listener ); @@ -215,8 +231,10 @@ public void testDecisionTableDefaultValue() { assertThat( captor.getValue().getSelected()).isEmpty(); } - @Test - public void testTwoDecisionTables() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void twoDecisionTables(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "two_decision_tables.dmn", this.getClass() ); final DMNRuntimeEventListener listener = Mockito.mock( DMNRuntimeEventListener.class ); runtime.addListener( listener ); @@ -242,8 +260,10 @@ public void testTwoDecisionTables() { assertThat( captor.getAllValues().get( 1 ).getDecisionTableName()).isEqualTo("b" ); } - @Test - public void testDTInputExpressionLocalXmlnsInference() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dTInputExpressionLocalXmlnsInference(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("drools1502-InputExpression.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://www.drools.org/kie-dmn/definitions", @@ -261,8 +281,10 @@ public void testDTInputExpressionLocalXmlnsInference() { assertThat( result.get( "MyDecision" )).isEqualTo("Decision taken" ); } - @Test - public void testDTInContext() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dTInContext(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DT_in_context.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_4acdcb25-b298-435e-abd5-efd00ed686a5", "Drawing 1" ); assertThat(dmnModel).isNotNull(); @@ -277,8 +299,10 @@ public void testDTInContext() { assertThat( ((Map) result.get( "D1" )).get( "Text color" )).isEqualTo("red" ); } - @Test - public void testDTUsingEqualsUnaryTestWithVariable1() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dTUsingEqualsUnaryTestWithVariable1(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DT_using_variables.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_ed1ec15b-40aa-424d-b1d0-4936df80b135", "DT Using variables" ); assertThat(dmnModel).isNotNull(); @@ -302,8 +326,10 @@ public void testDTUsingEqualsUnaryTestWithVariable1() { assertThat( result.get( "Compare String" )).isEqualTo("Same String" ); } - @Test - public void testDTUsingEqualsUnaryTestWithVariable2() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dTUsingEqualsUnaryTestWithVariable2(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DT_using_variables.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_ed1ec15b-40aa-424d-b1d0-4936df80b135", "DT Using variables" ); assertThat(dmnModel).isNotNull(); @@ -327,8 +353,10 @@ public void testDTUsingEqualsUnaryTestWithVariable2() { assertThat( result.get( "Compare String" )).isEqualTo("Different String" ); } - @Test - public void testEmptyOutputCell() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void emptyOutputCell(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "DT_empty_output_cell.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_77ae284e-ce52-4579-a50f-f3cc584d7f4b", "Calculation1" ); assertThat(dmnModel).isNotNull(); @@ -342,8 +370,10 @@ public void testEmptyOutputCell() { assertThat(dmnResult.getContext().get("Logique de décision 1")).isNull(); } - @Test - public void testNullRelation() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void nullRelation(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("nullrelation.dmn", getClass()); final DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_946a2145-89ae-4197-88b4-40e6f88c8101", "Null in relations"); assertThat(model).isNotNull(); @@ -354,8 +384,10 @@ public void testNullRelation() { assertThat(result.hasErrors()).as(DMNRuntimeUtil.formatMessages(result.getMessages())).isFalse(); } - @Test - public void testDecisionTableOutputDMNTypeCollection() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableOutputDMNTypeCollection(VariantTestConf conf) { + testConfig = conf; // DROOLS-2359 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionTableOutputDMNTypeCollection.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ae5d2033-c6d0-411f-a394-da33a70e5638", "Drawing 1"); @@ -372,8 +404,10 @@ public void testDecisionTableOutputDMNTypeCollection() { assertThat(result.get("a decision")).asList().containsExactly("abc", "xyz"); } - @Test - public void testDecisionTableOutputDMNTypeCollection_NOtypecheck() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableOutputDMNTypeCollectionNOtypecheck(VariantTestConf conf) { + testConfig = conf; // DROOLS-2359 // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieServices ks = KieServices.Factory.get(); @@ -394,8 +428,10 @@ public void testDecisionTableOutputDMNTypeCollection_NOtypecheck() { assertThat(result.get("a decision")).asList().containsExactly("abc", "xyz"); } - @Test - public void testDecisionTableOutputDMNTypeCollectionWithLOV() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableOutputDMNTypeCollectionWithLOV(VariantTestConf conf) { + testConfig = conf; // DROOLS-2359 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionTableOutputDMNTypeCollectionWithLOV.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ae5d2033-c6d0-411f-a394-da33a70e5638", "List of Words in DT"); @@ -412,8 +448,10 @@ public void testDecisionTableOutputDMNTypeCollectionWithLOV() { assertThat(result.get("a decision")).asList().containsExactly("abc", "a"); } - @Test - public void testDecisionTableOutputDMNTypeCollectionWithLOV_NOtypecheck() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableOutputDMNTypeCollectionWithLOVNOtypecheck(VariantTestConf conf) { + testConfig = conf; // DROOLS-2359 // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieServices ks = KieServices.Factory.get(); diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableWithSymbolsTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableWithSymbolsTest.java index 60c55d04f4c..8dd3c812cb5 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableWithSymbolsTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNDecisionTableWithSymbolsTest.java @@ -18,7 +18,8 @@ */ package org.kie.dmn.legacy.tests.core.v1_1; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -30,12 +31,10 @@ public class DMNDecisionTableWithSymbolsTest extends BaseDMN1_1VariantTest { - public DMNDecisionTableWithSymbolsTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testDecisionWithArgumentsOnOutput() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionWithArgumentsOnOutput(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Decide with symbols.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_79b16a68-013b-484c-98f5-49ff77808800", "Decide with symbols"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNInputRuntimeTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNInputRuntimeTest.java index b1417867aab..29978cde2f0 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNInputRuntimeTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNInputRuntimeTest.java @@ -24,7 +24,8 @@ import java.util.List; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNDecisionResult; import org.kie.dmn.api.core.DMNMessage; @@ -42,12 +43,10 @@ public class DMNInputRuntimeTest extends BaseDMN1_1VariantTest { - public DMNInputRuntimeTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testInputStringEvaluateAll() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inputStringEvaluateAll(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -65,8 +64,10 @@ public void testInputStringEvaluateAll() { assertThat(result.get("Greeting Message")).isEqualTo("Hello John Doe"); } - @Test - public void testInputStringEvaluateDecisionByName() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inputStringEvaluateDecisionByName(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -96,8 +97,10 @@ public void testInputStringEvaluateDecisionByName() { assertThat(dmnResult.getDecisionResultByName( "Greeting Message" ).getEvaluationStatus()).isEqualTo(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED); } - @Test - public void testInputStringEvaluateDecisionById() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inputStringEvaluateDecisionById(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -127,8 +130,10 @@ public void testInputStringEvaluateDecisionById() { assertThat(dmnResult.getDecisionResultByName( "Greeting Message" ).getEvaluationStatus()).isEqualTo(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED); } - @Test - public void testInputStringAllowedValuesEvaluateAll() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inputStringAllowedValuesEvaluateAll(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0003-input-data-string-allowed-values.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", "0003-input-data-string-allowed-values" ); assertThat(dmnModel).isNotNull(); @@ -143,13 +148,17 @@ public void testInputStringAllowedValuesEvaluateAll() { assertThat(result.get( "Employment Status Statement" )).isEqualTo("You are SELF-EMPLOYED"); } - @Test - public void testInputStringNotInTypeScopeEvaluateAll() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inputStringNotInTypeScopeEvaluateAll(VariantTestConf conf) { + testConfig = conf; testInputStringNotAllowedValuesEvaluateAll("NOT-ALLOWED-VALUE"); } - @Test - public void testInputStringWrongTypeEvaluateAll() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inputStringWrongTypeEvaluateAll(VariantTestConf conf) { + testConfig = conf; testInputStringNotAllowedValuesEvaluateAll(new Object()); } @@ -171,8 +180,10 @@ private void testInputStringNotAllowedValuesEvaluateAll(final Object inputValue) assertThat(dmnResult.getDecisionResults().get(0).getMessages().get(0).getSeverity()).isEqualTo(DMNMessage.Severity.ERROR); } - @Test - public void testInputNumberEvaluateAll() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inputNumberEvaluateAll(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0002-input-data-number.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", "0002-input-data-number" ); assertThat(dmnModel).isNotNull(); @@ -187,8 +198,10 @@ public void testInputNumberEvaluateAll() { assertThat(result.get( "Yearly Salary" )).isEqualTo( new BigDecimal(12000)); } - @Test - public void testGetRequiredInputsByName() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void getRequiredInputsByName(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -202,8 +215,10 @@ public void testGetRequiredInputsByName() { assertThat(inputs).hasSize(0); } - @Test - public void testGetRequiredInputsById() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void getRequiredInputsById(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -217,8 +232,10 @@ public void testGetRequiredInputsById() { assertThat(inputs).hasSize(0); } - @Test - public void testNonexistantInputNodeName() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void nonexistantInputNodeName(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -236,8 +253,10 @@ public void testNonexistantInputNodeName() { assertThat(dmnResult.getDecisionResults().get(0).getMessages().get(0).getSeverity()).isEqualTo(DMNMessage.Severity.ERROR); } - @Test - public void testAllowedValuesChecks() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void allowedValuesChecks(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "AllowedValuesChecks.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b-504f3e77b442", @@ -270,8 +289,10 @@ public void testAllowedValuesChecks() { assertThat(dmnResult4.getMessages().stream().anyMatch(m -> m.getMessageType().equals(DMNMessageType.ERROR_EVAL_NODE))).isTrue(); } - @Test - public void testDMNInputDataNodeTypeTest() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dmnInputDataNodeTypeTest(VariantTestConf conf) { + testConfig = conf; // DROOLS-1569 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DMNInputDataNodeTypeTest.dmn", this.getClass()); final String MODEL_NAMESPACE = "http://www.trisotech.com/definitions/_17396034-163a-48aa-9a7f-c6eb17f9cc6c"; @@ -311,8 +332,10 @@ public void testDMNInputDataNodeTypeTest() { assertThat(idnCarDamageResponsibility.getType().isComposite()).isTrue(); } - @Test - public void testInputClauseTypeRefWithAllowedValues() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inputClauseTypeRefWithAllowedValues(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("actualInputMatchInputValues-forTypeRef.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn/definitions", "definitions"); assertThat(dmnModel).isNotNull(); @@ -328,8 +351,10 @@ public void testInputClauseTypeRefWithAllowedValues() { assertThat(result.get("MyDecision")).isEqualTo("Decision taken"); } - @Test - public void testInputDataTypeRefWithAllowedValues() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inputDataTypeRefWithAllowedValues(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("actualInputMatchInputValues-forTypeRef.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn/definitions", "definitions"); assertThat(dmnModel).isNotNull(); @@ -344,8 +369,10 @@ public void testInputDataTypeRefWithAllowedValues() { assertThat(dmnResult.getMessages().get(0).getSourceId()).isEqualTo("_3d560678-a126-4654-a686-bc6d941fe40b"); } - @Test - public void testMissingInputData() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void missingInputData(VariantTestConf conf) { + testConfig = conf; final List messages = DMNRuntimeUtil.createExpectingDMNMessages("missing_input_data.dmn", getClass()); assertThat(messages.get(0).getMessageType()).isEqualTo(DMNMessageType.ERR_COMPILING_FEEL); } diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNRuntimeTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNRuntimeTest.java index 62177cdb051..70d6109c8ce 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNRuntimeTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/DMNRuntimeTest.java @@ -34,9 +34,12 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; import org.kie.dmn.api.core.DMNContext; @@ -75,6 +78,7 @@ import org.slf4j.LoggerFactory; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.kie.dmn.core.util.DMNTestUtil.getAndAssertModelNoErrors; import static org.kie.dmn.core.util.DynamicTypeUtils.entry; import static org.kie.dmn.core.util.DynamicTypeUtils.mapOf; @@ -88,12 +92,10 @@ public class DMNRuntimeTest extends BaseDMN1_1VariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMNRuntimeTest.class); - public DMNRuntimeTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testSimpleItemDefinition() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleItemDefinition(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item-def" ); assertThat(dmnModel).isNotNull(); @@ -110,8 +112,10 @@ public void testSimpleItemDefinition() { assertThat( result.get( "Yearly Salary" )).isEqualTo(new BigDecimal( "12000" ) ); } - @Test - public void testCompositeItemDefinition() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void compositeItemDefinition(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0008-LX-arithmetic.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0008-LX-arithmetic" ); assertThat(dmnModel).isNotNull(); @@ -130,8 +134,10 @@ public void testCompositeItemDefinition() { assertThat( result.get( "payment" )).isEqualTo(new BigDecimal( "2778.693549432766768088520383236299" ) ); } - @Test - public void testTrisotechNamespace() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void trisotechNamespace(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("trisotech_namespace.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_b8feec86-dadf-4051-9feb-8e6093bbb530", "Solution 3" ); assertThat(dmnModel).isNotNull(); @@ -149,8 +155,10 @@ public void testTrisotechNamespace() { assertThat( result.get( "Ship can enter a Dutch port" )).isEqualTo(Boolean.TRUE); } - @Test - public void testEmptyDecision1() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void emptyDecision1(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("empty_decision.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ba9fc4b1-5ced-4d00-9b61-290de4bf3213", "Solution 3" ); assertThat(dmnModel).isNotNull(); @@ -169,9 +177,11 @@ public void testEmptyDecision1() { assertThat( dmnResult.hasErrors()).isTrue(); assertThat( result.get( "Ship Can Enter v2" )).isEqualTo(Boolean.TRUE); } - - @Test - public void testEmptyDecision2() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void emptyDecision2(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("empty_decision.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ba9fc4b1-5ced-4d00-9b61-290de4bf3213", "Solution 3" ); assertThat(dmnModel).isNotNull(); @@ -199,8 +209,10 @@ public void testEmptyDecision2() { assertThat( result.get( "Ship Can Enter v2" )).isEqualTo(Boolean.TRUE); } - @Test - public void testEventListeners() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void eventListeners(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("car_damage_responsibility.dmn", this.getClass() ); final DMNRuntimeEventListener listener = mock(DMNRuntimeEventListener.class ); @@ -243,8 +255,10 @@ public void testEventListeners() { assertThat( result.get( "Payment method" )).isEqualTo("Check" ); } - @Test - public void testContextEventListeners() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void contextEventListeners(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("context_listener.dmn", this.getClass() ); final DMNRuntimeEventListener listener = mock(DMNRuntimeEventListener.class ); @@ -310,14 +324,18 @@ public void testContextEventListeners() { assertThat( result.get( "d1" )).isEqualTo("a" ); } - @Test - public void testErrorMessages() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void errorMessages(VariantTestConf conf) { + testConfig = conf; final List messages = DMNRuntimeUtil.createExpectingDMNMessages("car_damage_responsibility2.dmn", this.getClass()); assertThat(messages).isNotEmpty(); } - @Test - public void testOutputReuse() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void outputReuse(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Input_reuse_in_output.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_098bb607-eff7-4772-83ac-6ded8b371fa7", "Input reuse in output" ); assertThat(dmnModel).isNotNull(); @@ -333,8 +351,10 @@ public void testOutputReuse() { assertThat( result.get( "My Decision" )).isEqualTo("Fixed30" ); } - @Test - public void testSimpleNot() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleNot(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Simple_Not.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_98436ebb-7c42-48c0-8d11-d693e2a817c9", "Simple Not" ); assertThat(dmnModel).isNotNull(); @@ -349,8 +369,10 @@ public void testSimpleNot() { assertThat( result.get( "a" )).isEqualTo("Is Student" ); } - @Test - public void testSimpleNot2() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simpleNot2(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Simple_Not.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_98436ebb-7c42-48c0-8d11-d693e2a817c9", "Simple Not" ); assertThat(dmnModel).isNotNull(); @@ -365,8 +387,10 @@ public void testSimpleNot2() { assertThat( result.get( "a" )).isEqualTo("Is not a Student" ); } - @Test - public void testDinner() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dinner(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Dinner.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_0c45df24-0d57-4acc-b296-b4cba8b71a36", "Dinner" ); assertThat(dmnModel).isNotNull(); @@ -386,8 +410,10 @@ public void testDinner() { assertThat( dmnResult.getContext().get( "Drinks" )).asList().containsExactly( "Apero", "Ale", "Juice Boxes"); } - @Test - public void testNotificationsApproved2() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void notificationsApproved2(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("NotificationsTest2.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "building-structure-rules" ); assertThat(dmnModel).isNotNull(); @@ -403,8 +429,10 @@ public void testNotificationsApproved2() { assertThat( result.get( "Permit Status" )).isEqualTo("Building Activity Province Permit Required" ); } - @Test - public void testBoxedContext() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void boxedContext(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("BoxedContext.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_0de36357-fec0-4b4e-b7f1-382d381e06e9", "Dessin 1" ); assertThat(dmnModel).isNotNull(); @@ -420,8 +448,10 @@ public void testBoxedContext() { assertThat( (Map) dmnResult.getContext().get( "Math" )).containsEntry("Product", BigDecimal.valueOf(50)); } - @Test - public void testFunctionDefAndInvocation() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void functionDefAndInvocation(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("FunctionDefinition.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_0de36357-fec0-4b4e-b7f1-382d381e06e9", "Dessin 1" ); assertThat(dmnModel).isNotNull(); @@ -436,8 +466,10 @@ public void testFunctionDefAndInvocation() { assertThat((Map) dmnResult.getContext().get("Math")).containsEntry("Sum", BigDecimal.valueOf(15)); } - @Test - public void testBuiltInFunctionInvocation() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void builtInFunctionInvocation(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("BuiltInFunctionInvocation.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b77219ee-ec28-48e3-b240-8e0dbbabefeb", "built in function invocation" ); assertThat(dmnModel).isNotNull(); @@ -455,8 +487,10 @@ public void testBuiltInFunctionInvocation() { assertThat( dmnResult.getContext().get( "out of order" )).isEqualTo(BigDecimal.valueOf( 5 ) ); } - @Test - public void testBKMNode() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void bkmNode(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0009-invocation-arithmetic.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -479,8 +513,10 @@ public void testBKMNode() { isEqualTo(new BigDecimal("2878.69354943277").setScale(8, BigDecimal.ROUND_DOWN)); } - @Test - public void testItemDefCollection() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void itemDefCollection(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-filter.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -509,8 +545,10 @@ public void testItemDefCollection() { assertThat( dmnResult.getContext().get("filter01")).asList().containsExactly("Mary"); } - @Test - public void testList() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void list(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("list-expression.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -524,8 +562,10 @@ public void testList() { assertThat(dmnResult.getContext().get("Name list")).asList().containsExactly("John", "Mary"); } - @Test - public void testRelation() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void relation(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("relation-expression.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -550,8 +590,10 @@ public void testRelation() { assertThat( e.get( "Salary" )).isEqualTo(BigDecimal.valueOf( 120000 ) ); } - @Test - public void testLendingExample() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void lendingExample(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-lending.dmn", getClass() ); // runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -600,8 +642,10 @@ public void testLendingExample() { assertThat( ctx.get( "Routing" )).isEqualTo("ACCEPT" ); } - @Test - public void testDateAndTime() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dateAndTime(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0007-date-time.dmn", getClass() ); runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -653,8 +697,10 @@ public void testDateAndTime() { } - @Test - public void testFiltering() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void filtering(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Person_filtering_by_age.dmn", getClass() ); runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -668,8 +714,10 @@ public void testFiltering() { assertThat(((List)dmnResult.getContext().get("Filtering"))).as(DMNRuntimeUtil.formatMessages( dmnResult.getMessages())).hasSize(2); } - @Test - public void testNowFunction() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void nowFunction(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("today_function_test.dmn", getClass() ); runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -683,8 +731,10 @@ public void testNowFunction() { assertThat(dmnResult.getContext().get("When is it")).as(DMNRuntimeUtil.formatMessages( dmnResult.getMessages())).isEqualTo( "It is in the past" ); } - @Test - public void testTimeFunction() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void timeFunction(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("TimeFromDate.dmn", getClass() ); runtime.addListener( DMNRuntimeUtil.createListener() ); @@ -698,8 +748,10 @@ public void testTimeFunction() { assertThat(dmnResult.getContext().get("time")).as(DMNRuntimeUtil.formatMessages( dmnResult.getMessages() )).isEqualTo(LocalTime.of(5, 48, 23)); } - @Test - public void testAlternativeNSDecl() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void alternativeNSDecl(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("alternative_feel_ns_declaration.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -717,8 +769,10 @@ public void testAlternativeNSDecl() { assertThat( result.get( "Greeting Message" )).isEqualTo("Hello John Doe" ); } - @Test - public void testLoanComparison() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void loanComparison(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("loanComparison.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_3a1fd8f4-ea04-4453-aa30-ff14140e3441", "loanComparison" ); assertThat(dmnModel).isNotNull(); @@ -731,8 +785,10 @@ public void testLoanComparison() { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isFalse(); } - @Test - public void testGetViableLoanProducts() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void getViableLoanProducts(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Get_Viable_Loan_Products.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_3e1a628d-36bc-45f1-8464-b201735e5ce0", "Get Viable Loan Products" ); assertThat(dmnModel).isNotNull(); @@ -755,8 +811,10 @@ public void testGetViableLoanProducts() { assertThat((Collection) result.get("LoanTypes")).hasSize(3); } - @Test - public void testYearsAndMonthsDuration() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void yearsAndMonthsDuration(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("yearMonthDuration.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_6eda1490-21ca-441e-8a26-ab3ca800e43c", "Drawing 1" ); assertThat(dmnModel).isNotNull(); @@ -775,14 +833,18 @@ public void testYearsAndMonthsDuration() { assertThat( result.get( "How long" )).isEqualTo("Longer than a year" ); } - @Test - public void testInvalidVariableNames() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidVariableNames(VariantTestConf conf) { + testConfig = conf; final List messages = DMNRuntimeUtil.createExpectingDMNMessages("invalid-variable-names.dmn", this.getClass()); assertThat(messages).isNotEmpty(); } - @Test - public void testNull() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void testNull(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("null_values.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "Null values model" ); assertThat(dmnModel).isNotNull(); @@ -806,16 +868,20 @@ public void testNull() { } - @Test - public void testInvalidModel() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidModel(VariantTestConf conf) { + testConfig = conf; final List messages = DMNRuntimeUtil.createExpectingDMNMessages("Loan_Prequalification_Condensed_Invalid.dmn", this.getClass()); assertThat(messages).hasSize(2); assertThat(messages.get(0).getSourceId()).isEqualTo("_8b5cac9e-c8ca-4817-b05a-c70fa79a8d48"); assertThat(messages.get(1).getSourceId()).isEqualTo("_ef09d90e-e1a4-4ec9-885b-482d1f4a1cee"); } - @Test - public void testNullOnNumber() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void nullOnNumber(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Number_and_null_entry.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_a293b9f9-c912-41ee-8147-eae59ba86ac5", "Number and null entry" ); assertThat(dmnModel).isNotNull(); @@ -839,8 +905,10 @@ public void testNullOnNumber() { assertThat( result.get( "Decision Logic 1" )).isEqualTo("Positive number" ); } - @Test - public void testLoan_Recommendation2() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void loanRecommendation2(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Loan_Recommendation2.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_35c7339b-b868-43da-8f06-eb481708c73c", "Loan Recommendation2" ); assertThat(dmnModel).isNotNull(); @@ -871,9 +939,11 @@ public void testLoan_Recommendation2() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "Loan Recommendation" )).isEqualTo("Decline" ); } - - @Test - public void testPriority_table() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void priorityTable(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("priority_table.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_ff54a44d-b8f5-48fc-b2b7-43db767e8a1c", @@ -889,9 +959,11 @@ public void testPriority_table() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "Approval Status" )).isEqualTo("Declined" ); } - - @Test - public void testPriority_table_context_recursion() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void priorityTableContextRecursion(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("priority_table_context_recursion.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_ff54a44d-b8f5-48fc-b2b7-43db767e8a1c", @@ -907,15 +979,19 @@ public void testPriority_table_context_recursion() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "Approval Status" )).isEqualTo("Declined" ); } - - @Test - public void testPriority_table_missing_output_values() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void priorityTableMissingOutputValues(VariantTestConf conf) { + testConfig = conf; final List messages = DMNRuntimeUtil.createExpectingDMNMessages("DTABLE_PRIORITY_MISSING_OUTVALS.dmn", this.getClass()); assertThat(messages).hasSize(1); } - @Test - public void test_non_Priority_table_missing_output_values() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void non_priority_table_missing_output_values(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DTABLE_NON_PRIORITY_MISSING_OUTVALS.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", @@ -924,8 +1000,10 @@ public void test_non_Priority_table_missing_output_values() { assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); } - @Test - public void testPriority_table_one_output_value() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void priorityTableOneOutputValue(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DTABLE_PRIORITY_ONE_OUTVAL.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", @@ -933,9 +1011,11 @@ public void testPriority_table_one_output_value() { assertThat(dmnModel).isNotNull(); assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); } - - @Test - public void testNoPrefix() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void noPrefix(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("drools1502-noprefix.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://www.drools.org/kie-dmn/definitions", @@ -952,9 +1032,11 @@ public void testNoPrefix() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "MyDecision" )).isEqualTo("Decision taken" ); } - - @Test - public void testWrongConstraintsInItemDefinition() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void wrongConstraintsInItemDefinition(VariantTestConf conf) { + testConfig = conf; // DROOLS-1503 final List messages = DMNRuntimeUtil.createExpectingDMNMessages("WrongConstraintsInItemDefinition.dmn", this.getClass()); assertThat(messages).as(DMNRuntimeUtil.formatMessages(messages)).hasSize(3); @@ -967,9 +1049,11 @@ public void testWrongConstraintsInItemDefinition() { assertThat(messages.get(2).getSourceId()).isEqualTo("_31911de7-e184-411c-99d1-f33977971270"); assertThat(messages.get(2).getMessageType()).isEqualTo(DMNMessageType.MISSING_TYPE_REF); } - - @Test - public void testResolutionOfVariableWithLeadingOrTrailingSpaces() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void resolutionOfVariableWithLeadingOrTrailingSpaces(VariantTestConf conf) { + testConfig = conf; // DROOLS-1504 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("variableLeadingTrailingSpaces.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -991,8 +1075,10 @@ public void testResolutionOfVariableWithLeadingOrTrailingSpaces() { assertThat(result.get("Further Decision")).isEqualTo("The person was greeted with: 'Ciao John Doe'"); } - @Test - public void testOutOfOrderItemsNPE() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void outOfOrderItemsNPE(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("out-of-order-items.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/kie-dmn", @@ -1001,9 +1087,11 @@ public void testOutOfOrderItemsNPE() { assertThat(dmnModel.getMessages().stream().anyMatch( m -> m.getMessageType().equals( DMNMessageType.FAILED_VALIDATOR ) )) .as(DMNRuntimeUtil.formatMessages( dmnModel.getMessages() )).isFalse(); } - - @Test - public void testItemDefDependencies() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void itemDefDependencies(VariantTestConf conf) { + testConfig = conf; // DROOLS-1505 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("itemDef-dependency.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1024,9 +1112,11 @@ public void testItemDefDependencies() { final DMNContext result = dmnResult.getContext(); assertThat( result.get( "My Decision" )).isEqualTo("The person John Doe is located at 100 East Davie Street" ); } - - @Test - public void testDecisionResultTypeCheck() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionResultTypeCheck(VariantTestConf conf) { + testConfig = conf; // DROOLS-1513 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("LoanRecommendationWrongOutputType.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1050,8 +1140,10 @@ public void testDecisionResultTypeCheck() { assertThat( dmnResult.getMessages().get( 0 ).getMessageType()).isEqualTo(DMNMessageType.ERROR_EVAL_NODE ); } - @Test - public void testNPE() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void npe(VariantTestConf conf) { + testConfig = conf; // DROOLS-1512 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("NPE.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1066,9 +1158,11 @@ public void testNPE() { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isTrue(); assertThat( dmnResult.getMessages().stream().anyMatch( m -> m.getMessageType().equals( DMNMessageType.REQ_NOT_FOUND ) )).isEqualTo(Boolean.TRUE); } - - @Test - public void testUnionofLetters() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void unionofLetters(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Union_of_letters.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_76362694-41e8-400c-8dea-e5f033d4f405", @@ -1091,23 +1185,29 @@ public void testUnionofLetters() { assertThat( dmnResult2.getMessages().stream().anyMatch( m -> m.getMessageType().equals( DMNMessageType.ERROR_EVAL_NODE ) )).isTrue(); } - @Test - public void testUnknownVariable1() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void unknownVariable1(VariantTestConf conf) { + testConfig = conf; final List messages = DMNRuntimeUtil.createExpectingDMNMessages("unknown_variable1.dmn", this.getClass()); assertThat(messages.stream().filter(m -> m.getMessageType().equals(DMNMessageType.ERR_COMPILING_FEEL)) .filter(m -> m.getMessage().contains("Unknown variable 'NonSalaryPct'")) .count()).isEqualTo(1); } - @Test - public void testUnknownVariable2() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void unknownVariable2(VariantTestConf conf) { + testConfig = conf; final List messages = DMNRuntimeUtil.createExpectingDMNMessages("unknown_variable2.dmn", this.getClass()); assertThat(messages.get(0).getMessageType()).isEqualTo(DMNMessageType.ERR_COMPILING_FEEL); assertThat(messages.get(0).getMessage()).containsSequence("Unknown variable 'Borrower.liquidAssetsAmt'"); } - @Test - public void testSingleDecisionWithContext() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void singleDecisionWithContext(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("SingleDecisionWithContext.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_71af58db-e1df-4b0f-aee2-48e0e8d89672", @@ -1123,8 +1223,10 @@ public void testSingleDecisionWithContext() { assertThat( result.get( "MyDecision" )).isEqualTo("Hello John Doe" ); } - @Test - public void testEx_6_1() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void ex61(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Ex_6_1.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_5f1269c8-1e6f-4748-9eca-26aa1b1278ef", @@ -1158,9 +1260,11 @@ public void testEx_6_1() { assertThat( result.get( "Number of teams" )).isEqualTo(new BigDecimal(2) ); assertThat( result.get( "Sum of bonus points" )).isEqualTo(new BigDecimal(47) ); } - - @Test - public void testSingletonlist_function_call() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void singletonlistFunctionCall(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("singletonlist_fuction_call.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_0768879b-5ee1-410f-92f0-7732573b069d", @@ -1187,8 +1291,10 @@ public void testSingletonlist_function_call() { ); } - @Test - public void testJavaFunctionContext() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void javaFunctionContext(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("java_function_context.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/dmn/definitions/_b42317c4-4f0c-474e-a0bf-2895b0b3c314", @@ -1205,9 +1311,11 @@ public void testJavaFunctionContext() { assertThat( ((BigDecimal) result.get( "D1" )).setScale( 4, BigDecimal.ROUND_HALF_UP )).isEqualTo(new BigDecimal( "-1.0000" ) ); assertThat( ((BigDecimal) result.get( "D2" )).setScale( 4, BigDecimal.ROUND_HALF_UP )).isEqualTo(new BigDecimal( "-1.0000" ) ); } - - @Test - public void testJavaFunctionContext_withErrors() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void javaFunctionContextWithErrors(VariantTestConf conf) { + testConfig = conf; // DROOLS-1568 final List messages = DMNRuntimeUtil.createExpectingDMNMessages("java_function_context_with_errors.dmn", this.getClass()); assertThat(messages).hasSize(1); @@ -1216,9 +1324,11 @@ public void testJavaFunctionContext_withErrors() { // FEEL FuncDefNode not checked at compile time: assertTrue( sourceIDs.contains( "_a72a7aff-48c3-4806-83ca-fc1f1fe34320") ); assertThat(sourceIDs).contains("_a72a7aff-48c3-4806-83ca-fc1f1fe34321"); } - - @Test - public void test_countCSATradeRatings() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void count_csatrade_ratings(VariantTestConf conf) { + testConfig = conf; // DROOLS-1563 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("countCSATradeRatings.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1251,9 +1361,11 @@ public void test_countCSATradeRatings() { assertThat(dmnResult3.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult3.getMessages())).isTrue(); assertThat(dmnResult3.getMessages().stream().anyMatch( m -> m.getMessageType().equals( DMNMessageType.REQ_NOT_FOUND ))).isTrue(); } - - @Test - public void testForLoopTypeCheck() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void forLoopTypeCheck(VariantTestConf conf) { + testConfig = conf; // DROOLS-1580 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("PersonListHelloBKM.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1275,9 +1387,11 @@ public void testForLoopTypeCheck() { assertThat( (List)result.get("My Decision")).asList().contains( "The person named John Doe is 33 years old.", "The person named 47 is 47 years old."); } - - @Test - public void testTypeInferenceForNestedContextAnonymousEntry() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void typeInferenceForNestedContextAnonymousEntry(VariantTestConf conf) { + testConfig = conf; // DROOLS-1585 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("PersonListHelloBKM2.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1301,8 +1415,10 @@ public void testTypeInferenceForNestedContextAnonymousEntry() { ); } - @Test - public void testSameEveryTypeCheck() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void sameEveryTypeCheck(VariantTestConf conf) { + testConfig = conf; // DROOLS-1587 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("same_every_type_check.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( @@ -1324,8 +1440,10 @@ public void testSameEveryTypeCheck() { assertThat( result.get("Every are negative")).isEqualTo(Boolean.FALSE); } - @Test - public void testDateAllowedValues() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dateAllowedValues(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("date_allowed_values.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_fbf002a3-615b-4f02-98e4-c28d4676225a", @@ -1345,9 +1463,11 @@ public void testDateAllowedValues() { assertThat( (Map) result.get( "Decision Logic 1" )).containsEntry("years and months", duration); assertThat( (Map) result.get( "Decision Logic 1" )).containsEntry("Date Time", dateTime); } - - @Test - public void testArtificialAttributes() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void artificialAttributes(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string-artificial-attributes.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools", "0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -1364,9 +1484,11 @@ public void testArtificialAttributes() { assertThat( result.get( "Greeting Message" )).isEqualTo("Hello John Doe" ); } - - @Test - public void testInvokeFunctionSuccess() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invokeFunctionSuccess(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Caller.dmn", this.getClass(), "Calling.dmn" ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b0a696d6-3d57-4e97-b5d4-b44a63909d67", "Caller" ); assertThat(dmnModel).isNotNull(); @@ -1385,8 +1507,10 @@ public void testInvokeFunctionSuccess() { assertThat( result.get("Final decision")).isEqualTo("The final decision is: Hello, John Doe your number once double is equal to: 6"); } - @Test - public void testInvokeFunctionWrongNamespace() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invokeFunctionWrongNamespace(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Caller.dmn", this.getClass(), "Calling.dmn" ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b0a696d6-3d57-4e97-b5d4-b44a63909d67", "Caller" ); assertThat(dmnModel).isNotNull(); @@ -1404,8 +1528,10 @@ public void testInvokeFunctionWrongNamespace() { assertThat(dmnResult.getMessages()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).hasSize(2); } - @Test - public void testInvokeFunctionWrongDecisionName() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invokeFunctionWrongDecisionName(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Caller.dmn", this.getClass(), "Calling.dmn" ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b0a696d6-3d57-4e97-b5d4-b44a63909d67", "Caller" ); assertThat(dmnModel).isNotNull(); @@ -1423,8 +1549,10 @@ public void testInvokeFunctionWrongDecisionName() { assertThat(dmnResult.getMessages()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).hasSize(2); } - @Test - public void testInvokeFunctionCallerError() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invokeFunctionCallerError(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Caller.dmn", this.getClass(), "Calling.dmn" ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b0a696d6-3d57-4e97-b5d4-b44a63909d67", "Caller" ); @@ -1444,8 +1572,10 @@ public void testInvokeFunctionCallerError() { assertThat(dmnResult.getMessages()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).hasSize(2); } - @Test - public void testInvalidFunction() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidFunction(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources( "InvalidFunction.dmn", this.getClass() ); final DMNModel model = runtime.getModel( "http://www.trisotech.com/definitions/_84453b71-5d23-479f-9481-5196d92bacae", "0003-iteration-augmented" ); assertThat(model).isNotNull(); @@ -1473,8 +1603,10 @@ private DecisionNodeImpl buildSimplifiedDecisionNode(final Definitions def, fina return new DecisionNodeImpl(def.getDrgElement().stream().filter(drg -> drg.getName().equals(name)).filter(Decision.class::isInstance).map(Decision.class::cast).findFirst().get()); } - @Test - public void testCycleDetection() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void cycleDetection(VariantTestConf conf) { + testConfig = conf; final Definitions defs = buildSimplifiedDefinitions("ns", "a", "b"); final DecisionNodeImpl a = buildSimplifiedDecisionNode(defs, "a"); final DecisionNodeImpl b = buildSimplifiedDecisionNode(defs, "b"); @@ -1489,8 +1621,10 @@ public void testCycleDetection() { assertThat(result.hasErrors()).isTrue(); } - @Test - public void testCycleDetectionSelfReference() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void cycleDetectionSelfReference(VariantTestConf conf) { + testConfig = conf; final Definitions defs = buildSimplifiedDefinitions("ns", "self"); final DecisionNodeImpl decision = buildSimplifiedDecisionNode(defs, "self"); decision.addDependency("self", decision); @@ -1502,8 +1636,10 @@ public void testCycleDetectionSelfReference() { assertThat(result.hasErrors()).isTrue(); } - @Test - public void testSharedDependency() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void sharedDependency(VariantTestConf conf) { + testConfig = conf; final Definitions defs = buildSimplifiedDefinitions("ns", "a", "b", "c"); final DecisionNodeImpl a = buildSimplifiedDecisionNode(defs, "a"); final DecisionNodeImpl b = buildSimplifiedDecisionNode(defs, "b"); @@ -1520,8 +1656,10 @@ public void testSharedDependency() { assertThat(result.hasErrors()).isFalse(); } - @Test - public void testCycleDetectionDeadlyDiamond() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void cycleDetectionDeadlyDiamond(VariantTestConf conf) { + testConfig = conf; final Definitions defs = buildSimplifiedDefinitions("ns", "a", "b", "c", "d"); final DecisionNodeImpl a = buildSimplifiedDecisionNode(defs, "a"); final DecisionNodeImpl b = buildSimplifiedDecisionNode(defs, "b"); @@ -1542,8 +1680,10 @@ public void testCycleDetectionDeadlyDiamond() { assertThat(result.hasErrors()).isFalse(); } - @Test - public void testEx_4_3simplified() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void ex43simplified(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Ex_4_3simplified.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_5c5a9c72-627e-4666-ae85-31356fed3658", "Ex_4_3simplified"); assertThat(dmnModel).isNotNull(); @@ -1561,8 +1701,10 @@ public void testEx_4_3simplified() { assertThat(result.get("Formatted Monthly Payment")).isEqualTo("€123.12"); } - @Test - public void testEx_4_3simplifiedASD() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void ex43simplifiedASD(VariantTestConf conf) { + testConfig = conf; // DROOLS-2117 improve Msg.ERROR_EVAL_NODE_DEP_WRONG_TYPE final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Ex_4_3simplified.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_5c5a9c72-627e-4666-ae85-31356fed3658", "Ex_4_3simplified"); @@ -1582,8 +1724,10 @@ public void testEx_4_3simplifiedASD() { assertThat(dmnResult.getMessages().stream().filter(m -> m.getMessageType() == DMNMessageType.ERROR_EVAL_NODE).anyMatch(m -> m.getMessage().endsWith("is not allowed by the declared type (DMNType{ http://www.omg.org/spec/FEEL/20140401 : number })"))).isTrue(); } - @Test - public void testDrools2125() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void drools2125(VariantTestConf conf) { + testConfig = conf; // DROOLS-2125 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("drools2125.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_9f976b29-4cdd-42e9-8737-0ccbc2ad9498", "drools2125"); @@ -1605,8 +1749,10 @@ public void testDrools2125() { assertThat(result.get("person is person")).isEqualTo("yes"); } - @Test - public void testDROOLS2147() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void drools2147(VariantTestConf conf) { + testConfig = conf; // DROOLS-2147 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DROOLS-2147.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_cbdacb7b-f72d-457d-b4f4-54020a06db24", "Drawing 1"); @@ -1630,8 +1776,10 @@ public void testDROOLS2147() { assertThat(((List) peopleGroups.get(2))).hasSize(2); } - @Test - public void testDROOLS2147_message() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void drools2147Message(VariantTestConf conf) { + testConfig = conf; // DROOLS-2147 truncate message length final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Ex_4_3simplified.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_5c5a9c72-627e-4666-ae85-31356fed3658", "Ex_4_3simplified"); @@ -1652,8 +1800,10 @@ public void testDROOLS2147_message() { assertThat(dmnResult.getMessages().stream().filter(m -> m.getMessageType() == DMNMessageType.ERROR_EVAL_NODE).anyMatch(m -> m.getMessage().contains("... [string clipped after 50 chars, total length is"))).isTrue(); } - @Test - public void testDROOLS2192() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void drools2192(VariantTestConf conf) { + testConfig = conf; // DROOLS-2192 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("hardcoded_function_definition.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_99854980-65c8-4e9b-b365-bd30ded69f40", "hardcoded_function_definition"); @@ -1669,8 +1819,10 @@ public void testDROOLS2192() { assertThat(((BigDecimal) resultContext.get("hardcoded decision")).intValue()).isEqualTo(47); } - @Test - public void testDROOLS2200() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void drools2200(VariantTestConf conf) { + testConfig = conf; // DROOLS-2200 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("will_be_null_if_negative.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_c5889555-7ae5-4a67-a872-3a9492caf6e7", "will be null if negative"); @@ -1688,8 +1840,10 @@ public void testDROOLS2200() { assertThat(((Map) resultContext.get("will be null if negative")).get("s2")).isEqualTo("negative"); } - @Test - public void testDROOLS2201() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void drools2201(VariantTestConf conf) { + testConfig = conf; // DROOLS-2201 // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieServices ks = KieServices.Factory.get(); @@ -1711,8 +1865,10 @@ public void testDROOLS2201() { assertThat(((Map) resultContext.get("an hardcoded person with no name"))).containsKeys("age"); } - @Test - public void testDROOLS2201b() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void drools2201b(VariantTestConf conf) { + testConfig = conf; // DROOLS-2201 // do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime. final KieServices ks = KieServices.Factory.get(); @@ -1753,8 +1909,10 @@ public String getSurname() { } - @Test - public void testDROOLS2286() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void drools2286(VariantTestConf conf) { + testConfig = conf; // DROOLS-2286 final DROOLS2286 johnCena = new DROOLS2286("John", "Cena"); final DROOLS2286 leslieBrown = new DROOLS2286("Leslie", "Brown"); @@ -1770,8 +1928,10 @@ public void testDROOLS2286() { assertDROOLS2286(context); } - @Test - public void testDROOLS2286bis() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void drools2286bis(VariantTestConf conf) { + testConfig = conf; // DROOLS-2286 (map case) final Map johnCena = prototype(entry("name", "John"), entry("surname", "Cena")); final Map leslieBrown = prototype(entry("name", "Leslie"), entry("surname", "Brown")); @@ -1797,8 +1957,10 @@ private void assertDROOLS2286(final DMNContext context) { assertThat(resultObject).hasSize(2); } - @Test - public void testVerifyExtendedKieFEELFunction_now() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void verifyExtendedKieFEELFunctionNow(VariantTestConf conf) { + testConfig = conf; // DROOLS-2322 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("just_now.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_56fd6445-ff6a-4c28-8206-71fce7f80436", "just now"); @@ -1813,8 +1975,10 @@ public void testVerifyExtendedKieFEELFunction_now() { assertThat(dmnResult.getDecisionResultByName("a decision just now").getResult()).isNotNull(); } - @Test - public void testVerifyExtendedKieFEELFunction_today() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void verifyExtendedKieFEELFunctionToday(VariantTestConf conf) { + testConfig = conf; // DROOLS-2322 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("just_today.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_56fd6445-ff6a-4c28-8206-71fce7f80436", "just today"); @@ -1829,8 +1993,10 @@ public void testVerifyExtendedKieFEELFunction_today() { assertThat(dmnResult.getDecisionResultByName("a decision just today").getResult()).isNotNull(); } - @Test - public void testEnhancedForLoop() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void enhancedForLoop(VariantTestConf conf) { + testConfig = conf; // DROOLS-2307 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("drools2307.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_03d9481e-dcfc-4a59-9bdd-4f021cb2f0d8", "Drawing 1"); @@ -1846,8 +2012,10 @@ public void testEnhancedForLoop() { assertThat(result.get("an hardcoded forloop")).asList().containsExactly(new BigDecimal(2), new BigDecimal(3), new BigDecimal(4)); } - @Test - public void testList_of_Vowels() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void listOfVowels(VariantTestConf conf) { + testConfig = conf; // DROOLS-2357 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("List_of_Vowels.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_c5f007ce-4d45-4aac-8729-991d4abc7826", "List of Vowels"); @@ -1867,8 +2035,10 @@ public void testList_of_Vowels() { assertThat(result.get("Decide BAD")).isNull(); } - @Test - public void testEnhancedForLoop2() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void enhancedForLoop2(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("MACD-enhanced_iteration.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6cfe7d88-6741-45d1-968c-b61a597d0964", "MACD-enhanced iteration"); assertThat(dmnModel).isNotNull(); @@ -1890,8 +2060,10 @@ public void testEnhancedForLoop2() { assertThat(((Map) ((List) resultContext.get("MACDTable")).get(2)).get("aDate")).isEqualTo(LocalDate.of(2018, 3, 7)); } - @Test - public void testNotListInDT() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void notListInDT(VariantTestConf conf) { + testConfig = conf; // DROOLS-2416 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("anot.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_292c1c7b-6b38-415d-938f-e9ca51d30b2b", "anot"); @@ -1908,8 +2080,10 @@ public void testNotListInDT() { assertThat(result.get("what letter decision")).isEqualTo("vowel"); } - @Test - public void testListContainmentDT() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void listContainmentDT(VariantTestConf conf) { + testConfig = conf; // DROOLS-2416 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("list_containment_DT.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6ab2bd6d-adaa-45c4-a141-a84382a201eb", "list containment DT"); @@ -1926,8 +2100,10 @@ public void testListContainmentDT() { assertThat(result.get("Boarding Status")).isEqualTo("Denied"); } - @Test - public void testRelationwithemptycell() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void relationwithemptycell(VariantTestConf conf) { + testConfig = conf; // DROOLS-2439 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("relation_with_empty_cell.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_99a00903-2943-47df-bab1-a32f276617ea", "Relation with empty cell"); @@ -1947,8 +2123,10 @@ public void testRelationwithemptycell() { prototype(entry("name", "Matteo"), entry("age", null))); } - @Test - public void testFor() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void testFor(VariantTestConf conf) { + testConfig = conf; // DROOLS-2317 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Dynamic composition.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_c2d86765-c3c7-4e1d-b1fa-b830fa5bc529", "Dynamic composition"); @@ -1956,8 +2134,10 @@ public void testFor() { assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); } - @Test - public void testUsingReusableKeywordAsPartOfBKMName() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void usingReusableKeywordAsPartOfBKMName(VariantTestConf conf) { + testConfig = conf; // DROOLS-2317 FEEL Syntax error on function(bkm) containing `for` keyword final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("say_for_hello.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_b6f2a9ca-a246-4f27-896a-e8ef04ea439c", "say for hello"); @@ -1973,8 +2153,10 @@ public void testUsingReusableKeywordAsPartOfBKMName() { assertThat(result.get("just say")).asList().containsExactly("Hello", "Hello", "Hello"); } - @Test - public void testProductFunction() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void productFunction(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("product.dmn", this.getClass() ); final DMNModel model = runtime.getModel("http://www.trisotech.com/dmn/definitions/_40fdbc2c-a631-4ba4-8435-17571b5d1942", "Drawing 1" ); assertThat(model).isNotNull(); @@ -1989,8 +2171,10 @@ public void testProductFunction() { assertThat(result.getResult()).isEqualTo("This is product 1"); } - @Test - public void testNotWithPredicates20180601() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void notWithPredicates20180601(VariantTestConf conf) { + testConfig = conf; // DROOLS-2605 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("test20180601.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_9b8f2642-2597-4a99-9fcd-f9302692d3dc", "Drawing 1"); @@ -2012,8 +2196,10 @@ public void testNotWithPredicates20180601() { assertThat(dmnResult10.getDecisionResultByName("my decision").getResult()).isEqualTo(Boolean.TRUE); } - @Test - public void testNotWithPredicates20180601b() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void notWithPredicates20180601b(VariantTestConf conf) { + testConfig = conf; // DROOLS-2605 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("BruceTask20180601.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_3802fcb2-5b93-4502-aff4-0f5c61244eab", "Bruce Task"); @@ -2058,9 +2244,11 @@ public void testNotWithPredicates20180601b() { assertThat(((List) bruce.get("six")).stream().anyMatch(e -> ((Map) e).get("Title").equals("85"))).isTrue(); assertThat(((List) bruce.get("six")).stream().anyMatch(e -> ((Map) e).get("Title").equals("66"))).isTrue(); } - - @Test - public void testModelById() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void modelById(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModelById("https://github.com/kiegroup/kie-dmn/itemdef", "_simple-item-def" ); assertThat(dmnModel).isNotNull(); @@ -2068,8 +2256,10 @@ public void testModelById() { } - @Test - public void testWeekdayOnDateDMN12() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void weekdayOnDateDMN12(VariantTestConf conf) { + testConfig = conf; // DROOLS-2648 DMN v1.2 weekday on 'date', 'date and time' final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("weekday-on-date.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_55a2dafd-ab4d-4154-bace-826d426da251", "weekday on date"); @@ -2089,8 +2279,10 @@ public void testWeekdayOnDateDMN12() { } } - @Test - public void testDMN_Vs_FEEL_instanceof_interaction() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dmn_VsFEELInstanceofInteraction(VariantTestConf conf) { + testConfig = conf; // DROOLS-2665 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Instance_of.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_b5c4d644-5a15-4528-8028-86537cb1c836", "Instance of"); @@ -2114,8 +2306,10 @@ public void testDMN_Vs_FEEL_instanceof_interaction() { assertThat(result.get("Decision Logic 4")).isEqualTo(Boolean.TRUE); } - @Test - public void testInvokingAFunctionOnALiteralContext() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invokingAFunctionOnALiteralContext(VariantTestConf conf) { + testConfig = conf; // DROOLS-2732 FEEL invoking a function on a literal context final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("invokingAFunctionOnALiteralContext.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_781968dd-64dc-4231-9cd0-2ce590881f2c", "Drawing 1"); @@ -2132,16 +2326,20 @@ public void testInvokingAFunctionOnALiteralContext() { assertThat(result.get("invoking a function on a literal context")).isEqualTo(new BigDecimal(3)); } - @Test - public void testBoxedInvocationMissingExpression() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void boxedInvocationMissingExpression(VariantTestConf conf) { + testConfig = conf; // DROOLS-2813 DMN boxed invocation missing expression NPE and Validator issue final List messages = DMNRuntimeUtil.createExpectingDMNMessages("DROOLS-2813-NPE-BoxedInvocationMissingExpression.dmn", this.getClass()); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_EXPRESSION) && p.getSourceId().equals("_a111c4df-c5b5-4d84-81e7-3ec735b50d06"))).isTrue(); } - @Test - public void testNotHeuristicForFunctionInvocation() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void notHeuristicForFunctionInvocation(VariantTestConf conf) { + testConfig = conf; // DROOLS-2822 FEEL augment not() heuristic for function invocation final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Not-heuristic-for-function-invocation-drools-2822.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_82f7e67e-0a8c-492d-aa78-94851c10eee6", "Drawing 1"); @@ -2157,9 +2355,12 @@ public void testNotHeuristicForFunctionInvocation() { final DMNContext result = dmnResult.getContext(); assertThat(result.get("Not working")).isEqualTo(Boolean.FALSE); } - - @Test(timeout = 30_000L) - public void testAccessorCache() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + @Timeout(value = 30_000L, unit = TimeUnit.MILLISECONDS) + void accessorCache(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("20180731-pr1997.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_7a39d775-bce9-45e3-aa3b-147d6f0028c7", "20180731-pr1997"); assertThat(dmnModel).isNotNull(); @@ -2178,8 +2379,10 @@ public void testAccessorCache() { } } - @Test - public void testWrongTypeRefForDRGElement() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void wrongTypeRefForDRGElement(VariantTestConf conf) { + testConfig = conf; // DROOLS-2917 DMN resolveTypeRef returning null in BKM causes NPE during KieContainer compilation final List messages = DMNRuntimeUtil.createExpectingDMNMessages("WrongTypeRefForDRGElement.dmn", this.getClass()); DMNRuntimeUtil.formatMessages(messages); @@ -2189,8 +2392,10 @@ public void testWrongTypeRefForDRGElement() { assertThat(messages.stream().anyMatch(m -> m.getSourceId().equals("_45fa8674-f4f0-4c06-b2fd-52bbd17d8550"))).isTrue(); } - @Test - public void testDecisionTableInputClauseImportingItemDefinition() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionTableInputClauseImportingItemDefinition(VariantTestConf conf) { + testConfig = conf; // DROOLS-2927 DMN DecisionTable inputClause importing ItemDefinition throws NPE at compilation final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("imports/Imported_Model.dmn", this.getClass(), @@ -2211,8 +2416,10 @@ public void testDecisionTableInputClauseImportingItemDefinition() { assertThat(result.get("A Decision Table")).isEqualTo("NOT Allowed"); } - @Test - public void testAssignNullToAllowedValues() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void assignNullToAllowedValues(VariantTestConf conf) { + testConfig = conf; // DROOLS-3132 DMN assign null to ItemDefinition with allowedValues final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("assignNullToAllowedValues.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_700a46e0-01ed-4361-9034-4afdb2537ea4", "Drawing 1"); @@ -2229,8 +2436,10 @@ public void testAssignNullToAllowedValues() { assertThat(dmnResult.getMessages().stream().anyMatch(m -> m.getSourceId().equals("_09945fda-2b89-4148-8758-0bcb91a66e4a"))).isTrue(); } - @Test - public void testAssignNullToAllowedValuesExplicitingNull() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void assignNullToAllowedValuesExplicitingNull(VariantTestConf conf) { + testConfig = conf; // DROOLS-3132 DMN assign null to ItemDefinition with allowedValues final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("assignNullToAllowedValuesExplicitingNull.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_700a46e0-01ed-4361-9034-4afdb2537ea4", "Drawing 1"); @@ -2248,8 +2457,10 @@ public void testAssignNullToAllowedValuesExplicitingNull() { assertThat(dmnResult.getDecisionResultByName("decision over the input letter").getResult()).isNull(); } - @Test - public void testGetEntries() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void getEntries(VariantTestConf conf) { + testConfig = conf; // DROOLS-3308 DMN implement missing functions only described in chapter "10.3.2.6 Context" final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("getentriesgetvalue.dmn", this.getClass()); final DMNModel dmnModel = getAndAssertModelNoErrors(runtime, "http://www.trisotech.com/dmn/definitions/_0fad1a80-0642-4278-ac3d-47668c4f689a", "Drawing 1"); @@ -2262,8 +2473,10 @@ public void testGetEntries() { assertThat(dmnResult.getDecisionResultByName("using get entries").getResult()).asList().containsExactly("value2"); } - @Test - public void testGetValue() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void getValue(VariantTestConf conf) { + testConfig = conf; // DROOLS-3308 DMN implement missing functions only described in chapter "10.3.2.6 Context" final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("getentriesgetvalue.dmn", this.getClass()); final DMNModel dmnModel = getAndAssertModelNoErrors(runtime, "http://www.trisotech.com/dmn/definitions/_0fad1a80-0642-4278-ac3d-47668c4f689a", "Drawing 1"); @@ -2276,14 +2489,18 @@ public void testGetValue() { assertThat(dmnResult.getDecisionResultByName("using get value").getResult()).isEqualTo("value2"); } - @Test - public void testDTinputExprCollectionWithAllowedValuesA() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dTinputExprCollectionWithAllowedValuesA(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DROOLS-4379.dmn", this.getClass()); testDTinputExprCollectionWithAllowedValues(runtime); } - @Test - public void testDTinputExprCollectionWithAllowedValuesB() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dTinputExprCollectionWithAllowedValuesB(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DROOLS-4379b.dmn", this.getClass()); testDTinputExprCollectionWithAllowedValues(runtime); } @@ -2305,36 +2522,48 @@ private void testDTinputExprCollectionWithAllowedValues(final DMNRuntime runtime assertThat((List) result.get("D5")).asList().contains("r1", "r2"); } - @Test(expected = IllegalArgumentException.class) - public void testEvaluateByNameWithEmptyParam() { - final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass()); - final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item-def"); - assertThat(dmnModel).isNotNull(); - assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void evaluateByNameWithEmptyParam(VariantTestConf conf) { + testConfig = conf; + assertThrows(IllegalArgumentException.class, () -> { + final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass()); + final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item" + + "-def"); + assertThat(dmnModel).isNotNull(); + assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); - final DMNContext context = DMNFactory.newContext(); - context.set("Monthly Salary", 1000); + final DMNContext context = DMNFactory.newContext(); + context.set("Monthly Salary", 1000); - String[] decisionNames = new String[]{}; - runtime.evaluateByName(dmnModel, context, decisionNames); + String[] decisionNames = new String[]{}; + runtime.evaluateByName(dmnModel, context, decisionNames); + }); } - @Test(expected = IllegalArgumentException.class) - public void testEvaluateByIdWithEmptyParam() { - final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass()); - final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item-def"); - assertThat(dmnModel).isNotNull(); - assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void evaluateByIdWithEmptyParam(VariantTestConf conf) { + testConfig = conf; + assertThrows(IllegalArgumentException.class, () -> { + final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass()); + final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item" + + "-def"); + assertThat(dmnModel).isNotNull(); + assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); - final DMNContext context = DMNFactory.newContext(); - context.set("Monthly Salary", 1000); + final DMNContext context = DMNFactory.newContext(); + context.set("Monthly Salary", 1000); - String[] decisionIds = new String[]{}; - runtime.evaluateById(dmnModel, context, decisionIds); + String[] decisionIds = new String[]{}; + runtime.evaluateById(dmnModel, context, decisionIds); + }); } - @Test - public void testUniqueMissingMatchDefaultEmpty() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void uniqueMissingMatchDefaultEmpty(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("uniqueNoMatch.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://activiti.org/schema/1.0/dmn", "decisionmulti"); assertThat(dmnModel).isNotNull(); diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/FlightRebookingTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/FlightRebookingTest.java index fd5488c19f0..c6d7472fcfc 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/FlightRebookingTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/FlightRebookingTest.java @@ -25,7 +25,8 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNDecisionResult; import org.kie.dmn.api.core.DMNModel; @@ -38,12 +39,10 @@ public class FlightRebookingTest extends BaseDMN1_1VariantTest { - public FlightRebookingTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testSolution1() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + public void testSolution1(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn", "0019-flight-rebooking" ); assertThat(dmnModel).isNotNull(); @@ -64,8 +63,10 @@ public void testSolution1() { assertThat(result.get("Rebooked Passengers")).isEqualTo(loadExpectedResult()); } - @Test - public void testSolutionAlternate() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionAlternate(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking-alternative.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn", "0019-flight-rebooking" ); assertThat(dmnModel).isNotNull(); @@ -86,8 +87,10 @@ public void testSolutionAlternate() { assertThat(result.get("Rebooked Passengers")).isEqualTo(loadExpectedResult()); } - @Test - public void testSolutionSingletonLists() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionSingletonLists(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking-singleton-lists.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn", "0019-flight-rebooking" ); assertThat(dmnModel).isNotNull(); @@ -108,8 +111,10 @@ public void testSolutionSingletonLists() { assertThat(result.get("Rebooked Passengers")).isEqualTo(loadExpectedResult()); } - @Test - public void testSolutionBadExample() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionBadExample(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking-bad-example.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("https://www.drools.org/kie-dmn", "0019-flight-rebooking" ); assertThat(dmnModel).isNotNull(); @@ -130,8 +135,10 @@ public void testSolutionBadExample() { assertThat(result.get("Rebooked Passengers")).isEqualTo(loadExpectedResult()); } - @Test - public void testUninterpreted() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void uninterpreted(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0019-flight-rebooking-uninterpreted.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_188d6caf-a355-49b5-a692-bd6ce713da08", "0019-flight-rebooking" ); runtime.addListener( DMNRuntimeUtil.createListener() ); diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/OnlineDatingTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/OnlineDatingTest.java index 072df26ce6b..b8ea40d16eb 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/OnlineDatingTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/OnlineDatingTest.java @@ -25,7 +25,8 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -34,12 +35,10 @@ public class OnlineDatingTest extends BaseDMN1_1VariantTest { - public OnlineDatingTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testDMChallengeMarch2017() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dMChallengeMarch2017(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("dmcommunity_challenge_2017_03.dmn", this.getClass() ); final DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_1b5a3a8f-ccf0-459b-8783-38601977e828", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/VacationDaysTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/VacationDaysTest.java index 96362b9bd57..42a611f0f8a 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/VacationDaysTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/VacationDaysTest.java @@ -20,7 +20,8 @@ import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -32,42 +33,45 @@ public class VacationDaysTest extends BaseDMN1_1VariantTest { - public VacationDaysTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testSolutionCase1() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionCase1() { executeTest( 16, 1, 27 ); } - @Test - public void testSolutionCase2() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionCase2() { executeTest( 25, 5, 22 ); } - @Test - public void testSolutionCase3() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionCase3() { executeTest( 44, 20, 24 ); } - @Test - public void testSolutionCase4() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionCase4() { executeTest( 44, 30, 30 ); } - @Test - public void testSolutionCase5() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionCase5() { executeTest( 50, 20, 24 ); } - @Test - public void testSolutionCase6() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionCase6() { executeTest( 50, 30, 30 ); } - @Test - public void testSolutionCase7() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void solutionCase7() { executeTest( 60, 20, 30 ); } diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/decisionservices/DMNDecisionServicesTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/decisionservices/DMNDecisionServicesTest.java index 2832ad4c96b..53d8934e1e1 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/decisionservices/DMNDecisionServicesTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/decisionservices/DMNDecisionServicesTest.java @@ -21,7 +21,9 @@ import java.math.BigDecimal; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.builder.Message.Level; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; @@ -40,12 +42,11 @@ public class DMNDecisionServicesTest extends BaseDMN1_1VariantTest { public static final Logger LOG = LoggerFactory.getLogger(DMNDecisionServicesTest.class); - public DMNDecisionServicesTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testBasic() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void basic(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-decision-services.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -102,8 +103,10 @@ private void checkDSwithInputDecision2(final DMNRuntime runtime, final DMNModel assertThat(result.get("A")).isEqualTo("inBinC"); } - @Test - public void testDSInLiteralExpression() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dSInLiteralExpression(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServicesInLiteralExpression.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -122,8 +125,10 @@ public void testDSInLiteralExpression() { assertThat(result.get("Decide based on A and DS")).isEqualTo("xyde"); } - @Test - public void testDSInLiteralExpressionWithBKM() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dSInLiteralExpressionWithBKM(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServicesInLiteralExpressionWithBKM.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -142,8 +147,10 @@ public void testDSInLiteralExpressionWithBKM() { assertThat(result.get("Decide based on A and DS")).isEqualTo("xydemn"); } - @Test - public void testDSInLiteralExpressionWithBKMUsingInvocation() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dSInLiteralExpressionWithBKMUsingInvocation(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServicesInLiteralExpressionWithBKMUsingInvocation.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -162,8 +169,10 @@ public void testDSInLiteralExpressionWithBKMUsingInvocation() { assertThat(result.get("Decide based on A and DS")).isEqualTo("xydemn"); } - @Test - public void testDSInLiteralExpressionOnlyfromBKMUsingInvocation() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dSInLiteralExpressionOnlyfromBKMUsingInvocation(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServicesInLiteralExpressionOnlyFromBKMUsingInvocation.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_686f58d4-4ec3-4c65-8c06-0e4fd8983def", "Decision Services"); assertThat(dmnModel).isNotNull(); @@ -182,8 +191,10 @@ public void testDSInLiteralExpressionOnlyfromBKMUsingInvocation() { assertThat(result.get("Decide based on A and DS")).isEqualTo("demn"); } - @Test - public void testMixtypeDS() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void mixtypeDS(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("mixtype-DS.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_c9885563-aa54-4c7b-ae8a-738cfd29b544", "mixtype DS"); assertThat(dmnModel).isNotNull(); @@ -275,8 +286,10 @@ private void testMixtypeDS_checkDSgreetadult(final DMNRuntime runtime, final DMN assertThat(result.getAll()).doesNotContainKey("hardcoded now"); } - @Test - public void testDSForTypeCheck() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dSForTypeCheck(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionService20180718.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_6eef3a7c-bb0d-40bb-858d-f9067789c18a", "Decision Service 20180718"); assertThat(dmnModel).isNotNull(); @@ -343,8 +356,10 @@ private void testDSForTypeCheck_runDecisionService_WithWrongTypes(final DMNRunti .as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isTrue(); } - @Test - public void testDSSingletonOrMultipleOutputDecisions() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dSSingletonOrMultipleOutputDecisions(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Decision-Services-singleton-or-multiple-output-decisions.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_b4ebfbf2-8608-4297-9662-be70bab01974", "Decision Services singleton or multiple output decisions"); assertThat(dmnModel).isNotNull(); @@ -382,8 +397,10 @@ public void testDSSingletonOrMultipleOutputDecisions() { assertThat(dmnResultMultiple.getContext().getAll()).doesNotContainKey("a Value"); // Decision Service will not expose (nor encapsulate hence not execute) this decision. } - @Test - public void testDSSingletonOrMultipleOutputDecisions_OVERRIDE() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dSSingletonOrMultipleOutputDecisionsOVERRIDE(VariantTestConf conf) { + testConfig = conf; try { System.setProperty(CoerceDecisionServiceSingletonOutputOption.PROPERTY_NAME, "false"); final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Decision-Services-singleton-or-multiple-output-decisions.dmn", this.getClass()); @@ -430,8 +447,10 @@ public void testDSSingletonOrMultipleOutputDecisions_OVERRIDE() { } } - @Test - public void testImportDS() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void importDS(VariantTestConf conf) { + testConfig = conf; // DROOLS-2768 DMN Decision Service encapsulate Decision which imports a Decision Service final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("DecisionService20180718.dmn", this.getClass(), "ImportDecisionService20180718.dmn"); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_0ff3708a-c861-4a96-b85c-7b882f18b7a1", "Import Decision Service 20180718"); @@ -472,8 +491,10 @@ private void testImportDS_testEvaluateDS(final DMNRuntime runtime, final DMNMode assertThat(result.get("final Import L1 decision")).isEqualTo("Hello, L1 Import Evaluate DS NAME the result of invoking the imported DS is: Hello, L1 Import Evaluate DS NAME; you are allowed"); } - @Test - public void testTransitiveImportDS() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void transitiveImportDS(VariantTestConf conf) { + testConfig = conf; // DROOLS-2768 DMN Decision Service encapsulate Decision which imports a Decision Service final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("DecisionService20180718.dmn", this.getClass(), "ImportDecisionService20180718.dmn", @@ -514,8 +535,10 @@ private void testTransitiveImportDS_testEvaluateDS(final DMNRuntime runtime, fin assertThat(result.get("Final L2 Decision")).isEqualTo("The result of invoking the L1 DS was: Hello, L2 Bob DS the result of invoking the imported DS is: Hello, L2 Bob DS; you are allowed"); } - @Test - public void testDecisionServiceCompiler20180830() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void decisionServiceCompiler20180830(VariantTestConf conf) { + testConfig = conf; // DROOLS-2943 DMN DecisionServiceCompiler not correctly wired for DMNv1.2 format final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DecisionServiceABC.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_2443d3f5-f178-47c6-a0c9-b1fd1c933f60", "Drawing 1"); diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/imports/ImportsTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/imports/ImportsTest.java index 389b13e27c9..2123712873b 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/imports/ImportsTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/core/v1_1/imports/ImportsTest.java @@ -22,7 +22,9 @@ import java.util.Collections; import java.util.function.Function; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -42,12 +44,10 @@ public class ImportsTest extends BaseDMN1_1VariantTest { public static final Logger LOG = LoggerFactory.getLogger(ImportsTest.class); - public ImportsTest(VariantTestConf testConfig) { - super(testConfig); - } - - @Test - public void testImportDependenciesForDTInAContext() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void importDependenciesForDTInAContext(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Imported_Model.dmn", this.getClass(), "Import_BKM_and_have_a_Decision_Ctx_with_DT.dmn"); @@ -71,9 +71,11 @@ public void testImportDependenciesForDTInAContext() { LOG.debug("{}", evaluateAll); assertThat(evaluateAll.getDecisionResultByName("A Decision Ctx with DT").getResult()).isEqualTo("Respectfully, Hello John!"); } - - @Test - public void testImport2BKMs() { + + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void import2BKMs(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Do_say_hello_with_2_bkms.dmn", this.getClass(), "Saying_hello_2_bkms.dmn"); @@ -100,8 +102,10 @@ public void testImport2BKMs() { assertThat(evaluateAll.getDecisionResultByName("what about hello").getResult()).isEqualTo("Hello"); } - @Test - public void testImport2BKMsInvoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void import2BKMsInvoke(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Do_invoke_hello_with_2_bkms.dmn", this.getClass(), "Saying_hello_2_bkms.dmn"); @@ -125,8 +129,10 @@ public void testImport2BKMsInvoke() { assertThat(evaluateAll.getDecisionResultByName("invocation of hello").getResult()).isEqualTo("Hello, John"); } - @Test - public void testImport2BKMsInvokeUsingInputData() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void import2BKMsInvokeUsingInputData(VariantTestConf conf) { + testConfig = conf; // DROOLS-2746 DMN Invocation parameters resolution with imported function final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Do_invoke_hello_with_2_bkms_using_inputdata.dmn", this.getClass(), @@ -153,8 +159,10 @@ public void testImport2BKMsInvokeUsingInputData() { assertThat(evaluateAll.getDecisionResultByName("what about hello").getResult()).isEqualTo("Hello, Bob"); } - @Test - public void testImport3Levels() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void import3Levels(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("L3_Do_say_hello.dmn", this.getClass(), "Do_say_hello_with_2_bkms.dmn", @@ -192,8 +200,10 @@ public void testImport3Levels() { assertThat(evaluateAll.getDecisionResultByName("L3 what about hello").getResult()).isEqualTo("Hello"); } - @Test - public void testImportHardcodedDecisions() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void importHardcodedDecisions(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Spell_Greeting.dmn", this.getClass(), "Import_Spell_Greeting.dmn"); @@ -218,8 +228,10 @@ public void testImportHardcodedDecisions() { assertThat(evaluateAll.getDecisionResultByName("Say the Greeting to Person").getResult()).isEqualTo("Hello, John"); } - @Test - public void testImportTransitiveBaseModel() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void importTransitiveBaseModel(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), "ModelB.dmn", @@ -228,8 +240,10 @@ public void testImportTransitiveBaseModel() { getAndAssertModelNoErrors(runtime, "http://www.trisotech.com/dmn/definitions/_ae5b3c17-1ac3-4e1d-b4f9-2cf861aec6d9", "Say hello 1ID1D"); } - @Test - public void testImportTransitiveEvaluate2Layers() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void importTransitiveEvaluate2Layers(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), "ModelB.dmn", @@ -247,8 +261,10 @@ public void testImportTransitiveEvaluate2Layers() { assertThat(evaluateAll.getDecisionResultByName("Evaluating Say Hello").getResult()).isEqualTo("Evaluating Say Hello to: Hello, John"); } - @Test - public void testImportTransitiveEvaluate3Layers() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void importTransitiveEvaluate3Layers(VariantTestConf conf) { + testConfig = conf; final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), "ModelB.dmn", @@ -267,8 +283,10 @@ public void testImportTransitiveEvaluate3Layers() { assertThat(evaluateAll.getDecisionResultByName("Model C Decision based on Bs").getResult()).isEqualTo("B: Evaluating Say Hello to: Hello, B.A.John; B2:Evaluating Say Hello to: Hello, B2.A.John2"); } - @Test - public void testImportingID() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void importingID(VariantTestConf conf) { + testConfig = conf; // DROOLS-2944 DMN decision logic referencing DMN InputData final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), @@ -285,8 +303,10 @@ public void testImportingID() { assertThat(evaluateAll.getDecisionResultByName("Hello decision using imported InputData").getResult()).isEqualTo("Hello, DROOLS-2944"); } - @Test - public void testAllowDMNAPItoEvaluateDirectDependencyImportedDecisions() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void allowDMNAPItoEvaluateDirectDependencyImportedDecisions(VariantTestConf conf) { + testConfig = conf; // DROOLS-3012 Allow DMN API to evaluate direct-dependency imported Decisions final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), @@ -318,8 +338,10 @@ private void testAllowDMNAPItoEvaluateDirectDependencyImportedDecisions_evaluate assertThat(evaluateAll.getDecisionResultByName("modelA.Greet the Person").getResult()).isEqualTo("Hello, John"); } - @Test - public void testRetrieveDecisionByIDName() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void retrieveDecisionByIDName(VariantTestConf conf) { + testConfig = conf; // DROOLS-3026 final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), @@ -341,8 +363,10 @@ public void testRetrieveDecisionByIDName() { assertThat(dmnModel.getInputByName("modelA.Person name").getId()).isEqualTo("_4f6c136c-8512-4d71-8bbf-7c9eb6e74063"); // this is an imported InputData node. } - @Test - public void testImportChain() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void importChain(VariantTestConf conf) { + testConfig = conf; // DROOLS-3045 DMN model API to display namespace transitive import dependencies final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn", this.getClass(), diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorArtifactTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorArtifactTest.java index 4a620c6e467..73af0d29154 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorArtifactTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorArtifactTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorArtifactTest extends AbstractValidatorTest { +class ValidatorArtifactTest extends AbstractValidatorTest { @Test - public void testASSOC_REFERENCES_NOT_EMPTY_ReaderInput() throws IOException { + void assoc_references_not_empty_ReaderInput() throws IOException { try (final Reader reader = getReader( "artifact/ASSOC_REFERENCES_NOT_EMPTY.dmn" )) { final List validate = validator.validate( reader, @@ -47,7 +47,7 @@ public void testASSOC_REFERENCES_NOT_EMPTY_ReaderInput() throws IOException { } @Test - public void testASSOC_REFERENCES_NOT_EMPTY_FileInput() { + void assoc_references_not_empty_FileInput() { final List validate = validator.validate( getFile( "artifact/ASSOC_REFERENCES_NOT_EMPTY.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testASSOC_REFERENCES_NOT_EMPTY_FileInput() { } @Test - public void testASSOC_REFERENCES_NOT_EMPTY_DefinitionsInput() { + void assoc_references_not_empty_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "artifact/ASSOC_REFERENCES_NOT_EMPTY.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorAuthorityRequirementTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorAuthorityRequirementTest.java index 7cb72203669..ed736c3fb41 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorAuthorityRequirementTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorAuthorityRequirementTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorAuthorityRequirementTest extends AbstractValidatorTest { +class ValidatorAuthorityRequirementTest extends AbstractValidatorTest { @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_ReaderInput() throws IOException { + void auth_req_missing_dependency_req_auth_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_AUTH.dmn")) { final List validate = validator.validate( reader, @@ -47,7 +47,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_ReaderInput() throws IOExce } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_FileInput() { + void auth_req_missing_dependency_req_auth_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_AUTH.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_FileInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_DefinitionsInput() { + void auth_req_missing_dependency_req_auth_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_AUTH.dmn", "https://github.com/kiegroup/kie-dmn", @@ -67,7 +67,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_DefinitionsInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_ReaderInput() throws IOException { + void auth_req_missing_dependency_req_dec_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_DEC.dmn")) { final List validate = validator.validate( reader, @@ -78,7 +78,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_ReaderInput() throws IOExcep } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_FileInput() { + void auth_req_missing_dependency_req_dec_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_DEC.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -87,7 +87,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_FileInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_DefinitionsInput() { + void auth_req_missing_dependency_req_dec_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_DEC.dmn", "https://github.com/kiegroup/kie-dmn", @@ -98,7 +98,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_DefinitionsInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_ReaderInput() throws IOException { + void auth_req_missing_dependency_req_input_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_INPUT.dmn")) { final List validate = validator.validate( reader, @@ -109,7 +109,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_ReaderInput() throws IOExc } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_FileInput() { + void auth_req_missing_dependency_req_input_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_INPUT.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -118,7 +118,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_FileInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_DefinitionsInput() { + void auth_req_missing_dependency_req_input_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_INPUT.dmn", "https://github.com/kiegroup/kie-dmn", @@ -129,7 +129,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_DefinitionsInput() { } @Test - public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_ReaderInput() throws IOException { + void authreq_dep_req_auth_not_knowledgesource_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE.dmn")) { final List validate = validator.validate( reader, @@ -140,7 +140,7 @@ public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_ReaderInput() throws IO } @Test - public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_FileInput() { + void authreq_dep_req_auth_not_knowledgesource_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -149,7 +149,7 @@ public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_FileInput() { } @Test - public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_DefinitionsInput() { + void authreq_dep_req_auth_not_knowledgesource_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -160,7 +160,7 @@ public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_DefinitionsInput() { } @Test - public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_ReaderInput() throws IOException { + void authreq_dep_req_dec_not_decision_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_DEP_REQ_DEC_NOT_DECISION.dmn")) { final List validate = validator.validate( reader, @@ -171,7 +171,7 @@ public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_ReaderInput() throws IOExceptio } @Test - public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_FileInput() { + void authreq_dep_req_dec_not_decision_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_DEP_REQ_DEC_NOT_DECISION.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -180,7 +180,7 @@ public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_FileInput() { } @Test - public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_DefinitionsInput() { + void authreq_dep_req_dec_not_decision_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_DEP_REQ_DEC_NOT_DECISION.dmn", "https://github.com/kiegroup/kie-dmn", @@ -191,7 +191,7 @@ public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_DefinitionsInput() { } @Test - public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_ReaderInput() throws IOException { + void authreq_dep_req_input_not_input_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_DEP_REQ_INPUT_NOT_INPUT.dmn")) { final List validate = validator.validate( reader, @@ -202,7 +202,7 @@ public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_ReaderInput() throws IOException } @Test - public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_FileInput() { + void authreq_dep_req_input_not_input_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_DEP_REQ_INPUT_NOT_INPUT.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -211,7 +211,7 @@ public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_FileInput() { } @Test - public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_DefinitionsInput() { + void authreq_dep_req_input_not_input_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_DEP_REQ_INPUT_NOT_INPUT.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorBusinessContextTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorBusinessContextTest.java index d54b05fb05e..d48240bbc52 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorBusinessContextTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorBusinessContextTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorBusinessContextTest extends AbstractValidatorTest { +class ValidatorBusinessContextTest extends AbstractValidatorTest { @Test - public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_ReaderInput() throws IOException { + void org_unit_decision_made_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn")) { final List validate = validator.validate( reader, @@ -47,7 +47,7 @@ public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_ReaderInput() throws IOExcepti } @Test - public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_FileInput() { + void org_unit_decision_made_wrong_type_FileInput() { final List validate = validator.validate( getFile("businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_FileInput() { } @Test - public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_DefinitionsInput() { + void org_unit_decision_made_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -67,7 +67,7 @@ public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_DefinitionsInput() { } @Test - public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_ReaderInput() throws IOException { + void org_unit_decision_owned_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("businesscontext/ORG_UNIT_DECISION_OWNED_WRONG_TYPE.dmn")) { final List validate = validator.validate( reader, @@ -78,7 +78,7 @@ public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_ReaderInput() throws IOExcept } @Test - public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_FileInput() { + void org_unit_decision_owned_wrong_type_FileInput() { final List validate = validator.validate( getFile("businesscontext/ORG_UNIT_DECISION_OWNED_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -87,7 +87,7 @@ public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_FileInput() { } @Test - public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_DefinitionsInput() { + void org_unit_decision_owned_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businesscontext/ORG_UNIT_DECISION_OWNED_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -98,7 +98,7 @@ public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_DefinitionsInput() { } @Test - public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_ReaderInput() throws IOException { + void perf_indicator_imp_decision_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("businesscontext/PERF_INDICATOR_IMP_DECISION_WRONG_TYPE.dmn")) { final List validate = validator.validate( reader, @@ -109,7 +109,7 @@ public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_ReaderInput() throws IOEx } @Test - public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_FileInput() { + void perf_indicator_imp_decision_wrong_type_FileInput() { final List validate = validator.validate( getFile("businesscontext/PERF_INDICATOR_IMP_DECISION_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -118,7 +118,7 @@ public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_FileInput() { } @Test - public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_DefinitionsInput() { + void perf_indicator_imp_decision_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businesscontext/PERF_INDICATOR_IMP_DECISION_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorBusinessKnowledgeModelTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorBusinessKnowledgeModelTest.java index f79f6366535..e9ae73a1d5f 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorBusinessKnowledgeModelTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorBusinessKnowledgeModelTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorBusinessKnowledgeModelTest extends AbstractValidatorTest { +class ValidatorBusinessKnowledgeModelTest extends AbstractValidatorTest { @Test - public void testBKM_MISSING_VAR_ReaderInput() throws IOException { + void bkm_missing_var_ReaderInput() throws IOException { try (final Reader reader = getReader("businessknowledgemodel/BKM_MISSING_VAR.dmn")) { final List validate = validator.validate( reader, @@ -47,7 +47,7 @@ public void testBKM_MISSING_VAR_ReaderInput() throws IOException { } @Test - public void testBKM_MISSING_VAR_FileInput() { + void bkm_missing_var_FileInput() { final List validate = validator.validate( getFile("businessknowledgemodel/BKM_MISSING_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testBKM_MISSING_VAR_FileInput() { } @Test - public void testBKM_MISSING_VAR_DefinitionsInput() { + void bkm_missing_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businessknowledgemodel/BKM_MISSING_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -67,7 +67,7 @@ public void testBKM_MISSING_VAR_DefinitionsInput() { } @Test - public void testBKM_MISMATCH_VAR_ReaderInput() throws IOException { + void bkm_mismatch_var_ReaderInput() throws IOException { try (final Reader reader = getReader("businessknowledgemodel/BKM_MISMATCH_VAR.dmn")) { final List validate = validator.validate( reader, @@ -78,7 +78,7 @@ public void testBKM_MISMATCH_VAR_ReaderInput() throws IOException { } @Test - public void testBKM_MISMATCH_VAR_FileInput() { + void bkm_mismatch_var_FileInput() { final List validate = validator.validate( getFile("businessknowledgemodel/BKM_MISMATCH_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -87,7 +87,7 @@ public void testBKM_MISMATCH_VAR_FileInput() { } @Test - public void testBKM_MISMATCH_VAR_DefinitionsInput() { + void bkm_mismatch_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businessknowledgemodel/BKM_MISMATCH_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -98,7 +98,7 @@ public void testBKM_MISMATCH_VAR_DefinitionsInput() { } @Test - public void testBKM_MISSING_EXPR_ReaderInput() throws IOException { + void bkm_missing_expr_ReaderInput() throws IOException { try (final Reader reader = getReader("businessknowledgemodel/BKM_MISSING_EXPR.dmn")) { final List validate = validator.validate( reader, @@ -109,7 +109,7 @@ public void testBKM_MISSING_EXPR_ReaderInput() throws IOException { } @Test - public void testBKM_MISSING_EXPR_FileInput() { + void bkm_missing_expr_FileInput() { final List validate = validator.validate( getFile("businessknowledgemodel/BKM_MISSING_EXPR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -118,7 +118,7 @@ public void testBKM_MISSING_EXPR_FileInput() { } @Test - public void testBKM_MISSING_EXPR_DefinitionsInput() { + void bkm_missing_expr_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businessknowledgemodel/BKM_MISSING_EXPR.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorContextTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorContextTest.java index 77af5a0e498..886d5ae8ffa 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorContextTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorContextTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.model.api.Context; @@ -35,10 +35,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorContextTest extends AbstractValidatorTest { +class ValidatorContextTest extends AbstractValidatorTest { @Test - public void testCONTEXT_MISSING_EXPR_ReaderInput() throws IOException { + void context_missing_expr_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_MISSING_EXPR.dmn")) { final List validate = validator.validate( reader, @@ -50,7 +50,7 @@ public void testCONTEXT_MISSING_EXPR_ReaderInput() throws IOException { } @Test - public void testCONTEXT_MISSING_EXPR_FileInput() { + void context_missing_expr_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_MISSING_EXPR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -60,7 +60,7 @@ public void testCONTEXT_MISSING_EXPR_FileInput() { } @Test - public void testCONTEXT_MISSING_EXPR_DefinitionsInput() { + void context_missing_expr_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_MISSING_EXPR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -71,7 +71,7 @@ public void testCONTEXT_MISSING_EXPR_DefinitionsInput() { } @Test - public void testCONTEXT_MISSING_ENTRIES_ReaderInput() throws IOException { + void context_missing_entries_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_MISSING_ENTRIES.dmn")) { final List validate = validator.validate( reader, @@ -82,7 +82,7 @@ public void testCONTEXT_MISSING_ENTRIES_ReaderInput() throws IOException { } @Test - public void testCONTEXT_MISSING_ENTRIES_FileInput() { + void context_missing_entries_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_MISSING_ENTRIES.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -91,7 +91,7 @@ public void testCONTEXT_MISSING_ENTRIES_FileInput() { } @Test - public void testCONTEXT_MISSING_ENTRIES_DefinitionsInput() { + void context_missing_entries_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_MISSING_ENTRIES.dmn", "https://github.com/kiegroup/kie-dmn", @@ -102,7 +102,7 @@ public void testCONTEXT_MISSING_ENTRIES_DefinitionsInput() { } @Test - public void testCONTEXT_ENTRY_MISSING_VARIABLE_ReaderInput() throws IOException { + void context_entry_missing_variable_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_ENTRY_MISSING_VARIABLE.dmn")) { final List validate = validator.validate( reader, @@ -116,7 +116,7 @@ public void testCONTEXT_ENTRY_MISSING_VARIABLE_ReaderInput() throws IOException } @Test - public void testCONTEXT_ENTRY_MISSING_VARIABLE_FileInput() { + void context_entry_missing_variable_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_ENTRY_MISSING_VARIABLE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -128,7 +128,7 @@ public void testCONTEXT_ENTRY_MISSING_VARIABLE_FileInput() { } @Test - public void testCONTEXT_ENTRY_MISSING_VARIABLE_DefinitionsInput() { + void context_entry_missing_variable_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_ENTRY_MISSING_VARIABLE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -142,7 +142,7 @@ public void testCONTEXT_ENTRY_MISSING_VARIABLE_DefinitionsInput() { } @Test - public void testCONTEXT_DUP_ENTRY_ReaderInput() throws IOException { + void context_dup_entry_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_DUP_ENTRY.dmn")) { final List validate = validator.validate( reader, @@ -153,7 +153,7 @@ public void testCONTEXT_DUP_ENTRY_ReaderInput() throws IOException { } @Test - public void testCONTEXT_DUP_ENTRY_FileInput() { + void context_dup_entry_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_DUP_ENTRY.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -162,7 +162,7 @@ public void testCONTEXT_DUP_ENTRY_FileInput() { } @Test - public void testCONTEXT_DUP_ENTRY_DefinitionsInput() { + void context_dup_entry_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_DUP_ENTRY.dmn", "https://github.com/kiegroup/kie-dmn", @@ -173,7 +173,7 @@ public void testCONTEXT_DUP_ENTRY_DefinitionsInput() { } @Test - public void testCONTEXT_ENTRY_NOTYPEREF_ReaderInput() throws IOException { + void context_entry_notyperef_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_ENTRY_NOTYPEREF.dmn")) { final List validate = validator.validate( reader, @@ -184,7 +184,7 @@ public void testCONTEXT_ENTRY_NOTYPEREF_ReaderInput() throws IOException { } @Test - public void testCONTEXT_ENTRY_NOTYPEREF_FileInput() { + void context_entry_notyperef_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_ENTRY_NOTYPEREF.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -193,7 +193,7 @@ public void testCONTEXT_ENTRY_NOTYPEREF_FileInput() { } @Test - public void testCONTEXT_ENTRY_NOTYPEREF_DefinitionsInput() { + void context_entry_notyperef_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_ENTRY_NOTYPEREF.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDMNElementReferenceTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDMNElementReferenceTest.java index 8b8dbedb961..45720b3f9ea 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDMNElementReferenceTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDMNElementReferenceTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorDMNElementReferenceTest extends AbstractValidatorTest { +class ValidatorDMNElementReferenceTest extends AbstractValidatorTest { @Test - public void testELEMREF_NOHASH_ReaderInput() throws IOException { + void elemref_nohash_ReaderInput() throws IOException { try (final Reader reader = getReader("dmnelementref/ELEMREF_NOHASH.dmn")) { final List validationMessages = validator.validate( reader, @@ -46,7 +46,7 @@ public void testELEMREF_NOHASH_ReaderInput() throws IOException { } @Test - public void testELEMREF_NOHASH_FileInput() { + void elemref_nohash_FileInput() { final List validationMessages = validator.validate( getFile("dmnelementref/ELEMREF_NOHASH.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -54,7 +54,7 @@ public void testELEMREF_NOHASH_FileInput() { } @Test - public void testELEMREF_NOHASH_DefinitionsInput() { + void elemref_nohash_DefinitionsInput() { final List validationMessages = validator.validate( getDefinitions("dmnelementref/ELEMREF_NOHASH.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDecisionTableTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDecisionTableTest.java index e30c8b73bbe..e07fc50b001 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDecisionTableTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDecisionTableTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,11 +33,11 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorDecisionTableTest +class ValidatorDecisionTableTest extends AbstractValidatorTest { @Test - public void testDTABLE_EMPTY_ENTRY_ReaderInput() throws IOException { + void dtable_empty_entry_ReaderInput() throws IOException { try (final Reader reader = getReader("DTABLE_EMPTY_ENTRY.dmn")) { final List validate = validator.validate( reader, @@ -48,7 +48,7 @@ public void testDTABLE_EMPTY_ENTRY_ReaderInput() throws IOException { } @Test - public void testDTABLE_EMPTY_ENTRY_FileInput() { + void dtable_empty_entry_FileInput() { final List validate = validator.validate( getFile("DTABLE_EMPTY_ENTRY.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -57,7 +57,7 @@ public void testDTABLE_EMPTY_ENTRY_FileInput() { } @Test - public void testDTABLE_EMPTY_ENTRY_DefintionsInput() { + void dtable_empty_entry_DefintionsInput() { final List validate = validator.validate( getDefinitions("DTABLE_EMPTY_ENTRY.dmn", "https://github.com/kiegroup/kie-dmn", @@ -68,7 +68,7 @@ public void testDTABLE_EMPTY_ENTRY_DefintionsInput() { } @Test - public void testDTABLE_MULTIPLEOUT_NAME_ReaderInput() throws IOException { + void dtable_multipleout_name_ReaderInput() throws IOException { try (final Reader reader = getReader( "DTABLE_MULTIPLEOUTPUT_WRONG_OUTPUT.dmn" )) { List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(6); @@ -79,7 +79,7 @@ public void testDTABLE_MULTIPLEOUT_NAME_ReaderInput() throws IOException { } @Test - public void testDTABLE_MULTIPLEOUT_NAME_FileInput() { + void dtable_multipleout_name_FileInput() { List validate = validator.validate( getFile( "DTABLE_MULTIPLEOUTPUT_WRONG_OUTPUT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(6); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_NAME))).isTrue(); @@ -88,7 +88,7 @@ public void testDTABLE_MULTIPLEOUT_NAME_FileInput() { } @Test - public void testDTABLE_MULTIPLEOUT_NAME_DefinitionsInput() { + void dtable_multipleout_name_DefinitionsInput() { List validate = validator.validate( getDefinitions( "DTABLE_MULTIPLEOUTPUT_WRONG_OUTPUT.dmn", "https://github.com/kiegroup/kie-dmn", @@ -101,7 +101,7 @@ public void testDTABLE_MULTIPLEOUT_NAME_DefinitionsInput() { } @Test - public void testDTABLE_PRIORITY_MISSING_OUTVALS_ReaderInput() throws IOException { + void dtable_priority_missing_outvals_ReaderInput() throws IOException { try (final Reader reader = getReader( "DTABLE_PRIORITY_MISSING_OUTVALS.dmn" )) { List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).isNotEmpty(); @@ -110,14 +110,14 @@ public void testDTABLE_PRIORITY_MISSING_OUTVALS_ReaderInput() throws IOException } @Test - public void testDTABLE_PRIORITY_MISSING_OUTVALS_FileInput() { + void dtable_priority_missing_outvals_FileInput() { List validate = validator.validate( getFile( "DTABLE_PRIORITY_MISSING_OUTVALS.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).isNotEmpty(); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_OUTPUT_VALUES))).isTrue(); } @Test - public void testDTABLE_PRIORITY_MISSING_OUTVALS_DefinitionsInput() { + void dtable_priority_missing_outvals_DefinitionsInput() { List validate = validator.validate( getDefinitions( "DTABLE_PRIORITY_MISSING_OUTVALS.dmn", "https://github.com/kiegroup/kie-dmn", @@ -128,7 +128,7 @@ public void testDTABLE_PRIORITY_MISSING_OUTVALS_DefinitionsInput() { } @Test - public void testDTABLE_SINGLEOUT_NONAME_ReaderInput() throws IOException { + void dtable_singleout_noname_ReaderInput() throws IOException { try (final Reader reader = getReader( "DTABLE_SINGLEOUTPUT_WRONG_OUTPUT.dmn" )) { List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -138,7 +138,7 @@ public void testDTABLE_SINGLEOUT_NONAME_ReaderInput() throws IOException { } @Test - public void testDTABLE_SINGLEOUT_NONAME_FileInput() { + void dtable_singleout_noname_FileInput() { List validate = validator.validate( getFile( "DTABLE_SINGLEOUTPUT_WRONG_OUTPUT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.ILLEGAL_USE_OF_NAME))).isTrue(); @@ -146,7 +146,7 @@ public void testDTABLE_SINGLEOUT_NONAME_FileInput() { } @Test - public void testDTABLE_SINGLEOUT_NONAME_DefinitionsInput() { + void dtable_singleout_noname_DefinitionsInput() { List validate = validator.validate( getDefinitions("DTABLE_SINGLEOUTPUT_WRONG_OUTPUT.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDecisionTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDecisionTest.java index 6962e40fdd7..474c035c482 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDecisionTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorDecisionTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorDecisionTest extends AbstractValidatorTest { +class ValidatorDecisionTest extends AbstractValidatorTest { @Test - public void testDECISION_MISSING_EXPR_ReaderInput() throws IOException { + void decision_missing_expr_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MISSING_EXPR.dmn")) { final List validate = validator.validate( reader, @@ -47,7 +47,7 @@ public void testDECISION_MISSING_EXPR_ReaderInput() throws IOException { } @Test - public void testDECISION_MISSING_EXPR_FileInput() { + void decision_missing_expr_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_MISSING_EXPR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testDECISION_MISSING_EXPR_FileInput() { } @Test - public void testDECISION_MISSING_EXPR_DefinitionsInput() { + void decision_missing_expr_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MISSING_EXPR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -67,7 +67,7 @@ public void testDECISION_MISSING_EXPR_DefinitionsInput() { } @Test - public void testDECISION_MISSING_VAR_ReaderInput() throws IOException { + void decision_missing_var_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MISSING_VAR.dmn")) { final List validate = validator.validate( reader, @@ -78,7 +78,7 @@ public void testDECISION_MISSING_VAR_ReaderInput() throws IOException { } @Test - public void testDECISION_MISSING_VAR_FileInput() { + void decision_missing_var_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_MISSING_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -87,7 +87,7 @@ public void testDECISION_MISSING_VAR_FileInput() { } @Test - public void testDECISION_MISSING_VAR_DefinitionsInput() { + void decision_missing_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MISSING_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -98,7 +98,7 @@ public void testDECISION_MISSING_VAR_DefinitionsInput() { } @Test - public void testDECISION_MISSING_VARbis_ReaderInput() throws IOException { + void decision_missing_vaRbisReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MISSING_VARbis.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -107,7 +107,7 @@ public void testDECISION_MISSING_VARbis_ReaderInput() throws IOException { } @Test - public void testDECISION_MISSING_VARbis_FileInput() { + void decision_missing_vaRbisFileInput() { final List validate = validator.validate( getFile("decision/DECISION_MISSING_VARbis.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -115,7 +115,7 @@ public void testDECISION_MISSING_VARbis_FileInput() { } @Test - public void testDECISION_MISSING_VARbis_DefinitionsInput() { + void decision_missing_vaRbisDefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MISSING_VARbis.dmn", "https://github.com/kiegroup/kie-dmn", @@ -126,7 +126,7 @@ public void testDECISION_MISSING_VARbis_DefinitionsInput() { } @Test - public void testDECISION_MISMATCH_VAR_ReaderInput() throws IOException { + void decision_mismatch_var_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MISMATCH_VAR.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -135,7 +135,7 @@ public void testDECISION_MISMATCH_VAR_ReaderInput() throws IOException { } @Test - public void testDECISION_MISMATCH_VAR_FileInput() { + void decision_mismatch_var_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_MISMATCH_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -143,7 +143,7 @@ public void testDECISION_MISMATCH_VAR_FileInput() { } @Test - public void testDECISION_MISMATCH_VAR_DefinitionsInput() { + void decision_mismatch_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MISMATCH_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -154,7 +154,7 @@ public void testDECISION_MISMATCH_VAR_DefinitionsInput() { } @Test - public void testDECISION_MULTIPLE_EXPRESSIONS_ReaderInput() throws IOException { + void decision_multiple_expressions_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MULTIPLE_EXPRESSIONS.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -163,7 +163,7 @@ public void testDECISION_MULTIPLE_EXPRESSIONS_ReaderInput() throws IOException { } @Test - public void testDECISION_MULTIPLE_EXPRESSIONS_FileInput() { + void decision_multiple_expressions_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_MULTIPLE_EXPRESSIONS.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -171,7 +171,7 @@ public void testDECISION_MULTIPLE_EXPRESSIONS_FileInput() { } @Test - public void testDECISION_MULTIPLE_EXPRESSIONS_DefinitionsInput() { + void decision_multiple_expressions_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MULTIPLE_EXPRESSIONS.dmn", "https://github.com/kiegroup/kie-dmn", @@ -181,7 +181,7 @@ public void testDECISION_MULTIPLE_EXPRESSIONS_DefinitionsInput() { } @Test - public void testDECISION_PERF_INDICATOR_WRONG_TYPE_ReaderInput() throws IOException { + void decision_perf_indicator_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_PERF_INDICATOR_WRONG_TYPE.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -190,7 +190,7 @@ public void testDECISION_PERF_INDICATOR_WRONG_TYPE_ReaderInput() throws IOExcept } @Test - public void testDECISION_PERF_INDICATOR_WRONG_TYPE_FileInput() { + void decision_perf_indicator_wrong_type_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_PERF_INDICATOR_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -198,7 +198,7 @@ public void testDECISION_PERF_INDICATOR_WRONG_TYPE_FileInput() { } @Test - public void testDECISION_PERF_INDICATOR_WRONG_TYPE_DefinitionsInput() { + void decision_perf_indicator_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_PERF_INDICATOR_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -209,7 +209,7 @@ public void testDECISION_PERF_INDICATOR_WRONG_TYPE_DefinitionsInput() { } @Test - public void testDECISION_DECISION_MAKER_WRONG_TYPE_ReaderInput() throws IOException { + void decision_decision_maker_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_DECISION_MAKER_WRONG_TYPE.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -218,7 +218,7 @@ public void testDECISION_DECISION_MAKER_WRONG_TYPE_ReaderInput() throws IOExcept } @Test - public void testDECISION_DECISION_MAKER_WRONG_TYPE_FileInput() { + void decision_decision_maker_wrong_type_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_DECISION_MAKER_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -226,7 +226,7 @@ public void testDECISION_DECISION_MAKER_WRONG_TYPE_FileInput() { } @Test - public void testDECISION_DECISION_MAKER_WRONG_TYPE_DefinitionsInput() { + void decision_decision_maker_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_DECISION_MAKER_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -237,7 +237,7 @@ public void testDECISION_DECISION_MAKER_WRONG_TYPE_DefinitionsInput() { } @Test - public void testDECISION_DECISION_OWNER_WRONG_TYPE_ReaderInput() throws IOException { + void decision_decision_owner_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_DECISION_OWNER_WRONG_TYPE.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -246,7 +246,7 @@ public void testDECISION_DECISION_OWNER_WRONG_TYPE_ReaderInput() throws IOExcept } @Test - public void testDECISION_DECISION_OWNER_WRONG_TYPE_FileInput() { + void decision_decision_owner_wrong_type_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_DECISION_OWNER_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -254,7 +254,7 @@ public void testDECISION_DECISION_OWNER_WRONG_TYPE_FileInput() { } @Test - public void testDECISION_DECISION_OWNER_WRONG_TYPE_DefinitionsInput() { + void decision_decision_owner_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_DECISION_OWNER_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -265,7 +265,7 @@ public void testDECISION_DECISION_OWNER_WRONG_TYPE_DefinitionsInput() { } @Test - public void testDECISION_CYCLIC_DEPENDENCY_ReaderInput() throws IOException { + void decision_cyclic_dependency_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_CYCLIC_DEPENDENCY.dmn")) { final List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -274,14 +274,14 @@ public void testDECISION_CYCLIC_DEPENDENCY_ReaderInput() throws IOException { } @Test - public void testDECISION_CYCLIC_DEPENDENCY_FileInput() { + void decision_cyclic_dependency_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_CYCLIC_DEPENDENCY.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND))).isTrue(); } @Test - public void testDECISION_CYCLIC_DEPENDENCY_DefinitionsInput() { + void decision_cyclic_dependency_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_CYCLIC_DEPENDENCY.dmn", "https://github.com/kiegroup/kie-dmn", @@ -292,7 +292,7 @@ public void testDECISION_CYCLIC_DEPENDENCY_DefinitionsInput() { } @Test - public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_ReaderInput() throws IOException { + void decision_cyclic_dependency_self_reference_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE.dmn")) { final List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -301,14 +301,14 @@ public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_ReaderInput() throws I } @Test - public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_FileInput() { + void decision_cyclic_dependency_self_reference_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND))).isTrue(); } @Test - public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_DefinitionsInput() { + void decision_cyclic_dependency_self_reference_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -319,7 +319,7 @@ public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_DefinitionsInput() { } @Test - public void testDECISION_DEADLY_DIAMOND_ReaderInput() throws IOException { + void decision_deadly_diamond_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_DEADLY_DIAMOND.dmn")) { final List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); @@ -327,13 +327,13 @@ public void testDECISION_DEADLY_DIAMOND_ReaderInput() throws IOException { } @Test - public void testDECISION_DEADLY_DIAMOND_FileInput() { + void decision_deadly_diamond_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_DEADLY_DIAMOND.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testDECISION_DEADLY_DIAMOND_DefinitionsInput() { + void decision_deadly_diamond_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_DEADLY_DIAMOND.dmn", "https://github.com/kiegroup/kie-dmn", @@ -343,7 +343,7 @@ public void testDECISION_DEADLY_DIAMOND_DefinitionsInput() { } @Test - public void testDECISION_DEADLY_KITE_ReaderInput() throws IOException { + void decision_deadly_kite_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_DEADLY_KITE.dmn")) { final List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); @@ -351,13 +351,13 @@ public void testDECISION_DEADLY_KITE_ReaderInput() throws IOException { } @Test - public void testDECISION_DEADLY_KITE_FileInput() { + void decision_deadly_kite_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_DEADLY_KITE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testDECISION_DEADLY_KITE_DefinitionsInput() { + void decision_deadly_kite_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_DEADLY_KITE.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorImportTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorImportTest.java index b518b9e5db1..2bc87a8028b 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorImportTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorImportTest.java @@ -23,8 +23,8 @@ import java.util.Arrays; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -48,9 +48,9 @@ public class ValidatorImportTest extends AbstractValidatorTest { public static final Logger LOG = LoggerFactory.getLogger(ValidatorImportTest.class); - @Ignore + @Disabled @Test - public void testBaseModelOK() { + void baseModelOK() { DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("import/Base-model.dmn", this.getClass(), "import/Import-base-model.dmn"); DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_b33fa7d9-f501-423b-afa8-15ded7e7f493", "Import base model"); assertThat(dmnModel).isNotNull(); @@ -64,7 +64,7 @@ public void testBaseModelOK() { } @Test - public void testBaseModelOKFromReaderInput() throws IOException { + void baseModelOKFromReaderInput() throws IOException { try (final Reader reader0 = getReader("import/Base-model.dmn"); final Reader reader1 = getReader("import/Import-base-model.dmn");) { final List messages = validator.validateUsing(// VALIDATE_SCHEMA, disabled, due to QName use not compliant. @@ -76,7 +76,7 @@ public void testBaseModelOKFromReaderInput() throws IOException { } @Test - public void testBaseModelOKFromFileInput() throws IOException { + void baseModelOKFromFileInput() throws IOException { final List messages = validator.validateUsing(// VALIDATE_SCHEMA, disabled, due to QName use not compliant. Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) @@ -86,7 +86,7 @@ public void testBaseModelOKFromFileInput() throws IOException { } @Test - public void testBaseModelImportModelNameFromFileInput() throws IOException { + void baseModelImportModelNameFromFileInput() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL) .theseModels(getFile("import/Import-base-model-modelnameattribute.dmn"), // DROOLS-2938 getFile("import/Base-model.dmn")); @@ -94,7 +94,7 @@ public void testBaseModelImportModelNameFromFileInput() throws IOException { } @Test - public void testBaseModelOKFromDefinitionsInput() throws IOException { + void baseModelOKFromDefinitionsInput() throws IOException { final List messages = validator.validateUsing(// VALIDATE_SCHEMA, disabled, due to QName use not compliant. Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) @@ -108,7 +108,7 @@ public void testBaseModelOKFromDefinitionsInput() throws IOException { } @Test - public void testWrongImportBaseModelFromReaderInput() throws IOException { + void wrongImportBaseModelFromReaderInput() throws IOException { try (final Reader reader0 = getReader("import/Base-model.dmn"); final Reader reader1 = getReader("import/Wrong-Import-base-model.dmn");) { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL) @@ -120,9 +120,9 @@ public void testWrongImportBaseModelFromReaderInput() throws IOException { .equals("http://www.trisotech.com/definitions/_70df1ad5-2a33-4ede-b8b2-869988ac1d30#_1d52934e-aa4e-47c9-a011-fc989d795664"))).isTrue(); } } - + @Test - public void testWrongImportBaseModelFromFileInput() throws IOException { + void wrongImportBaseModelFromFileInput() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL) .theseModels(getFile("import/Base-model.dmn"), getFile("import/Wrong-Import-base-model.dmn")); @@ -134,7 +134,7 @@ public void testWrongImportBaseModelFromFileInput() throws IOException { } @Test - public void testWrongImportBaseModelFromDefinitionsInput() throws IOException { + void wrongImportBaseModelFromDefinitionsInput() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL) .theseModels(getDefinitions(Arrays.asList("import/Base-model.dmn", "import/Wrong-Import-base-model.dmn"), "http://www.trisotech.com/definitions/_70df1ad5-2a33-4ede-b8b2-869988ac1d30", @@ -149,7 +149,7 @@ public void testWrongImportBaseModelFromDefinitionsInput() throws IOException { } @Test - public void testOnlyImportBaseModelFromReaderInput() throws IOException { + void onlyImportBaseModelFromReaderInput() throws IOException { try (final Reader reader1 = getReader("import/Only-Import-base-model.dmn");) { final List messages = validator.validate(reader1, Validation.VALIDATE_MODEL); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.IMPORT_NOT_FOUND))).isTrue(); @@ -157,13 +157,13 @@ public void testOnlyImportBaseModelFromReaderInput() throws IOException { } @Test - public void testOnlyImportBaseModelFromFileInput() throws IOException { + void onlyImportBaseModelFromFileInput() throws IOException { final List messages = validator.validate(getFile("import/Only-Import-base-model.dmn"), Validation.VALIDATE_MODEL); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.IMPORT_NOT_FOUND))).isTrue(); } @Test - public void testOnlyImportBaseModelFromDefinitionsInput() throws IOException { + void onlyImportBaseModelFromDefinitionsInput() throws IOException { final List messages = validator.validate(getDefinitions("import/Only-Import-base-model.dmn", "http://www.trisotech.com/dmn/definitions/_a9bfa4de-cf5c-4b2f-9011-ab576e00b162", "Only Import base model"), diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorInformationRequirementTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorInformationRequirementTest.java index 82f4c0b7397..c042c80082d 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorInformationRequirementTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorInformationRequirementTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorInformationRequirementTest extends AbstractValidatorTest { +class ValidatorInformationRequirementTest extends AbstractValidatorTest { @Test - public void testINFOREQ_MISSING_INPUT_ReaderInput() throws IOException { + void inforeq_missing_input_ReaderInput() throws IOException { try (final Reader reader = getReader( "informationrequirement/INFOREQ_MISSING_INPUT.dmn" )) { final List validate = validator.validate( reader, @@ -48,7 +48,7 @@ public void testINFOREQ_MISSING_INPUT_ReaderInput() throws IOException { } @Test - public void testINFOREQ_MISSING_INPUT_FileInput() { + void inforeq_missing_input_FileInput() { final List validate = validator.validate( getFile( "informationrequirement/INFOREQ_MISSING_INPUT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -58,7 +58,7 @@ public void testINFOREQ_MISSING_INPUT_FileInput() { } @Test - public void testINFOREQ_MISSING_INPUT_DefinitionsInput() { + void inforeq_missing_input_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "informationrequirement/INFOREQ_MISSING_INPUT.dmn", "https://github.com/kiegroup/kie-dmn", @@ -70,7 +70,7 @@ public void testINFOREQ_MISSING_INPUT_DefinitionsInput() { } @Test - public void testINFOREQ_INPUT_NOT_INPUTDATA_ReaderInput() throws IOException { + void inforeq_input_not_inputdata_ReaderInput() throws IOException { try (final Reader reader = getReader( "informationrequirement/INFOREQ_INPUT_NOT_INPUTDATA.dmn" )) { final List validate = validator.validate( reader, @@ -82,7 +82,7 @@ public void testINFOREQ_INPUT_NOT_INPUTDATA_ReaderInput() throws IOException { } @Test - public void testINFOREQ_INPUT_NOT_INPUTDATA_FileInput() { + void inforeq_input_not_inputdata_FileInput() { final List validate = validator.validate( getFile( "informationrequirement/INFOREQ_INPUT_NOT_INPUTDATA.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -92,7 +92,7 @@ public void testINFOREQ_INPUT_NOT_INPUTDATA_FileInput() { } @Test - public void testINFOREQ_INPUT_NOT_INPUTDATA_DefinitionsInput() { + void inforeq_input_not_inputdata_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "informationrequirement/INFOREQ_INPUT_NOT_INPUTDATA.dmn", "https://github.com/kiegroup/kie-dmn", @@ -104,7 +104,7 @@ public void testINFOREQ_INPUT_NOT_INPUTDATA_DefinitionsInput() { } @Test - public void testINFOREQ_MISSING_DECISION_ReaderInput() throws IOException { + void inforeq_missing_decision_ReaderInput() throws IOException { try (final Reader reader = getReader( "informationrequirement/INFOREQ_MISSING_DECISION.dmn" )) { final List validate = validator.validate( reader, @@ -116,7 +116,7 @@ public void testINFOREQ_MISSING_DECISION_ReaderInput() throws IOException { } @Test - public void testINFOREQ_MISSING_DECISION_FileInput() { + void inforeq_missing_decision_FileInput() { final List validate = validator.validate( getFile( "informationrequirement/INFOREQ_MISSING_DECISION.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -126,7 +126,7 @@ public void testINFOREQ_MISSING_DECISION_FileInput() { } @Test - public void testINFOREQ_MISSING_DECISION_DefinitionsInput() { + void inforeq_missing_decision_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "informationrequirement/INFOREQ_MISSING_DECISION.dmn", "https://github.com/kiegroup/kie-dmn", @@ -138,7 +138,7 @@ public void testINFOREQ_MISSING_DECISION_DefinitionsInput() { } @Test - public void testINFOREQ_DECISION_NOT_DECISION_ReaderInput() throws IOException { + void inforeq_decision_not_decision_ReaderInput() throws IOException { try (final Reader reader = getReader( "informationrequirement/INFOREQ_DECISION_NOT_DECISION.dmn" )) { final List validate = validator.validate( reader, @@ -150,7 +150,7 @@ public void testINFOREQ_DECISION_NOT_DECISION_ReaderInput() throws IOException { } @Test - public void testINFOREQ_DECISION_NOT_DECISION_FileInput() { + void inforeq_decision_not_decision_FileInput() { final List validate = validator.validate( getFile( "informationrequirement/INFOREQ_DECISION_NOT_DECISION.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -160,7 +160,7 @@ public void testINFOREQ_DECISION_NOT_DECISION_FileInput() { } @Test - public void testINFOREQ_DECISION_NOT_DECISION_DefinitionsInput() { + void inforeq_decision_not_decision_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "informationrequirement/INFOREQ_DECISION_NOT_DECISION.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorInputDataTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorInputDataTest.java index 1ff99e6bfc4..6f4748ff1ec 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorInputDataTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorInputDataTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorInputDataTest extends AbstractValidatorTest { +class ValidatorInputDataTest extends AbstractValidatorTest { @Test - public void testINPUT_MISSING_VAR_ReaderInput() throws IOException { + void input_missing_var_ReaderInput() throws IOException { try (final Reader reader = getReader("inputdata/INPUTDATA_MISSING_VAR.dmn")) { final List validate = validator.validate( reader, @@ -47,7 +47,7 @@ public void testINPUT_MISSING_VAR_ReaderInput() throws IOException { } @Test - public void testINPUT_MISSING_VAR_FileInput() { + void input_missing_var_FileInput() { final List validate = validator.validate( getFile("inputdata/INPUTDATA_MISSING_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testINPUT_MISSING_VAR_FileInput() { } @Test - public void testINPUT_MISSING_VAR_DefintionsInput() { + void input_missing_var_DefintionsInput() { final List validate = validator.validate( getDefinitions("inputdata/INPUTDATA_MISSING_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -67,7 +67,7 @@ public void testINPUT_MISSING_VAR_DefintionsInput() { } @Test - public void testINPUT_MISMATCH_VAR_ReaderInput() throws IOException { + void input_mismatch_var_ReaderInput() throws IOException { try (final Reader reader = getReader("inputdata/INPUTDATA_MISMATCH_VAR.dmn")) { final List validate = validator.validate( reader, @@ -78,7 +78,7 @@ public void testINPUT_MISMATCH_VAR_ReaderInput() throws IOException { } @Test - public void testINPUT_MISMATCH_VAR_FileInput() { + void input_mismatch_var_FileInput() { final List validate = validator.validate( getFile("inputdata/INPUTDATA_MISMATCH_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -87,7 +87,7 @@ public void testINPUT_MISMATCH_VAR_FileInput() { } @Test - public void testINPUT_MISMATCH_VAR_DefinitionsInput() { + void input_mismatch_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("inputdata/INPUTDATA_MISMATCH_VAR.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorKnowledgeRequirementTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorKnowledgeRequirementTest.java index ba6409c8153..b6f3c413192 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorKnowledgeRequirementTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorKnowledgeRequirementTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorKnowledgeRequirementTest extends AbstractValidatorTest { +class ValidatorKnowledgeRequirementTest extends AbstractValidatorTest { @Test - public void testKNOWREQ_MISSING_BKM_ReaderInput() throws IOException { + void knowreq_missing_bkm_ReaderInput() throws IOException { try (final Reader reader = getReader( "knowledgerequirement/KNOWREQ_MISSING_BKM.dmn" )) { final List validate = validator.validate( reader, @@ -48,7 +48,7 @@ public void testKNOWREQ_MISSING_BKM_ReaderInput() throws IOException { } @Test - public void testKNOWREQ_MISSING_BKM_FileInput() { + void knowreq_missing_bkm_FileInput() { final List validate = validator.validate( getFile( "knowledgerequirement/KNOWREQ_MISSING_BKM.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -58,7 +58,7 @@ public void testKNOWREQ_MISSING_BKM_FileInput() { } @Test - public void testKNOWREQ_MISSING_BKM_DefinitionsInput() { + void knowreq_missing_bkm_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "knowledgerequirement/KNOWREQ_MISSING_BKM.dmn", "https://github.com/kiegroup/kie-dmn", @@ -70,7 +70,7 @@ public void testKNOWREQ_MISSING_BKM_DefinitionsInput() { } @Test - public void testKNOWREQ_REQ_DECISION_NOT_BKM_ReaderInput() throws IOException { + void knowreq_req_decision_not_bkm_ReaderInput() throws IOException { try (final Reader reader = getReader( "knowledgerequirement/KNOWREQ_REQ_DECISION_NOT_BKM.dmn" )) { final List validate = validator.validate( reader, @@ -82,7 +82,7 @@ public void testKNOWREQ_REQ_DECISION_NOT_BKM_ReaderInput() throws IOException { } @Test - public void testKNOWREQ_REQ_DECISION_NOT_BKM_FileInput() { + void knowreq_req_decision_not_bkm_FileInput() { final List validate = validator.validate( getFile( "knowledgerequirement/KNOWREQ_REQ_DECISION_NOT_BKM.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -92,7 +92,7 @@ public void testKNOWREQ_REQ_DECISION_NOT_BKM_FileInput() { } @Test - public void testKNOWREQ_REQ_DECISION_NOT_BKM_DefinitionsInput() { + void knowreq_req_decision_not_bkm_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "knowledgerequirement/KNOWREQ_REQ_DECISION_NOT_BKM.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorKnowledgeSourceTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorKnowledgeSourceTest.java index 7e96e2a0640..16c3e7b6063 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorKnowledgeSourceTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorKnowledgeSourceTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorKnowledgeSourceTest extends AbstractValidatorTest { +class ValidatorKnowledgeSourceTest extends AbstractValidatorTest { @Test - public void testKNOW_SOURCE_MISSING_OWNER_ReaderInput() throws IOException { + void know_source_missing_owner_ReaderInput() throws IOException { try (final Reader reader = getReader( "knowledgesource/KNOW_SOURCE_MISSING_OWNER.dmn" )) { final List validate = validator.validate( reader, @@ -47,7 +47,7 @@ public void testKNOW_SOURCE_MISSING_OWNER_ReaderInput() throws IOException { } @Test - public void testKNOW_SOURCE_MISSING_OWNER_FileInput() { + void know_source_missing_owner_FileInput() { final List validate = validator.validate( getFile( "knowledgesource/KNOW_SOURCE_MISSING_OWNER.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testKNOW_SOURCE_MISSING_OWNER_FileInput() { } @Test - public void testKNOW_SOURCE_MISSING_OWNER_DefinitionsInput() { + void know_source_missing_owner_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "knowledgesource/KNOW_SOURCE_MISSING_OWNER.dmn", "https://github.com/kiegroup/kie-dmn", @@ -67,7 +67,7 @@ public void testKNOW_SOURCE_MISSING_OWNER_DefinitionsInput() { } @Test - public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_ReaderInput() throws IOException { + void know_source_owner_not_org_unit_ReaderInput() throws IOException { try (final Reader reader = getReader( "knowledgesource/KNOW_SOURCE_OWNER_NOT_ORG_UNIT.dmn" )) { final List validate = validator.validate( reader, @@ -78,7 +78,7 @@ public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_ReaderInput() throws IOException } @Test - public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_FileInput() { + void know_source_owner_not_org_unit_FileInput() { final List validate = validator.validate( getFile( "knowledgesource/KNOW_SOURCE_OWNER_NOT_ORG_UNIT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -87,7 +87,7 @@ public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_FileInput() { } @Test - public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_DefinitionsInput() { + void know_source_owner_not_org_unit_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "knowledgesource/KNOW_SOURCE_OWNER_NOT_ORG_UNIT.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorTest.java index c03b440479f..f7b58b4f7eb 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorTest.java @@ -25,8 +25,8 @@ import java.net.URISyntaxException; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.api.core.DMNModel; @@ -47,10 +47,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorTest extends AbstractValidatorTest { +class ValidatorTest extends AbstractValidatorTest { @Test - public void testDryRun() { + void dryRun() { DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", DMNInputRuntimeTest.class ); DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -63,7 +63,7 @@ public void testDryRun() { } @Test - public void testMACDInputDefinitions() { + void macdInputDefinitions() { DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "MACD-enhanced_iteration.dmn", DMNInputRuntimeTest.class ); DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_6cfe7d88-6741-45d1-968c-b61a597d0964", "MACD-enhanced iteration" ); assertThat(dmnModel).isNotNull(); @@ -77,7 +77,7 @@ public void testMACDInputDefinitions() { } @Test - public void testMACDInputReader() throws IOException { + void macdInputReader() throws IOException { try (final Reader reader = new InputStreamReader(getClass().getResourceAsStream("/org/kie/dmn/core/MACD-enhanced_iteration.dmn") )) { List messages = DMNValidatorFactory.newValidator().validate(reader, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(messages).as(messages.toString()).hasSize(0); @@ -105,29 +105,29 @@ private Definitions utilDefinitions(String filename, String modelName) { } return null; } - + @Test - public void testInvalidXml() throws URISyntaxException { + void invalidXml() throws URISyntaxException { List validateXML = validator.validate( new File(this.getClass().getResource( "invalidXml.dmn" ).toURI()), DMNValidator.Validation.VALIDATE_SCHEMA); assertThat(validateXML).as(ValidatorUtil.formatMessages( validateXML )).hasSize(1); assertThat(validateXML.get(0).getMessageType()).as(validateXML.get(0).toString()).isEqualTo(DMNMessageType.FAILED_XML_VALIDATION); } @Test - public void testINVOCATION_MISSING_EXPR() { + void invocationMissingExpr() { List validate = validator.validate( getReader( "INVOCATION_MISSING_EXPR.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSizeGreaterThan(0); assertThat(validate.get(0).getMessageType()).as(validate.get(0).toString()).isEqualTo(DMNMessageType.MISSING_EXPRESSION); } @Test - public void testNAME_IS_VALID() { + void nameIsValid() { List validate = validator.validate( getReader( "NAME_IS_VALID.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testNAME_INVALID_empty_name() { + void name_invalidEmptyName() { List validate = validator.validate( getReader( "DROOLS-1447.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(5); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.FAILED_XML_VALIDATION))).isTrue(); @@ -135,97 +135,98 @@ public void testNAME_INVALID_empty_name() { assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.INVALID_NAME) && p.getSourceId().equals("_5e43b55c-888e-443c-b1b9-80e4aa6746bd"))).isTrue(); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.INVALID_NAME) && p.getSourceId().equals("_b1e4588e-9ce1-4474-8e4e-48dbcdb7524b"))).isTrue(); } - + @Test - public void testDRGELEM_NOT_UNIQUE() { + void drgelemNotUnique() { List validate = validator.validate( getReader( "DRGELEM_NOT_UNIQUE.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATE_NAME))).isTrue(); } - + @Test - public void testFORMAL_PARAM_DUPLICATED() { + void formalParamDuplicated() { List validate = validator.validate( getReader( "FORMAL_PARAM_DUPLICATED.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(3); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATED_PARAM))).isTrue(); } - + @Test - public void testINVOCATION_INCONSISTENT_PARAM_NAMES() { + void invocationInconsistentParamNames() { List validate = validator.validate( getReader( "INVOCATION_INCONSISTENT_PARAM_NAMES.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSizeGreaterThan(0); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - - @Test @Ignore( "Needs to be improved as invocations can be used to invoke functions node defined in BKMs. E.g., FEEL built in functions, etc.") - public void testINVOCATION_MISSING_TARGET() { + + @Test + @Disabled("Needs to be improved as invocations can be used to invoke functions node defined in BKMs. E.g., FEEL built in functions, etc.") + void invocationMissingTarget() { Definitions definitions = utilDefinitions( "INVOCATION_MISSING_TARGET.dmn", "INVOCATION_MISSING_TARGET" ); List validate = validator.validate(definitions); // assertTrue( validate.stream().anyMatch( p -> p.getMessageType().equals( DMNMessageType.INVOCATION_MISSING_TARGET ) ) ); } - - @Ignore("known current limitation") + + @Disabled("known current limitation") @Test - public void testINVOCATION_MISSING_TARGETRbis() { + void invocation_missing_targetRbis() { Definitions definitions = utilDefinitions( "INVOCATION_MISSING_TARGETbis.dmn", "INVOCATION_MISSING_TARGETbis" ); List validate = validator.validate(definitions); // assertTrue( validate.stream().anyMatch( p -> p.getMessageType().equals( DMNMessageType.INVOCATION_MISSING_TARGET ) ) ); } - + @Test - public void testINVOCATION_WRONG_PARAM_COUNT() { + void invocationWrongParamCount() { List validate = validator.validate( getReader( "INVOCATION_WRONG_PARAM_COUNT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSizeGreaterThan(0); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - + @Test - public void testITEMCOMP_DUPLICATED() { + void itemcompDuplicated() { List validate = validator.validate( getReader( "ITEMCOMP_DUPLICATED.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATED_ITEM_DEF))).isTrue(); } - + @Test - public void testITEMDEF_NOT_UNIQUE() { + void itemdefNotUnique() { List validate = validator.validate( getReader( "ITEMDEF_NOT_UNIQUE.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(3); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATED_ITEM_DEF))).isTrue(); } - + @Test - public void testITEMDEF_NOT_UNIQUE_DROOLS_1450() { + void itemdefNotUniqueDrools1450() { // DROOLS-1450 List validate = validator.validate( getReader( "ITEMDEF_NOT_UNIQUE_DROOLS-1450.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } - + @Test - public void testRELATION_DUP_COLUMN() { + void relationDupColumn() { List validate = validator.validate( getReader( "RELATION_DUP_COLUMN.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATED_RELATION_COLUMN))).isTrue(); } - + @Test - public void testRELATION_ROW_CELL_NOTLITERAL() { + void relationRowCellNotliteral() { List validate = validator.validate( getReader( "RELATION_ROW_CELL_NOTLITERAL.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.RELATION_CELL_NOT_LITERAL))).isTrue(); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_EXPRESSION))).isTrue(); } - + @Test - public void testRELATION_ROW_CELLCOUNTMISMATCH() { + void relationRowCellcountmismatch() { List validate = validator.validate( getReader( "RELATION_ROW_CELLCOUNTMISMATCH.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.RELATION_CELL_COUNT_MISMATCH))).isTrue(); } @Test - public void testMortgageRecommender() { + void mortgageRecommender() { // This file has a gazillion errors. The goal of this test is simply check that the validator itself is not blowing up // and raising an exception. The errors in the file itself are irrelevant. List validate = validator.validate( getReader( "MortgageRecommender.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -233,14 +234,14 @@ public void testMortgageRecommender() { } @Test - public void testREQAUTH_NOT_KNOWLEDGESOURCEbis() { + void reqauth_not_knowledgesourcEbis() { // DROOLS-1435 List validate = validator.validate( getReader( "REQAUTH_NOT_KNOWLEDGESOURCEbis.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); } @Test - public void testVARIABLE_LEADING_TRAILING_SPACES() { + void variableLeadingTrailingSpaces() { List validate = validator.validate( getReader( "VARIABLE_LEADING_TRAILING_SPACES.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).isNotEmpty(); assertThat(validate).anySatisfy(p -> { @@ -254,14 +255,14 @@ public void testVARIABLE_LEADING_TRAILING_SPACES() { } @Test - public void testUNKNOWN_VARIABLE() { + void unknownVariable() { List validate = validator.validate( getReader( "UNKNOWN_VARIABLE.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.ERR_COMPILING_FEEL))).isTrue(); } @Test - public void testVALIDATION() { + void validation() { List validate = validator.validate( getReader( "validation.dmn" ), VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(7); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.INVALID_NAME))).isTrue(); @@ -273,28 +274,28 @@ public void testVALIDATION() { } @Test - public void testUsingSemanticNamespacePrefix() { + void usingSemanticNamespacePrefix() { // DROOLS-2419 List validate = validator.validate(getReader("UsingSemanticNS.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testUsingSemanticNamespacePrefixAndExtensions() { + void usingSemanticNamespacePrefixAndExtensions() { // DROOLS-2447 List validate = validator.validate(getReader("Hello_World_semantic_namespace_with_extensions.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testNoPrefixAndExtensions() { + void noPrefixAndExtensions() { // DROOLS-2447 List validate = validator.validate(getReader("Hello_World_no_prefix_with_extensions.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testDecisionService20181008() { + void decisionService20181008() { // DROOLS-3087 DMN Validation of DecisionService referencing a missing import List validate = validator.validateUsing(VALIDATE_MODEL, VALIDATE_COMPILATION) .theseModels(getReader("DSWithImport20181008-ModelA.dmn"), diff --git a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorTypeRefTest.java b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorTypeRefTest.java index 38e9f322478..d86455b24e9 100644 --- a/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorTypeRefTest.java +++ b/kie-dmn/kie-dmn-legacy-tests/src/test/java/org/kie/dmn/legacy/tests/validation/v1_1/ValidatorTypeRefTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.AbstractValidatorTest; @@ -33,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorTypeRefTest extends AbstractValidatorTest { +class ValidatorTypeRefTest extends AbstractValidatorTest { @Test - public void testTYPEREF_NO_FEEL_TYPE_ReaderInput() throws IOException { + void typeref_no_feel_type_ReaderInput() throws IOException { try (final Reader reader = getReader("typeref/TYPEREF_NO_FEEL_TYPE.dmn")) { final List validate = validator.validate( reader, @@ -47,7 +47,7 @@ public void testTYPEREF_NO_FEEL_TYPE_ReaderInput() throws IOException { } @Test - public void testTYPEREF_NO_FEEL_TYPE_FileInput() { + void typeref_no_feel_type_FileInput() { final List validate = validator.validate( getFile("typeref/TYPEREF_NO_FEEL_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testTYPEREF_NO_FEEL_TYPE_FileInput() { } @Test - public void testTYPEREF_NO_FEEL_TYPE_DefinitionsInput() { + void typeref_no_feel_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("typeref/TYPEREF_NO_FEEL_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", "TYPEREF_NO_FEEL_TYPE"), VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -65,7 +65,7 @@ public void testTYPEREF_NO_FEEL_TYPE_DefinitionsInput() { } @Test - public void testTYPEREF_NO_NS_ReaderInput() throws IOException { + void typeref_no_ns_ReaderInput() throws IOException { try (final Reader reader = getReader("typeref/TYPEREF_NO_NS.dmn")) { final List validate = validator.validate( reader, @@ -77,7 +77,7 @@ public void testTYPEREF_NO_NS_ReaderInput() throws IOException { } @Test - public void testTYPEREF_NO_NS_FileInput() { + void typeref_no_ns_FileInput() { final List validate = validator.validate( getFile("typeref/TYPEREF_NO_NS.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -87,7 +87,7 @@ public void testTYPEREF_NO_NS_FileInput() { } @Test - public void testTYPEREF_NO_NS_DefinitionsInput() { + void typeref_no_ns_DefinitionsInput() { final List validate = validator.validate( getDefinitions("typeref/TYPEREF_NO_NS.dmn", "https://github.com/kiegroup/kie-dmn", "TYPEREF_NO_NS"), VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -96,7 +96,7 @@ public void testTYPEREF_NO_NS_DefinitionsInput() { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_ReaderInput() throws IOException { + void typeref_not_feel_not_def_ReaderInput() throws IOException { try (final Reader reader = getReader("typeref/TYPEREF_NOT_FEEL_NOT_DEF.dmn")) { final List validate = validator.validate( reader, @@ -108,7 +108,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_ReaderInput() throws IOException { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_FileInput() { + void typeref_not_feel_not_def_FileInput() { final List validate = validator.validate( getFile("typeref/TYPEREF_NOT_FEEL_NOT_DEF.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -118,7 +118,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_FileInput() { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_DefinitionsInput() { + void typeref_not_feel_not_def_DefinitionsInput() { final List validate = validator.validate( getDefinitions("typeref/TYPEREF_NOT_FEEL_NOT_DEF.dmn", "https://github.com/kiegroup/kie-dmn", "TYPEREF_NOT_FEEL_NOT_DEF"), VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -128,7 +128,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_DefinitionsInput() { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_ResourceInput() throws IOException { + void typeref_not_feel_not_defValidResourceInput() throws IOException { // DROOLS-1433 // the assumption is that the following document TYPEREF_NOT_FEEL_NOT_DEF_valid.dmn should NOT contain any DMNMessageTypeId.TYPEREF_NOT_FEEL_NOT_DEF at all // the test also highlight typically in a DMN model many nodes would not define a typeRef, resulting in a large number of false negative @@ -141,7 +141,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_ResourceInput() throws IOExceptio } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_FileInput() { + void typeref_not_feel_not_defValidFileInput() { // DROOLS-1433 // the assumption is that the following document TYPEREF_NOT_FEEL_NOT_DEF_valid.dmn should NOT contain any DMNMessageTypeId.TYPEREF_NOT_FEEL_NOT_DEF at all // the test also highlight typically in a DMN model many nodes would not define a typeRef, resulting in a large number of false negative @@ -152,7 +152,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_FileInput() { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_DefinitionsInput() { + void typeref_not_feel_not_defValidDefinitionsInput() { // DROOLS-1433 // the assumption is that the following document TYPEREF_NOT_FEEL_NOT_DEF_valid.dmn should NOT contain any DMNMessageTypeId.TYPEREF_NOT_FEEL_NOT_DEF at all // the test also highlight typically in a DMN model many nodes would not define a typeRef, resulting in a large number of false negative @@ -161,9 +161,9 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_DefinitionsInput() { VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } - + @Test - public void testBKM_WITH_NO_TYPEREF_IS_OK_DefinitionsInput() { + void bkm_with_no_typeref_is_ok_DefinitionsInput() { // DROOLS-2631 final List validate = validator.validate( getDefinitions("typeref/BKM_WITH_NO_TYPEREF_IS_OK.dmn", "http://www.trisotech.com/dmn/definitions/_7e8d7561-657a-4729-b2a9-5a6279df6d5d", "Drawing 1"), diff --git a/kie-dmn/kie-dmn-model/pom.xml b/kie-dmn/kie-dmn-model/pom.xml index 04915150eb6..27b83587bab 100644 --- a/kie-dmn/kie-dmn-model/pom.xml +++ b/kie-dmn/kie-dmn-model/pom.xml @@ -45,11 +45,6 @@ provided - - junit - junit - test - org.mockito mockito-core @@ -80,6 +75,11 @@ yasson test + + org.junit.jupiter + junit-jupiter + test + diff --git a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/AssociationDirectionTest.java b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/AssociationDirectionTest.java index 72072b7971b..f7df00129e4 100644 --- a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/AssociationDirectionTest.java +++ b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/AssociationDirectionTest.java @@ -18,15 +18,15 @@ */ package org.kie.dmn.model.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -public class AssociationDirectionTest { +class AssociationDirectionTest { @Test - public void testFromValue() { + void fromValue() { assertThat(AssociationDirection.fromValue("None")).isEqualTo(AssociationDirection.NONE); assertThat(AssociationDirection.fromValue("One")).isEqualTo(AssociationDirection.ONE); assertThat(AssociationDirection.fromValue("Both")).isEqualTo(AssociationDirection.BOTH); diff --git a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/DecisionTableOrientationTest.java b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/DecisionTableOrientationTest.java index faf4d6bb8f3..c4f29f05399 100644 --- a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/DecisionTableOrientationTest.java +++ b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/DecisionTableOrientationTest.java @@ -18,15 +18,15 @@ */ package org.kie.dmn.model.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -public class DecisionTableOrientationTest { +class DecisionTableOrientationTest { @Test - public void testFromValue() { + void fromValue() { assertThat(DecisionTableOrientation.fromValue("Rule-as-Row")).isEqualTo(DecisionTableOrientation.RULE_AS_ROW); assertThat(DecisionTableOrientation.fromValue("Rule-as-Column")).isEqualTo(DecisionTableOrientation.RULE_AS_COLUMN); assertThat(DecisionTableOrientation.fromValue("CrossTable")).isEqualTo(DecisionTableOrientation.CROSS_TABLE); diff --git a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/FunctionKindTest.java b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/FunctionKindTest.java index 21e162a12eb..29f3a719336 100644 --- a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/FunctionKindTest.java +++ b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/FunctionKindTest.java @@ -18,15 +18,15 @@ */ package org.kie.dmn.model.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -public class FunctionKindTest { +class FunctionKindTest { @Test - public void testFromValue() { + void fromValue() { assertThat(FunctionKind.fromValue("FEEL")).isEqualTo(FunctionKind.FEEL); assertThat(FunctionKind.fromValue("Java")).isEqualTo(FunctionKind.JAVA); assertThat(FunctionKind.fromValue("JAVA")).isEqualTo(FunctionKind.JAVA); diff --git a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/HitPolicyTest.java b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/HitPolicyTest.java index eaa024820a4..647100bae0e 100644 --- a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/HitPolicyTest.java +++ b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/HitPolicyTest.java @@ -18,20 +18,20 @@ */ package org.kie.dmn.model.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -public class HitPolicyTest { +class HitPolicyTest { @Test - public void testFromValue() { + void fromValue() { assertThatIllegalArgumentException().isThrownBy(() -> HitPolicy.fromValue("asd")); } @Test - public void testMultiHit() { + void multiHit() { assertThat(HitPolicy.UNIQUE.isMultiHit()).isFalse(); assertThat(HitPolicy.FIRST.isMultiHit()).isFalse(); assertThat(HitPolicy.PRIORITY.isMultiHit()).isFalse(); diff --git a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/RowLocationTest.java b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/RowLocationTest.java index 8d8ec39283a..66cbc4ff8f4 100644 --- a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/RowLocationTest.java +++ b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/RowLocationTest.java @@ -20,14 +20,14 @@ import javax.xml.stream.Location; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -public class RowLocationTest { +class RowLocationTest { @Test - public void smokeTest() { + void smokeTest() { RowLocation ut = new RowLocation(new DummyLocation()); assertThat(ut.getCharacterOffset()).isEqualTo(-1); assertThat(ut.getColumnNumber()).isEqualTo(-1); diff --git a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/TUnaryTestsTest.java b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/TUnaryTestsTest.java index d6ae702d7dd..fe2801c7c9e 100644 --- a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/TUnaryTestsTest.java +++ b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/TUnaryTestsTest.java @@ -18,15 +18,15 @@ */ package org.kie.dmn.model.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.model.v1_2.TDMNElement; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -public class TUnaryTestsTest { +class TUnaryTestsTest { @Test - public void smokeTest() { + void smokeTest() { UnaryTests ut = new STUnaryTests(); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> ut.getTypeRef()); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> ut.setTypeRef(null)); diff --git a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/dmndi/AlignmentKindTest.java b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/dmndi/AlignmentKindTest.java index f636eaf7c62..2b2ed58d6df 100644 --- a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/dmndi/AlignmentKindTest.java +++ b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/dmndi/AlignmentKindTest.java @@ -18,15 +18,15 @@ */ package org.kie.dmn.model.api.dmndi; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -public class AlignmentKindTest { +class AlignmentKindTest { @Test - public void testFromValue() { + void fromValue() { assertThat(AlignmentKind.fromValue("start")).isEqualTo(AlignmentKind.START).hasFieldOrPropertyWithValue("value", "start"); assertThat(AlignmentKind.fromValue("end")).isEqualTo(AlignmentKind.END); assertThat(AlignmentKind.fromValue("center")).isEqualTo(AlignmentKind.CENTER); diff --git a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/dmndi/KnownColorTest.java b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/dmndi/KnownColorTest.java index ea923e97653..cd8d60c2b94 100644 --- a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/dmndi/KnownColorTest.java +++ b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/api/dmndi/KnownColorTest.java @@ -18,15 +18,15 @@ */ package org.kie.dmn.model.api.dmndi; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -public class KnownColorTest { +class KnownColorTest { @Test - public void testFromValue() { + void fromValue() { assertThat(KnownColor.fromValue("maroon")).isEqualTo(KnownColor.MAROON).hasFieldOrPropertyWithValue("value", "maroon"); assertThat(KnownColor.fromValue("red")).isEqualTo(KnownColor.RED); assertThat(KnownColor.fromValue("orange")).isEqualTo(KnownColor.ORANGE); diff --git a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/jandex/KieDMNModelJandexTest.java b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/jandex/KieDMNModelJandexTest.java index 44999d32c37..0a383ce6fbe 100644 --- a/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/jandex/KieDMNModelJandexTest.java +++ b/kie-dmn/kie-dmn-model/src/test/java/org/kie/dmn/model/jandex/KieDMNModelJandexTest.java @@ -34,12 +34,11 @@ import jakarta.json.bind.Jsonb; import jakarta.json.bind.JsonbBuilder; import jakarta.json.bind.JsonbConfig; - import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; import org.jboss.jandex.Index; import org.jboss.jandex.Indexer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.model.api.DMNModelInstrumentedBase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,7 +51,7 @@ public class KieDMNModelJandexTest { private final String moduleName = "kie-dmn-model"; @Test - public void testReflectConfigJSON() throws Exception { + void reflectConfigJSON() throws Exception { Indexer indexer = new Indexer(); InputStream stream = getClass().getClassLoader() .getResourceAsStream("org/kie/dmn/model/api/DMNModelInstrumentedBase.class"); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/AllowNullTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/AllowNullTest.java index ce1758dc84c..60779ed8546 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/AllowNullTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/AllowNullTest.java @@ -31,7 +31,7 @@ class AllowNullTest extends BaseDMNOASTest { @Test - void testVowels() throws Exception { + void vowels() throws Exception { final DMNRuntime runtime = createRuntime("vowels.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -46,7 +46,7 @@ void testVowels() throws Exception { } @Test - void testVowelsAllowNull() throws Exception { + void vowelsAllowNull() throws Exception { final DMNRuntime runtime = createRuntime("vowelsAllowNull.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -61,7 +61,7 @@ void testVowelsAllowNull() throws Exception { } @Test - void testSoundItemDefAllowNull() throws Exception { + void soundItemDefAllowNull() throws Exception { final DMNRuntime runtime = createRuntime("RecommenderHitPolicy1_allowNull_itemDef.dmn", DMNRuntimeTest.class); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/CH11Test.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/CH11Test.java index 4918a19aa22..fbe2b45d76e 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/CH11Test.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/CH11Test.java @@ -31,7 +31,7 @@ class CH11Test extends BaseDMNOASTest { @Test - void test_dmn14support() throws Exception { + void dmn14support() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("Chapter 11 Example.dmn", DMN14specificTest.class, "Financial.dmn"); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java index 9755f3d1fd7..3e387292db1 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java @@ -42,7 +42,7 @@ class EnumGenerationTest extends BaseDMNOASTest { private static JsonNode definitions; @BeforeAll - public static void setup() { + static void setup() { DMNRuntime runtime = createRuntime(DMN_FILE, EnumGenerationTest.class); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -54,7 +54,7 @@ public static void setup() { } @Test - void testNumberAllowedValues() { + void numberAllowedValues() { JsonNode node = definitions.get("numberAllowedValues"); assertThat(node).isNotNull(); ArrayNode arrayNode = (ArrayNode) node.get("enum"); @@ -69,7 +69,7 @@ void testNumberAllowedValues() { } @Test - void testStringAllowedValues() { + void stringAllowedValues() { JsonNode node = definitions.get("stringAllowedValues"); assertThat(node).isNotNull(); ArrayNode arrayNode = (ArrayNode) node.get("enum"); @@ -84,7 +84,7 @@ void testStringAllowedValues() { } @Test - void testStringNullableAllowedValues() { + void stringNullableAllowedValues() { JsonNode node = definitions.get("stringNullableAllowedValues"); assertThat(node).isNotNull(); ArrayNode arrayNode = (ArrayNode) node.get("enum"); @@ -98,7 +98,7 @@ void testStringNullableAllowedValues() { } @Test - void testNumberTypeConstraint() { + void numberTypeConstraint() { JsonNode node = definitions.get("numberTypeConstraint"); assertThat(node).isNotNull(); ArrayNode arrayNode = (ArrayNode) node.get("enum"); @@ -113,7 +113,7 @@ void testNumberTypeConstraint() { } @Test - void testStringTypeConstraint() { + void stringTypeConstraint() { JsonNode node = definitions.get("stringTypeConstraint"); assertThat(node).isNotNull(); ArrayNode arrayNode = (ArrayNode) node.get("enum"); @@ -128,7 +128,7 @@ void testStringTypeConstraint() { } @Test - void testStringNullableTypeConstraint() { + void stringNullableTypeConstraint() { JsonNode node = definitions.get("stringNullableTypeConstraint"); assertThat(node).isNotNull(); ArrayNode arrayNode = (ArrayNode) node.get("enum"); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ImportingTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ImportingTest.java index 17816d04fd6..2b7a02aec24 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ImportingTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ImportingTest.java @@ -18,22 +18,21 @@ */ package org.kie.dmn.openapi; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.networknt.schema.JsonSchema; import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.imports.ImportsTest; import org.kie.dmn.openapi.model.DMNOASResult; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.JsonSchema; - import static org.assertj.core.api.Assertions.assertThat; class ImportingTest extends BaseDMNOASTest { @Test - void testBasicImports() throws Exception { + void basicImports() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("baseSum.dmn", ImportsTest.class, "importingSum.dmn"); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MultipleModelsTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MultipleModelsTest.java index 9a3d5da0791..4b590d8305e 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MultipleModelsTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/MultipleModelsTest.java @@ -32,7 +32,7 @@ class MultipleModelsTest extends BaseDMNOASTest { @Test - void testNSEW() throws Exception { + void nsew() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("NSEW.dmn", DMNRuntimeTypesTest.class, "Traffic Violation.dmn"); @@ -50,7 +50,7 @@ void testNSEW() throws Exception { } @Test - void testTF() throws Exception { + void tf() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("NSEW.dmn", DMNRuntimeTypesTest.class, "Traffic Violation.dmn"); @@ -71,7 +71,7 @@ void testTF() throws Exception { } @Test - void testCH11() throws Exception { + void ch11() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("Chapter 11 Example.dmn", DMN13specificTest.class, "Financial.dmn"); @@ -87,7 +87,7 @@ void testCH11() throws Exception { } @Test - void testSameName() throws Exception { + void sameName() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("sameNameNS1.dmn", this.getClass(), "sameNameNS2.dmn"); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/NumberAllowedValuesTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/NumberAllowedValuesTest.java index ce4aca2cf9f..a496ffbc314 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/NumberAllowedValuesTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/NumberAllowedValuesTest.java @@ -18,21 +18,20 @@ */ package org.kie.dmn.openapi; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.networknt.schema.JsonSchema; import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.openapi.model.DMNOASResult; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.JsonSchema; - import static org.assertj.core.api.Assertions.assertThat; class NumberAllowedValuesTest extends BaseDMNOASTest { @Test - void testAllowedValues() throws Exception { + void allowedValues() throws Exception { final DMNRuntime runtime = createRuntime("numberAllowedValues.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -44,7 +43,7 @@ void testAllowedValues() throws Exception { } @Test - void testNumberList() throws Exception { + void numberList() throws Exception { final DMNRuntime runtime = createRuntime("numberList.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -57,7 +56,7 @@ void testNumberList() throws Exception { } @Test - void testGT() throws Exception { + void gt() throws Exception { final DMNRuntime runtime = createRuntime("numberGT.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonsTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonsTest.java index 51dec56d143..71011abdac9 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonsTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/PersonsTest.java @@ -43,7 +43,7 @@ void test() throws Exception { } @Test - void testForPrefix() throws Exception { + void forPrefix() throws Exception { final DMNRuntime runtime = createRuntime("persons.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels(), "#/definitions/").build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ProcessItemTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ProcessItemTest.java index 5441ed06c3c..ae51a97270b 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ProcessItemTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/ProcessItemTest.java @@ -69,7 +69,7 @@ private void checkProcessItem_2(final DMNRuntime runtime, DMNOASResult result) t } @Test - void test_together() throws Exception { + void together() throws Exception { final DMNRuntime runtime = createRuntimeWithAdditionalResources("processItem.dmn", this.getClass(), "processItem_2.dmn"); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); @@ -78,7 +78,7 @@ void test_together() throws Exception { } @Test - void test_Colliding() { + void colliding() { final DMNRuntime runtime = createRuntimeWithAdditionalResources("processItem.dmn", this.getClass(), "processItemCollidingNS.dmn"); assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(() -> DMNOASGeneratorFactory.generator(runtime.getModels()).build()) diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/UndefinedTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/UndefinedTest.java index a0d8ad0a9e6..adf6246f98b 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/UndefinedTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/UndefinedTest.java @@ -30,7 +30,7 @@ class UndefinedTest extends BaseDMNOASTest { @Test - void testUndefinedIO() throws Exception { + void undefinedIO() throws Exception { final DMNRuntime runtime = createRuntime("undefinedIO.dmn", this.getClass()); DMNOASResult result = DMNOASGeneratorFactory.generator(runtime.getModels()).build(); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNTypeSchemasTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNTypeSchemasTest.java index 93d9fca6f2a..45174987c1c 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNTypeSchemasTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNTypeSchemasTest.java @@ -40,7 +40,7 @@ class DMNTypeSchemasTest { @Test - void testPopulateSchemaWithConstraintsForAllowedValues() { + void populateSchemaWithConstraintsForAllowedValues() { List enumBase = Arrays.asList("DMN", "PMML", "JBPMN", "DRL"); List toEnum = enumBase.stream().map(toMap -> String.format("\"%s\"", toMap)).collect(Collectors.toUnmodifiableList()); @@ -71,7 +71,7 @@ void testPopulateSchemaWithConstraintsForAllowedValues() { } @Test - void testPopulateSchemaWithConstraintsForTypeConstraints() { + void populateSchemaWithConstraintsForTypeConstraints() { List enumBase = Arrays.asList("DMN", "PMML", "JBPMN", "DRL"); List toEnum = enumBase.stream().map(toMap -> String.format("\"%s\"", toMap)).collect(Collectors.toUnmodifiableList()); @@ -103,7 +103,7 @@ void testPopulateSchemaWithConstraintsForTypeConstraints() { } @Test - void testPopulateSchemaWithRangesForAllowedValues() { + void populateSchemaWithRangesForAllowedValues() { List toRange = Arrays.asList("(>1)", "(<=10)"); String allowedValuesString = String.join(",", toRange.stream().map(toMap -> String.format("%s", toMap)).toList()); @@ -122,7 +122,7 @@ void testPopulateSchemaWithRangesForAllowedValues() { } @Test - void testPopulateSchemaWithRangesForTypeConstraints() { + void populateSchemaWithRangesForTypeConstraints() { List toRange = Arrays.asList("(>1)", "(<=10)"); String typeConstraintsString = String.join(",", toRange.stream().map(toMap -> String.format("%s", toMap)).toList()); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapperTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapperTest.java index 7010edd09d0..c0951f69bde 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapperTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/DMNUnaryTestsMapperTest.java @@ -48,7 +48,7 @@ class DMNUnaryTestsMapperTest { @Test - void testPopulateSchemaFromUnaryTestsForEnumsWithoutNull() { + void populateSchemaFromUnaryTestsForEnumsWithoutNull() { Schema toPopulate = OASFactory.createObject(Schema.class); List expectedStrings = Arrays.asList("ONE", "TWO"); List toEnum = expectedStrings.stream().map(toMap -> String.format("\"%s\"", toMap)).collect(Collectors.toUnmodifiableList()); @@ -63,7 +63,7 @@ void testPopulateSchemaFromUnaryTestsForEnumsWithoutNull() { } @Test - void testPopulateSchemaFromUnaryTestsForEnumsWithNull() { + void populateSchemaFromUnaryTestsForEnumsWithNull() { Schema toPopulate = OASFactory.createObject(Schema.class); List expectedStrings = Arrays.asList(null, "ONE", "TWO"); List toEnum = expectedStrings.stream().map(toFormat -> toFormat == null ? "null": String.format("\"%s\"", toFormat)).collect(Collectors.toUnmodifiableList()); @@ -77,7 +77,7 @@ void testPopulateSchemaFromUnaryTestsForEnumsWithNull() { } @Test - void testPopulateSchemaFromUnaryTestsForEnumSucceed() { + void populateSchemaFromUnaryTestsForEnumSucceed() { List enumBase = Arrays.asList("DMN", "PMML", "JBPMN", "DRL"); List toEnum = enumBase.stream().map(toMap -> String.format("\"%s\"", toMap)).collect(Collectors.toUnmodifiableList()); String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); @@ -112,7 +112,7 @@ void testPopulateSchemaFromUnaryTestsForEnumSucceed() { } @Test - void testPopulateSchemaFromUnaryTestsFails() { + void populateSchemaFromUnaryTestsFails() { List toEnum = Arrays.asList(null, null, "@\"2024-01-01\""); String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); List toCheck = @@ -123,7 +123,7 @@ void testPopulateSchemaFromUnaryTestsFails() { } @Test - void testPopulateSchemaFromBaseNodeSucceed() { + void populateSchemaFromBaseNodeSucceed() { List enumBase = List.of("DMN"); List toEnum = enumBase.stream().map(toMap -> String.format("\"%s\"", toMap)).toList(); String expression = String.join(",", toEnum.stream().map(toMap -> String.format("%s", toMap)).toList()); diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapperTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapperTest.java index e714250e15d..fb4e2369d43 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapperTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/impl/RangeNodeSchemaMapperTest.java @@ -42,7 +42,7 @@ class RangeNodeSchemaMapperTest { private static final FEEL feel = FEEL.newInstance(); @Test - void testEvaluateUnaryTestsForNumberRange() { + void evaluateUnaryTestsForNumberRange() { List toRange = Arrays.asList("(>1)", "(<=10)"); List ranges = getBaseNodes(toRange, RangeNode.class); Schema toPopulate = OASFactory.createObject(Schema.class); @@ -54,7 +54,7 @@ void testEvaluateUnaryTestsForNumberRange() { } @Test - void testEvaluateUnaryTestsForDateRange() { + void evaluateUnaryTestsForDateRange() { List expectedDates = Arrays.asList(LocalDate.of(2022, 1, 1), LocalDate.of(2024, 1, 1)); List formattedDates = expectedDates.stream() .map(toFormat -> String.format("@\"%s-0%s-0%s\"", toFormat.getYear(), toFormat.getMonthValue(), toFormat.getDayOfMonth())) @@ -72,7 +72,7 @@ void testEvaluateUnaryTestsForDateRange() { } @Test - void testConsolidateRangesForNumberRange() { + void consolidateRangesForNumberRange() { Range lowRange = new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, null, Range.RangeBoundary.OPEN); Range highRange = new RangeImpl(Range.RangeBoundary.OPEN, null, BigDecimal.TEN, Range.RangeBoundary.CLOSED); List ranges = getRangeNodes(lowRange, highRange); @@ -83,7 +83,7 @@ void testConsolidateRangesForNumberRange() { } @Test - void testConsolidateRangesForDateRange() { + void consolidateRangesForDateRange() { List expectedDates = Arrays.asList(LocalDate.of(2022, 1, 1), LocalDate.of(2024, 1, 1)); Range lowRange = new RangeImpl(Range.RangeBoundary.OPEN, expectedDates.get(0), null, Range.RangeBoundary.OPEN); Range highRange = new RangeImpl(Range.RangeBoundary.OPEN, null, expectedDates.get(1), @@ -102,7 +102,7 @@ void testConsolidateRangesForDateRange() { } @Test - void testConsolidateRangesInvalidRepeatedLB() { + void consolidateRangesInvalidRepeatedLB() { Range lowRange = new RangeImpl(Range.RangeBoundary.CLOSED, 0, null, Range.RangeBoundary.CLOSED); Range highRange = new RangeImpl(Range.RangeBoundary.CLOSED, 0, 100, Range.RangeBoundary.CLOSED); List ranges = getRangeNodes(lowRange, highRange); @@ -111,7 +111,7 @@ void testConsolidateRangesInvalidRepeatedLB() { } @Test - void testConsolidateRangesInvalidRepeatedUB() { + void consolidateRangesInvalidRepeatedUB() { Range lowRange = new RangeImpl(Range.RangeBoundary.CLOSED, null, 50, Range.RangeBoundary.CLOSED); Range highRange = new RangeImpl(Range.RangeBoundary.CLOSED, null, 100, Range.RangeBoundary.CLOSED); List ranges = getRangeNodes(lowRange, highRange); diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests-trusty/pom.xml b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests-trusty/pom.xml index 8171a8418e5..8861992393d 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests-trusty/pom.xml +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests-trusty/pom.xml @@ -173,11 +173,6 @@ assertj-core test - - junit - junit - test - diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/pom.xml b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/pom.xml index cf4d997a2de..3e2193a8d9a 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/pom.xml +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/pom.xml @@ -64,13 +64,13 @@ slf4j-api - junit - junit + org.assertj + assertj-core test - org.assertj - assertj-core + org.junit.jupiter + junit-jupiter test diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNKMeansModelPMMLTest.java b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNKMeansModelPMMLTest.java index b6a123536c8..1aef999869a 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNKMeansModelPMMLTest.java +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNKMeansModelPMMLTest.java @@ -20,7 +20,7 @@ import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -39,7 +39,7 @@ public abstract class DMNKMeansModelPMMLTest { private DMNModel dmnModel; @Test - public void testKMeans() { + public void kMeans() { runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("KMeans.dmn", DMNKMeansModelPMMLTest.class, "test_kmeans.pmml"); diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNMiningModelPMMLTest.java b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNMiningModelPMMLTest.java index 2fa8c36829a..65f1c1ceffc 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNMiningModelPMMLTest.java +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNMiningModelPMMLTest.java @@ -20,7 +20,7 @@ import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -37,7 +37,7 @@ public abstract class DMNMiningModelPMMLTest { public static final Logger LOG = LoggerFactory.getLogger(DMNMiningModelPMMLTest.class); @Test - public void testMiningModelSum() { + public void miningModelSum() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("SumMiningModel.dmn", DMNMiningModelPMMLTest.class, "test_mining_model_summed.pmml"); diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNNaiveBayesPMMLTest.java b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNNaiveBayesPMMLTest.java index b3ef0fbd9c9..7fd69ea9e8a 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNNaiveBayesPMMLTest.java +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNNaiveBayesPMMLTest.java @@ -20,7 +20,7 @@ import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -39,7 +39,7 @@ public abstract class DMNNaiveBayesPMMLTest { private DMNModel dmnModel; @Test - public void testKMeans() { + public void kMeans() { runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("NaiveBayes.dmn", DMNNaiveBayesPMMLTest.class, "test_naive_bayes.pmml"); diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNNeuralNetworkPMMLTest.java b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNNeuralNetworkPMMLTest.java index 2ab5e5a420c..bb119d5b4ab 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNNeuralNetworkPMMLTest.java +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNNeuralNetworkPMMLTest.java @@ -20,7 +20,7 @@ import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -40,7 +40,7 @@ public abstract class DMNNeuralNetworkPMMLTest { private DMNModel dmnModel; @Test - public void testNeuralNetworks() { + public void neuralNetworks() { runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("NeuralNetwork.dmn", DMNKMeansModelPMMLTest.class, "test_nn.pmml"); diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNRegressionPMMLTest.java b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNRegressionPMMLTest.java index 67a4ec42963..18781c9451f 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNRegressionPMMLTest.java +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNRegressionPMMLTest.java @@ -20,7 +20,7 @@ import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -37,7 +37,7 @@ public abstract class DMNRegressionPMMLTest { public static final Logger LOG = LoggerFactory.getLogger(DMNRegressionPMMLTest.class); @Test - public void testRegression() { + public void regression() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("KiePMMLRegression.dmn", DMNRegressionPMMLTest.class, "test_regression.pmml"); diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNRuntimePMMLTest.java b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNRuntimePMMLTest.java index 59b897d095d..f583d4955fa 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNRuntimePMMLTest.java +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNRuntimePMMLTest.java @@ -20,12 +20,11 @@ import java.io.InputStreamReader; import java.math.BigDecimal; -import java.util.Arrays; import java.util.Collections; import java.util.Map; import org.drools.compiler.kie.builder.impl.DrlProject; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -66,7 +65,7 @@ public DMNRuntimePMMLTest() { private static final double COMPARISON_DELTA = 0.000001; @Test - public void testBasic() { + public void basic() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("KiePMMLScoreCard.dmn", DMNRuntimePMMLTest.class, "test_scorecard.pmml"); @@ -74,7 +73,7 @@ public void testBasic() { } @Test - public void testWithInputTypes() { + public void withInputTypes() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("KiePMMLScoreCard_wInputType.dmn", DMNRuntimePMMLTest.class, "test_scorecard.pmml"); @@ -82,7 +81,7 @@ public void testWithInputTypes() { } @Test - public void testBasicNoKieAssembler() { + public void basicNoKieAssembler() { DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() .setRelativeImportResolver((ns, n, uri) -> new InputStreamReader(DMNRuntimePMMLTest.class.getResourceAsStream(uri))) .buildConfiguration() @@ -127,7 +126,7 @@ static void runDMNModelInvokingPMML(final DMNRuntime runtime) { * test to use same building steps of BC/WB */ @Test - public void testSteppedCompilation() { + public void steppedCompilation() { KieServices ks = KieServices.Factory.get(); KieFileSystem kfs = ks.newKieFileSystem(); @@ -150,7 +149,7 @@ public void testSteppedCompilation() { } @Test - public void testMultiOutputs() { + public void multiOutputs() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("KiePMMLRegressionClax.dmn", DMNRuntimePMMLTest.class, "test_regression_clax.pmml"); diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNTreePMMLTest.java b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNTreePMMLTest.java index a8143199b72..e883a9b0d06 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNTreePMMLTest.java +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/DMNTreePMMLTest.java @@ -18,7 +18,7 @@ */ package org.kie.dmn.pmml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -38,7 +38,7 @@ public abstract class DMNTreePMMLTest { private static final String NOTHING = "nothing"; @Test - public void testTreeWithOutput() { + public void treeWithOutput() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("KiePMMLTree.dmn", DMNTreePMMLTest.class, "test_tree.pmml"); @@ -49,7 +49,7 @@ public void testTreeWithOutput() { } @Test - public void testTreeWithoutOutput() { + public void treeWithoutOutput() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("KiePMMLTree_no_output.dmn", DMNTreePMMLTest.class, "test_tree_no_output.pmml"); diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/PMMLInfoTest.java b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/PMMLInfoTest.java index 4e0f2202d83..cb90b6c934e 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/PMMLInfoTest.java +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/PMMLInfoTest.java @@ -18,14 +18,14 @@ */ package org.kie.dmn.pmml; -import org.junit.Test; +import java.io.InputStream; + +import org.junit.jupiter.api.Test; import org.kie.dmn.core.pmml.PMMLInfo; import org.kie.dmn.core.pmml.PMMLModelInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.InputStream; - import static org.assertj.core.api.Assertions.assertThat; @@ -34,7 +34,7 @@ public abstract class PMMLInfoTest { public static final Logger LOG = LoggerFactory.getLogger(PMMLInfoTest.class); @Test - public void testPMMLInfo() throws Exception { + public void pmmlInfo() throws Exception { InputStream inputStream = PMMLInfoTest.class.getResourceAsStream("test_scorecard.pmml"); PMMLInfo p0 = PMMLInfo.from(inputStream); assertThat(p0.getModels()).hasSize(1); diff --git a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/PMMLValidatorImportTest.java b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/PMMLValidatorImportTest.java index 806b6e880b8..c5c62725781 100644 --- a/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/PMMLValidatorImportTest.java +++ b/kie-dmn/kie-dmn-pmml-tests-parent/kie-dmn-pmml-tests/src/test/java/org/kie/dmn/pmml/PMMLValidatorImportTest.java @@ -18,7 +18,11 @@ */ package org.kie.dmn.pmml; -import org.junit.Test; +import java.io.IOException; +import java.io.Reader; +import java.util.List; + +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.model.api.Definitions; import org.kie.dmn.validation.AbstractValidatorTest; @@ -26,16 +30,12 @@ import org.kie.dmn.validation.DMNValidator.Validation; import org.kie.dmn.validation.ValidatorUtil; -import java.io.IOException; -import java.io.Reader; -import java.util.List; - import static org.assertj.core.api.Assertions.assertThat; public abstract class PMMLValidatorImportTest extends AbstractValidatorTest { @Test - public void testImportPMML() throws IOException { + public void importPMML() throws IOException { // DROOLS-4187 kie-dmn-validation: Incorrect import detection final List messages = validator.validateUsing(Validation.VALIDATE_MODEL) .theseModels(getReader("Invoke_Iris.dmn", PMMLValidatorImportTest.class)); @@ -44,7 +44,7 @@ public void testImportPMML() throws IOException { } @Test - public void testImportPMML2() throws IOException { + public void importPMML2() throws IOException { // DROOLS-4395 [DMN Designer] Validation fails for included PMML model try (Reader defsReader = getReader("KiePMMLScoreCard_wInputType.dmn", DMNRuntimePMMLTest.class);) { final Definitions defs = getDefinitions(defsReader, diff --git a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/pom.xml b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/pom.xml index dc55881fa36..e032a96e657 100644 --- a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/pom.xml +++ b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/pom.xml @@ -85,15 +85,15 @@ jaxb-runtime provided - + - junit - junit + org.assertj + assertj-core test - org.assertj - assertj-core + org.junit.jupiter + junit-jupiter test diff --git a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/AdultTest.java b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/AdultTest.java index 3f3a25a2e03..3b42f97d6ca 100644 --- a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/AdultTest.java +++ b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/AdultTest.java @@ -18,10 +18,9 @@ */ package org.kie.dmn.ruleset2dmn; -import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder; @@ -30,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.ruleset2dmn.TestUtils.ctxFromJson; -public class AdultTest { +class AdultTest { @Test - public void test() throws Exception { + void test() throws Exception { String dmnXml = Converter.parse("adult", this.getClass().getResourceAsStream("/adult.pmml")); // Files.write(new File("src/test/resources/adult.dmn").toPath(), dmnXml.getBytes()); DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() diff --git a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/ChurnRulesFromSPSSModelerTest.java b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/ChurnRulesFromSPSSModelerTest.java index 7799dbd8c03..521df81d2c9 100644 --- a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/ChurnRulesFromSPSSModelerTest.java +++ b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/ChurnRulesFromSPSSModelerTest.java @@ -18,10 +18,9 @@ */ package org.kie.dmn.ruleset2dmn; -import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder; @@ -30,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.ruleset2dmn.TestUtils.ctxFromJson; -public class ChurnRulesFromSPSSModelerTest { - +class ChurnRulesFromSPSSModelerTest { + @Test - public void test() throws Exception { + void test() throws Exception { final String modelName = "ChurnSPSS"; final String dmnXml = Converter.parse(modelName, this.getClass().getResourceAsStream("/Churn Rules from SPSS Modeler.xml")); // Files.write(new File("src/test/resources/ChurnSPSS.dmn").toPath(), dmnXml.getBytes()); diff --git a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/ChurnTest.java b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/ChurnTest.java index c2519b7a44c..01a15fe2fba 100644 --- a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/ChurnTest.java +++ b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/ChurnTest.java @@ -18,10 +18,9 @@ */ package org.kie.dmn.ruleset2dmn; -import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder; @@ -30,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.ruleset2dmn.TestUtils.ctxFromJson; -public class ChurnTest { +class ChurnTest { @Test - public void test() throws Exception { + void test() throws Exception { String dmnXml = Converter.parse("churn", this.getClass().getResourceAsStream("/churn.pmml")); // Files.write(new File("src/test/resources/churn.dmn").toPath(), dmnXml.getBytes()); DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() diff --git a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/IrisTest.java b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/IrisTest.java index 04229953688..149eab5acd4 100644 --- a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/IrisTest.java +++ b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/IrisTest.java @@ -18,10 +18,9 @@ */ package org.kie.dmn.ruleset2dmn; -import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder; @@ -30,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.ruleset2dmn.TestUtils.ctxFromJson; -public class IrisTest { +class IrisTest { @Test - public void test() throws Exception { + void test() throws Exception { final String dmnXml = Converter.parse("iris", this.getClass().getResourceAsStream("/iris.pmml")); // Files.write(new File("src/test/resources/iris.dmn").toPath(), dmnXml.getBytes()); DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() diff --git a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/MiniloanTest.java b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/MiniloanTest.java index 0918d2bc4a3..63e5fb880f8 100644 --- a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/MiniloanTest.java +++ b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/MiniloanTest.java @@ -18,10 +18,9 @@ */ package org.kie.dmn.ruleset2dmn; -import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder; @@ -30,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.ruleset2dmn.TestUtils.ctxFromJson; -public class MiniloanTest { - +class MiniloanTest { + @Test - public void test() throws Exception { + void test() throws Exception { String dmnXml = Converter.parse("miniloan", this.getClass().getResourceAsStream("/miniloan.pmml")); // Files.write(new File("src/test/resources/miniloan.dmn").toPath(), dmnXml.getBytes()); DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() diff --git a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/TotoTest.java b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/TotoTest.java index 291432f6589..635b0539235 100644 --- a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/TotoTest.java +++ b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/TotoTest.java @@ -19,10 +19,9 @@ package org.kie.dmn.ruleset2dmn; import java.math.BigDecimal; -import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder; @@ -31,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.ruleset2dmn.TestUtils.ctxFromJson; -public class TotoTest { - +class TotoTest { + @Test - public void test() throws Exception { + void test() throws Exception { final String dmnXml = Converter.parse("toto", this.getClass().getResourceAsStream("/toto.pmml")); // Files.write(new File("src/test/resources/toto.dmn").toPath(), dmnXml.getBytes()); DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() diff --git a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/WifiTest.java b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/WifiTest.java index ef023f7d46a..e950c64cce7 100644 --- a/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/WifiTest.java +++ b/kie-dmn/kie-dmn-ruleset2dmn-parent/kie-dmn-ruleset2dmn/src/test/java/org/kie/dmn/ruleset2dmn/WifiTest.java @@ -19,10 +19,9 @@ package org.kie.dmn.ruleset2dmn; import java.math.BigDecimal; -import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder; @@ -31,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.ruleset2dmn.TestUtils.ctxFromJson; -public class WifiTest { - +class WifiTest { + @Test - public void test() throws Exception { + void test() throws Exception { final String dmnXml = Converter.parse("wifi", this.getClass().getResourceAsStream("/wifi.pmml")); // Files.write(new File("src/test/resources/wifi.dmn").toPath(), dmnXml.getBytes()); DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults() diff --git a/kie-dmn/kie-dmn-signavio/pom.xml b/kie-dmn/kie-dmn-signavio/pom.xml index feb101a85b3..c29cd5c3acf 100644 --- a/kie-dmn/kie-dmn-signavio/pom.xml +++ b/kie-dmn/kie-dmn-signavio/pom.xml @@ -95,12 +95,6 @@ com.thoughtworks.xstream xstream - - - junit - junit - test - ch.qos.logback logback-classic @@ -111,12 +105,22 @@ org.assertj assertj-core test - + + + org.junit.jupiter + junit-jupiter + test + org.mockito mockito-core test + + org.mockito + mockito-junit-jupiter + test + org.drools drools-xml-support diff --git a/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/MultiInstanceDecisionLogicTest.java b/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/MultiInstanceDecisionLogicTest.java index 3e9bdf74af0..efdd893722d 100644 --- a/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/MultiInstanceDecisionLogicTest.java +++ b/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/MultiInstanceDecisionLogicTest.java @@ -23,8 +23,8 @@ import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.ast.DMNNode; import org.kie.dmn.core.ast.DMNBaseNode; @@ -37,12 +37,11 @@ import static java.util.function.Function.identity; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import static org.assertj.core.api.Assertions.assertThat; - -public class MultiInstanceDecisionLogicTest { +class MultiInstanceDecisionLogicTest { private static final String ITERATOR = "I1"; private static final String TOP_LEVEL = "A"; @@ -52,10 +51,10 @@ public class MultiInstanceDecisionLogicTest { @Mock private DMNModel model; - - - @Before - public void setup() { + + + @BeforeEach + void setup() { MockitoAnnotations.openMocks(this); doReturn(TOP_LEVEL).when(mid).getTopLevelDecisionId(); doReturn(ITERATOR).when(mid).getIteratorShapeId(); @@ -95,10 +94,10 @@ private DMNBaseNode input(String id) { doReturn(input).when(model).getInputById(id); return input; } - - - @Test - public void thatFindAllChildElements_withMid_collectsCorrectChildsAndSkipsExternals() { + + + @Test + void thatFindAllChildElements_withMid_collectsCorrectChildsAndSkipsExternals() { // Arrange MultiInstanceDecisionLogic.MIDDependenciesProcessor processor = new MultiInstanceDecisionLogic.MIDDependenciesProcessor(mid, model); diff --git a/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/SignavioTest.java b/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/SignavioTest.java index 84e631875ab..c9e77a9ab6e 100644 --- a/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/SignavioTest.java +++ b/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/SignavioTest.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -46,9 +46,9 @@ public class SignavioTest { public static final Logger LOG = LoggerFactory.getLogger(SignavioTest.class); - + @Test - public void test() { + void test() { DMNRuntime runtime = createRuntime("Test_Signavio_multiple.dmn"); List models = runtime.getModels(); @@ -63,9 +63,9 @@ public void test() { assertThat((List) evaluateAll.getContext().get("Greeting for each Person in Persons")).contains("Hello p1", "Hello p2"); } - + @Test - public void testUnmarshall() { + void unmarshall() { DMNRuntime runtime = createRuntime("Test_Signavio_multiple.dmn"); DMNModel model0 = runtime.getModels().get(0); Definitions definitions = model0.getDefinitions(); @@ -81,7 +81,7 @@ public void testUnmarshall() { } @Test - public void testUsingSignavioFunctions() { + void usingSignavioFunctions() { DMNRuntime runtime = createRuntime("Using_Signavio_functions.dmn"); List models = runtime.getModels(); @@ -102,7 +102,7 @@ public void testUsingSignavioFunctions() { * Check the custom Signavio functions work in the LiteralExpression too */ @Test - public void testUsingSignavioFunctionsInLiteralExpression() { + void usingSignavioFunctionsInLiteralExpression() { DMNRuntime runtime = createRuntime("Starts_with_an_A.dmn"); assertStartsWithAnA(runtime, "Abc", true); @@ -123,7 +123,7 @@ private void assertStartsWithAnA(final DMNRuntime runtime, final String testStri } @Test - public void testSurveyMIDSUM() { + void surveyMIDSUM() { DMNRuntime runtime = createRuntime("survey MID SUM.dmn"); checkSurveryMID(runtime, Arrays.asList(1, 2, 3), new BigDecimal(6)); } @@ -163,56 +163,56 @@ private DMNRuntime createRuntime(String modelFileName) { } @Test - public void testSurveyMIDMIN() { + void surveyMIDMIN() { DMNRuntime runtime = createRuntime("survey MID MIN.dmn"); checkSurveryMID(runtime, Arrays.asList(1, 2, 3), new BigDecimal(1)); } @Test - public void testSurveyMIDMAX() { + void surveyMIDMAX() { DMNRuntime runtime = createRuntime("survey MID MAX.dmn"); checkSurveryMID(runtime, Arrays.asList(1, 2, 3), new BigDecimal(3)); } @Test - public void testSurveyMIDCOUNT() { + void surveyMIDCOUNT() { DMNRuntime runtime = createRuntime("survey MID COUNT.dmn"); checkSurveryMID(runtime, Arrays.asList(1, 1, 1), new BigDecimal(3));// the COUNT in MID is list size, checked on Simulator. } @Test - public void testSurveyMIDALLTRUE() { + void surveyMIDALLTRUE() { DMNRuntime runtime = createRuntime("survey MID ALLTRUE.dmn"); checkSurveryMID(runtime, Arrays.asList(1, 2), true); checkSurveryMID(runtime, Arrays.asList(-1, 2), false); } @Test - public void testSurveyMIDANYTRUE() { + void surveyMIDANYTRUE() { DMNRuntime runtime = createRuntime("survey MID ANYTRUE.dmn"); checkSurveryMID(runtime, Arrays.asList(1, -2), true); checkSurveryMID(runtime, Arrays.asList(-1, -2), false); } @Test - public void testSurveyMIDALLFALSE() { + void surveyMIDALLFALSE() { DMNRuntime runtime = createRuntime("survey MID ALLFALSE.dmn"); checkSurveryMID(runtime, Arrays.asList(1, 2), false); checkSurveryMID(runtime, Arrays.asList(-1, 2), false); checkSurveryMID(runtime, Arrays.asList(1, -2), false); checkSurveryMID(runtime, Arrays.asList(-1, -2), true); } - + @Test - public void testZipFunctions() { + void zipFunctions() { DMNRuntime runtime = createRuntime("Test_SignavioZipFunctions.dmn"); checkBothFunctionsAreWorking(runtime); } - - + + @Test @SuppressWarnings("unchecked") - public void testMidTakesCareOfRequirements() { + void midTakesCareOfRequirements() { DMNRuntime runtime = createRuntime("Test_SignavioMID.dmn"); List models = runtime.getModels(); @@ -231,10 +231,10 @@ public void testMidTakesCareOfRequirements() { assertThat(result).doesNotContainNull(); } - - + + @Test - public void testSignavioConcatFunction() { + void signavioConcatFunction() { DMNRuntime runtime = createRuntime("Signavio_Concat.dmn"); List models = runtime.getModels(); @@ -266,9 +266,9 @@ private void checkBothFunctionsAreWorking(DMNRuntime runtime) { assertThat((List) evaluateAll.getDecisionResultByName("zipvararg").getResult()).hasSize(2); assertThat((List) evaluateAll.getDecisionResultByName("zipsinglelist").getResult()).hasSize(2); } - + @Test - public void testSignavioIterateMultiinstanceWithComplexInputs() { + void signavioIterateMultiinstanceWithComplexInputs() { DMNRuntime runtime = createRuntime("Iterate Complex List.dmn"); DMNContext context = runtime.newContext(); @@ -287,9 +287,9 @@ public void testSignavioIterateMultiinstanceWithComplexInputs() { assertThat(evaluateAll.getDecisionResultByName("extractNames").getResult()).isEqualTo(Arrays.asList("John Doe", "Alice")); } - + @Test - public void testSignavioIterateMultiinstanceMultipleDecisions() { + void signavioIterateMultiinstanceMultipleDecisions() { DMNRuntime runtime = createRuntime("MID with multiple inside decisions.dmn"); DMNContext context = runtime.newContext(); @@ -302,9 +302,9 @@ public void testSignavioIterateMultiinstanceMultipleDecisions() { assertThat(evaluateAll.getDecisionResultByName("overallage").getResult()).isEqualTo(new BigDecimal("18")); } - + @Test - public void testSignavioIterateMultiinstanceMultipleDecisionsOutside() { + void signavioIterateMultiinstanceMultipleDecisionsOutside() { DMNRuntime runtime = createRuntime("MID with outside requirement.dmn"); DMNContext context = runtime.newContext(); diff --git a/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/feel/runtime/ExtendedFunctionsBaseFEELTest.java b/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/feel/runtime/ExtendedFunctionsBaseFEELTest.java index 718803696ec..45c813bf730 100644 --- a/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/feel/runtime/ExtendedFunctionsBaseFEELTest.java +++ b/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/feel/runtime/ExtendedFunctionsBaseFEELTest.java @@ -18,12 +18,8 @@ */ package org.kie.dmn.signavio.feel.runtime; -import java.util.Arrays; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.api.feel.runtime.events.FEELEventListener; import org.kie.dmn.feel.FEEL; @@ -37,27 +33,24 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public abstract class ExtendedFunctionsBaseFEELTest { private final FEEL feel = FEEL.newInstance(List.of(new KieDMNSignavioProfile())); - @Parameterized.Parameter(0) public String expression; - @Parameterized.Parameter(1) public Object result; - @Parameterized.Parameter(2) public FEELEvent.Severity severity; - @Test - public void testExpression() { + public void expression(String expression, Object result, FEELEvent.Severity severity) { + this.expression = expression; + this.result = result; + this.severity = severity; + FEELEventListener listener = mock( FEELEventListener.class ); feel.addListener( listener ); - feel.addListener( evt -> { - System.out.println(evt); - } ); + feel.addListener(System.out::println); assertResult(expression, result); if( severity != null ) { @@ -69,6 +62,8 @@ public void testExpression() { } } + abstract protected void instanceTest(String expression, Object result, FEELEvent.Severity severity); + protected void assertResult(String expression, Object result) { if (result == null) { assertThat(feel.evaluate(expression)).as("Evaluating: '" + expression + "'").isNull(); diff --git a/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/feel/runtime/FEELExtendedFunctionsTest.java b/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/feel/runtime/FEELExtendedFunctionsTest.java index 8413b5c7b5c..404effe48a8 100644 --- a/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/feel/runtime/FEELExtendedFunctionsTest.java +++ b/kie-dmn/kie-dmn-signavio/src/test/java/org/kie/dmn/signavio/feel/runtime/FEELExtendedFunctionsTest.java @@ -30,7 +30,9 @@ import java.util.Collection; import java.util.List; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.dmn.api.feel.runtime.events.FEELEvent; import static org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity.ERROR; import static org.kie.dmn.signavio.util.DynamicTypeUtils.entry; @@ -38,8 +40,13 @@ public class FEELExtendedFunctionsTest extends ExtendedFunctionsBaseFEELTest { - @Parameterized.Parameters(name = "{index}: {0} ({1}) = {2}") - public static Collection data() { + @ParameterizedTest + @MethodSource("data") + protected void instanceTest(String expression, Object result, FEELEvent.Severity severity) { + expression(expression, result, severity); + } + + private static Collection data() { final Object[][] cases = new Object[][] { { "string(\"Happy %.0fth birthday, Mr %s!\", 38, \"Doe\")", "Happy 38th birthday, Mr Doe!", null}, { "all( true, true, true )", Boolean.TRUE , null}, diff --git a/kie-dmn/kie-dmn-trisotech/pom.xml b/kie-dmn/kie-dmn-trisotech/pom.xml index 9d0bb085b65..a06f4690464 100644 --- a/kie-dmn/kie-dmn-trisotech/pom.xml +++ b/kie-dmn/kie-dmn-trisotech/pom.xml @@ -95,17 +95,11 @@ com.thoughtworks.xstream xstream - - - junit - junit - test - org.assertj assertj-core test - + ch.qos.logback logback-classic @@ -127,5 +121,10 @@ drools-xml-support test + + org.junit.jupiter + junit-jupiter + test + diff --git a/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/backend/marshalling/v1_3/xstream/UnmarshalMarshalTest.java b/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/backend/marshalling/v1_3/xstream/UnmarshalMarshalTest.java index a0b50aef48f..ede9b5d4cbb 100644 --- a/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/backend/marshalling/v1_3/xstream/UnmarshalMarshalTest.java +++ b/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/backend/marshalling/v1_3/xstream/UnmarshalMarshalTest.java @@ -33,7 +33,7 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.marshalling.DMNMarshaller; import org.kie.dmn.model.api.Definitions; import org.kie.dmn.model.v1_3.KieDMNModelInstrumentedBase; @@ -61,17 +61,17 @@ public class UnmarshalMarshalTest { protected static final Logger LOG = LoggerFactory.getLogger(UnmarshalMarshalTest.class); @Test - public void testV13_conditional() throws Exception { + void v13Conditional() throws Exception { testRoundTripV13("org/kie/dmn/trisotech/backend/marshalling/v1_3/", "conditional.dmn"); } @Test - public void testV13_iterator() throws Exception { + void v13Iterator() throws Exception { testRoundTripV13("org/kie/dmn/trisotech/backend/marshalling/v1_3/", "iterator.dmn"); } @Test - public void testV13_filter() throws Exception { + void v13Filter() throws Exception { testRoundTripV13("org/kie/dmn/trisotech/backend/marshalling/v1_3/", "filter.dmn"); } diff --git a/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/core/DMN14ExpressionsTest.java b/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/core/DMN14ExpressionsTest.java index 99c98f8fdeb..a46a0db680d 100644 --- a/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/core/DMN14ExpressionsTest.java +++ b/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/core/DMN14ExpressionsTest.java @@ -24,10 +24,9 @@ import java.util.List; import java.util.UUID; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -46,14 +45,12 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DMN14ExpressionsTest { private DMNRuntime runtime; private DMNModel model; private TestStrategy testConfig; - @Parameterized.Parameters(name = "{0}") public static Object[] params() { return new Object[]{TestStrategy.KIE_API, TestStrategy.DMNRUNTIMEBUILDER}; } @@ -101,20 +98,22 @@ public DMNRuntime createRuntimeUsingBuilder(String model, Class class1) { .getOrElseThrow(e -> new RuntimeException("Error initalizing DMNRuntime", e)); } - public DMN14ExpressionsTest(final TestStrategy testConfig) { + public void initDMN14ExpressionsTest(final TestStrategy testConfig) { this.testConfig = testConfig; } - @Before - public void setup() { + @BeforeEach + void setup() { runtime = createRuntime("dmn14expressions.dmn", DMN14ExpressionsTest.class); assertThat(runtime).isNotNull(); model = runtime.getModel("http://www.trisotech.com/definitions/_3404349f-5046-4ad3-ad15-7f1e27291ab5", "DMN 1.4 expressions"); assertThat(model).isNotNull(); } - @Test - public void testConditionalWithInput() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void conditionalWithInput(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Boolean Input", true)), "Conditional"); assertThat(results.getDecisionResultByName("Conditional").getResult()).isEqualTo("Conditional evaluated to TRUE"); @@ -126,16 +125,20 @@ public void testConditionalWithInput() throws Throwable { } - @Test - public void testConditionalNonBooleanIf() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void conditionalNonBooleanIf(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(), "Non boolean"); assertThat(results.getMessages()).hasSize(1); assertThat(results.getMessages().iterator().next().getMessageType()).isEqualTo(DMNMessageType.ERROR_EVAL_NODE); } - @Test - public void testIteratorFor() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorFor(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 1)), "Addition"); assertThat(results.getDecisionResultByName("Addition").getResult().toString()).isEqualTo(Arrays.asList(2, 3, 4, 5).toString()); @@ -143,36 +146,44 @@ public void testIteratorFor() throws Throwable { assertThat(results.getDecisionResultByName("Addition").getResult().toString()).isEqualTo(Arrays.asList(3, 4, 5, 6).toString()); } - @Test - public void testIteratorForPartial() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorForPartial(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 0)), "Addition Partial"); assertThat(results.getDecisionResultByName("Addition Partial").getResult().toString()).isEqualTo(Arrays.asList(1, 3, 6, 10).toString()); results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "Addition Partial"); assertThat(results.getDecisionResultByName("Addition Partial").getResult().toString()).isEqualTo(Arrays.asList(1, 8, 16, 25).toString()); } - - @Test - public void testIteratorForInRangeClose() throws Throwable { + + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorForInRangeClose(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 1)), "Addition Range Close"); assertThat(results.getDecisionResultByName("Addition Range Close").getResult().toString()).isEqualTo(Arrays.asList(3, 4).toString()); results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 2)), "Addition Range Close"); assertThat(results.getDecisionResultByName("Addition Range Close").getResult().toString()).isEqualTo(Arrays.asList(4, 5).toString()); - } + } - @Test - public void testIteratorForInRangeOpen() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorForInRangeOpen(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 1)), "Addition Range Open"); assertThat(results.getDecisionResultByName("Addition Range Open").getResult().toString()).isEqualTo(Arrays.asList(2, 3, 4, 5).toString()); results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 2)), "Addition Range Open"); assertThat(results.getDecisionResultByName("Addition Range Open").getResult().toString()).isEqualTo(Arrays.asList(3, 4, 5, 6).toString()); - } + } + - - @Test - public void testIteratorSome() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorSome(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "Number Greater Exists"); assertThat(((Boolean) results.getDecisionResultByName("Number Greater Exists").getResult()).booleanValue()).isTrue(); @@ -183,8 +194,10 @@ public void testIteratorSome() throws Throwable { assertThat(((Boolean) results.getDecisionResultByName("Number Greater Exists").getResult()).booleanValue()).isFalse(); } - @Test - public void testIteratorEvery() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void iteratorEvery(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "All Greater"); assertThat(((Boolean) results.getDecisionResultByName("All Greater").getResult()).booleanValue()).isFalse(); @@ -195,8 +208,10 @@ public void testIteratorEvery() throws Throwable { assertThat(((Boolean) results.getDecisionResultByName("All Greater").getResult()).booleanValue()).isFalse(); } - @Test - public void testFilterIndex() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void filterIndex(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "Match by index"); assertThat(results.getDecisionResultByName("Match by index").getResult()).isEqualTo(new BigDecimal(5)); @@ -208,8 +223,10 @@ public void testFilterIndex() throws Throwable { } - @Test - public void testFilterExpression() throws Throwable { + @MethodSource("params") + @ParameterizedTest(name = "{0}") + public void filterExpression(final TestStrategy testConfig) throws Throwable { + initDMN14ExpressionsTest(testConfig); DMNResult results = runtime.evaluateByName(model, new DMNContextImpl(Collections.singletonMap("Number Input", 5)), "Match by Fnct"); assertThat(results.getDecisionResultByName("Match by Fnct").getResult().toString()).isEqualTo(Arrays.asList(6, 7, 8, 9, 10).toString()); diff --git a/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/core/DMN14GenericSynthTest.java b/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/core/DMN14GenericSynthTest.java index fbe0ea1d799..02380a0ae05 100644 --- a/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/core/DMN14GenericSynthTest.java +++ b/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/core/DMN14GenericSynthTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -48,7 +48,7 @@ public DMNRuntime createRuntime(String model, Class class1) { } @Test - public void testFilterDatatype() throws Throwable { + void filterDatatype() throws Throwable { DMNRuntime runtime = createRuntime("boxedcontextextension/filter-datatype.dmn", TrisotechValidationTest.class); assertThat(runtime).isNotNull(); DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_caa02430-93c6-4ba7-a646-81bbcef32978", "Drawing 1"); @@ -68,7 +68,7 @@ private void checkFilterDatatype(DMNRuntime runtime, DMNModel model) { } @Test - public void testFilterDatatype2() throws Throwable { + void filterDatatype2() throws Throwable { DMNRuntime runtime = createRuntime("boxedcontextextension/filter-datatype2.dmn", TrisotechValidationTest.class); assertThat(runtime).isNotNull(); DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_caa02430-93c6-4ba7-a646-81bbcef32978", "Drawing 1"); @@ -78,7 +78,7 @@ public void testFilterDatatype2() throws Throwable { } @Test - public void testIteratorDatatype() throws Throwable { + void iteratorDatatype() throws Throwable { DMNRuntime runtime = createRuntime("boxedcontextextension/iterator-datatype.dmn", TrisotechValidationTest.class); assertThat(runtime).isNotNull(); DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_caa02430-93c6-4ba7-a646-81bbcef32978", "Drawing 1"); @@ -98,7 +98,7 @@ private void checkIteratorDatatype(DMNRuntime runtime, DMNModel model) { } @Test - public void testIteratorDatatype2() throws Throwable { + void iteratorDatatype2() throws Throwable { DMNRuntime runtime = createRuntime("boxedcontextextension/iterator-datatype2.dmn", TrisotechValidationTest.class); assertThat(runtime).isNotNull(); DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_caa02430-93c6-4ba7-a646-81bbcef32978", "Drawing 1"); diff --git a/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/validation/TrisotechValidationTest.java b/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/validation/TrisotechValidationTest.java index d6abcc3ef08..68b34d2db22 100644 --- a/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/validation/TrisotechValidationTest.java +++ b/kie-dmn/kie-dmn-trisotech/src/test/java/org/kie/dmn/trisotech/validation/TrisotechValidationTest.java @@ -20,13 +20,12 @@ import java.io.InputStreamReader; import java.io.Reader; -import java.util.Arrays; import java.util.List; import java.util.Properties; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.marshalling.DMNMarshaller; import org.kie.dmn.core.assembler.DMNAssemblerService; @@ -46,16 +45,16 @@ public class TrisotechValidationTest { protected static DMNValidator validator; protected static DMNMarshaller marshaller; - @BeforeClass - public static void init() { + @BeforeAll + static void init() { List dmnProfiles = List.of(new TrisotechDMNProfile()); Properties p = new Properties(); p.put(DMNAssemblerService.DMN_DECISION_LOGIC_COMPILER, TrisotechDMNEvaluatorCompilerFactory.class.getCanonicalName()); validator = DMNValidatorFactory.newValidator(dmnProfiles, p); } - @AfterClass - public static void dispose() { + @AfterAll + static void dispose() { validator.dispose(); } @@ -68,7 +67,7 @@ protected Reader getReader(final String resourceFileName, Class clazz) { } @Test - public void testBoxedExtension_Conditional13() { + void boxedExtensionConditional13() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .usingSchema(TrisotechSchema.INSTANCEv1_3) .theseModels(getReader("boxedcontextextension/conditional.dmn")); @@ -76,14 +75,15 @@ public void testBoxedExtension_Conditional13() { } @Test - public void testBoxedExtension_Iterator13() { + void boxedExtensionIterator13() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .usingSchema(TrisotechSchema.INSTANCEv1_3) .theseModels(getReader("boxedcontextextension/iterator.dmn")); assertThat(validate).hasSize(0); } + @Test - public void testBoxedExtension_IteratorDataType13() { + void boxedExtensionIteratorDataType13() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .usingSchema(TrisotechSchema.INSTANCEv1_3) .theseModels(getReader("boxedcontextextension/iterator-datatype.dmn")); @@ -91,7 +91,7 @@ public void testBoxedExtension_IteratorDataType13() { } @Test - public void testBoxedExtension_Filter13() { + void boxedExtensionFilter13() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .usingSchema(TrisotechSchema.INSTANCEv1_3) .theseModels(getReader("boxedcontextextension/filter.dmn")); @@ -99,7 +99,7 @@ public void testBoxedExtension_Filter13() { } @Test - public void testBoxedExtension_FilterDataType13() { + void boxedExtensionFilterDataType13() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .usingSchema(TrisotechSchema.INSTANCEv1_3) .theseModels(getReader("boxedcontextextension/filter-datatype.dmn")); diff --git a/kie-dmn/kie-dmn-validation/pom.xml b/kie-dmn/kie-dmn-validation/pom.xml index 863a165af95..ad3857e2847 100644 --- a/kie-dmn/kie-dmn-validation/pom.xml +++ b/kie-dmn/kie-dmn-validation/pom.xml @@ -147,11 +147,6 @@ tests test - - junit - junit - test - ch.qos.logback logback-classic @@ -162,6 +157,11 @@ assertj-core test + + org.junit.jupiter + junit-jupiter + test + org.kie kie-dmn-core diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/AbstractValidatorTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/AbstractValidatorTest.java index dd4ce3e44b7..977fcfd5c96 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/AbstractValidatorTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/AbstractValidatorTest.java @@ -27,8 +27,8 @@ import org.drools.io.FileSystemResource; import org.drools.io.ReaderResource; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.kie.api.io.Resource; import org.kie.dmn.api.marshalling.DMNExtensionRegister; import org.kie.dmn.api.marshalling.DMNMarshaller; @@ -46,7 +46,7 @@ public abstract class AbstractValidatorTest { protected static DMNValidator validator; protected static DMNMarshaller marshaller; - @BeforeClass + @BeforeAll public static void init() { List defaultDMNProfiles = DMNAssemblerService.getDefaultDMNProfiles(ChainedProperties.getChainedProperties(ClassLoaderUtil.findDefaultClassLoader())); validator = DMNValidatorFactory.newValidator(defaultDMNProfiles); @@ -58,7 +58,7 @@ public static void init() { } } - @AfterClass + @AfterAll public static void dispose() { if (validator != null) validator.dispose(); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/MessageReporterTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/MessageReporterTest.java index 9c3c5de307b..a621202738a 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/MessageReporterTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/MessageReporterTest.java @@ -18,11 +18,9 @@ */ package org.kie.dmn.validation; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage.Severity; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.core.util.Msg; @@ -30,7 +28,9 @@ import org.kie.dmn.model.api.Decision; import org.kie.dmn.model.v1_3.TDecision; -public class MessageReporterTest { +import static org.assertj.core.api.Assertions.assertThat; + +class MessageReporterTest { private static final Msg.Message0 m0 = new Msg.Message0(DMNMessageType.KIE_API, "Hello World."); private static final Msg.Message1 m1 = new Msg.Message1(DMNMessageType.KIE_API, "Hello World %s"); @@ -39,7 +39,7 @@ public class MessageReporterTest { private static final Msg.Message4 m4 = new Msg.Message4(DMNMessageType.KIE_API, "Hello World %s %s %s %s"); @Test - public void smokeTest() { + void smokeTest() { MessageReporter ut = new MessageReporter(null); ut.report(Severity.INFO, aDecision(), m0); ut.report(Severity.INFO, aDecision(), m1, 1); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/UsingResourceValidatorTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/UsingResourceValidatorTest.java index 7c57466d41c..9627a29d5a3 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/UsingResourceValidatorTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/UsingResourceValidatorTest.java @@ -20,7 +20,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.core.DMNInputRuntimeTest; @@ -33,51 +33,51 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class UsingResourceValidatorTest extends AbstractValidatorTest { +class UsingResourceValidatorTest extends AbstractValidatorTest { private static final Logger LOG = LoggerFactory.getLogger(UsingResourceValidatorTest.class); @Test - public void testInvalidXml_single() { + void invalidXmlSingle() { List validateXML = validator.validate( getResource( "invalidXml.dmn" ), VALIDATE_SCHEMA); assertThat(validateXML).as(ValidatorUtil.formatMessages(validateXML)).hasSize(1); assertThat(validateXML.get(0).getMessageType()).as(validateXML.get(0).toString()).isEqualTo(DMNMessageType.FAILED_XML_VALIDATION); assertThat(validateXML.get(0).getPath()).containsSequence("invalidXml.dmn"); } - + @Test - public void testInvalidXml_builder() { + void invalidXmlBuilder() { List validateXML = validator.validateUsing(VALIDATE_SCHEMA).theseModels(getResource( "invalidXml.dmn" ), getResource( "0001-input-data-string.dmn", DMNInputRuntimeTest.class )); assertThat(validateXML).as(ValidatorUtil.formatMessages(validateXML)).hasSize(1); assertThat(validateXML.get(0).getMessageType()).as(validateXML.get(0).toString()).isEqualTo(DMNMessageType.FAILED_XML_VALIDATION); assertThat(validateXML.get(0).getPath()).containsSequence("invalidXml.dmn"); } - + @Test - public void testFailingModelValidation_single() { + void failingModelValidationSingle() { final List messages = validator.validate( getResource("import/importingMyHelloDSbkmBoxedInvocation_wrongDoubleImportName.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL ); LOG.debug("{}", messages); assertThat(messages.stream().anyMatch(p -> p.getPath().endsWith("importingMyHelloDSbkmBoxedInvocation_wrongDoubleImportName.dmn") && p.getText().contains("myHelloDS") && p.getMessageType().equals(DMNMessageType.DUPLICATE_NAME))).isTrue(); } - + @Test - public void testFailingModelValidation_builder() { + void failingModelValidationBuilder() { final List messages = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL) .theseModels(getResource("myHelloDS.dmn", DMNDecisionServicesTest.class), getResource("import/importingMyHelloDSbkmBoxedInvocation_wrongDoubleImportName.dmn")); LOG.debug("{}", messages); assertThat(messages.stream().anyMatch(p -> p.getPath().endsWith("importingMyHelloDSbkmBoxedInvocation_wrongDoubleImportName.dmn") && p.getText().contains("myHelloDS") && p.getMessageType().equals(DMNMessageType.DUPLICATE_NAME))).isTrue(); } - + @Test - public void testFailingCompilation_single() { + void failingCompilationSingle() { final List messages = validator.validate( getResource("invalidFEEL.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); LOG.debug("{}", messages); assertThat(messages.stream().anyMatch(p -> p.getPath().endsWith("invalidFEEL.dmn") && p.getText().contains("Error compiling FEEL expression") && p.getMessageType().equals(DMNMessageType.ERR_COMPILING_FEEL))).isTrue(); } - + @Test - public void testFailingCompilation_builder() { + void failingCompilationBuilder() { final List messages = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .theseModels(getResource("invalidFEEL.dmn")); LOG.debug("{}", messages); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorArtifactTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorArtifactTest.java index e95ed660679..be044762c12 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorArtifactTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorArtifactTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -31,10 +31,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorArtifactTest extends AbstractValidatorTest { +class ValidatorArtifactTest extends AbstractValidatorTest { @Test - public void testASSOC_REFERENCES_NOT_EMPTY_ReaderInput() throws IOException { + void assoc_references_not_empty_ReaderInput() throws IOException { try (final Reader reader = getReader( "artifact/ASSOC_REFERENCES_NOT_EMPTY.dmn" )) { final List validate = validator.validate( reader, @@ -45,7 +45,7 @@ public void testASSOC_REFERENCES_NOT_EMPTY_ReaderInput() throws IOException { } @Test - public void testASSOC_REFERENCES_NOT_EMPTY_FileInput() { + void assoc_references_not_empty_FileInput() { final List validate = validator.validate( getFile( "artifact/ASSOC_REFERENCES_NOT_EMPTY.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -54,7 +54,7 @@ public void testASSOC_REFERENCES_NOT_EMPTY_FileInput() { } @Test - public void testASSOC_REFERENCES_NOT_EMPTY_DefinitionsInput() { + void assoc_references_not_empty_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "artifact/ASSOC_REFERENCES_NOT_EMPTY.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorAuthorityRequirementTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorAuthorityRequirementTest.java index 5ae3761ee2d..525719431be 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorAuthorityRequirementTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorAuthorityRequirementTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -31,10 +31,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorAuthorityRequirementTest extends AbstractValidatorTest { +class ValidatorAuthorityRequirementTest extends AbstractValidatorTest { @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_ReaderInput() throws IOException { + void auth_req_missing_dependency_req_auth_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_AUTH.dmn")) { final List validate = validator.validate( reader, @@ -45,7 +45,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_ReaderInput() throws IOExce } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_FileInput() { + void auth_req_missing_dependency_req_auth_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_AUTH.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -54,7 +54,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_FileInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_DefinitionsInput() { + void auth_req_missing_dependency_req_auth_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_AUTH.dmn", "https://github.com/kiegroup/kie-dmn", @@ -65,7 +65,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_AUTH_DefinitionsInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_ReaderInput() throws IOException { + void auth_req_missing_dependency_req_dec_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_DEC.dmn")) { final List validate = validator.validate( reader, @@ -76,7 +76,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_ReaderInput() throws IOExcep } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_FileInput() { + void auth_req_missing_dependency_req_dec_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_DEC.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -85,7 +85,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_FileInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_DefinitionsInput() { + void auth_req_missing_dependency_req_dec_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_DEC.dmn", "https://github.com/kiegroup/kie-dmn", @@ -96,7 +96,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_DEC_DefinitionsInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_ReaderInput() throws IOException { + void auth_req_missing_dependency_req_input_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_INPUT.dmn")) { final List validate = validator.validate( reader, @@ -107,7 +107,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_ReaderInput() throws IOExc } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_FileInput() { + void auth_req_missing_dependency_req_input_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_INPUT.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -116,7 +116,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_FileInput() { } @Test - public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_DefinitionsInput() { + void auth_req_missing_dependency_req_input_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_MISSING_DEPENDENCY_REQ_INPUT.dmn", "https://github.com/kiegroup/kie-dmn", @@ -127,7 +127,7 @@ public void testAUTH_REQ_MISSING_DEPENDENCY_REQ_INPUT_DefinitionsInput() { } @Test - public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_ReaderInput() throws IOException { + void authreq_dep_req_auth_not_knowledgesource_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE.dmn")) { final List validate = validator.validate( reader, @@ -138,7 +138,7 @@ public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_ReaderInput() throws IO } @Test - public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_FileInput() { + void authreq_dep_req_auth_not_knowledgesource_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -147,7 +147,7 @@ public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_FileInput() { } @Test - public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_DefinitionsInput() { + void authreq_dep_req_auth_not_knowledgesource_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -158,7 +158,7 @@ public void testAUTHREQ_DEP_REQ_AUTH_NOT_KNOWLEDGESOURCE_DefinitionsInput() { } @Test - public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_ReaderInput() throws IOException { + void authreq_dep_req_dec_not_decision_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_DEP_REQ_DEC_NOT_DECISION.dmn")) { final List validate = validator.validate( reader, @@ -169,7 +169,7 @@ public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_ReaderInput() throws IOExceptio } @Test - public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_FileInput() { + void authreq_dep_req_dec_not_decision_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_DEP_REQ_DEC_NOT_DECISION.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -178,7 +178,7 @@ public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_FileInput() { } @Test - public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_DefinitionsInput() { + void authreq_dep_req_dec_not_decision_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_DEP_REQ_DEC_NOT_DECISION.dmn", "https://github.com/kiegroup/kie-dmn", @@ -189,7 +189,7 @@ public void testAUTHREQ_DEP_REQ_DEC_NOT_DECISION_DefinitionsInput() { } @Test - public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_ReaderInput() throws IOException { + void authreq_dep_req_input_not_input_ReaderInput() throws IOException { try (final Reader reader = getReader("authorityrequirement/AUTHREQ_DEP_REQ_INPUT_NOT_INPUT.dmn")) { final List validate = validator.validate( reader, @@ -200,7 +200,7 @@ public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_ReaderInput() throws IOException } @Test - public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_FileInput() { + void authreq_dep_req_input_not_input_FileInput() { final List validate = validator.validate( getFile("authorityrequirement/AUTHREQ_DEP_REQ_INPUT_NOT_INPUT.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -209,7 +209,7 @@ public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_FileInput() { } @Test - public void testAUTHREQ_DEP_REQ_INPUT_NOT_INPUT_DefinitionsInput() { + void authreq_dep_req_input_not_input_DefinitionsInput() { final List validate = validator.validate( getDefinitions("authorityrequirement/AUTHREQ_DEP_REQ_INPUT_NOT_INPUT.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorBusinessContextTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorBusinessContextTest.java index ee32923f99e..736bed001bc 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorBusinessContextTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorBusinessContextTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -31,10 +31,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorBusinessContextTest extends AbstractValidatorTest { +class ValidatorBusinessContextTest extends AbstractValidatorTest { @Test - public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_ReaderInput() throws IOException { + void org_unit_decision_made_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn")) { final List validate = validator.validate( reader, @@ -45,7 +45,7 @@ public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_ReaderInput() throws IOExcepti } @Test - public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_FileInput() { + void org_unit_decision_made_wrong_type_FileInput() { final List validate = validator.validate( getFile("businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -54,7 +54,7 @@ public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_FileInput() { } @Test - public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_DefinitionsInput() { + void org_unit_decision_made_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -65,7 +65,7 @@ public void testORG_UNIT_DECISION_MADE_WRONG_TYPE_DefinitionsInput() { } @Test - public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_ReaderInput() throws IOException { + void org_unit_decision_owned_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("businesscontext/ORG_UNIT_DECISION_OWNED_WRONG_TYPE.dmn")) { final List validate = validator.validate( reader, @@ -76,7 +76,7 @@ public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_ReaderInput() throws IOExcept } @Test - public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_FileInput() { + void org_unit_decision_owned_wrong_type_FileInput() { final List validate = validator.validate( getFile("businesscontext/ORG_UNIT_DECISION_OWNED_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -85,7 +85,7 @@ public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_FileInput() { } @Test - public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_DefinitionsInput() { + void org_unit_decision_owned_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businesscontext/ORG_UNIT_DECISION_OWNED_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -96,7 +96,7 @@ public void testORG_UNIT_DECISION_OWNED_WRONG_TYPE_DefinitionsInput() { } @Test - public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_ReaderInput() throws IOException { + void perf_indicator_imp_decision_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("businesscontext/PERF_INDICATOR_IMP_DECISION_WRONG_TYPE.dmn")) { final List validate = validator.validate( reader, @@ -107,7 +107,7 @@ public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_ReaderInput() throws IOEx } @Test - public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_FileInput() { + void perf_indicator_imp_decision_wrong_type_FileInput() { final List validate = validator.validate( getFile("businesscontext/PERF_INDICATOR_IMP_DECISION_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -116,7 +116,7 @@ public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_FileInput() { } @Test - public void testPERF_INDICATOR_IMP_DECISION_WRONG_TYPE_DefinitionsInput() { + void perf_indicator_imp_decision_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businesscontext/PERF_INDICATOR_IMP_DECISION_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorBusinessKnowledgeModelTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorBusinessKnowledgeModelTest.java index 95232cfec6e..52a6e8c9d4d 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorBusinessKnowledgeModelTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorBusinessKnowledgeModelTest.java @@ -18,23 +18,23 @@ */ package org.kie.dmn.validation; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; - import java.io.IOException; import java.io.Reader; import java.util.List; -import org.junit.Test; + +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import static org.assertj.core.api.Assertions.assertThat; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorBusinessKnowledgeModelTest extends AbstractValidatorTest { +class ValidatorBusinessKnowledgeModelTest extends AbstractValidatorTest { @Test - public void testBKM_MISSING_VAR_ReaderInput() throws IOException { + void bkm_missing_var_ReaderInput() throws IOException { try (final Reader reader = getReader("businessknowledgemodel/BKM_MISSING_VAR.dmn")) { final List validate = validator.validate( reader, @@ -45,7 +45,7 @@ public void testBKM_MISSING_VAR_ReaderInput() throws IOException { } @Test - public void testBKM_MISSING_VAR_FileInput() { + void bkm_missing_var_FileInput() { final List validate = validator.validate( getFile("businessknowledgemodel/BKM_MISSING_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -54,7 +54,7 @@ public void testBKM_MISSING_VAR_FileInput() { } @Test - public void testBKM_MISSING_VAR_DefinitionsInput() { + void bkm_missing_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businessknowledgemodel/BKM_MISSING_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -65,7 +65,7 @@ public void testBKM_MISSING_VAR_DefinitionsInput() { } @Test - public void testBKM_MISMATCH_VAR_ReaderInput() throws IOException { + void bkm_mismatch_var_ReaderInput() throws IOException { try (final Reader reader = getReader("businessknowledgemodel/BKM_MISMATCH_VAR.dmn")) { final List validate = validator.validate( reader, @@ -76,7 +76,7 @@ public void testBKM_MISMATCH_VAR_ReaderInput() throws IOException { } @Test - public void testBKM_MISMATCH_VAR_FileInput() { + void bkm_mismatch_var_FileInput() { final List validate = validator.validate( getFile("businessknowledgemodel/BKM_MISMATCH_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -85,7 +85,7 @@ public void testBKM_MISMATCH_VAR_FileInput() { } @Test - public void testBKM_MISMATCH_VAR_DefinitionsInput() { + void bkm_mismatch_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businessknowledgemodel/BKM_MISMATCH_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -96,7 +96,7 @@ public void testBKM_MISMATCH_VAR_DefinitionsInput() { } @Test - public void testBKM_MISSING_EXPR_ReaderInput() throws IOException { + void bkm_missing_expr_ReaderInput() throws IOException { try (final Reader reader = getReader("businessknowledgemodel/BKM_MISSING_EXPR.dmn")) { final List validate = validator.validate( reader, @@ -107,7 +107,7 @@ public void testBKM_MISSING_EXPR_ReaderInput() throws IOException { } @Test - public void testBKM_MISSING_EXPR_FileInput() { + void bkm_missing_expr_FileInput() { final List validate = validator.validate( getFile("businessknowledgemodel/BKM_MISSING_EXPR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -116,7 +116,7 @@ public void testBKM_MISSING_EXPR_FileInput() { } @Test - public void testBKM_MISSING_EXPR_DefinitionsInput() { + void bkm_missing_expr_DefinitionsInput() { final List validate = validator.validate( getDefinitions("businessknowledgemodel/BKM_MISSING_EXPR.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorContextTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorContextTest.java index 045d793149d..73155bf2bb3 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorContextTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorContextTest.java @@ -18,25 +18,25 @@ */ package org.kie.dmn.validation; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; - import java.io.IOException; import java.io.Reader; import java.util.List; -import org.junit.Test; + +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.model.api.Context; import org.kie.dmn.model.api.ContextEntry; import static org.assertj.core.api.Assertions.assertThat; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorContextTest extends AbstractValidatorTest { +class ValidatorContextTest extends AbstractValidatorTest { @Test - public void testCONTEXT_MISSING_EXPR_ReaderInput() throws IOException { + void context_missing_expr_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_MISSING_EXPR.dmn")) { final List validate = validator.validate( reader, @@ -48,7 +48,7 @@ public void testCONTEXT_MISSING_EXPR_ReaderInput() throws IOException { } @Test - public void testCONTEXT_MISSING_EXPR_FileInput() { + void context_missing_expr_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_MISSING_EXPR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -58,7 +58,7 @@ public void testCONTEXT_MISSING_EXPR_FileInput() { } @Test - public void testCONTEXT_MISSING_EXPR_DefinitionsInput() { + void context_missing_expr_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_MISSING_EXPR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -69,7 +69,7 @@ public void testCONTEXT_MISSING_EXPR_DefinitionsInput() { } @Test - public void testCONTEXT_MISSING_ENTRIES_ReaderInput() throws IOException { + void context_missing_entries_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_MISSING_ENTRIES.dmn")) { final List validate = validator.validate( reader, @@ -80,7 +80,7 @@ public void testCONTEXT_MISSING_ENTRIES_ReaderInput() throws IOException { } @Test - public void testCONTEXT_MISSING_ENTRIES_FileInput() { + void context_missing_entries_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_MISSING_ENTRIES.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -89,7 +89,7 @@ public void testCONTEXT_MISSING_ENTRIES_FileInput() { } @Test - public void testCONTEXT_MISSING_ENTRIES_DefinitionsInput() { + void context_missing_entries_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_MISSING_ENTRIES.dmn", "https://github.com/kiegroup/kie-dmn", @@ -100,7 +100,7 @@ public void testCONTEXT_MISSING_ENTRIES_DefinitionsInput() { } @Test - public void testCONTEXT_ENTRY_MISSING_VARIABLE_ReaderInput() throws IOException { + void context_entry_missing_variable_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_ENTRY_MISSING_VARIABLE.dmn")) { final List validate = validator.validate( reader, @@ -114,7 +114,7 @@ public void testCONTEXT_ENTRY_MISSING_VARIABLE_ReaderInput() throws IOException } @Test - public void testCONTEXT_ENTRY_MISSING_VARIABLE_FileInput() { + void context_entry_missing_variable_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_ENTRY_MISSING_VARIABLE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -126,7 +126,7 @@ public void testCONTEXT_ENTRY_MISSING_VARIABLE_FileInput() { } @Test - public void testCONTEXT_ENTRY_MISSING_VARIABLE_DefinitionsInput() { + void context_entry_missing_variable_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_ENTRY_MISSING_VARIABLE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -140,7 +140,7 @@ public void testCONTEXT_ENTRY_MISSING_VARIABLE_DefinitionsInput() { } @Test - public void testCONTEXT_DUP_ENTRY_ReaderInput() throws IOException { + void context_dup_entry_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_DUP_ENTRY.dmn")) { final List validate = validator.validate( reader, @@ -151,7 +151,7 @@ public void testCONTEXT_DUP_ENTRY_ReaderInput() throws IOException { } @Test - public void testCONTEXT_DUP_ENTRY_FileInput() { + void context_dup_entry_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_DUP_ENTRY.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -160,7 +160,7 @@ public void testCONTEXT_DUP_ENTRY_FileInput() { } @Test - public void testCONTEXT_DUP_ENTRY_DefinitionsInput() { + void context_dup_entry_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_DUP_ENTRY.dmn", "https://github.com/kiegroup/kie-dmn", @@ -171,7 +171,7 @@ public void testCONTEXT_DUP_ENTRY_DefinitionsInput() { } @Test - public void testCONTEXT_ENTRY_NOTYPEREF_ReaderInput() throws IOException { + void context_entry_notyperef_ReaderInput() throws IOException { try (final Reader reader = getReader("context/CONTEXT_ENTRY_NOTYPEREF.dmn")) { final List validate = validator.validate( reader, @@ -182,7 +182,7 @@ public void testCONTEXT_ENTRY_NOTYPEREF_ReaderInput() throws IOException { } @Test - public void testCONTEXT_ENTRY_NOTYPEREF_FileInput() { + void context_entry_notyperef_FileInput() { final List validate = validator.validate( getFile("context/CONTEXT_ENTRY_NOTYPEREF.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -191,7 +191,7 @@ public void testCONTEXT_ENTRY_NOTYPEREF_FileInput() { } @Test - public void testCONTEXT_ENTRY_NOTYPEREF_DefinitionsInput() { + void context_entry_notyperef_DefinitionsInput() { final List validate = validator.validate( getDefinitions("context/CONTEXT_ENTRY_NOTYPEREF.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMN14Test.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMN14Test.java index 200a18d7164..72a613a2575 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMN14Test.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMN14Test.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,12 +33,12 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorDMN14Test extends AbstractValidatorTest { +class ValidatorDMN14Test extends AbstractValidatorTest { private static final Logger LOG = LoggerFactory.getLogger(ValidatorDMN14Test.class); - + @Test - public void testSimple_ReaderInput() throws IOException { + void simpleReaderInput() throws IOException { try (final Reader reader = getReader("dmn14simple.dmn")) { final List validate = validator.validate( reader, @@ -48,7 +48,7 @@ public void testSimple_ReaderInput() throws IOException { } @Test - public void testSimple_FileInput() { + void simpleFileInput() { final List validate = validator.validate( getFile("dmn14simple.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testSimple_FileInput() { } @Test - public void testSimple_DefintionsInput() { + void simpleDefintionsInput() { final List validate = validator.validate( getDefinitions("dmn14simple.dmn", "http://www.trisotech.com/definitions/_d9232146-7aaa-49a9-8668-261a01844ace", @@ -66,7 +66,7 @@ public void testSimple_DefintionsInput() { } @Test - public void testBoxedExtension_Conditional14() { + void boxedExtensionConditional14() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .theseModels(getReader("dmn14boxed/conditional.dmn")); LOG.debug("{}", validate); @@ -74,28 +74,29 @@ public void testBoxedExtension_Conditional14() { } @Test - public void testBoxedExtension_Iterator14() { + void boxedExtensionIterator14() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .theseModels(getReader("dmn14boxed/iterator.dmn")); LOG.debug("{}", validate); assertThat(validate).hasSize(0); } + @Test - public void testBoxedExtension_IteratorDataType14() { + void boxedExtensionIteratorDataType14() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .theseModels(getReader("dmn14boxed/iterator-datatype.dmn")); assertThat(validate).hasSize(0); } @Test - public void testBoxedExtension_Filter14() { + void boxedExtensionFilter14() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .theseModels(getReader("dmn14boxed/filter.dmn")); assertThat(validate).hasSize(0); } @Test - public void testBoxedExtension_FilterDataType14() { + void boxedExtensionFilterDataType14() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) .theseModels(getReader("dmn14boxed/filter-datatype.dmn")); assertThat(validate).hasSize(0); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMNDITest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMNDITest.java index 3179c005859..c9b7b3336a2 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMNDITest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMNDITest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.Message.Level; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -32,10 +32,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorDMNDITest extends AbstractValidatorTest { +class ValidatorDMNDITest extends AbstractValidatorTest { @Test - public void testAllElements() throws IOException { + void allElements() throws IOException { try (final Reader reader = getReader("dmndi/all-elements.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -44,7 +44,7 @@ public void testAllElements() throws IOException { } @Test - public void testMISSING_DMNSHAPE_MISSING_DMNEDGE() throws IOException { + void missingDmnshapeMissingDmnedge() throws IOException { try (final Reader reader = getReader("dmndi/all-elements-with-dmndi-no-dmnshape.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -55,7 +55,7 @@ public void testMISSING_DMNSHAPE_MISSING_DMNEDGE() throws IOException { } @Test - public void testUNKNOWN_REF() throws IOException { + void unknownRef() throws IOException { try (final Reader reader = getReader("dmndi/all-elements-invalid-ref.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMNElementReferenceTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMNElementReferenceTest.java index 027d12f1e5d..8c286fb0ec6 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMNElementReferenceTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDMNElementReferenceTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -31,10 +31,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorDMNElementReferenceTest extends AbstractValidatorTest { +class ValidatorDMNElementReferenceTest extends AbstractValidatorTest { @Test - public void testELEMREF_NOHASH_ReaderInput() throws IOException { + void elemref_nohash_ReaderInput() throws IOException { try (final Reader reader = getReader("dmnelementref/ELEMREF_NOHASH.dmn")) { final List validationMessages = validator.validate( reader, @@ -44,7 +44,7 @@ public void testELEMREF_NOHASH_ReaderInput() throws IOException { } @Test - public void testELEMREF_NOHASH_FileInput() { + void elemref_nohash_FileInput() { final List validationMessages = validator.validate( getFile("dmnelementref/ELEMREF_NOHASH.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -52,7 +52,7 @@ public void testELEMREF_NOHASH_FileInput() { } @Test - public void testELEMREF_NOHASH_DefinitionsInput() { + void elemref_nohash_DefinitionsInput() { final List validationMessages = validator.validate( getDefinitions("dmnelementref/ELEMREF_NOHASH.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionServiceTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionServiceTest.java index acbd3773ba5..8fd89033aee 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionServiceTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionServiceTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -39,12 +39,12 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorDecisionServiceTest extends AbstractValidatorTest { +class ValidatorDecisionServiceTest extends AbstractValidatorTest { private static final Logger LOG = LoggerFactory.getLogger(ValidatorDecisionServiceTest.class); @Test - public void testOUTPUT_NOT_FOUND_FOR_DS_ReaderInput() throws IOException { + void output_not_found_for_ds_ReaderInput() throws IOException { try (final Reader reader = getReader("decisionservice/HelloDS_noOutput.dmn")) { final List validate = validator.validate( reader, @@ -55,7 +55,7 @@ public void testOUTPUT_NOT_FOUND_FOR_DS_ReaderInput() throws IOException { } @Test - public void testOUTPUT_NOT_FOUND_FOR_DS_FileInput() { + void output_not_found_for_ds_FileInput() { final List validate = validator.validate( getFile("decisionservice/HelloDS_noOutput.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -64,7 +64,7 @@ public void testOUTPUT_NOT_FOUND_FOR_DS_FileInput() { } @Test - public void testOUTPUT_NOT_FOUND_FOR_DS_DefinitionsInput() { + void output_not_found_for_ds_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decisionservice/HelloDS_noOutput.dmn", "https://kiegroup.org/dmn/_7C3C7416-2F33-4718-AE35-F3843C5250DB", @@ -75,7 +75,7 @@ public void testOUTPUT_NOT_FOUND_FOR_DS_DefinitionsInput() { } @Test - public void testOKDS() { + void okds() { DMNRuntime runtime = DMNRuntimeUtil.createRuntime("decisionservice/HelloDS_OK.dmn", this.getClass()); DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_7C3C7416-2F33-4718-AE35-F3843C5250DB", "HelloDS"); @@ -94,7 +94,7 @@ public void testOKDS() { } @Test - public void testDS1ofEach() { + void dS1ofEach() { DMNRuntime runtime = DMNRuntimeUtil.createRuntime("decisionservice/DS1ofEach_OK.dmn", this.getClass()); DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_40B3D02F-868C-4925-A1F2-5710DFEEF51E", "DS1ofEach"); @@ -117,7 +117,7 @@ public void testDS1ofEach() { } @Test - public void testENCAPSULATED_NOT_FOUND_FOR_DS_ReaderInput() throws IOException { + void encapsulated_not_found_for_ds_ReaderInput() throws IOException { try (final Reader reader = getReader("decisionservice/DS1ofEach_missingEncapsulated.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL); @@ -128,7 +128,7 @@ public void testENCAPSULATED_NOT_FOUND_FOR_DS_ReaderInput() throws IOException { } @Test - public void testENCAPSULATED_NOT_FOUND_FOR_DS_FileInput() { + void encapsulated_not_found_for_ds_FileInput() { final List validate = validator.validate(getFile("decisionservice/DS1ofEach_missingEncapsulated.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -137,7 +137,7 @@ public void testENCAPSULATED_NOT_FOUND_FOR_DS_FileInput() { } @Test - public void testENCAPSULATED_NOT_FOUND_FOR_DS_DefinitionsInput() { + void encapsulated_not_found_for_ds_DefinitionsInput() { final List validate = validator.validate(getDefinitions("decisionservice/DS1ofEach_missingEncapsulated.dmn", "https://kiegroup.org/dmn/_40B3D02F-868C-4925-A1F2-5710DFEEF51E", "DS1ofEach"), @@ -148,7 +148,7 @@ public void testENCAPSULATED_NOT_FOUND_FOR_DS_DefinitionsInput() { } @Test - public void testDECISIONINPUT_NOT_FOUND_FOR_DS_ReaderInput() throws IOException { + void decisioninput_not_found_for_ds_ReaderInput() throws IOException { try (final Reader reader = getReader("decisionservice/DS1ofEach_missingDecisionInput.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL); @@ -159,7 +159,7 @@ public void testDECISIONINPUT_NOT_FOUND_FOR_DS_ReaderInput() throws IOException } @Test - public void testDECISIONINPUT_NOT_FOUND_FOR_DS_FileInput() { + void decisioninput_not_found_for_ds_FileInput() { final List validate = validator.validate(getFile("decisionservice/DS1ofEach_missingDecisionInput.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -168,7 +168,7 @@ public void testDECISIONINPUT_NOT_FOUND_FOR_DS_FileInput() { } @Test - public void testDECISIONINPUT_NOT_FOUND_FOR_DS_DefinitionsInput() { + void decisioninput_not_found_for_ds_DefinitionsInput() { final List validate = validator.validate(getDefinitions("decisionservice/DS1ofEach_missingDecisionInput.dmn", "https://kiegroup.org/dmn/_40B3D02F-868C-4925-A1F2-5710DFEEF51E", "DS1ofEach"), @@ -179,7 +179,7 @@ public void testDECISIONINPUT_NOT_FOUND_FOR_DS_DefinitionsInput() { } @Test - public void testINPUTDATA_NOT_FOUND_FOR_DS_ReaderInput() throws IOException { + void inputdata_not_found_for_ds_ReaderInput() throws IOException { try (final Reader reader = getReader("decisionservice/DS1ofEach_missingInputData.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL); @@ -190,7 +190,7 @@ public void testINPUTDATA_NOT_FOUND_FOR_DS_ReaderInput() throws IOException { } @Test - public void testINPUTDATA_NOT_FOUND_FOR_DS_FileInput() { + void inputdata_not_found_for_ds_FileInput() { final List validate = validator.validate(getFile("decisionservice/DS1ofEach_missingInputData.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -199,7 +199,7 @@ public void testINPUTDATA_NOT_FOUND_FOR_DS_FileInput() { } @Test - public void testINPUTDATA_NOT_FOUND_FOR_DS_DefinitionsInput() { + void inputdata_not_found_for_ds_DefinitionsInput() { final List validate = validator.validate(getDefinitions("decisionservice/DS1ofEach_missingInputData.dmn", "https://kiegroup.org/dmn/_40B3D02F-868C-4925-A1F2-5710DFEEF51E", "DS1ofEach"), @@ -210,7 +210,7 @@ public void testINPUTDATA_NOT_FOUND_FOR_DS_DefinitionsInput() { } @Test - public void testOUTPUTELEMENT_NOT_FOUND_FOR_DS_ReaderInput() throws IOException { + void outputelement_not_found_for_ds_ReaderInput() throws IOException { try (final Reader reader = getReader("decisionservice/DS1ofEach_missingOutput.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL); @@ -220,7 +220,7 @@ public void testOUTPUTELEMENT_NOT_FOUND_FOR_DS_ReaderInput() throws IOException } @Test - public void testOUTPUTELEMENT_NOT_FOUND_FOR_DS_FileInput() { + void outputelement_not_found_for_ds_FileInput() { final List validate = validator.validate(getFile("decisionservice/DS1ofEach_missingOutput.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -228,7 +228,7 @@ public void testOUTPUTELEMENT_NOT_FOUND_FOR_DS_FileInput() { } @Test - public void testOUTPUTELEMENT_NOT_FOUND_FOR_DS_DefinitionsInput() { + void outputelement_not_found_for_ds_DefinitionsInput() { final List validate = validator.validate(getDefinitions("decisionservice/DS1ofEach_missingOutput.dmn", "https://kiegroup.org/dmn/_40B3D02F-868C-4925-A1F2-5710DFEEF51E", "DS1ofEach"), diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionTableTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionTableTest.java index c0e6440aca4..12accc04498 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionTableTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionTableTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -31,11 +31,11 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorDecisionTableTest +class ValidatorDecisionTableTest extends AbstractValidatorTest { @Test - public void testDTABLE_EMPTY_ENTRY_ReaderInput() throws IOException { + void dtable_empty_entry_ReaderInput() throws IOException { try (final Reader reader = getReader("DTABLE_EMPTY_ENTRY.dmn")) { final List validate = validator.validate( reader, @@ -46,7 +46,7 @@ public void testDTABLE_EMPTY_ENTRY_ReaderInput() throws IOException { } @Test - public void testDTABLE_EMPTY_ENTRY_FileInput() { + void dtable_empty_entry_FileInput() { final List validate = validator.validate( getFile("DTABLE_EMPTY_ENTRY.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -55,7 +55,7 @@ public void testDTABLE_EMPTY_ENTRY_FileInput() { } @Test - public void testDTABLE_EMPTY_ENTRY_DefintionsInput() { + void dtable_empty_entry_DefintionsInput() { final List validate = validator.validate( getDefinitions("DTABLE_EMPTY_ENTRY.dmn", "https://github.com/kiegroup/kie-dmn", @@ -66,7 +66,7 @@ public void testDTABLE_EMPTY_ENTRY_DefintionsInput() { } @Test - public void testDTABLE_MULTIPLEOUT_NAME_ReaderInput() throws IOException { + void dtable_multipleout_name_ReaderInput() throws IOException { try (final Reader reader = getReader( "DTABLE_MULTIPLEOUTPUT_WRONG_OUTPUT.dmn" )) { List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(6); @@ -77,7 +77,7 @@ public void testDTABLE_MULTIPLEOUT_NAME_ReaderInput() throws IOException { } @Test - public void testDTABLE_MULTIPLEOUT_NAME_FileInput() { + void dtable_multipleout_name_FileInput() { List validate = validator.validate( getFile( "DTABLE_MULTIPLEOUTPUT_WRONG_OUTPUT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(6); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_NAME))).isTrue(); @@ -86,7 +86,7 @@ public void testDTABLE_MULTIPLEOUT_NAME_FileInput() { } @Test - public void testDTABLE_MULTIPLEOUT_NAME_DefinitionsInput() { + void dtable_multipleout_name_DefinitionsInput() { List validate = validator.validate( getDefinitions( "DTABLE_MULTIPLEOUTPUT_WRONG_OUTPUT.dmn", "https://github.com/kiegroup/kie-dmn", @@ -99,7 +99,7 @@ public void testDTABLE_MULTIPLEOUT_NAME_DefinitionsInput() { } @Test - public void testDTABLE_PRIORITY_MISSING_OUTVALS_ReaderInput() throws IOException { + void dtable_priority_missing_outvals_ReaderInput() throws IOException { try (final Reader reader = getReader( "DTABLE_PRIORITY_MISSING_OUTVALS.dmn" )) { List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).isNotEmpty(); @@ -108,14 +108,14 @@ public void testDTABLE_PRIORITY_MISSING_OUTVALS_ReaderInput() throws IOException } @Test - public void testDTABLE_PRIORITY_MISSING_OUTVALS_FileInput() { + void dtable_priority_missing_outvals_FileInput() { List validate = validator.validate( getFile( "DTABLE_PRIORITY_MISSING_OUTVALS.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).isNotEmpty(); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_OUTPUT_VALUES))).isTrue(); } @Test - public void testDTABLE_PRIORITY_MISSING_OUTVALS_DefinitionsInput() { + void dtable_priority_missing_outvals_DefinitionsInput() { List validate = validator.validate( getDefinitions( "DTABLE_PRIORITY_MISSING_OUTVALS.dmn", "https://github.com/kiegroup/kie-dmn", @@ -126,7 +126,7 @@ public void testDTABLE_PRIORITY_MISSING_OUTVALS_DefinitionsInput() { } @Test - public void testDTABLE_SINGLEOUT_NONAME_ReaderInput() throws IOException { + void dtable_singleout_noname_ReaderInput() throws IOException { try (final Reader reader = getReader( "DTABLE_SINGLEOUTPUT_WRONG_OUTPUT.dmn" )) { List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -136,7 +136,7 @@ public void testDTABLE_SINGLEOUT_NONAME_ReaderInput() throws IOException { } @Test - public void testDTABLE_SINGLEOUT_NONAME_FileInput() { + void dtable_singleout_noname_FileInput() { List validate = validator.validate( getFile( "DTABLE_SINGLEOUTPUT_WRONG_OUTPUT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.ILLEGAL_USE_OF_NAME))).isTrue(); @@ -144,7 +144,7 @@ public void testDTABLE_SINGLEOUT_NONAME_FileInput() { } @Test - public void testDTABLE_SINGLEOUT_NONAME_DefinitionsInput() { + void dtable_singleout_noname_DefinitionsInput() { List validate = validator.validate( getDefinitions("DTABLE_SINGLEOUTPUT_WRONG_OUTPUT.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionTest.java index fa73842182d..c19c16c7d32 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorDecisionTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.Message.Level; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -37,10 +37,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorDecisionTest extends AbstractValidatorTest { +class ValidatorDecisionTest extends AbstractValidatorTest { @Test - public void testDECISION_MISSING_EXPR_ReaderInput() throws IOException { + void decision_missing_expr_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MISSING_EXPR.dmn")) { final List validate = validator.validate( reader, @@ -51,7 +51,7 @@ public void testDECISION_MISSING_EXPR_ReaderInput() throws IOException { } @Test - public void testDECISION_MISSING_EXPR_FileInput() { + void decision_missing_expr_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_MISSING_EXPR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -60,7 +60,7 @@ public void testDECISION_MISSING_EXPR_FileInput() { } @Test - public void testDECISION_MISSING_EXPR_DefinitionsInput() { + void decision_missing_expr_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MISSING_EXPR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -71,7 +71,7 @@ public void testDECISION_MISSING_EXPR_DefinitionsInput() { } @Test - public void testDECISION_MISSING_VAR_ReaderInput() throws IOException { + void decision_missing_var_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MISSING_VAR.dmn")) { final List validate = validator.validate( reader, @@ -82,7 +82,7 @@ public void testDECISION_MISSING_VAR_ReaderInput() throws IOException { } @Test - public void testDECISION_MISSING_VAR_FileInput() { + void decision_missing_var_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_MISSING_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -91,7 +91,7 @@ public void testDECISION_MISSING_VAR_FileInput() { } @Test - public void testDECISION_MISSING_VAR_DefinitionsInput() { + void decision_missing_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MISSING_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -102,7 +102,7 @@ public void testDECISION_MISSING_VAR_DefinitionsInput() { } @Test - public void testDECISION_MISSING_VARbis_ReaderInput() throws IOException { + void decision_missing_vaRbisReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MISSING_VARbis.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -111,7 +111,7 @@ public void testDECISION_MISSING_VARbis_ReaderInput() throws IOException { } @Test - public void testDECISION_MISSING_VARbis_FileInput() { + void decision_missing_vaRbisFileInput() { final List validate = validator.validate( getFile("decision/DECISION_MISSING_VARbis.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -119,7 +119,7 @@ public void testDECISION_MISSING_VARbis_FileInput() { } @Test - public void testDECISION_MISSING_VARbis_DefinitionsInput() { + void decision_missing_vaRbisDefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MISSING_VARbis.dmn", "https://github.com/kiegroup/kie-dmn", @@ -130,7 +130,7 @@ public void testDECISION_MISSING_VARbis_DefinitionsInput() { } @Test - public void testDECISION_MISMATCH_VAR_ReaderInput() throws IOException { + void decision_mismatch_var_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MISMATCH_VAR.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -139,7 +139,7 @@ public void testDECISION_MISMATCH_VAR_ReaderInput() throws IOException { } @Test - public void testDECISION_MISMATCH_VAR_FileInput() { + void decision_mismatch_var_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_MISMATCH_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -147,7 +147,7 @@ public void testDECISION_MISMATCH_VAR_FileInput() { } @Test - public void testDECISION_MISMATCH_VAR_DefinitionsInput() { + void decision_mismatch_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MISMATCH_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -158,7 +158,7 @@ public void testDECISION_MISMATCH_VAR_DefinitionsInput() { } @Test - public void testDECISION_MULTIPLE_EXPRESSIONS_ReaderInput() throws IOException { + void decision_multiple_expressions_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_MULTIPLE_EXPRESSIONS.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -167,7 +167,7 @@ public void testDECISION_MULTIPLE_EXPRESSIONS_ReaderInput() throws IOException { } @Test - public void testDECISION_MULTIPLE_EXPRESSIONS_FileInput() { + void decision_multiple_expressions_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_MULTIPLE_EXPRESSIONS.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -175,7 +175,7 @@ public void testDECISION_MULTIPLE_EXPRESSIONS_FileInput() { } @Test - public void testDECISION_MULTIPLE_EXPRESSIONS_DefinitionsInput() { + void decision_multiple_expressions_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MULTIPLE_EXPRESSIONS.dmn", "https://github.com/kiegroup/kie-dmn", @@ -185,7 +185,7 @@ public void testDECISION_MULTIPLE_EXPRESSIONS_DefinitionsInput() { } @Test - public void testDECISION_PERF_INDICATOR_WRONG_TYPE_ReaderInput() throws IOException { + void decision_perf_indicator_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_PERF_INDICATOR_WRONG_TYPE.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -194,7 +194,7 @@ public void testDECISION_PERF_INDICATOR_WRONG_TYPE_ReaderInput() throws IOExcept } @Test - public void testDECISION_PERF_INDICATOR_WRONG_TYPE_FileInput() { + void decision_perf_indicator_wrong_type_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_PERF_INDICATOR_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -202,7 +202,7 @@ public void testDECISION_PERF_INDICATOR_WRONG_TYPE_FileInput() { } @Test - public void testDECISION_PERF_INDICATOR_WRONG_TYPE_DefinitionsInput() { + void decision_perf_indicator_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_PERF_INDICATOR_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -213,7 +213,7 @@ public void testDECISION_PERF_INDICATOR_WRONG_TYPE_DefinitionsInput() { } @Test - public void testDECISION_DECISION_MAKER_WRONG_TYPE_ReaderInput() throws IOException { + void decision_decision_maker_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_DECISION_MAKER_WRONG_TYPE.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -222,7 +222,7 @@ public void testDECISION_DECISION_MAKER_WRONG_TYPE_ReaderInput() throws IOExcept } @Test - public void testDECISION_DECISION_MAKER_WRONG_TYPE_FileInput() { + void decision_decision_maker_wrong_type_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_DECISION_MAKER_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -230,7 +230,7 @@ public void testDECISION_DECISION_MAKER_WRONG_TYPE_FileInput() { } @Test - public void testDECISION_DECISION_MAKER_WRONG_TYPE_DefinitionsInput() { + void decision_decision_maker_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_DECISION_MAKER_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -241,7 +241,7 @@ public void testDECISION_DECISION_MAKER_WRONG_TYPE_DefinitionsInput() { } @Test - public void testDECISION_DECISION_OWNER_WRONG_TYPE_ReaderInput() throws IOException { + void decision_decision_owner_wrong_type_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_DECISION_OWNER_WRONG_TYPE.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -250,7 +250,7 @@ public void testDECISION_DECISION_OWNER_WRONG_TYPE_ReaderInput() throws IOExcept } @Test - public void testDECISION_DECISION_OWNER_WRONG_TYPE_FileInput() { + void decision_decision_owner_wrong_type_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_DECISION_OWNER_WRONG_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -258,7 +258,7 @@ public void testDECISION_DECISION_OWNER_WRONG_TYPE_FileInput() { } @Test - public void testDECISION_DECISION_OWNER_WRONG_TYPE_DefinitionsInput() { + void decision_decision_owner_wrong_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_DECISION_OWNER_WRONG_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -269,7 +269,7 @@ public void testDECISION_DECISION_OWNER_WRONG_TYPE_DefinitionsInput() { } @Test - public void testDECISION_CYCLIC_DEPENDENCY_ReaderInput() throws IOException { + void decision_cyclic_dependency_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_CYCLIC_DEPENDENCY.dmn")) { final List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); @@ -278,14 +278,14 @@ public void testDECISION_CYCLIC_DEPENDENCY_ReaderInput() throws IOException { } @Test - public void testDECISION_CYCLIC_DEPENDENCY_FileInput() { + void decision_cyclic_dependency_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_CYCLIC_DEPENDENCY.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND))).isTrue(); } @Test - public void testDECISION_CYCLIC_DEPENDENCY_DefinitionsInput() { + void decision_cyclic_dependency_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_CYCLIC_DEPENDENCY.dmn", "https://github.com/kiegroup/kie-dmn", @@ -296,7 +296,7 @@ public void testDECISION_CYCLIC_DEPENDENCY_DefinitionsInput() { } @Test - public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_ReaderInput() throws IOException { + void decision_cyclic_dependency_self_reference_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE.dmn")) { final List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); @@ -305,14 +305,14 @@ public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_ReaderInput() throws I } @Test - public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_FileInput() { + void decision_cyclic_dependency_self_reference_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND))).isTrue(); } @Test - public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_DefinitionsInput() { + void decision_cyclic_dependency_self_reference_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -323,7 +323,7 @@ public void testDECISION_CYCLIC_DEPENDENCY_SELF_REFERENCE_DefinitionsInput() { } @Test - public void testDECISION_DEADLY_DIAMOND_ReaderInput() throws IOException { + void decision_deadly_diamond_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_DEADLY_DIAMOND.dmn")) { final List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); @@ -331,13 +331,13 @@ public void testDECISION_DEADLY_DIAMOND_ReaderInput() throws IOException { } @Test - public void testDECISION_DEADLY_DIAMOND_FileInput() { + void decision_deadly_diamond_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_DEADLY_DIAMOND.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testDECISION_DEADLY_DIAMOND_DefinitionsInput() { + void decision_deadly_diamond_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_DEADLY_DIAMOND.dmn", "https://github.com/kiegroup/kie-dmn", @@ -347,7 +347,7 @@ public void testDECISION_DEADLY_DIAMOND_DefinitionsInput() { } @Test - public void testDECISION_DEADLY_KITE_ReaderInput() throws IOException { + void decision_deadly_kite_ReaderInput() throws IOException { try (final Reader reader = getReader("decision/DECISION_DEADLY_KITE.dmn")) { final List validate = validator.validate( reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); @@ -355,13 +355,13 @@ public void testDECISION_DEADLY_KITE_ReaderInput() throws IOException { } @Test - public void testDECISION_DEADLY_KITE_FileInput() { + void decision_deadly_kite_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_DEADLY_KITE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testDECISION_DEADLY_KITE_DefinitionsInput() { + void decision_deadly_kite_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_DEADLY_KITE.dmn", "https://github.com/kiegroup/kie-dmn", @@ -371,23 +371,23 @@ public void testDECISION_DEADLY_KITE_DefinitionsInput() { } @Test - public void testDECISION_MISSING_REQ_ReaderInput() throws IOException { // ELEMREF_MISSING + void decision_missing_req_ReaderInput() throws IOException { // ELEMREF_MISSING try (final Reader reader = getReader("decision/DECISION_MISSING_REQ.dmn")) { final List validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND))).isTrue(); } } - + @Test - public void testDECISION_MISSING_REQ_FileInput() { + void decision_missing_req_FileInput() { final List validate = validator.validate( getFile("decision/DECISION_MISSING_REQ.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL ); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND))).isTrue(); } @Test - public void testDECISION_MISSING_REQ_DefinitionsInput() { + void decision_missing_req_DefinitionsInput() { final List validate = validator.validate( getDefinitions("decision/DECISION_MISSING_REQ.dmn", "https://github.com/kiegroup/kie-dmn", @@ -396,9 +396,9 @@ public void testDECISION_MISSING_REQ_DefinitionsInput() { assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND))).isTrue(); } - + @Test - public void testDTCollectOperatorsMultipleOutputs() { + void dTCollectOperatorsMultipleOutputs() { // DROOLS-6590 DMN composite output on DT Collect with operators - this is beyond the spec. DMNRuntime runtime = DMNRuntimeUtil.createRuntime("multipleOutputsCollectDT.dmn", DMNRuntimeTest.class); DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_943A3581-5FD1-4BCF-9A52-AC7242CC451C", "multipleOutputsCollectDT"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorImportTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorImportTest.java index a2934945471..67787975ccf 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorImportTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorImportTest.java @@ -24,8 +24,8 @@ import java.util.Arrays; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -48,9 +48,9 @@ public class ValidatorImportTest extends AbstractValidatorTest { public static final Logger LOG = LoggerFactory.getLogger(ValidatorImportTest.class); - @Ignore + @Disabled @Test - public void testBaseModelOK() { + void baseModelOK() { DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("import/Base-model.dmn", this.getClass(), "import/Import-base-model.dmn"); DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_b33fa7d9-f501-423b-afa8-15ded7e7f493", "Import base model"); assertThat(dmnModel).isNotNull(); @@ -64,7 +64,7 @@ public void testBaseModelOK() { } @Test - public void testBaseModelOKFromReaderInput() throws IOException { + void baseModelOKFromReaderInput() throws IOException { try (final Reader reader0 = getReader("import/Base-model.dmn"); final Reader reader1 = getReader("import/Import-base-model.dmn");) { final List messages = validator.validateUsing(// VALIDATE_SCHEMA, disabled, due to QName use not compliant. @@ -76,7 +76,7 @@ public void testBaseModelOKFromReaderInput() throws IOException { } @Test - public void testBaseModelOKFromFileInput() throws IOException { + void baseModelOKFromFileInput() throws IOException { final List messages = validator.validateUsing(// VALIDATE_SCHEMA, disabled, due to QName use not compliant. Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) @@ -86,7 +86,7 @@ public void testBaseModelOKFromFileInput() throws IOException { } @Test - public void testBaseModelImportModelNameFromFileInput() throws IOException { + void baseModelImportModelNameFromFileInput() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL) .theseModels(getFile("import/Import-base-model-modelnameattribute.dmn"), // DROOLS-2938 getFile("import/Base-model.dmn")); @@ -94,7 +94,7 @@ public void testBaseModelImportModelNameFromFileInput() throws IOException { } @Test - public void testBaseModelOKFromDefinitionsInput() throws IOException { + void baseModelOKFromDefinitionsInput() throws IOException { final List messages = validator.validateUsing(// VALIDATE_SCHEMA, disabled, due to QName use not compliant. Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) @@ -108,7 +108,7 @@ public void testBaseModelOKFromDefinitionsInput() throws IOException { } @Test - public void testWrongImportBaseModelFromReaderInput() throws IOException { + void wrongImportBaseModelFromReaderInput() throws IOException { try (final Reader reader0 = getReader("import/Base-model.dmn"); final Reader reader1 = getReader("import/Wrong-Import-base-model.dmn");) { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL) @@ -120,9 +120,9 @@ public void testWrongImportBaseModelFromReaderInput() throws IOException { .equals("http://www.trisotech.com/definitions/_70df1ad5-2a33-4ede-b8b2-869988ac1d30#_1d52934e-aa4e-47c9-a011-fc989d795664"))).isTrue(); } } - + @Test - public void testWrongImportBaseModelFromFileInput() throws IOException { + void wrongImportBaseModelFromFileInput() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL) .theseModels(getFile("import/Base-model.dmn"), getFile("import/Wrong-Import-base-model.dmn")); @@ -134,7 +134,7 @@ public void testWrongImportBaseModelFromFileInput() throws IOException { } @Test - public void testWrongImportBaseModelFromDefinitionsInput() throws IOException { + void wrongImportBaseModelFromDefinitionsInput() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL) .theseModels(getDefinitions(Arrays.asList("import/Base-model.dmn", "import/Wrong-Import-base-model.dmn"), "http://www.trisotech.com/definitions/_70df1ad5-2a33-4ede-b8b2-869988ac1d30", @@ -149,7 +149,7 @@ public void testWrongImportBaseModelFromDefinitionsInput() throws IOException { } @Test - public void testOnlyImportBaseModelFromReaderInput() throws IOException { + void onlyImportBaseModelFromReaderInput() throws IOException { try (final Reader reader1 = getReader("import/Only-Import-base-model.dmn");) { final List messages = validator.validate(reader1, Validation.VALIDATE_MODEL); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.IMPORT_NOT_FOUND))).isTrue(); @@ -157,13 +157,13 @@ public void testOnlyImportBaseModelFromReaderInput() throws IOException { } @Test - public void testOnlyImportBaseModelFromFileInput() throws IOException { + void onlyImportBaseModelFromFileInput() throws IOException { final List messages = validator.validate(getFile("import/Only-Import-base-model.dmn"), Validation.VALIDATE_MODEL); assertThat(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.IMPORT_NOT_FOUND))).isTrue(); } @Test - public void testOnlyImportBaseModelFromDefinitionsInput() throws IOException { + void onlyImportBaseModelFromDefinitionsInput() throws IOException { final List messages = validator.validate(getDefinitions("import/Only-Import-base-model.dmn", "http://www.trisotech.com/dmn/definitions/_a9bfa4de-cf5c-4b2f-9011-ab576e00b162", "Only Import base model"), @@ -172,7 +172,7 @@ public void testOnlyImportBaseModelFromDefinitionsInput() throws IOException { } @Test - public void testImportNoAddtnAttribute() throws IOException { + void importNoAddtnAttribute() throws IOException { // DROOLS-4187 kie-dmn-validation: Incorrect import detection final List messages = validator.validateUsing(Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) @@ -191,41 +191,41 @@ public void testImportNoAddtnAttribute() throws IOException { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isFalse(); assertThat(dmnResult.getDecisionResultByName("aaa").getResult()).isEqualTo(new BigDecimal(2)); } - + @Test - public void testImportNameOK() throws IOException { + void importNameOK() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) .theseModels(getReader("myHelloDS.dmn", DMNDecisionServicesTest.class), getReader("importingMyHelloDSbkmBoxedInvocation.dmn", DMNDecisionServicesTest.class)); assertThat(messages).as(ValidatorUtil.formatMessages(messages)).hasSize(0); } - + @Test - public void testImportNameNotUniqueWithDRG() throws IOException { + void importNameNotUniqueWithDRG() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) .theseModels(getReader("myHelloDS.dmn", DMNDecisionServicesTest.class), getReader("import/importingMyHelloDSbkmBoxedInvocation_wrongBKMname.dmn")); assertThat(messages.stream().anyMatch(p -> p.getText().contains("myHelloDS") && p.getMessageType().equals(DMNMessageType.DUPLICATE_NAME))).isTrue(); } - + @Test - public void testImportNameNotUniqueWithItemDef() throws IOException { + void importNameNotUniqueWithItemDef() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) .theseModels(getReader("myHelloDS.dmn", DMNDecisionServicesTest.class), getReader("import/importingMyHelloDSbkmBoxedInvocation_wrongItemDefName.dmn")); assertThat(messages.stream().anyMatch(p -> p.getText().contains("myHelloDS") && p.getMessageType().equals(DMNMessageType.DUPLICATE_NAME))).isTrue(); } - + @Test - public void testImportNameOKWithItemDefComponent() throws IOException { + void importNameOKWithItemDefComponent() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) .theseModels(getReader("myHelloDS.dmn", DMNDecisionServicesTest.class), getReader("import/importingMyHelloDSbkmBoxedInvocation_okItemDefName.dmn")); assertThat(messages).as(ValidatorUtil.formatMessages(messages)).hasSize(0); } - + @Test - public void testImportNameNotUniqueWithOtherImport() throws IOException { + void importNameNotUniqueWithOtherImport() throws IOException { final List messages = validator.validateUsing(Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION) .theseModels(getReader("myHelloDS.dmn", DMNDecisionServicesTest.class), getReader("import/importingMyHelloDSbkmBoxedInvocation_wrongDoubleImportName.dmn")); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorInformationRequirementTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorInformationRequirementTest.java index 3b6a32cebd7..4c612befee7 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorInformationRequirementTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorInformationRequirementTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -31,10 +31,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorInformationRequirementTest extends AbstractValidatorTest { +class ValidatorInformationRequirementTest extends AbstractValidatorTest { @Test - public void testINFOREQ_MISSING_INPUT_ReaderInput() throws IOException { + void inforeq_missing_input_ReaderInput() throws IOException { try (final Reader reader = getReader( "informationrequirement/INFOREQ_MISSING_INPUT.dmn" )) { final List validate = validator.validate( reader, @@ -46,7 +46,7 @@ public void testINFOREQ_MISSING_INPUT_ReaderInput() throws IOException { } @Test - public void testINFOREQ_MISSING_INPUT_FileInput() { + void inforeq_missing_input_FileInput() { final List validate = validator.validate( getFile( "informationrequirement/INFOREQ_MISSING_INPUT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testINFOREQ_MISSING_INPUT_FileInput() { } @Test - public void testINFOREQ_MISSING_INPUT_DefinitionsInput() { + void inforeq_missing_input_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "informationrequirement/INFOREQ_MISSING_INPUT.dmn", "https://github.com/kiegroup/kie-dmn", @@ -68,7 +68,7 @@ public void testINFOREQ_MISSING_INPUT_DefinitionsInput() { } @Test - public void testINFOREQ_INPUT_NOT_INPUTDATA_ReaderInput() throws IOException { + void inforeq_input_not_inputdata_ReaderInput() throws IOException { try (final Reader reader = getReader( "informationrequirement/INFOREQ_INPUT_NOT_INPUTDATA.dmn" )) { final List validate = validator.validate( reader, @@ -80,7 +80,7 @@ public void testINFOREQ_INPUT_NOT_INPUTDATA_ReaderInput() throws IOException { } @Test - public void testINFOREQ_INPUT_NOT_INPUTDATA_FileInput() { + void inforeq_input_not_inputdata_FileInput() { final List validate = validator.validate( getFile( "informationrequirement/INFOREQ_INPUT_NOT_INPUTDATA.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -90,7 +90,7 @@ public void testINFOREQ_INPUT_NOT_INPUTDATA_FileInput() { } @Test - public void testINFOREQ_INPUT_NOT_INPUTDATA_DefinitionsInput() { + void inforeq_input_not_inputdata_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "informationrequirement/INFOREQ_INPUT_NOT_INPUTDATA.dmn", "https://github.com/kiegroup/kie-dmn", @@ -102,7 +102,7 @@ public void testINFOREQ_INPUT_NOT_INPUTDATA_DefinitionsInput() { } @Test - public void testINFOREQ_MISSING_DECISION_ReaderInput() throws IOException { + void inforeq_missing_decision_ReaderInput() throws IOException { try (final Reader reader = getReader( "informationrequirement/INFOREQ_MISSING_DECISION.dmn" )) { final List validate = validator.validate( reader, @@ -114,7 +114,7 @@ public void testINFOREQ_MISSING_DECISION_ReaderInput() throws IOException { } @Test - public void testINFOREQ_MISSING_DECISION_FileInput() { + void inforeq_missing_decision_FileInput() { final List validate = validator.validate( getFile( "informationrequirement/INFOREQ_MISSING_DECISION.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -124,7 +124,7 @@ public void testINFOREQ_MISSING_DECISION_FileInput() { } @Test - public void testINFOREQ_MISSING_DECISION_DefinitionsInput() { + void inforeq_missing_decision_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "informationrequirement/INFOREQ_MISSING_DECISION.dmn", "https://github.com/kiegroup/kie-dmn", @@ -136,7 +136,7 @@ public void testINFOREQ_MISSING_DECISION_DefinitionsInput() { } @Test - public void testINFOREQ_DECISION_NOT_DECISION_ReaderInput() throws IOException { + void inforeq_decision_not_decision_ReaderInput() throws IOException { try (final Reader reader = getReader( "informationrequirement/INFOREQ_DECISION_NOT_DECISION.dmn" )) { final List validate = validator.validate( reader, @@ -148,7 +148,7 @@ public void testINFOREQ_DECISION_NOT_DECISION_ReaderInput() throws IOException { } @Test - public void testINFOREQ_DECISION_NOT_DECISION_FileInput() { + void inforeq_decision_not_decision_FileInput() { final List validate = validator.validate( getFile( "informationrequirement/INFOREQ_DECISION_NOT_DECISION.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -158,7 +158,7 @@ public void testINFOREQ_DECISION_NOT_DECISION_FileInput() { } @Test - public void testINFOREQ_DECISION_NOT_DECISION_DefinitionsInput() { + void inforeq_decision_not_decision_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "informationrequirement/INFOREQ_DECISION_NOT_DECISION.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorInputDataTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorInputDataTest.java index 79f04fb877a..92313525f4c 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorInputDataTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorInputDataTest.java @@ -18,22 +18,23 @@ */ package org.kie.dmn.validation; -import static org.assertj.core.api.Assertions.assertThat; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; - import java.io.IOException; import java.io.Reader; import java.util.List; -import org.junit.Test; + +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; -public class ValidatorInputDataTest extends AbstractValidatorTest { +import static org.assertj.core.api.Assertions.assertThat; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; + +class ValidatorInputDataTest extends AbstractValidatorTest { @Test - public void testINPUT_MISSING_VAR_ReaderInput() throws IOException { + void input_missing_var_ReaderInput() throws IOException { try (final Reader reader = getReader("inputdata/INPUTDATA_MISSING_VAR.dmn")) { final List validate = validator.validate( reader, @@ -44,7 +45,7 @@ public void testINPUT_MISSING_VAR_ReaderInput() throws IOException { } @Test - public void testINPUT_MISSING_VAR_FileInput() { + void input_missing_var_FileInput() { final List validate = validator.validate( getFile("inputdata/INPUTDATA_MISSING_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -53,7 +54,7 @@ public void testINPUT_MISSING_VAR_FileInput() { } @Test - public void testINPUT_MISSING_VAR_DefintionsInput() { + void input_missing_var_DefintionsInput() { final List validate = validator.validate( getDefinitions("inputdata/INPUTDATA_MISSING_VAR.dmn", "https://github.com/kiegroup/kie-dmn", @@ -64,7 +65,7 @@ public void testINPUT_MISSING_VAR_DefintionsInput() { } @Test - public void testINPUT_MISMATCH_VAR_ReaderInput() throws IOException { + void input_mismatch_var_ReaderInput() throws IOException { try (final Reader reader = getReader("inputdata/INPUTDATA_MISMATCH_VAR.dmn")) { final List validate = validator.validate( reader, @@ -75,7 +76,7 @@ public void testINPUT_MISMATCH_VAR_ReaderInput() throws IOException { } @Test - public void testINPUT_MISMATCH_VAR_FileInput() { + void input_mismatch_var_FileInput() { final List validate = validator.validate( getFile("inputdata/INPUTDATA_MISMATCH_VAR.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -84,7 +85,7 @@ public void testINPUT_MISMATCH_VAR_FileInput() { } @Test - public void testINPUT_MISMATCH_VAR_DefinitionsInput() { + void input_mismatch_var_DefinitionsInput() { final List validate = validator.validate( getDefinitions("inputdata/INPUTDATA_MISMATCH_VAR.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorKnowledgeRequirementTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorKnowledgeRequirementTest.java index 362e58f8a1b..2453e23e3cb 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorKnowledgeRequirementTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorKnowledgeRequirementTest.java @@ -18,23 +18,23 @@ */ package org.kie.dmn.validation; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; -import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; - import java.io.IOException; import java.io.Reader; import java.util.List; -import org.junit.Test; + +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import static org.assertj.core.api.Assertions.assertThat; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; +import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorKnowledgeRequirementTest extends AbstractValidatorTest { +class ValidatorKnowledgeRequirementTest extends AbstractValidatorTest { @Test - public void testKNOWREQ_MISSING_BKM_ReaderInput() throws IOException { + void knowreq_missing_bkm_ReaderInput() throws IOException { try (final Reader reader = getReader( "knowledgerequirement/KNOWREQ_MISSING_BKM.dmn" )) { final List validate = validator.validate( reader, @@ -46,7 +46,7 @@ public void testKNOWREQ_MISSING_BKM_ReaderInput() throws IOException { } @Test - public void testKNOWREQ_MISSING_BKM_FileInput() { + void knowreq_missing_bkm_FileInput() { final List validate = validator.validate( getFile( "knowledgerequirement/KNOWREQ_MISSING_BKM.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -56,7 +56,7 @@ public void testKNOWREQ_MISSING_BKM_FileInput() { } @Test - public void testKNOWREQ_MISSING_BKM_DefinitionsInput() { + void knowreq_missing_bkm_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "knowledgerequirement/KNOWREQ_MISSING_BKM.dmn", "https://github.com/kiegroup/kie-dmn", @@ -68,7 +68,7 @@ public void testKNOWREQ_MISSING_BKM_DefinitionsInput() { } @Test - public void testKNOWREQ_REQ_DECISION_NOT_BKM_ReaderInput() throws IOException { + void knowreq_req_decision_not_bkm_ReaderInput() throws IOException { try (final Reader reader = getReader( "knowledgerequirement/KNOWREQ_REQ_DECISION_NOT_BKM.dmn" )) { final List validate = validator.validate( reader, @@ -80,7 +80,7 @@ public void testKNOWREQ_REQ_DECISION_NOT_BKM_ReaderInput() throws IOException { } @Test - public void testKNOWREQ_REQ_DECISION_NOT_BKM_FileInput() { + void knowreq_req_decision_not_bkm_FileInput() { final List validate = validator.validate( getFile( "knowledgerequirement/KNOWREQ_REQ_DECISION_NOT_BKM.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -90,7 +90,7 @@ public void testKNOWREQ_REQ_DECISION_NOT_BKM_FileInput() { } @Test - public void testKNOWREQ_REQ_DECISION_NOT_BKM_DefinitionsInput() { + void knowreq_req_decision_not_bkm_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "knowledgerequirement/KNOWREQ_REQ_DECISION_NOT_BKM.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorKnowledgeSourceTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorKnowledgeSourceTest.java index 5142971f21e..807733995df 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorKnowledgeSourceTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorKnowledgeSourceTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -31,10 +31,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorKnowledgeSourceTest extends AbstractValidatorTest { +class ValidatorKnowledgeSourceTest extends AbstractValidatorTest { @Test - public void testKNOW_SOURCE_MISSING_OWNER_ReaderInput() throws IOException { + void know_source_missing_owner_ReaderInput() throws IOException { try (final Reader reader = getReader( "knowledgesource/KNOW_SOURCE_MISSING_OWNER.dmn" )) { final List validate = validator.validate( reader, @@ -45,7 +45,7 @@ public void testKNOW_SOURCE_MISSING_OWNER_ReaderInput() throws IOException { } @Test - public void testKNOW_SOURCE_MISSING_OWNER_FileInput() { + void know_source_missing_owner_FileInput() { final List validate = validator.validate( getFile( "knowledgesource/KNOW_SOURCE_MISSING_OWNER.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -54,7 +54,7 @@ public void testKNOW_SOURCE_MISSING_OWNER_FileInput() { } @Test - public void testKNOW_SOURCE_MISSING_OWNER_DefinitionsInput() { + void know_source_missing_owner_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "knowledgesource/KNOW_SOURCE_MISSING_OWNER.dmn", "https://github.com/kiegroup/kie-dmn", @@ -65,7 +65,7 @@ public void testKNOW_SOURCE_MISSING_OWNER_DefinitionsInput() { } @Test - public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_ReaderInput() throws IOException { + void know_source_owner_not_org_unit_ReaderInput() throws IOException { try (final Reader reader = getReader( "knowledgesource/KNOW_SOURCE_OWNER_NOT_ORG_UNIT.dmn" )) { final List validate = validator.validate( reader, @@ -76,7 +76,7 @@ public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_ReaderInput() throws IOException } @Test - public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_FileInput() { + void know_source_owner_not_org_unit_FileInput() { final List validate = validator.validate( getFile( "knowledgesource/KNOW_SOURCE_OWNER_NOT_ORG_UNIT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -85,7 +85,7 @@ public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_FileInput() { } @Test - public void testKNOW_SOURCE_OWNER_NOT_ORG_UNIT_DefinitionsInput() { + void know_source_owner_not_org_unit_DefinitionsInput() { final List validate = validator.validate( getDefinitions( "knowledgesource/KNOW_SOURCE_OWNER_NOT_ORG_UNIT.dmn", "https://github.com/kiegroup/kie-dmn", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorTest.java index d3668ecca91..4099be40e0e 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorTest.java @@ -31,8 +31,8 @@ import java.util.zip.ZipEntry; import org.drools.io.ClassPathResource; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.builder.Message.Level; import org.kie.api.io.Resource; import org.kie.dmn.api.core.DMNMessage; @@ -56,13 +56,13 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorTest extends AbstractValidatorTest { +class ValidatorTest extends AbstractValidatorTest { private static final Logger LOGGER = LoggerFactory.getLogger(ValidatorTest.class); @@ -70,7 +70,7 @@ public class ValidatorTest extends AbstractValidatorTest { static final DMNValidator.ValidatorBuilder validatorBuilder = validator.validateUsing(DMNValidator.Validation.VALIDATE_SCHEMA, DMNValidator.Validation.VALIDATE_MODEL); @Test - public void testDryRun() { + void dryRun() { DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "0001-input-data-string.dmn", DMNInputRuntimeTest.class ); DMNModel dmnModel = runtime.getModel( "https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string" ); assertThat(dmnModel).isNotNull(); @@ -82,7 +82,7 @@ public void testDryRun() { } @Test - public void testMACDInputDefinitions() { + void macdInputDefinitions() { DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "MACD-enhanced_iteration.dmn", DMNInputRuntimeTest.class ); DMNModel dmnModel = runtime.getModel( "http://www.trisotech.com/definitions/_6cfe7d88-6741-45d1-968c-b61a597d0964", "MACD-enhanced iteration" ); assertThat(dmnModel).isNotNull(); @@ -96,15 +96,15 @@ public void testMACDInputDefinitions() { } @Test - public void testMACDInputReader() throws IOException { + void macdInputReader() throws IOException { try (final Reader reader = new InputStreamReader(Objects.requireNonNull(getClass().getResourceAsStream("/org/kie/dmn/core/MACD-enhanced_iteration.dmn")))) { List messages = DMNValidatorFactory.newValidator().validate(reader, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(messages).withFailMessage(messages.toString()).hasSize(0); } } - + @Test - public void testInvalidXml() throws URISyntaxException { + void invalidXml() throws URISyntaxException { List validateXML = validator.validate( new File(this.getClass().getResource( "invalidXml.dmn" ).toURI()), DMNValidator.Validation.VALIDATE_SCHEMA); assertThat(validateXML).withFailMessage(ValidatorUtil.formatMessages(validateXML)).hasSize(1); assertThat(validateXML.get( 0 ).getMessageType()).withFailMessage(validateXML.get( 0 ).toString()).isEqualTo(DMNMessageType.FAILED_XML_VALIDATION); @@ -112,20 +112,20 @@ public void testInvalidXml() throws URISyntaxException { } @Test - public void testINVOCATION_MISSING_EXPR() { + void invocationMissingExpr() { List validate = validator.validate( getReader( "INVOCATION_MISSING_EXPR.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSizeGreaterThan(0); assertThat(validate.get(0).getMessageType()).withFailMessage(validate.get(0).toString()).isEqualTo(DMNMessageType.MISSING_EXPRESSION); } @Test - public void testNAME_IS_VALID() { + void nameIsValid() { List validate = validator.validate( getReader( "NAME_IS_VALID.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testNAME_INVALID_empty_name() { + void name_invalidEmptyName() { List validate = validator.validate( getReader( "DROOLS-1447.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(5); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.FAILED_XML_VALIDATION))).isTrue(); @@ -135,102 +135,103 @@ public void testNAME_INVALID_empty_name() { } @Test - public void testNAME_EMPTY_empty_model_name() { + void name_emptyEmptyModelName() { List validate = validator.validate( getReader( "EmptyModelName.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.INVALID_NAME) && p.getSourceId().equals("_f27bb64b-6fc7-4e1f-9848-11ba35e0df44"))).isTrue(); } - + @Test - public void testDRGELEM_NOT_UNIQUE() { + void drgelemNotUnique() { List validate = validator.validate( getReader( "DRGELEM_NOT_UNIQUE.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATE_NAME))).isTrue(); } - + @Test - public void testFORMAL_PARAM_DUPLICATED() { + void formalParamDuplicated() { List validate = validator.validate( getReader( "FORMAL_PARAM_DUPLICATED.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(3); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATED_PARAM))).isTrue(); } - + @Test - public void testINVOCATION_INCONSISTENT_PARAM_NAMES() { + void invocationInconsistentParamNames() { List validate = validator.validate( getReader( "INVOCATION_INCONSISTENT_PARAM_NAMES.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSizeGreaterThan(0); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - - @Test @Ignore( "Needs to be improved as invocations can be used to invoke functions node defined in BKMs. E.g., FEEL built in functions, etc.") - public void testINVOCATION_MISSING_TARGET() { + + @Test + @Disabled("Needs to be improved as invocations can be used to invoke functions node defined in BKMs. E.g., FEEL built in functions, etc.") + void invocationMissingTarget() { Definitions definitions = utilDefinitions( "INVOCATION_MISSING_TARGET.dmn" ); List validate = validator.validate(definitions); // assertTrue( validate.stream().anyMatch( p -> p.getMessageType().equals( DMNMessageType.INVOCATION_MISSING_TARGET ) ) ); } - - @Ignore("known current limitation") + + @Disabled("known current limitation") @Test - public void testINVOCATION_MISSING_TARGETRbis() { + void invocation_missing_targetRbis() { Definitions definitions = utilDefinitions( "INVOCATION_MISSING_TARGETbis.dmn"); List validate = validator.validate(definitions); // assertTrue( validate.stream().anyMatch( p -> p.getMessageType().equals( DMNMessageType.INVOCATION_MISSING_TARGET ) ) ); } - + @Test - public void testINVOCATION_WRONG_PARAM_COUNT() { + void invocationWrongParamCount() { List validate = validator.validate( getReader( "INVOCATION_WRONG_PARAM_COUNT.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSizeGreaterThan(0); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.PARAMETER_MISMATCH))).isTrue(); } - + @Test - public void testITEMCOMP_DUPLICATED() { + void itemcompDuplicated() { List validate = validator.validate( getReader( "ITEMCOMP_DUPLICATED.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATED_ITEM_DEF))).isTrue(); } - + @Test - public void testITEMDEF_NOT_UNIQUE() { + void itemdefNotUnique() { List validate = validator.validate( getReader( "ITEMDEF_NOT_UNIQUE.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(3); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATED_ITEM_DEF))).isTrue(); } - + @Test - public void testITEMDEF_NOT_UNIQUE_DROOLS_1450() { + void itemdefNotUniqueDrools1450() { // DROOLS-1450 List validate = validator.validate( getReader( "ITEMDEF_NOT_UNIQUE_DROOLS-1450.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(0); } - + @Test - public void testRELATION_DUP_COLUMN() { + void relationDupColumn() { List validate = validator.validate( getReader( "RELATION_DUP_COLUMN.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DUPLICATED_RELATION_COLUMN))).isTrue(); } - + @Test - public void testRELATION_ROW_CELL_NOTLITERAL() { + void relationRowCellNotliteral() { List validate = validator.validate( getReader( "RELATION_ROW_CELL_NOTLITERAL.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(2); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.RELATION_CELL_NOT_LITERAL))).isTrue(); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_EXPRESSION))).isTrue(); } - + @Test - public void testRELATION_ROW_CELLCOUNTMISMATCH() { + void relationRowCellcountmismatch() { List validate = validator.validate( getReader( "RELATION_ROW_CELLCOUNTMISMATCH.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.RELATION_CELL_COUNT_MISMATCH))).isTrue(); } @Test - public void testMortgageRecommender() { + void mortgageRecommender() { // This file has a gazillion errors. The goal of this test is simply check that the validator itself is not blowing up // and raising an exception. The errors in the file itself are irrelevant. List validate = validator.validate( getReader( "MortgageRecommender.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -238,14 +239,14 @@ public void testMortgageRecommender() { } @Test - public void testREQAUTH_NOT_KNOWLEDGESOURCEbis() { + void reqauth_not_knowledgesourcEbis() { // DROOLS-1435 List validate = validator.validate( getReader( "REQAUTH_NOT_KNOWLEDGESOURCEbis.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(1); } @Test - public void testVARIABLE_LEADING_TRAILING_SPACES() { + void variableLeadingTrailingSpaces() { List validate = validator.validate( getReader( "VARIABLE_LEADING_TRAILING_SPACES.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).isNotEmpty(); assertThat(validate).anySatisfy(p -> { @@ -257,9 +258,9 @@ public void testVARIABLE_LEADING_TRAILING_SPACES() { assertThat(p.getSourceId()).isEqualTo("_1f54fd51-6805-4280-b576-607450f85edd"); }); } - + @Test - public void testNAME_NOT_NORMALIZED() { + void nameNotNormalized() { List validate = validator.validate( getReader( "NAME_NOT_NORMALIZED.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).isNotEmpty(); assertThat(validate).anySatisfy(p -> { @@ -273,14 +274,14 @@ public void testNAME_NOT_NORMALIZED() { } @Test - public void testUNKNOWN_VARIABLE() { + void unknownVariable() { List validate = validator.validate( getReader( "UNKNOWN_VARIABLE.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(1); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.ERR_COMPILING_FEEL))).isTrue(); } @Test - public void testUNKNOWN_OPERATOR() { + void unknownOperator() { List validate = validator.validate( getReader( "UNKNOWN_OPERATOR.dmn" ), VALIDATE_SCHEMA, VALIDATE_MODEL, @@ -289,7 +290,7 @@ public void testUNKNOWN_OPERATOR() { } @Test - public void testVALIDATION() { + void validation() { List validate = validator.validate( getReader( "validation.dmn" ), VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(7); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.INVALID_NAME))).isTrue(); @@ -301,28 +302,28 @@ public void testVALIDATION() { } @Test - public void testUsingSemanticNamespacePrefix() { + void usingSemanticNamespacePrefix() { // DROOLS-2419 List validate = validator.validate(getReader("UsingSemanticNS.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testUsingSemanticNamespacePrefixAndExtensions() { + void usingSemanticNamespacePrefixAndExtensions() { // DROOLS-2447 List validate = validator.validate(getReader("Hello_World_semantic_namespace_with_extensions.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testNoPrefixAndExtensions() { + void noPrefixAndExtensions() { // DROOLS-2447 List validate = validator.validate(getReader("Hello_World_no_prefix_with_extensions.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testRelationwithemptycell() { + void relationwithemptycell() { // DROOLS-2439 DMNRuntime runtime = DMNRuntimeUtil.createRuntime("relation_with_empty_cell.dmn", DMNRuntimeTest.class); DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_99a00903-2943-47df-bab1-a32f276617ea", "Relation with empty cell"); @@ -336,21 +337,21 @@ public void testRelationwithemptycell() { } @Test - public void testRelationwithemptycellJustValidator() { + void relationwithemptycellJustValidator() { // DROOLS-2439 List validate = validator.validate(getReader("relation_with_empty_cell.dmn", DMNRuntimeTest.class), VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).withFailMessage(ValidatorUtil.formatMessages(validate)).hasSize(0); } @Test - public void testBoxedInvocationMissingExpression() { + void boxedInvocationMissingExpression() { // DROOLS-2813 DMN boxed invocation missing expression NPE and Validator issue List validate = validator.validate(getReader("DROOLS-2813-NPE-BoxedInvocationMissingExpression.dmn", DMNRuntimeTest.class), VALIDATE_MODEL); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_EXPRESSION) && p.getSourceId().equals("_a111c4df-c5b5-4d84-81e7-3ec735b50d06"))).isTrue(); } @Test - public void testDMNv1_2_ch11Modified() { + void dMNv12Ch11Modified() { // DROOLS-2832 List validate = validator.validate(getReader("v1_2/ch11MODIFIED.dmn", DMNRuntimeTest.class), VALIDATE_SCHEMA, @@ -360,7 +361,7 @@ public void testDMNv1_2_ch11Modified() { } @Test - public void testDMNv1_2_ch11() { + void dMNv12Ch11() { // DROOLS-2832 List validate = validator.validate(getReader("DMNv12_ch11.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL); @@ -373,7 +374,7 @@ public void testDMNv1_2_ch11() { } @Test - public void testDecisionServiceCompiler20180830() { + void decisionServiceCompiler20180830() { // DROOLS-2943 DMN DecisionServiceCompiler not correctly wired for DMNv1.2 format List validate = validator.validate(getReader("DecisionServiceABC.dmn", DMNDecisionServicesTest.class), VALIDATE_MODEL, @@ -382,7 +383,7 @@ public void testDecisionServiceCompiler20180830() { } @Test - public void testDecisionServiceCompiler20180830DMNV12() { + void decisionServiceCompiler20180830DMNV12() { // DROOLS-2943 DMN DecisionServiceCompiler not correctly wired for DMNv1.2 format List validate = validator.validate(getReader("DecisionServiceABC_DMN12.dmn", org.kie.dmn.core.v1_2.DMNDecisionServicesTest.class), VALIDATE_MODEL, @@ -394,7 +395,7 @@ public void testDecisionServiceCompiler20180830DMNV12() { } @Test - public void testDecisionService20181008() { + void decisionService20181008() { // DROOLS-3087 DMN Validation of DecisionService referencing a missing import List validate = validator.validateUsing(VALIDATE_MODEL, VALIDATE_COMPILATION) .theseModels(getReader("DSWithImport20181008-ModelA.dmn"), @@ -408,7 +409,7 @@ public void testDecisionService20181008() { } @Test - public void testInvalidFunctionNameInvocation() { + void invalidFunctionNameInvocation() { List validate = validator.validate(getReader("invalidFunctionNameInvocation.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -416,7 +417,7 @@ public void testInvalidFunctionNameInvocation() { } @Test - public void testDecisionNoExpr() { + void decisionNoExpr() { // DROOLS-4765 DMN validation rule alignment for missing expression List validate = validator.validate(getReader("noExpr.dmn", DMNRuntimeTest.class), VALIDATE_MODEL); // this test ensures the WARN for missing expr on the Decision node also applies when using static model validation rules (before compilation) @@ -427,7 +428,7 @@ public void testDecisionNoExpr() { } @Test - public void testValidateSchemaAndModels() { + void validateSchemaAndModels() { // DROOLS-4773 DMN Validator fluent builder schema & analysis using reader List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL) @@ -437,7 +438,7 @@ public void testValidateSchemaAndModels() { } @Test - public void testDMNv1_3_simple() { + void dMNv13Simple() { List validate = validator.validate(getReader("simple.dmn", DMN13specificTest.class), VALIDATE_SCHEMA, VALIDATE_MODEL, @@ -446,7 +447,7 @@ public void testDMNv1_3_simple() { } @Test - public void testDMNv1_3_ch11example1() { + void dMNv13Ch11example1() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) @@ -462,7 +463,7 @@ public void testDMNv1_3_ch11example1() { } @Test - public void testSomethingInBetweenOC() { + void somethingInBetweenOC() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) @@ -474,7 +475,7 @@ public void testSomethingInBetweenOC() { } @Test - public void testDMNv1_3_ch11example2() { + void dMNv13Ch11example2() { List validate = validator.validateUsing(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION) @@ -484,7 +485,7 @@ public void testDMNv1_3_ch11example2() { } @Test - public void test_dttyperef() { + void dttyperef() { List validate = validator.validate(getReader("wrongxml/dttyperef.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(1); DMNMessage v0 = validate.get(0); @@ -494,7 +495,7 @@ public void test_dttyperef() { } @Test - public void testBkmAndBindingWarnLevel() { + void bkmAndBindingWarnLevel() { // DROOLS-4875 DMN validation message alignment to DMN XSD constraint List validate = validator.validate(getReader("bkmAndBinding.dmn"), VALIDATE_SCHEMA, @@ -510,25 +511,25 @@ public void testBkmAndBindingWarnLevel() { } @Test - public void testInformationItemMissingTypeRef_SC() { + void informationItemMissingTypeRefSC() { // DROOLS-5152 DMN align message level for missing typeRef attribute checkInformationItemMissingTypeRef(VALIDATE_SCHEMA, VALIDATE_COMPILATION); } @Test - public void testInformationItemMissingTypeRef_SM() { + void informationItemMissingTypeRefSM() { // DROOLS-5152 DMN align message level for missing typeRef attribute checkInformationItemMissingTypeRef(VALIDATE_SCHEMA, VALIDATE_MODEL); } @Test - public void testInformationItemMissingTypeRef_SMC() { + void informationItemMissingTypeRefSMC() { // DROOLS-5152 DMN align message level for missing typeRef attribute checkInformationItemMissingTypeRef(VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); } @Test - public void validateAllValidSharedModels() throws IOException { + void validateAllValidSharedModels() throws IOException { String modelFilesPath = "valid_models/"; URL modelFilesJarURL = Collections.list(Thread.currentThread().getContextClassLoader().getResources( "valid_models/")) diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorTypeRefTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorTypeRefTest.java index 584625ccb64..eee694c0b44 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorTypeRefTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/ValidatorTypeRefTest.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -31,10 +31,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorTypeRefTest extends AbstractValidatorTest { +class ValidatorTypeRefTest extends AbstractValidatorTest { @Test - public void testTYPEREF_NO_FEEL_TYPE_ReaderInput() throws IOException { + void typeref_no_feel_type_ReaderInput() throws IOException { try (final Reader reader = getReader("typeref/TYPEREF_NO_FEEL_TYPE.dmn")) { final List validate = validator.validate( reader, @@ -45,7 +45,7 @@ public void testTYPEREF_NO_FEEL_TYPE_ReaderInput() throws IOException { } @Test - public void testTYPEREF_NO_FEEL_TYPE_FileInput() { + void typeref_no_feel_type_FileInput() { final List validate = validator.validate( getFile("typeref/TYPEREF_NO_FEEL_TYPE.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -54,7 +54,7 @@ public void testTYPEREF_NO_FEEL_TYPE_FileInput() { } @Test - public void testTYPEREF_NO_FEEL_TYPE_DefinitionsInput() { + void typeref_no_feel_type_DefinitionsInput() { final List validate = validator.validate( getDefinitions("typeref/TYPEREF_NO_FEEL_TYPE.dmn", "https://github.com/kiegroup/kie-dmn", "TYPEREF_NO_FEEL_TYPE"), VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -63,7 +63,7 @@ public void testTYPEREF_NO_FEEL_TYPE_DefinitionsInput() { } @Test - public void testTYPEREF_NO_NS_ReaderInput() throws IOException { + void typeref_no_ns_ReaderInput() throws IOException { try (final Reader reader = getReader("typeref/TYPEREF_NO_NS.dmn")) { final List validate = validator.validate( reader, @@ -74,7 +74,7 @@ public void testTYPEREF_NO_NS_ReaderInput() throws IOException { } @Test - public void testTYPEREF_NO_NS_FileInput() { + void typeref_no_ns_FileInput() { final List validate = validator.validate( getFile("typeref/TYPEREF_NO_NS.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -83,7 +83,7 @@ public void testTYPEREF_NO_NS_FileInput() { } @Test - public void testTYPEREF_NO_NS_DefinitionsInput() { + void typeref_no_ns_DefinitionsInput() { final List validate = validator.validate( getDefinitions("typeref/TYPEREF_NO_NS.dmn", "https://github.com/kiegroup/kie-dmn", "TYPEREF_NO_NS"), VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -92,7 +92,7 @@ public void testTYPEREF_NO_NS_DefinitionsInput() { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_ReaderInput() throws IOException { + void typeref_not_feel_not_def_ReaderInput() throws IOException { try (final Reader reader = getReader("typeref/TYPEREF_NOT_FEEL_NOT_DEF.dmn")) { final List validate = validator.validate( reader, @@ -104,7 +104,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_ReaderInput() throws IOException { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_FileInput() { + void typeref_not_feel_not_def_FileInput() { final List validate = validator.validate( getFile("typeref/TYPEREF_NOT_FEEL_NOT_DEF.dmn"), VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -114,7 +114,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_FileInput() { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_DefinitionsInput() { + void typeref_not_feel_not_def_DefinitionsInput() { final List validate = validator.validate( getDefinitions("typeref/TYPEREF_NOT_FEEL_NOT_DEF.dmn", "https://github.com/kiegroup/kie-dmn", "TYPEREF_NOT_FEEL_NOT_DEF"), VALIDATE_MODEL, VALIDATE_COMPILATION); @@ -124,7 +124,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_DefinitionsInput() { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_ResourceInput() throws IOException { + void typeref_not_feel_not_defValidResourceInput() throws IOException { // DROOLS-1433 // the assumption is that the following document TYPEREF_NOT_FEEL_NOT_DEF_valid.dmn should NOT contain any DMNMessageTypeId.TYPEREF_NOT_FEEL_NOT_DEF at all // the test also highlight typically in a DMN model many nodes would not define a typeRef, resulting in a large number of false negative @@ -137,7 +137,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_ResourceInput() throws IOExceptio } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_FileInput() { + void typeref_not_feel_not_defValidFileInput() { // DROOLS-1433 // the assumption is that the following document TYPEREF_NOT_FEEL_NOT_DEF_valid.dmn should NOT contain any DMNMessageTypeId.TYPEREF_NOT_FEEL_NOT_DEF at all // the test also highlight typically in a DMN model many nodes would not define a typeRef, resulting in a large number of false negative @@ -148,7 +148,7 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_FileInput() { } @Test - public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_DefinitionsInput() { + void typeref_not_feel_not_defValidDefinitionsInput() { // DROOLS-1433 // the assumption is that the following document TYPEREF_NOT_FEEL_NOT_DEF_valid.dmn should NOT contain any DMNMessageTypeId.TYPEREF_NOT_FEEL_NOT_DEF at all // the test also highlight typically in a DMN model many nodes would not define a typeRef, resulting in a large number of false negative @@ -157,9 +157,9 @@ public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_DefinitionsInput() { VALIDATE_MODEL, VALIDATE_COMPILATION); assertThat(validate).as(ValidatorUtil.formatMessages(validate)).hasSize(0); } - + @Test - public void testBKM_WITH_NO_TYPEREF_IS_OK_DefinitionsInput() { + void bkm_with_no_typeref_is_ok_DefinitionsInput() { // DROOLS-2631 final List validate = validator.validate( getDefinitions("typeref/BKM_WITH_NO_TYPEREF_IS_OK.dmn", "http://www.trisotech.com/dmn/definitions/_7e8d7561-657a-4729-b2a9-5a6279df6d5d", "Drawing 1"), diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/classloader/ValidatorClassloaderTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/classloader/ValidatorClassloaderTest.java index 3e5e25696e6..3ff5d97d546 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/classloader/ValidatorClassloaderTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/classloader/ValidatorClassloaderTest.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -47,12 +47,12 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA; -public class ValidatorClassloaderTest extends AbstractValidatorTest { +class ValidatorClassloaderTest extends AbstractValidatorTest { private static final Logger LOG = LoggerFactory.getLogger(ValidatorClassloaderTest.class); @Test - public void test() { + void test() { String JAVA_SOURCE = "package com.acme.functions;\n" + "public class Dummy {\n" + " public static String hello() {\n" + diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AK0100domainOnTableTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AK0100domainOnTableTest.java index 8e5515dd1ef..6f8c018a14e 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AK0100domainOnTableTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AK0100domainOnTableTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -34,10 +34,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class AK0100domainOnTableTest extends AbstractDTAnalysisTest { +class AK0100domainOnTableTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("AK0100-domainOnTable.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_e9e5c68a-ebc3-4f09-a107-2049edbe554d"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AK0100v2domainOnTableTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AK0100v2domainOnTableTest.java index c7773579247..869c5f6137f 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AK0100v2domainOnTableTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AK0100v2domainOnTableTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -34,10 +34,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class AK0100v2domainOnTableTest extends AbstractDTAnalysisTest { +class AK0100v2domainOnTableTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("AK0100v2-domainOnTable.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_e9e5c68a-ebc3-4f09-a107-2049edbe554d"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AgeKittenTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AgeKittenTest.java index baa814b6d8a..db4fe63b1f5 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AgeKittenTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/AgeKittenTest.java @@ -24,7 +24,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -36,22 +36,22 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class AgeKittenTest extends AbstractDTAnalysisTest { +class AgeKittenTest extends AbstractDTAnalysisTest { @Test - public void test_AgeKitten_domainOnTable() { + void age_kitten_domain_on_table() { List validate = validator.validate(getReader("AgeKitten-domainOnTable.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkAnalysis(validate); } @Test - public void test_AgeKitten() { + void age_kitten() { List validate = validator.validate(getReader("AgeKitten.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkAnalysis(validate); } @Test - public void test_AgeKittenImport() throws IOException { + void age_kitten_import() throws IOException { try (final Reader reader0 = getReader("AgeKittenItemDef.dmn"); final Reader reader1 = getReader("AgeKittenImporting.dmn");) { final List validate = validator.validateUsing(VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE) diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/BuiltinAndOtherValuesTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/BuiltinAndOtherValuesTest.java index e858328739c..02288099a6e 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/BuiltinAndOtherValuesTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/BuiltinAndOtherValuesTest.java @@ -23,7 +23,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.lang.types.impl.ComparablePeriod; import org.kie.dmn.feel.runtime.Range.RangeBoundary; @@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class BuiltinAndOtherValuesTest extends AbstractDTAnalysisTest { +class BuiltinAndOtherValuesTest extends AbstractDTAnalysisTest { @Test - public void testComplexDTdates() { + void complexDTdates() { List validate = validator.validate(getReader("complexDTdates.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_a8a4362e-9f2d-4051-9bd6-e7356244f6b7"); @@ -47,7 +47,7 @@ public void testComplexDTdates() { } @Test - public void testComplexDTdatesV2() { + void complexDTdatesV2() { List validate = validator.validate(getReader("complexDTdatesV2.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_a8a4362e-9f2d-4051-9bd6-e7356244f6b7"); @@ -94,7 +94,7 @@ private void checkComplexDTDates(DTAnalysis analysis) { } @Test - public void testWeirdPosNeg() { + void weirdPosNeg() { List validate = validator.validate(getReader("weirdPosNeg.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_54ae95be-6866-4dc1-8c10-1c5a4dd15c93"); @@ -117,7 +117,7 @@ public void testWeirdPosNeg() { } @Test - public void testWeirdYMduration() { + void weirdYMduration() { List validate = validator.validate(getReader("weirdYMduration.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_fe7d267b-d770-461e-8300-e09981147341"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Check1stNFViolationTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Check1stNFViolationTest.java index a14e3cfac09..b2fee1eeff3 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Check1stNFViolationTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Check1stNFViolationTest.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.Message.Level; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class Check1stNFViolationTest extends AbstractDTAnalysisTest { +class Check1stNFViolationTest extends AbstractDTAnalysisTest { @Test - public void testCheck1stNFViolation() { + void check1stNFViolation() { List validate = validator.validate(getReader("DT1stNFViolation.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysisDuplicate = getAnalysis(validate, "_053034d5-0e1f-4c4a-8513-ab3c6ba538db"); @@ -53,7 +53,7 @@ public void testCheck1stNFViolation() { } @Test - public void testCheck1stNFViolationB() { + void check1stNFViolationB() { List validate = validator.validate(getReader("DT1stNFViolationB.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysisDuplicate = getAnalysis(validate, "_053034d5-0e1f-4c4a-8513-ab3c6ba538db"); @@ -64,7 +64,7 @@ public void testCheck1stNFViolationB() { } @Test - public void testCheck1stNFViolationDuplicateNoSubsumption() { + void check1stNFViolationDuplicateNoSubsumption() { List validate = validator.validate(getReader("DT1stNFViolationDuplicateNoSubsumption.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_221BF4A4-F8D4-466C-96E4-311FE3C9867B"); @@ -77,7 +77,7 @@ public void testCheck1stNFViolationDuplicateNoSubsumption() { } @Test - public void testCheck1stNFViolationCollect() { + void check1stNFViolationCollect() { List validate = validator.validate(getReader("DT1stNFViolationCollect.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysisDuplicate = getAnalysis(validate, "_4237d55b-2589-48a5-8183-f9f4e0e00c07"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Check2ndNFViolationTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Check2ndNFViolationTest.java index d45a5a1c3fd..a3380f205c7 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Check2ndNFViolationTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Check2ndNFViolationTest.java @@ -20,7 +20,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.dtanalysis.model.Contraction; @@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class Check2ndNFViolationTest extends AbstractDTAnalysisTest { +class Check2ndNFViolationTest extends AbstractDTAnalysisTest { @Test - public void testCheck2ndNFViolation() { + void check2ndNFViolation() { List validate = validator.validate(getReader("DT2ndNFViolation.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_4e358bae-7012-42dd-acea-e88b3aa3c8b2"); @@ -47,7 +47,7 @@ public void testCheck2ndNFViolation() { } @Test - public void testCheck2ndNFViolation3combo() { + void check2ndNFViolation3combo() { List validate = validator.validate(getReader("DT2ndNF3combo.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_BA703D04-803A-44AA-8A31-F5EEDD4FD54E"); @@ -56,7 +56,7 @@ public void testCheck2ndNFViolation3combo() { } @Test - public void testCheck2ndNFViolationWasADash() { + void check2ndNFViolationWasADash() { List validate = validator.validate(getReader("DT2ndNFWasADash.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_C40525EF-9735-410B-A070-E0336E108268"); @@ -65,7 +65,7 @@ public void testCheck2ndNFViolationWasADash() { } @Test - public void testCheck2ndNFViolationWasADash2() { + void check2ndNFViolationWasADash2() { List validate = validator.validate(getReader("DT2ndNFWasADash2.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_D3F1D5B8-642B-446D-9099-DE4CB978CB94"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/ContractionRulesTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/ContractionRulesTest.java index e5a8b62460a..56d584639aa 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/ContractionRulesTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/ContractionRulesTest.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.feel.runtime.Range.RangeBoundary; @@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class ContractionRulesTest extends AbstractDTAnalysisTest { +class ContractionRulesTest extends AbstractDTAnalysisTest { @Test - public void testContractionRules() { + void contractionRules() { List validate = validator.validate(getReader("Contraction.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_01d9abb9-b968-49c0-b6ab-909f3e03d8d3"); assertThat(analysis.getGaps()).hasSize(0); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalyserValueFromNodeVisitorTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalyserValueFromNodeVisitorTest.java index a527403ef99..40698a1cbf6 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalyserValueFromNodeVisitorTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalyserValueFromNodeVisitorTest.java @@ -20,13 +20,13 @@ import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.lang.ast.FunctionInvocationNode; import org.kie.dmn.feel.lang.impl.FEELImpl; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -public class DMNDTAnalyserValueFromNodeVisitorTest { +class DMNDTAnalyserValueFromNodeVisitorTest { private final FEELImpl tFEEL = (FEELImpl) org.kie.dmn.feel.FEEL.newInstance(); @@ -34,7 +34,7 @@ public class DMNDTAnalyserValueFromNodeVisitorTest { * None of these are valid FEEL expression ootb and cannot be used to determine discrete value in the domain */ @Test - public void smokeTest() { + void smokeTest() { DMNDTAnalyserValueFromNodeVisitor ut = new DMNDTAnalyserValueFromNodeVisitor(Collections.emptyList()); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> ut.visit(compile("date()"))); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> ut.visit(compile("date and time()"))); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalysisExceptionTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalysisExceptionTest.java index 9b3d056e583..69acbdab8b5 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalysisExceptionTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalysisExceptionTest.java @@ -18,16 +18,16 @@ */ package org.kie.dmn.validation.dtanalysis; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.model.api.DecisionTable; import org.kie.dmn.model.v1_3.TDecisionTable; import static org.assertj.core.api.Assertions.assertThat; -public class DMNDTAnalysisExceptionTest { +class DMNDTAnalysisExceptionTest { @Test - public void smokeTest() { + void smokeTest() { DecisionTable dtRef = new TDecisionTable(); DMNDTAnalysisException ut = new DMNDTAnalysisException("smoke test", dtRef); assertThat(ut.getDt()).isEqualTo(dtRef); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DTNestingTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DTNestingTest.java index 3469d91c330..d2b90a66aba 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DTNestingTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DTNestingTest.java @@ -19,10 +19,9 @@ package org.kie.dmn.validation.dtanalysis; import java.math.BigDecimal; -import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -33,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class DTNestingTest extends AbstractDTAnalysisTest { +class DTNestingTest extends AbstractDTAnalysisTest { @Test - public void testDTnestedEverywhere() { + void dTnestedEverywhere() { List validate = validator.validate(getReader("DTnestedEverywhere.dmn"), ANALYZE_DECISION_TABLE); checkPositiveTableNestedInSubcontextOfDecision(validate); checkNegativeTableInBKM(validate); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DTinBKMTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DTinBKMTest.java index 798553ebab0..7419b054089 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DTinBKMTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/DTinBKMTest.java @@ -20,7 +20,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.dtanalysis.model.DTAnalysis; @@ -28,9 +28,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class DTinBKMTest extends AbstractDTAnalysisTest { +class DTinBKMTest extends AbstractDTAnalysisTest { @Test - public void testDTnestedEverywhere() { + void dTnestedEverywhere() { List validate = validator.validate(getReader("dtInBKM.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_860A5A56-0C43-4B42-B1DB-7415984E5624"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/EnumerationWithNullTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/EnumerationWithNullTest.java index 701e6c67740..842ed676d6c 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/EnumerationWithNullTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/EnumerationWithNullTest.java @@ -18,10 +18,9 @@ */ package org.kie.dmn.validation.dtanalysis; -import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -32,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class EnumerationWithNullTest extends AbstractDTAnalysisTest { +class EnumerationWithNullTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("EnumerationWithNull.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_5ef1ff81-621d-4c9a-9881-0aaf865758cb"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/FailingOutputConstraintsTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/FailingOutputConstraintsTest.java index 0f3e2feeda8..57cddd549ab 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/FailingOutputConstraintsTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/FailingOutputConstraintsTest.java @@ -20,7 +20,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.dtanalysis.model.DTAnalysis; @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class FailingOutputConstraintsTest extends AbstractDTAnalysisTest { +class FailingOutputConstraintsTest extends AbstractDTAnalysisTest { @Test - public void testFailingOutputConstraints() { + void failingOutputConstraints() { List validate = validator.validate(getReader("FailingOutputConstraints.dmn"), ANALYZE_DECISION_TABLE); assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR))).as("It should contain DMNMessage for output outside of LoV").isTrue(); debugValidatorMsg(validate); @@ -41,9 +41,9 @@ public void testFailingOutputConstraints() { assertThat(analysis.getGaps()).hasSize(1); assertThat(analysis.getOverlaps()).hasSize(0); } - + @Test - public void testFailingOutputConstraintsWhenOutputIsSymbol() { + void failingOutputConstraintsWhenOutputIsSymbol() { List validate = validator.validate(getReader("FailingOutputConstraints2.dmn"), ANALYZE_DECISION_TABLE); debugValidatorMsg(validate); assertThat(validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR))).as("It should NOT contain DMNMessage for output outside of LoV (using a symbol in output)").isTrue(); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Gaps0100domainOnTableTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Gaps0100domainOnTableTest.java index 9ff3fa4777b..44f0818d1fa 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Gaps0100domainOnTableTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/Gaps0100domainOnTableTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -34,10 +34,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class Gaps0100domainOnTableTest extends AbstractDTAnalysisTest { +class Gaps0100domainOnTableTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("Gaps0100-domainOnTable.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_70a95e62-8f5b-4b75-8cb9-9a9f781077da"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsAndOverlaps1Test.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsAndOverlaps1Test.java index 6c9d15aac09..6aeafbad3cf 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsAndOverlaps1Test.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsAndOverlaps1Test.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -35,10 +35,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class GapsAndOverlaps1Test extends AbstractDTAnalysisTest { +class GapsAndOverlaps1Test extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("GapsAndOverlaps1.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_cd2e0a28-3cc2-456b-90b6-392d9c3574af"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsAndOverlaps1domainOnTableTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsAndOverlaps1domainOnTableTest.java index 7908a88a049..14b6bc8dec9 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsAndOverlaps1domainOnTableTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsAndOverlaps1domainOnTableTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -35,10 +35,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class GapsAndOverlaps1domainOnTableTest extends AbstractDTAnalysisTest { +class GapsAndOverlaps1domainOnTableTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("GapsAndOverlaps1-domainOnTable.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_cd2e0a28-3cc2-456b-90b6-392d9c3574af"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsCube3Test.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsCube3Test.java index 85e2eed48ae..faa55b4e369 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsCube3Test.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsCube3Test.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -34,10 +34,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class GapsCube3Test extends AbstractDTAnalysisTest { +class GapsCube3Test extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("GapsCube3.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_4b41743d-ff04-4855-bf0b-993d475a9d62"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsOverlapsBooleanTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsOverlapsBooleanTest.java index 79ff3ce0e25..f2a71efa299 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsOverlapsBooleanTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsOverlapsBooleanTest.java @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -34,10 +34,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class GapsOverlapsBooleanTest extends AbstractDTAnalysisTest { +class GapsOverlapsBooleanTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("GapsOverlapsBoolean.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_EE34FD37-00D1-47A7-B2F6-CC9BCEF30005"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsXYTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsXYTest.java index 3fc440004e4..e146fde19f1 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsXYTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/GapsXYTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -37,21 +37,21 @@ public class GapsXYTest extends AbstractDTAnalysisTest { @Test - public void test_GapsXY() { + void gaps_xy() { List validate = validator.validate(getReader("GapsXY.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkAnalysis(validate); } - + @Test - public void test_GapsXY_usingResource() { + void gaps_xy_using_resource() { List validate = validator.validate(getResource("GapsXY.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkAnalysis(validate); LOG.debug("{}", validate); assertThat(validate).allMatch(m -> m.getPath().endsWith("GapsXY.dmn")); } - + @Test - public void test_GapsXY_usingBuilderWithResource() { + void gaps_xy_using_builder_with_resource() { List validate = validator.validateUsing(VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE).theseModels(getResource("GapsXY.dmn")); checkAnalysis(validate); LOG.debug("{}", validate); @@ -59,7 +59,7 @@ public void test_GapsXY_usingBuilderWithResource() { } @Test - public void test_GapsXYv2() { + void gaps_xyv2() { List validate = validator.validate(getReader("GapsXYv2.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkAnalysis(validate); } diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/HitPolicyFirstTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/HitPolicyFirstTest.java index 00517f5a7c1..8995a73c211 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/HitPolicyFirstTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/HitPolicyFirstTest.java @@ -20,7 +20,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.dtanalysis.model.DTAnalysis; @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class HitPolicyFirstTest extends AbstractDTAnalysisTest { +class HitPolicyFirstTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("DTAnalysisFirst.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_38EB6C20-6DF4-4EA0-A421-206B9F31AF22"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/IntervalTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/IntervalTest.java index 12cc0ea1ad5..e865fd0b289 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/IntervalTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/IntervalTest.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; import org.kie.dmn.validation.dtanalysis.model.Domain; @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class IntervalTest { +class IntervalTest { @Test - public void testFlatten() { + void flatten() { Interval a = new Interval(RangeBoundary.CLOSED, 0, 3, RangeBoundary.OPEN, 0, 0); Interval b = new Interval(RangeBoundary.CLOSED, 1, 2, RangeBoundary.CLOSED, 0, 0); Interval c = new Interval(RangeBoundary.CLOSED, 3, 4, RangeBoundary.CLOSED, 0, 0); @@ -44,7 +44,7 @@ public void testFlatten() { } @Test - public void testFlatten2() { + void flatten2() { Interval a = new Interval(RangeBoundary.CLOSED, 0, 3, RangeBoundary.OPEN, 0, 0); Interval b = new Interval(RangeBoundary.CLOSED, 1, 2, RangeBoundary.CLOSED, 0, 0); Interval c = new Interval(RangeBoundary.OPEN, 3, 4, RangeBoundary.CLOSED, 0, 0); @@ -55,7 +55,7 @@ public void testFlatten2() { } @Test - public void testFlatten3() { + void flatten3() { Interval a = new Interval(RangeBoundary.CLOSED, 0, 3, RangeBoundary.CLOSED, 0, 0); Interval b = new Interval(RangeBoundary.CLOSED, 1, 2, RangeBoundary.CLOSED, 0, 0); Interval c = new Interval(RangeBoundary.CLOSED, 3, 4, RangeBoundary.CLOSED, 0, 0); @@ -65,7 +65,7 @@ public void testFlatten3() { } @Test - public void testInvertOverDomain() { + void invertOverDomain() { Interval a = new Interval(RangeBoundary.CLOSED, 0, 3, RangeBoundary.OPEN, 1, 2); Interval domain = new Interval(RangeBoundary.CLOSED, Interval.NEG_INF, Interval.POS_INF, RangeBoundary.CLOSED, 0, 0); @@ -76,7 +76,7 @@ public void testInvertOverDomain() { } @Test - public void testInvertOverDomain2() { + void invertOverDomain2() { Interval a = new Interval(RangeBoundary.CLOSED, "i", "o", RangeBoundary.OPEN, 9, 8); Interval domain = new Interval(RangeBoundary.CLOSED, "a", "u", RangeBoundary.CLOSED, 0, 0); @@ -85,9 +85,9 @@ public void testInvertOverDomain2() { assertInterval(result.get(0), RangeBoundary.CLOSED, "a", "i", RangeBoundary.OPEN, 9, 8); assertInterval(result.get(1), RangeBoundary.CLOSED, "o", "u", RangeBoundary.CLOSED, 9, 8); } - + @Test - public void testInvertOverDomainList1() { + void invertOverDomainList1() { Interval i0 = new Interval(RangeBoundary.CLOSED, "a", "a", RangeBoundary.CLOSED, 9, 8); Interval i1 = new Interval(RangeBoundary.CLOSED, "e", "e", RangeBoundary.CLOSED, 9, 8); Interval domain = new Interval(RangeBoundary.CLOSED, Interval.NEG_INF, Interval.POS_INF, RangeBoundary.CLOSED, 0, 0); @@ -98,9 +98,9 @@ public void testInvertOverDomainList1() { assertInterval(result.get(1), RangeBoundary.OPEN, "a", "e", RangeBoundary.OPEN, 9, 8); assertInterval(result.get(2), RangeBoundary.OPEN, "e", Interval.POS_INF, RangeBoundary.CLOSED, 9, 8); } - + @Test - public void testInvertOverDomainList2() { + void invertOverDomainList2() { Interval i0 = new Interval(RangeBoundary.CLOSED, "a", "e", RangeBoundary.OPEN, 9, 8); Interval i1 = new Interval(RangeBoundary.CLOSED, "e", "i", RangeBoundary.CLOSED, 9, 8); Interval domain = new Interval(RangeBoundary.CLOSED, Interval.NEG_INF, Interval.POS_INF, RangeBoundary.CLOSED, 0, 0); @@ -110,9 +110,9 @@ public void testInvertOverDomainList2() { assertInterval(result.get(0), RangeBoundary.CLOSED, Interval.NEG_INF, "a", RangeBoundary.OPEN, 9, 8); assertInterval(result.get(1), RangeBoundary.OPEN, "i", Interval.POS_INF, RangeBoundary.CLOSED, 9, 8); } - + @Test - public void testInvertOverDomainList3() { + void invertOverDomainList3() { Interval i0 = new Interval(RangeBoundary.CLOSED, "a", "e", RangeBoundary.OPEN, 9, 8); Interval i1 = new Interval(RangeBoundary.OPEN, "e", "i", RangeBoundary.CLOSED, 9, 8); Interval domain = new Interval(RangeBoundary.CLOSED, Interval.NEG_INF, Interval.POS_INF, RangeBoundary.CLOSED, 0, 0); @@ -123,9 +123,9 @@ public void testInvertOverDomainList3() { assertInterval(result.get(1), RangeBoundary.CLOSED, "e", "e", RangeBoundary.CLOSED, 9, 8); assertInterval(result.get(2), RangeBoundary.OPEN, "i", Interval.POS_INF, RangeBoundary.CLOSED, 9, 8); } - + @Test - public void testInvertOverDomainList4() { + void invertOverDomainList4() { Interval i0 = new Interval(RangeBoundary.CLOSED, "a", "a", RangeBoundary.CLOSED, 9, 8); Interval i1 = new Interval(RangeBoundary.CLOSED, "e", "e", RangeBoundary.CLOSED, 9, 8); Interval i2 = new Interval(RangeBoundary.CLOSED, "i", "i", RangeBoundary.CLOSED, 9, 8); @@ -183,7 +183,7 @@ public boolean isDiscreteDomain() { } @Test - public void testHumanFriendlyContinuous() { + void humanFriendlyContinuous() { Interval domainInterval = new Interval(RangeBoundary.CLOSED, 0, 100, RangeBoundary.CLOSED, 0, 0); DummyDomain domain = new DummyDomain(domainInterval, Collections.emptyList()); @@ -195,18 +195,18 @@ public void testHumanFriendlyContinuous() { assertThat(new Interval(RangeBoundary.CLOSED, 0, 99, RangeBoundary.OPEN , 0, 0).asHumanFriendly(domain)).startsWith("<"); assertThat(new Interval(RangeBoundary.CLOSED, 0, 99, RangeBoundary.OPEN , 0, 0).asHumanFriendly(domain)).doesNotStartWith("<="); } - + @Test - public void testFlatten4() { + void flatten4() { Interval a = new Interval(RangeBoundary.CLOSED, LocalDate.parse("2021-01-01"), LocalDate.parse("2021-03-31"), RangeBoundary.CLOSED, 0, 0); Interval b = new Interval(RangeBoundary.CLOSED, LocalDate.parse("2021-04-01"), LocalDate.parse("2021-04-30"), RangeBoundary.CLOSED, 0, 0); List result = Interval.flatten(Arrays.asList(b, a)); assertThat(result).containsExactly(new Interval(RangeBoundary.CLOSED, LocalDate.parse("2021-01-01"), LocalDate.parse("2021-04-30"), RangeBoundary.CLOSED, 0, 0)); } - + @Test - public void testNoFlatten() { + void noFlatten() { Interval a = new Interval(RangeBoundary.CLOSED, LocalDate.parse("2021-01-01"), LocalDate.parse("2021-03-31"), RangeBoundary.CLOSED, 0, 0); Interval b = new Interval(RangeBoundary.OPEN, LocalDate.parse("2021-04-01"), LocalDate.parse("2021-04-30"), RangeBoundary.CLOSED, 0, 0); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MaskTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MaskTest.java index f0c4d7ee9e0..3a606928dda 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MaskTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MaskTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.feel.runtime.Range.RangeBoundary; @@ -37,10 +37,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class MaskTest extends AbstractDTAnalysisTest { +class MaskTest extends AbstractDTAnalysisTest { @Test - public void test_MaskBasic() { + void mask_basic() { List validate = validator.validate(getReader("MaskBasic.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_BA703D04-803A-44AA-8A31-F5EEDD4FD54E"); assertThat(analysis.getGaps()).hasSize(0); @@ -70,7 +70,7 @@ public void test_MaskBasic() { } @Test - public void test_MaskTest() { + void mask_test() { List validate = validator.validate(getReader("MaskTest.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_BA703D04-803A-44AA-8A31-F5EEDD4FD54E"); assertThat(analysis.getGaps()).hasSize(0); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MisleadingRulesTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MisleadingRulesTest.java index fff41fe4fdf..5f410053096 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MisleadingRulesTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MisleadingRulesTest.java @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.feel.runtime.Range.RangeBoundary; @@ -36,10 +36,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class MisleadingRulesTest extends AbstractDTAnalysisTest { +class MisleadingRulesTest extends AbstractDTAnalysisTest { @Test - public void testMisleadingRules() { + void misleadingRules() { List validate = validator.validate(getReader("MisleadingRules.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_BA703D04-803A-44AA-8A31-F5EEDD4FD54E"); assertThat(analysis.getGaps()).hasSize(0); @@ -75,7 +75,7 @@ public void testMisleadingRules() { } @Test - public void testMisleadingRules2() { + void misleadingRules2() { List validate = validator.validate(getReader("MisleadingRules2.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_0cffdf05-071b-423b-94b9-182c2cc2435c"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MultipleModelsTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MultipleModelsTest.java index 3c213842f50..ddcd2ab0d5e 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MultipleModelsTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/MultipleModelsTest.java @@ -20,10 +20,9 @@ import java.io.IOException; import java.io.Reader; -import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.DMNValidator.Validation; @@ -34,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class MultipleModelsTest extends AbstractDTAnalysisTest { +class MultipleModelsTest extends AbstractDTAnalysisTest { @Test - public void testMultipleFromReaderInput() throws IOException { + void multipleFromReaderInput() throws IOException { try (final Reader reader0 = getReader("MyDecisionTable.dmn"); final Reader reader1 = getReader("tVowelDefinition.dmn");) { final List messages = validator.validateUsing(Validation.ANALYZE_DECISION_TABLE) @@ -47,7 +46,7 @@ public void testMultipleFromReaderInput() throws IOException { } @Test - public void testMultipleFromFileInput() { + void multipleFromFileInput() { final List messages = validator.validateUsing(Validation.ANALYZE_DECISION_TABLE) .theseModels(getFile("MyDecisionTable.dmn"), getFile("tVowelDefinition.dmn")); @@ -55,7 +54,7 @@ public void testMultipleFromFileInput() { } @Test - public void testMultipleFromDefinitionsInput() throws IOException { + void multipleFromDefinitionsInput() throws IOException { final List messages = validator.validateUsing(Validation.ANALYZE_DECISION_TABLE) .theseModels(getDefinitions("MyDecisionTable.dmn", "http://www.trisotech.com/definitions/_6b77f7ac-d61a-4fb0-9e24-7ebf04444f59", diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NoGapsDateAdjacentTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NoGapsDateAdjacentTest.java index 08faad7d03d..8de6c01714b 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NoGapsDateAdjacentTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NoGapsDateAdjacentTest.java @@ -20,17 +20,17 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.validation.dtanalysis.model.DTAnalysis; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class NoGapsDateAdjacentTest extends AbstractDTAnalysisTest { +class NoGapsDateAdjacentTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("NoGapsDateAdjacent.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_322732ef-01be-40fb-abd7-ec599c2efa47"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NoGapsDomainOnTypeRefTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NoGapsDomainOnTypeRefTest.java index fec6d150256..55cf1e6235f 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NoGapsDomainOnTypeRefTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NoGapsDomainOnTypeRefTest.java @@ -20,24 +20,24 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.validation.dtanalysis.model.DTAnalysis; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class NoGapsDomainOnTypeRefTest extends AbstractDTAnalysisTest { +class NoGapsDomainOnTypeRefTest extends AbstractDTAnalysisTest { @Test - public void test_NoGapsDomainOnTypeRef() { + void no_gaps_domain_on_type_ref() { List validate = validator.validate(getReader("NoGapsDomainOnTypeRef.dmn"), ANALYZE_DECISION_TABLE); checkAnalysis(validate); } @Test - public void test_NoGapsDomainOnTypeRefv2() { + void no_gaps_domain_on_type_refv2() { List validate = validator.validate(getReader("NoGapsDomainOnTypeRefv2.dmn"), ANALYZE_DECISION_TABLE); checkAnalysis(validate); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NotTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NotTest.java index 15129996b43..ce4c0b36e54 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NotTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NotTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class NotTest extends AbstractDTAnalysisTest { +class NotTest extends AbstractDTAnalysisTest { @Test - public void testNOTString() { + void notString() { List validate = validator.validate(getReader("DTusingNOT.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_b53fac34-fb12-4601-8605-c226e68292f9"); @@ -76,7 +76,7 @@ public void testNOTString() { } @Test - public void testNOTString2() { + void notString2() { List validate = validator.validate(getReader("DTusingNOT2.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_b53fac34-fb12-4601-8605-c226e68292f9"); @@ -99,9 +99,9 @@ public void testNOTString2() { assertThat(analysis.getOverlaps()).hasSize(0); } - + @Test - public void testNotStringVowel() { + void notStringVowel() { List validate = validator.validate(getReader("NotStringVowel.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_406133D7-96FE-4237-8726-44D839F400D6"); @@ -111,9 +111,9 @@ public void testNotStringVowel() { // assert OVERLAPs count. assertThat(analysis.getOverlaps()).hasSize(0); } - + @Test - public void testNotStringVowel2() { + void notStringVowel2() { List validate = validator.validate(getReader("NotStringVowel2.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_406133D7-96FE-4237-8726-44D839F400D6"); @@ -128,7 +128,7 @@ public void testNotStringVowel2() { } @Test - public void testNOTnumber() { + void nOTnumber() { List validate = validator.validate(getReader("DTusingNOTnumber.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_d0cbacca-55d4-47dd-acc6-131add2a8a53"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NullTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NullTest.java index 90d27efa3b5..31fbf737b97 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NullTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/NullTest.java @@ -18,7 +18,10 @@ */ package org.kie.dmn.validation.dtanalysis; -import org.junit.Test; +import java.math.BigDecimal; +import java.util.List; + +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -26,25 +29,21 @@ import org.kie.dmn.validation.dtanalysis.model.Hyperrectangle; import org.kie.dmn.validation.dtanalysis.model.Interval; -import java.math.BigDecimal; -import java.util.Arrays; -import java.util.List; - import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; -public class NullTest extends AbstractDTAnalysisTest { +class NullTest extends AbstractDTAnalysisTest { @Test - public void testNullBooleanBefore() { + void nullBooleanBefore() { List validate = validator.validate(getReader("NullBooleanBefore.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkNullBoolean(validate); } @Test - public void testNullBooleanAfter() { + void nullBooleanAfter() { List validate = validator.validate(getReader("NullBooleanAfter.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkNullBoolean(validate); } @@ -72,13 +71,13 @@ private void checkNullBoolean(List validate) { } @Test - public void testNullNumberBefore() { + void nullNumberBefore() { List validate = validator.validate(getReader("NullNumberBefore.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkNullNumber(validate); } @Test - public void testNullNumberAfter() { + void nullNumberAfter() { List validate = validator.validate(getReader("NullNumberAfter.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkNullNumber(validate); } @@ -106,13 +105,13 @@ private void checkNullNumber(List validate) { } @Test - public void testGapsXYv2WithNull() { + void gapsXYv2WithNull() { List validate = validator.validate(getReader("GapsXYv2WithNull.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); GapsXYTest.checkAnalysis(validate); } @Test - public void testNotNullAndEmptyRule() { + void notNullAndEmptyRule() { final List validate = validator.validate(getReader("notnulltest.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); final DTAnalysis analysis = getAnalysis(validate, "_850C5F03-DA51-4DE7-89E4-61D2C502A03E"); assertThat(analysis.getOverlaps()).hasSize(1); @@ -126,7 +125,7 @@ public void testNotNullAndEmptyRule() { } @Test - public void testNullsWithActiveRules() { + void nullsWithActiveRules() { final List validate = validator.validate(getReader("nulltestdt.dmn"), VALIDATE_MODEL, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); final DTAnalysis analysis = getAnalysis(validate, "decisiontablewithnulls"); assertThat(analysis.getOverlaps()).isEmpty(); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/OverlapHitPolicyTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/OverlapHitPolicyTest.java index 9aba69a94b1..3c82994e70b 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/OverlapHitPolicyTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/OverlapHitPolicyTest.java @@ -24,9 +24,8 @@ import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.feel.runtime.Range.RangeBoundary; @@ -44,20 +43,18 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -@RunWith(Parameterized.class) public class OverlapHitPolicyTest extends AbstractDTAnalysisTest { - - @Parameterized.Parameter() public HitPolicy hp; - @Parameterized.Parameters(name = "using {0}") public static Collection data() { // Overlaps are not checked for COLLECT hit policy return Arrays.asList(HitPolicy.values()).stream().filter(hp-> hp!= HitPolicy.COLLECT).collect(Collectors.toList()); } - @Test - public void testOverlapHitPolicy() { + @MethodSource("data") + @ParameterizedTest(name = "using {0}") + public void overlapHitPolicy(HitPolicy hp) { + initOverlapHitPolicyTest(hp); Definitions definitions = getDefinitions("OverlapHitPolicy.dmn", "https://github.com/kiegroup/drools/kie-dmn/_3010653A-DD3F-4C88-89DA-3FDD845F6604", "OverlapHitPolicy"); // mutates XML file in the Hit Policy, accordingly to this test parameter. @@ -102,4 +99,8 @@ private void checkAnalysis(List validate) { assertThat(analysis.getOverlaps()).containsAll(overlaps); } + public void initOverlapHitPolicyTest(HitPolicy hp) { + this.hp = hp; + } + } diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/OverlapsMsgTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/OverlapsMsgTest.java index 206980f7504..d6692f3a602 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/OverlapsMsgTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/OverlapsMsgTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -35,10 +35,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class OverlapsMsgTest extends AbstractDTAnalysisTest { +class OverlapsMsgTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("improveHF.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_CA4B40F8-2354-48B6-B323-5C4E4B2CE467"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/PiTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/PiTest.java index 364c8de4bcf..b39f6ad26e5 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/PiTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/PiTest.java @@ -19,10 +19,9 @@ package org.kie.dmn.validation.dtanalysis; import java.math.BigDecimal; -import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -34,10 +33,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class PiTest extends AbstractDTAnalysisTest { +class PiTest extends AbstractDTAnalysisTest { @Test - public void testPi() { + void pi() { List validate = validator.validate(getReader("Pi.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); checkAnalysis(validate); } diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/PosDoubleNegHalfTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/PosDoubleNegHalfTest.java index c1dcd2534ad..ef1d0557ec4 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/PosDoubleNegHalfTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/PosDoubleNegHalfTest.java @@ -19,10 +19,9 @@ package org.kie.dmn.validation.dtanalysis; import java.math.BigDecimal; -import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -33,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class PosDoubleNegHalfTest extends AbstractDTAnalysisTest { +class PosDoubleNegHalfTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("posDoubleNegHalf.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_d18aa93e-3f67-4dda-9b36-93ae75835bdf"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/RecommenderHitPolicyTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/RecommenderHitPolicyTest.java index cc260b0ab8c..c75e0e58274 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/RecommenderHitPolicyTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/RecommenderHitPolicyTest.java @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.model.api.Decision; @@ -34,10 +34,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class RecommenderHitPolicyTest extends AbstractDTAnalysisTest { +class RecommenderHitPolicyTest extends AbstractDTAnalysisTest { @Test - public void testGaps() { + void gaps() { Definitions definitions = getDefinitions("RecommenderHitPolicy1.dmn", "http://www.trisotech.com/definitions/_50aea0bb-4482-48f6-acfe-4abc1a1bd0d6", "Drawing 1"); List validate = validator.validate(definitions, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_3aa68aee-6314-482f-a0be-84c2411d65d7"); @@ -46,9 +46,9 @@ public void testGaps() { assertThat(analysis.getGaps()).hasSize(1); assertThat(validate.stream().noneMatch(m -> m.getMessageType() == DMNMessageType.DECISION_TABLE_HITPOLICY_RECOMMENDER)).isTrue(); } - + @Test - public void testGapsAllowNull() { + void gapsAllowNull() { Definitions definitions = getDefinitions("RecommenderHitPolicy1_allowNull.dmn", "http://www.trisotech.com/definitions/_50aea0bb-4482-48f6-acfe-4abc1a1bd0d6", "Drawing 1"); List validate = validator.validate(definitions, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_3aa68aee-6314-482f-a0be-84c2411d65d7"); @@ -59,7 +59,7 @@ public void testGapsAllowNull() { } @Test - public void testNoGapsNoOverlaps() { + void noGapsNoOverlaps() { List wrongHPs = Arrays.asList(HitPolicy.ANY, HitPolicy.PRIORITY, HitPolicy.FIRST); for (HitPolicy hp : wrongHPs) { List validate = getRecommenderHitPolicy2(hp); @@ -84,7 +84,7 @@ private List getRecommenderHitPolicy2(HitPolicy hp) { } @Test - public void testNoGapsOverlapsSameValue() { + void noGapsOverlapsSameValue() { List wrongHPs = Arrays.asList(HitPolicy.UNIQUE, HitPolicy.PRIORITY, HitPolicy.FIRST); for (HitPolicy hp : wrongHPs) { List validate = getRecommenderHitPolicy3(hp); @@ -109,7 +109,7 @@ private List getRecommenderHitPolicy3(HitPolicy hp) { } @Test - public void testNoGapsOverlapsDiffValue() { + void noGapsOverlapsDiffValue() { List wrongHPs = Arrays.asList(HitPolicy.UNIQUE, HitPolicy.ANY, HitPolicy.FIRST); for (HitPolicy hp : wrongHPs) { List validate = getRecommenderHitPolicy4(hp); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/RuleOrderDashTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/RuleOrderDashTest.java index 0c45ced3f8f..38d2da0ceb3 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/RuleOrderDashTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/RuleOrderDashTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class RuleOrderDashTest extends AbstractDTAnalysisTest { +class RuleOrderDashTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("RuleOrderDash.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_eb02106a-cee1-47f5-a9d9-3160c5ac868b"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SRGapsOverlapsSubsumption2Test.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SRGapsOverlapsSubsumption2Test.java index 25d4ff6c049..bc6c60895ef 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SRGapsOverlapsSubsumption2Test.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SRGapsOverlapsSubsumption2Test.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.feel.runtime.Range.RangeBoundary; import org.kie.dmn.validation.dtanalysis.model.Bound; @@ -35,10 +35,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; -public class SRGapsOverlapsSubsumption2Test extends AbstractDTAnalysisTest { +class SRGapsOverlapsSubsumption2Test extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("SRGapsOverlapsSubsumption2.dmn"), VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_ccd87aa2-7081-4338-bafa-3a2cbf27c44c"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SameMsgInAllAPITest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SameMsgInAllAPITest.java index 4ac6c8e20a0..12839c12524 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SameMsgInAllAPITest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SameMsgInAllAPITest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.feel.runtime.Range.RangeBoundary; @@ -38,16 +38,16 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; -public class SameMsgInAllAPITest extends AbstractDTAnalysisTest { +class SameMsgInAllAPITest extends AbstractDTAnalysisTest { @Test - public void testSingleModelAPI() { + void singleModelAPI() { List validate = validator.validate(getReader("sameMsgInAllAPI.dmn"), VALIDATE_COMPILATION, VALIDATE_MODEL, ANALYZE_DECISION_TABLE); verify(validate); } @Test - public void testFluentAPI() { + void fluentAPI() { List validate = validator.validateUsing(VALIDATE_COMPILATION, VALIDATE_MODEL, ANALYZE_DECISION_TABLE).theseModels(getReader("sameMsgInAllAPI.dmn")); verify(validate); } diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SimpleStringNoGapTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SimpleStringNoGapTest.java index 00fd73c38b7..0cf5d63fe2e 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SimpleStringNoGapTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SimpleStringNoGapTest.java @@ -20,7 +20,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.dtanalysis.model.DTAnalysis; @@ -30,10 +30,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; -public class SimpleStringNoGapTest extends AbstractDTAnalysisTest { +class SimpleStringNoGapTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("simpleStringNoGap.dmn"), VALIDATE_COMPILATION, VALIDATE_MODEL, ANALYZE_DECISION_TABLE); assertThat(validate).hasSize(1); // Gap Analysis skipped because of free string. assertThat(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_GAP))).as("It should contain DMNMessage for the skipped gap analysis").isTrue(); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SomeProblemTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SomeProblemTest.java index 05bd341a607..3b622a2d4f1 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SomeProblemTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SomeProblemTest.java @@ -20,7 +20,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.Message.Level; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; @@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class SomeProblemTest extends AbstractDTAnalysisTest { +class SomeProblemTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("SomeProblem.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis1 = getAnalysis(validate, "_a36e37f8-aae0-4118-8267-cbb37c7955cb"); @@ -43,54 +43,54 @@ public void test() { DTAnalysis analysis2 = getAnalysis(validate, "_2aea80b4-19fa-4831-8829-4db925a128aa"); assertThat(analysis2.isError()).isTrue(); } - + @Test - public void testLtGtNumber() { + void ltGtNumber() { List validate = validator.validate(getReader("problemLtGtNumber.dmn"), ANALYZE_DECISION_TABLE); assertThat(validate).anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR) && p.getText().contains("Unrecognized unary test: '<> 47'; did you meant to write 'not(47)' instead?")); DTAnalysis analysis1 = getAnalysis(validate, "_207A079D-3C86-48D9-AE18-40D9485514F3"); assertThat(analysis1.isError()).isTrue(); } - + @Test - public void testGtLtString() { + void gtLtString() { List validate = validator.validate(getReader("problemGtLtString.dmn"), ANALYZE_DECISION_TABLE); assertThat(validate).anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR) && p.getText().contains("Unrecognized unary test: '><\"a\"'; did you meant to write 'not(\"a\")' instead?")); DTAnalysis analysis1 = getAnalysis(validate, "_207A079D-3C86-48D9-AE18-40D9485514F3"); assertThat(analysis1.isError()).isTrue(); } - + @Test - public void testDiseqNumber() { + void diseqNumber() { List validate = validator.validate(getReader("problemDiseqNumber.dmn"), ANALYZE_DECISION_TABLE); assertThat(validate).anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR) && p.getText().contains("Unrecognized unary test: '!= 47'; did you meant to write 'not(47)' instead?")); DTAnalysis analysis1 = getAnalysis(validate, "_B390752D-2181-40AF-A42C-737B3009DBAB"); assertThat(analysis1.isError()).isTrue(); } - + @Test - public void testDiseqString() { + void diseqString() { List validate = validator.validate(getReader("problemDiseqString.dmn"), ANALYZE_DECISION_TABLE); assertThat(validate).anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR) && p.getText().contains("Unrecognized unary test: '!=\"a\"'; did you meant to write 'not(\"a\")' instead?")); DTAnalysis analysis1 = getAnalysis(validate, "_B390752D-2181-40AF-A42C-737B3009DBAB"); assertThat(analysis1.isError()).isTrue(); } - + @Test - public void testValidDiseqNumber1() { + void validDiseqNumber1() { List validate = validator.validate(getReader("validDiseqNumber1.dmn"), ANALYZE_DECISION_TABLE); assertThat(validate).anyMatch(p -> p.getLevel() == Level.WARNING && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR) && p.getText().contains("Unmanaged unary test: '? != 47'; you could write 'not(47)' instead.")); DTAnalysis analysis1 = getAnalysis(validate, "_C72B227B-AF0C-4BC4-9E3F-CD44F842C886"); assertThat(analysis1.isError()).isTrue(); } - + @Test - public void testValidDiseqNumber2() { + void validDiseqNumber2() { List validate = validator.validate(getReader("validDiseqNumber2.dmn"), ANALYZE_DECISION_TABLE); assertThat(validate).noneMatch(p -> p.getLevel()== Level.ERROR || p.getLevel() == Level.WARNING); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SomeProblemruleOutsideDomainTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SomeProblemruleOutsideDomainTest.java index 95b634258c3..989babd7595 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SomeProblemruleOutsideDomainTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SomeProblemruleOutsideDomainTest.java @@ -20,17 +20,17 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.validation.dtanalysis.model.DTAnalysis; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class SomeProblemruleOutsideDomainTest extends AbstractDTAnalysisTest { +class SomeProblemruleOutsideDomainTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("SomeProblem-ruleOutsideDomain.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_4466518e-6240-46b0-bcb4-c7ddf5560e3a"); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/StringWithoutEnumNoGapTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/StringWithoutEnumNoGapTest.java index 15fdb5e75dd..dd6f4e0438d 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/StringWithoutEnumNoGapTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/StringWithoutEnumNoGapTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.feel.runtime.Range.RangeBoundary; @@ -39,10 +39,10 @@ import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION; import static org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL; -public class StringWithoutEnumNoGapTest extends AbstractDTAnalysisTest { +class StringWithoutEnumNoGapTest extends AbstractDTAnalysisTest { @Test - public void test() { + void test() { List validate = validator.validate(getReader("stringWithoutEnumNoGap.dmn"), VALIDATE_COMPILATION, VALIDATE_MODEL, ANALYZE_DECISION_TABLE); assertThat(validate).hasSize(3); // no gap but no enum "skip Gap analysis" message, (omit 2 overlaps DROOLS-5363), 2 masked, (omit 2 misleading as redundant with Masked). debugValidatorMsg(validate); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SubsumptionRulesTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SubsumptionRulesTest.java index 993a46d674e..9bdf18847b5 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SubsumptionRulesTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SubsumptionRulesTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.feel.runtime.Range.RangeBoundary; @@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class SubsumptionRulesTest extends AbstractDTAnalysisTest { +class SubsumptionRulesTest extends AbstractDTAnalysisTest { @Test - public void testSubsumptionRules() { + void subsumptionRules() { List validate = validator.validate(getReader("Subsumption.dmn"), ANALYZE_DECISION_TABLE); DTAnalysis analysis = getAnalysis(validate, "_82100fc5-8799-4ee2-981f-215ded39e68a"); assertThat(analysis.getGaps()).hasSize(0); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SymbolInDTTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SymbolInDTTest.java index 18d72d8ed3a..dcb0d380d38 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SymbolInDTTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/SymbolInDTTest.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.function.Predicate; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNMessageType; import org.kie.dmn.validation.dtanalysis.model.DTAnalysis; @@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE; -public class SymbolInDTTest extends AbstractDTAnalysisTest { +class SymbolInDTTest extends AbstractDTAnalysisTest { @Test - public void testSymbolMyThreshold() { + void symbolMyThreshold() { List validate = validator.validate(getReader("SymbolInDT.dmn"), ANALYZE_DECISION_TABLE); assertThat(validate.stream().anyMatch(messageForSymbol("my threshold"))).as("It should contain DMNMessage for symbol not supported in input").isTrue(); @@ -43,9 +43,9 @@ public void testSymbolMyThreshold() { private Predicate messageForSymbol(String symbolName) { return p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_ANALYSIS_ERROR) && p.getText().contains("symbol reference: '"+symbolName+"'."); } - + @Test - public void testSymbolLastDateOfWork() { + void symbolLastDateOfWork() { List validate = validator.validate(getReader("SymbolInDT2.dmn"), ANALYZE_DECISION_TABLE); assertThat(validate.stream().anyMatch(messageForSymbol("Last Date of Work"))).as("It should contain DMNMessage for symbol not supported in input").isTrue(); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/mcdc/ExampleMCDCTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/mcdc/ExampleMCDCTest.java index e104393316f..77ec9cc5bdb 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/mcdc/ExampleMCDCTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/mcdc/ExampleMCDCTest.java @@ -40,7 +40,7 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage; import org.kie.dmn.api.core.DMNModel; @@ -68,7 +68,7 @@ public class ExampleMCDCTest extends AbstractDTAnalysisTest { private static final Logger LOG = LoggerFactory.getLogger(ExampleMCDCTest.class); @Test - public void test1() throws Exception { + void test1() throws Exception { final String resourceFileName = "example1.dmn"; List validate = validator.validate(getReader(resourceFileName), ANALYZE_DECISION_TABLE, COMPUTE_DECISION_TABLE_MCDC); @@ -83,7 +83,7 @@ public void test1() throws Exception { } @Test - public void test2() throws Exception { + void test2() throws Exception { final String resourceFileName = "example2.dmn"; List validate = validator.validate(getReader(resourceFileName), ANALYZE_DECISION_TABLE, COMPUTE_DECISION_TABLE_MCDC); diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/model/NullBoundImplTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/model/NullBoundImplTest.java index e09f0932d80..27a691a1d7c 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/model/NullBoundImplTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/dtanalysis/model/NullBoundImplTest.java @@ -20,7 +20,7 @@ import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.feel.runtime.Range; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ public class NullBoundImplTest { * assert the requirement over NullBoundImpl.NULL to always throw exception if attempting to use it. */ @Test - public void test() { + void test() { assertThatIllegalStateException().isThrownBy(() -> NullBoundImpl.NULL.compareTo(new Bound<>(BigDecimal.ONE, Range.RangeBoundary.CLOSED, null))); assertThatIllegalStateException().isThrownBy(() -> NullBoundImpl.NULL.getValue()); assertThatIllegalStateException().isThrownBy(() -> NullBoundImpl.NULL.getBoundaryType()); @@ -45,7 +45,7 @@ public void test() { } @Test - public void testToStringInLogger() { + void toStringInLogger() { LOG.info("{}", NullBoundImpl.NULL); // this could sometimes happen in debug mode } } diff --git a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/v1_5/DMN15ValidationsTest.java b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/v1_5/DMN15ValidationsTest.java index 77f7aebe504..78af94a45c3 100644 --- a/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/v1_5/DMN15ValidationsTest.java +++ b/kie-dmn/kie-dmn-validation/src/test/java/org/kie/dmn/validation/v1_5/DMN15ValidationsTest.java @@ -24,7 +24,7 @@ import java.util.Map; import org.drools.io.ClassPathResource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.io.Resource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNMessage; @@ -39,8 +39,8 @@ import org.slf4j.LoggerFactory; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.kie.dmn.core.util.DynamicTypeUtils.entry; import static org.kie.dmn.core.util.DynamicTypeUtils.prototype; @@ -53,7 +53,7 @@ public class DMN15ValidationsTest { @Test - public void overridingUnnamedImportValidation() { + void overridingUnnamedImportValidation() { String importedModelFileName = "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"; String importingModelFileName = "valid_models/DMNv1_5/Importing_OverridingEmptyNamed_Model.dmn"; String modelName = "Importing empty-named Model"; @@ -64,7 +64,7 @@ public void overridingUnnamedImportValidation() { } @Test - public void namedImportValidation() { + void namedImportValidation() { String importedModelFileName = "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"; String importingModelFileName = "valid_models/DMNv1_5/Importing_Named_Model.dmn"; String modelName = "Importing named Model"; @@ -75,19 +75,19 @@ public void namedImportValidation() { } @Test - public void unnamedImportValidationWithHrefNamespace() { + void unnamedImportValidationWithHrefNamespace() { commonUnnamedImportValidation("valid_models/DMNv1_5/Importing_EmptyNamed_Model_With_Href_Namespace.dmn", "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"); } @Test - public void unnamedImportValidationWithoutHrefNamespace() { + void unnamedImportValidationWithoutHrefNamespace() { commonUnnamedImportValidation("valid_models/DMNv1_5/Importing_EmptyNamed_Model_Without_Href_Namespace.dmn", "valid_models/DMNv1_5/Imported_Model_Unamed.dmn"); } @Test - public void forLoopDatesEvaluateValidation() { + void forLoopDatesEvaluateValidation() { String modelFileName = "valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn"; String modelName = "For Loop Dates Evaluate"; String modelNamespace = "http://www.trisotech.com/dmn/definitions/_09E8A38A-AD24-4C3D-8307-029C0C4D373F"; @@ -96,7 +96,7 @@ public void forLoopDatesEvaluateValidation() { } @Test - public void listReplaceEvaluateValidation() { + void listReplaceEvaluateValidation() { String modelFileName = "valid_models/DMNv1_5/ListReplaceEvaluate.dmn"; String modelName = "List Replace Evaluate"; String modelNamespace = "http://www.trisotech.com/dmn/definitions/_09E8A38A-AD24-4C3D-8307-029C0C4D373F"; @@ -105,7 +105,7 @@ public void listReplaceEvaluateValidation() { } @Test - public void negationOfDurationEvaluateValidation() { + void negationOfDurationEvaluateValidation() { String modelFileName = "valid_models/DMNv1_5/NegationOfDurationEvaluate.dmn"; String modelName = "Negation of Duration Evaluate"; String modelNamespace = "http://www.trisotech.com/dmn/definitions/_09E8A38A-AD24-4C3D-8307-029C0C4D373F"; @@ -114,7 +114,7 @@ public void negationOfDurationEvaluateValidation() { } @Test - public void dateToDateTimeFunctionValidation() { + void dateToDateTimeFunctionValidation() { String modelFileName = "valid_models/DMNv1_5/DateToDateTimeFunction.dmn"; String modelName = "new-file"; String modelNamespace = "https://kiegroup.org/dmn/_A7F17D7B-F0AB-4C0B-B521-02EA26C2FBEE"; @@ -123,7 +123,7 @@ public void dateToDateTimeFunctionValidation() { } @Test - public void typeConstraintsChecksValidation() { + void typeConstraintsChecksValidation() { String modelFileName = "valid_models/DMNv1_5/TypeConstraintsChecks.dmn"; String modelName = "TypeConstraintsChecks"; String modelNamespace = "http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b-504f3e77b442"; diff --git a/kie-dmn/kie-dmn-xls2dmn-cli/pom.xml b/kie-dmn/kie-dmn-xls2dmn-cli/pom.xml index adf7488f631..469e788a42d 100644 --- a/kie-dmn/kie-dmn-xls2dmn-cli/pom.xml +++ b/kie-dmn/kie-dmn-xls2dmn-cli/pom.xml @@ -84,13 +84,13 @@ - junit - junit + org.assertj + assertj-core test - org.assertj - assertj-core + org.junit.jupiter + junit-jupiter test diff --git a/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/CardApprovalTest.java b/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/CardApprovalTest.java index 2bd761830f0..8c1b1a32804 100644 --- a/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/CardApprovalTest.java +++ b/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/CardApprovalTest.java @@ -21,7 +21,7 @@ import java.io.File; import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -29,13 +29,12 @@ import org.kie.dmn.core.util.DMNRuntimeUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import picocli.CommandLine; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.xls2dmn.cli.TestUtils.getRuntime; -import picocli.CommandLine; - -public class CardApprovalTest { +class CardApprovalTest { static final Logger LOG = LoggerFactory.getLogger(CardApprovalTest.class); @@ -50,13 +49,13 @@ private DMNRuntime getDMNRuntimeWithSameVMApp() throws Exception { } @Test - public void testCLI() throws Exception { + void cli() throws Exception { final DMNRuntime dmnRuntime = getDMNRuntimeWithCLI(); checkCardApprovalDMNModel(dmnRuntime); } @Test - public void testSameVMApp() throws Exception { + void sameVMApp() throws Exception { final DMNRuntime dmnRuntime = getDMNRuntimeWithSameVMApp(); checkCardApprovalDMNModel(dmnRuntime); } diff --git a/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/ChineseLunarYearsTest.java b/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/ChineseLunarYearsTest.java index d05291acd55..beadf181e70 100644 --- a/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/ChineseLunarYearsTest.java +++ b/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/ChineseLunarYearsTest.java @@ -21,7 +21,7 @@ import java.io.File; import java.time.LocalDate; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -29,18 +29,17 @@ import org.kie.dmn.core.util.DMNRuntimeUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import picocli.CommandLine; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.xls2dmn.cli.TestUtils.getRuntime; -import picocli.CommandLine; - -public class ChineseLunarYearsTest { +class ChineseLunarYearsTest { private static final Logger LOG = LoggerFactory.getLogger(ChineseLunarYearsTest.class); @Test - public void testCLI() throws Exception { + void cli() throws Exception { File tempFile = File.createTempFile("xls2dmn", ".dmn"); final DMNRuntime dmnRuntime = getRuntime(new CommandLine(new App())::execute, tempFile, new String[]{"src/test/resources/ChineseLunarYears.xlsx", tempFile.toString()}); DMNModel dmnModel = dmnRuntime.getModels().get(0); diff --git a/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/XLS2DMNParserTest.java b/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/XLS2DMNParserTest.java index 7d91230bec7..d091e5a60d8 100644 --- a/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/XLS2DMNParserTest.java +++ b/kie-dmn/kie-dmn-xls2dmn-cli/src/test/java/org/kie/dmn/xls2dmn/cli/XLS2DMNParserTest.java @@ -21,11 +21,8 @@ import java.io.File; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.dmn.api.core.DMNContext; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNResult; @@ -37,23 +34,17 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.xls2dmn.cli.TestUtils.validateRuntime; -@RunWith(Parameterized.class) public class XLS2DMNParserTest { private static final Logger LOG = LoggerFactory.getLogger(XLS2DMNParserTest.class); - @Parameters(name = "file: {0}") - public static Iterable data() { + protected static Iterable data() { return Arrays.asList("/Loan_approvals.xlsx", "/Loan_approvals_colshuffled.xlsx"); } private String filename; private DMNRuntime dmnRuntime; private DMNModel dmnModel; - - public XLS2DMNParserTest(String filename) { - this.filename = filename; - } private DMNRuntime getRuntimeLoanApprovalXslx() throws Exception { File tempFile = File.createTempFile("xls2dmn", ".dmn"); @@ -62,14 +53,16 @@ private DMNRuntime getRuntimeLoanApprovalXslx() throws Exception { return validateRuntime(tempFile); } - @Before - public void init() throws Exception { + void init(String filename) throws Exception { + this.filename = filename; dmnRuntime = getRuntimeLoanApprovalXslx(); dmnModel = dmnRuntime.getModels().get(0); } - @Test - public void testLoanApprovalXslx() { + @MethodSource("data") + @ParameterizedTest(name = "file: {0}") + public void loanApprovalXslx(String filename) throws Exception { + init(filename); DMNContext dmnContext = dmnRuntime.newContext(); dmnContext.set("DTI Ratio", 1); dmnContext.set("PITI Ratio", 1); @@ -79,9 +72,11 @@ public void testLoanApprovalXslx() { assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResult.getMessages())).isFalse(); assertThat(dmnResult.getDecisionResultByName("Loan Approval").getResult()).isEqualTo("Not approved"); } - - @Test - public void testLoanApprovalXslx_Approved() { + + @MethodSource("data") + @ParameterizedTest(name = "file: {0}") + public void loanApprovalXslxApproved(String filename) throws Exception { + init(filename); DMNContext dmnContext = dmnRuntime.newContext(); dmnContext.set("DTI Ratio", .1); dmnContext.set("PITI Ratio", .1); diff --git a/kie-dmn/pom.xml b/kie-dmn/pom.xml index b875a0445d6..f65c0ea87a9 100644 --- a/kie-dmn/pom.xml +++ b/kie-dmn/pom.xml @@ -69,4 +69,33 @@ + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + + + junit:junit + + + + + + + enforce + + enforce + + + true + + + + + + +