diff --git a/.rat-excludes b/.rat-excludes index 67155c8d5d2..298ba4b109c 100644 --- a/.rat-excludes +++ b/.rat-excludes @@ -4,24 +4,16 @@ .rat-excludes # DISCLAIMER-WIP DISCLAIMER-WIP -# drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java -CsvLineParser.java # drools-decisiontables/src/test/resources/data/ComplexWorkbook.drl.csv ComplexWorkbook.drl.csv # drools-decisiontables/src/test/resources/data/TestCsv.drl.csv TestCsv.drl.csv # drools-decisiontables/src/test/resources/org/drools/decisiontable/DeclaresWorkbook.drl.csv DeclaresWorkbook.drl.csv -# drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV.drl.csv -changeSetTestCSV.drl.csv -# drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV2.drl.csv -changeSetTestCSV2.drl.csv # drools-decisiontables/src/test/resources/org/drools/decisiontable/columnReplaceTest.drl.csv columnReplaceTest.drl.csv # drools-decisiontables/src/test/resources/org/drools/decisiontable/emptyAction.drl.csv emptyAction.drl.csv -# drools-decisiontables/src/test/resources/org/drools/decisiontable/scannerChangeSetTestCSV.drl.csv -scannerChangeSetTestCSV.drl.csv # drools-decisiontables/src/test/resources/org/drools/decisiontable/unicode.drl.csv unicode.drl.csv # drools-decisiontables/src/test/resources/org/drools/decisiontable/integrationtests/csv/kmoduleCSVTest.dtable.drl.csv diff --git a/LICENSE b/LICENSE index fc4062804b2..85e668af1df 100644 --- a/LICENSE +++ b/LICENSE @@ -234,17 +234,6 @@ for drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/Ja (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ------------------------------------------------------------------------------------ - for drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java - - Inner logic adapted from a C++ original that was Copyright (C) 1999 - Lucent Technologies Excerpted from 'The Practice of Programming' by Brian - Kernighan and Rob Pike. - - Included by permission of the http://tpop.awl.com/ web site, which says: - "You may use this code for any purpose, as long as you leave the - copyright notice and book citation attached." - ------------------------------------------------------------------------------------ for kie-dmn/kie-dmn-backend/src/test/resources/DC.xsd kie-dmn/kie-dmn-backend/src/test/resources/DI.xsd @@ -739,4 +728,387 @@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS RELEASE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------------ +for drools-docs/supplemental-ui/js/search-ui.js + drools-docs/supplemental-ui/css/search.css + +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at https://mozilla.org/MPL/2.0/. + + +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. \ No newline at end of file diff --git a/drools-base/src/main/java/org/drools/base/definitions/ProcessPackage.java b/drools-base/src/main/java/org/drools/base/definitions/ProcessPackage.java index 92e579ca676..3424ce3a146 100644 --- a/drools-base/src/main/java/org/drools/base/definitions/ProcessPackage.java +++ b/drools-base/src/main/java/org/drools/base/definitions/ProcessPackage.java @@ -41,7 +41,6 @@ public static ProcessPackage getOrCreate(ResourceTypePackageRegistry rtps) { rtp = new ProcessPackage(); // register the same instance for all types. There is no distinction rtps.put(ResourceType.BPMN2, rtp); - rtps.put(ResourceType.DRF, rtp); rtps.put(ResourceType.CMMN, rtp); } return rtp; @@ -55,7 +54,7 @@ public Map getRuleFlows() { /** * The ResourceType for {@link ProcessPackage} is always BPMN2, - * but there is no distinction between DRF, and CMMN as they all live under + * but there is no distinction between CMMN as they all live under * the same package. */ @Override diff --git a/drools-beliefs/src/test/java/org/drools/beliefs/bayes/JunctionTreeBuilderTest.java b/drools-beliefs/src/test/java/org/drools/beliefs/bayes/JunctionTreeBuilderTest.java index a284033836a..cc603e4c21c 100644 --- a/drools-beliefs/src/test/java/org/drools/beliefs/bayes/JunctionTreeBuilderTest.java +++ b/drools-beliefs/src/test/java/org/drools/beliefs/bayes/JunctionTreeBuilderTest.java @@ -187,7 +187,7 @@ public void testCreateClique() { jtBuilder.createClique(dX1.getId(), clonedAdjMatrix, vertices, adjList ); assertThat(vertices).hasSize(3); - assertThat(vertices).containsExactly(2, 3, 4); + assertThat(vertices).containsExactlyInAnyOrder(2, 3, 4); assertLinkedNode(jtBuilder, 1, 2, 3, 4); assertLinkedNode(jtBuilder, 2, 1, 3, 4); @@ -477,7 +477,7 @@ public void testIterativeEliminationUsingEdgeAndWeight() { adjList = clonedAdjMatrix[ id ]; jtBuilder.createClique(4, clonedAdjMatrix, verticesToUpdate, adjList); assertThat(verticesToUpdate).hasSize(3); - assertThat(verticesToUpdate).containsExactly(1, 2, 6); // don't forget 3 and 5 were already eliminated + assertThat(verticesToUpdate).containsExactlyInAnyOrder(1, 2, 6); // don't forget 3 and 5 were already eliminated jtBuilder.eliminateVertex(p, elmVertMap, clonedAdjMatrix, adjList, verticesToUpdate, v ); // assert all new edges diff --git a/drools-compiler/src/main/java/org/drools/compiler/builder/impl/CompositeKnowledgeBuilderImpl.java b/drools-compiler/src/main/java/org/drools/compiler/builder/impl/CompositeKnowledgeBuilderImpl.java index 1c53ddae0b3..2cb56df7f9c 100644 --- a/drools-compiler/src/main/java/org/drools/compiler/builder/impl/CompositeKnowledgeBuilderImpl.java +++ b/drools-compiler/src/main/java/org/drools/compiler/builder/impl/CompositeKnowledgeBuilderImpl.java @@ -136,7 +136,6 @@ private void buildProcesses() { private void buildResources() { buildResourceType(ResourceBuilder.DSL_RESOURCE_BUILDER, ResourceType.DSL); - buildResourceType(ResourceBuilder.DRF_RESOURCE_BUILDER, ResourceType.DRF); buildResourceType(ResourceBuilder.XSD_RESOURCE_BUILDER, ResourceType.XSD); } @@ -277,8 +276,6 @@ private interface ResourceBuilder { ResourceBuilder BPMN2_RESOURCE_BUILDER = ( kBuilder, resourceDescr ) -> kBuilder.addKnowledgeResource( resourceDescr.resource, ResourceType.BPMN2, resourceDescr.configuration ); ResourceBuilder CMMN_RESOURCE_BUILDER = ( kBuilder, resourceDescr ) -> kBuilder.addKnowledgeResource( resourceDescr.resource, ResourceType.CMMN, resourceDescr.configuration ); - - ResourceBuilder DRF_RESOURCE_BUILDER = ( kBuilder, resourceDescr ) -> kBuilder.addKnowledgeResource( resourceDescr.resource, ResourceType.DRF, resourceDescr.configuration ); } } diff --git a/drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderImpl.java b/drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderImpl.java index cd19e2ded43..8b332a20d7f 100644 --- a/drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderImpl.java +++ b/drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderImpl.java @@ -340,16 +340,6 @@ public void addDsl(Resource resource) throws IOException { } } - /** - * Add a ruleflow (.rfm) asset to this package. - */ - public void addRuleFlow(Reader processSource) { - addKnowledgeResource( - new ReaderResource(processSource, ResourceType.DRF), - ResourceType.DRF, - null); - } - @Deprecated public void addProcessFromXml(Resource resource) { addKnowledgeResource( @@ -362,11 +352,6 @@ public ProcessBuilder getProcessBuilder() { return processBuilder; } - @Deprecated - public void addProcessFromXml( Reader processSource) { - addProcessFromXml(new ReaderResource(processSource, ResourceType.DRF)); - } - public void addKnowledgeResource(Resource resource, ResourceType type, ResourceConfiguration configuration) { diff --git a/drools-compiler/src/main/java/org/drools/compiler/rule/builder/util/AccumulateUtil.java b/drools-compiler/src/main/java/org/drools/compiler/rule/builder/util/AccumulateUtil.java index 192873909f1..9fc2564123a 100644 --- a/drools-compiler/src/main/java/org/drools/compiler/rule/builder/util/AccumulateUtil.java +++ b/drools-compiler/src/main/java/org/drools/compiler/rule/builder/util/AccumulateUtil.java @@ -55,6 +55,10 @@ public static String getFunctionName(Supplier> exprClassSupplier, Strin functionName = "maxI"; } else if (exprClass == Long.class) { functionName = "maxL"; + } else if (exprClass == BigInteger.class) { + functionName = "maxBI"; + } else if (exprClass == BigDecimal.class) { + functionName = "maxBD"; } else if (Number.class.isAssignableFrom( exprClass )) { functionName = "maxN"; } @@ -64,6 +68,10 @@ public static String getFunctionName(Supplier> exprClassSupplier, Strin functionName = "minI"; } else if (exprClass == Long.class) { functionName = "minL"; + } else if (exprClass == BigInteger.class) { + functionName = "minBI"; + } else if (exprClass == BigDecimal.class) { + functionName = "minBD"; } else if (Number.class.isAssignableFrom( exprClass )) { functionName = "minN"; } diff --git a/drools-compiler/src/main/resources/META-INF/drools-processes-5.0.xsd b/drools-compiler/src/main/resources/META-INF/drools-processes-5.0.xsd deleted file mode 100644 index 4afa6fad704..00000000000 --- a/drools-compiler/src/main/resources/META-INF/drools-processes-5.0.xsd +++ /dev/null @@ -1,623 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/drools-core/src/main/java/org/drools/core/base/accumulators/BigDecimalMaxAccumulateFunction.java b/drools-core/src/main/java/org/drools/core/base/accumulators/BigDecimalMaxAccumulateFunction.java new file mode 100644 index 00000000000..884fa35a822 --- /dev/null +++ b/drools-core/src/main/java/org/drools/core/base/accumulators/BigDecimalMaxAccumulateFunction.java @@ -0,0 +1,100 @@ +/** + * 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.core.base.accumulators; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.math.BigDecimal; + +/** + * An implementation of an accumulator capable of calculating maximum values + */ +public class BigDecimalMaxAccumulateFunction extends AbstractAccumulateFunction { + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + + } + + public void writeExternal(ObjectOutput out) throws IOException { + + } + + protected static class MaxData implements Externalizable { + public BigDecimal max = null; + + public MaxData() {} + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + max = (BigDecimal) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(max); + } + + @Override + public String toString() { + return "max"; + } + } + + public MaxData createContext() { + return new MaxData(); + } + + public void init(MaxData data) { + data.max = null; + } + + public void accumulate(MaxData data, + Object value) { + if (value != null) { + BigDecimal bdValue = (BigDecimal) value; + data.max = data.max == null || data.max.compareTo(bdValue) < 0 ? + bdValue : + data.max; + } + } + + public void reverse(MaxData data, + Object value) { + } + + @Override + public boolean tryReverse( MaxData data, Object value ) { + if (value != null) { + return data.max.compareTo((BigDecimal) value) > 0; + } + return true; + } + + public Object getResult(MaxData data) { + return data.max; + } + + public boolean supportsReverse() { + return false; + } + + public Class getResultType() { + return BigDecimal.class; + } +} diff --git a/drools-core/src/main/java/org/drools/core/base/accumulators/BigDecimalMinAccumulateFunction.java b/drools-core/src/main/java/org/drools/core/base/accumulators/BigDecimalMinAccumulateFunction.java new file mode 100644 index 00000000000..c3f0a628315 --- /dev/null +++ b/drools-core/src/main/java/org/drools/core/base/accumulators/BigDecimalMinAccumulateFunction.java @@ -0,0 +1,98 @@ +/** + * 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.core.base.accumulators; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.math.BigDecimal; + +/** + * An implementation of an accumulator capable of calculating minimum values + */ +public class BigDecimalMinAccumulateFunction extends AbstractAccumulateFunction { + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + } + + public void writeExternal(ObjectOutput out) throws IOException { + } + + protected static class MinData implements Externalizable { + public BigDecimal min = null; + + public MinData() {} + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + min = (BigDecimal) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(min); + } + + @Override + public String toString() { + return "min"; + } + } + + public MinData createContext() { + return new MinData(); + } + + public void init(MinData data) { + data.min = null; + } + + public void accumulate(MinData data, + Object value) { + if (value != null) { + BigDecimal bdValue = (BigDecimal) value; + data.min = data.min == null || data.min.compareTo(bdValue) > 0 ? + bdValue : + data.min; + } + } + + @Override + public boolean tryReverse( MinData data, Object value ) { + if (value != null) { + return data.min.compareTo((BigDecimal) value) < 0; + } + return true; + } + + public void reverse(MinData data, + Object value) { + } + + public Object getResult(MinData data) { + return data.min; + } + + public boolean supportsReverse() { + return false; + } + + public Class getResultType() { + return BigDecimal.class; + } +} diff --git a/drools-core/src/main/java/org/drools/core/base/accumulators/BigIntegerMaxAccumulateFunction.java b/drools-core/src/main/java/org/drools/core/base/accumulators/BigIntegerMaxAccumulateFunction.java new file mode 100644 index 00000000000..2fee047f05d --- /dev/null +++ b/drools-core/src/main/java/org/drools/core/base/accumulators/BigIntegerMaxAccumulateFunction.java @@ -0,0 +1,100 @@ +/** + * 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.core.base.accumulators; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.math.BigInteger; + +/** + * An implementation of an accumulator capable of calculating maximum values + */ +public class BigIntegerMaxAccumulateFunction extends AbstractAccumulateFunction { + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + + } + + public void writeExternal(ObjectOutput out) throws IOException { + + } + + protected static class MaxData implements Externalizable { + public BigInteger max = null; + + public MaxData() {} + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + max = (BigInteger) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(max); + } + + @Override + public String toString() { + return "max"; + } + } + + public MaxData createContext() { + return new MaxData(); + } + + public void init(MaxData data) { + data.max = null; + } + + public void accumulate(MaxData data, + Object value) { + if (value != null) { + BigInteger biValue = (BigInteger) value; + data.max = data.max == null || data.max.compareTo(biValue) < 0 ? + biValue : + data.max; + } + } + + public void reverse(MaxData data, + Object value) { + } + + @Override + public boolean tryReverse( MaxData data, Object value ) { + if (value != null) { + return data.max.compareTo((BigInteger) value) > 0; + } + return true; + } + + public Object getResult(MaxData data) { + return data.max; + } + + public boolean supportsReverse() { + return false; + } + + public Class getResultType() { + return BigInteger.class; + } +} diff --git a/drools-core/src/main/java/org/drools/core/base/accumulators/BigIntegerMinAccumulateFunction.java b/drools-core/src/main/java/org/drools/core/base/accumulators/BigIntegerMinAccumulateFunction.java new file mode 100644 index 00000000000..f292e73afff --- /dev/null +++ b/drools-core/src/main/java/org/drools/core/base/accumulators/BigIntegerMinAccumulateFunction.java @@ -0,0 +1,98 @@ +/** + * 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.core.base.accumulators; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.math.BigInteger; + +/** + * An implementation of an accumulator capable of calculating minimum values + */ +public class BigIntegerMinAccumulateFunction extends AbstractAccumulateFunction { + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + } + + public void writeExternal(ObjectOutput out) throws IOException { + } + + protected static class MinData implements Externalizable { + public BigInteger min = null; + + public MinData() {} + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + min = (BigInteger) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(min); + } + + @Override + public String toString() { + return "min"; + } + } + + public MinData createContext() { + return new MinData(); + } + + public void init(MinData data) { + data.min = null; + } + + public void accumulate(MinData data, + Object value) { + if (value != null) { + BigInteger biValue = (BigInteger) value; + data.min = data.min == null || data.min.compareTo(biValue) > 0 ? + biValue : + data.min; + } + } + + @Override + public boolean tryReverse( MinData data, Object value ) { + if (value != null) { + return data.min.compareTo((BigInteger) value) < 0; + } + return true; + } + + public void reverse(MinData data, + Object value) { + } + + public Object getResult(MinData data) { + return data.min; + } + + public boolean supportsReverse() { + return false; + } + + public Class getResultType() { + return BigInteger.class; + } +} diff --git a/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java b/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java index 51365d30d7c..88a05d6e053 100644 --- a/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java +++ b/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java @@ -507,30 +507,6 @@ public void addLastLeftTuple( TupleImpl leftTuple) { lastLeftTuple = leftTuple; } - private void addLastTuple(TupleImpl tuple, boolean left) { - if (left) { - addLastLeftTuple(tuple); - } else { - addLastRightTuple(tuple); - } - } - - private void setFirstTuple(TupleImpl tuple, boolean left) { - if (left) { - firstLeftTuple = tuple; - } else { - firstRightTuple = tuple; - } - } - - private void setLastTuple(TupleImpl tuple, boolean left) { - if (left) { - lastLeftTuple = tuple; - } else { - lastRightTuple = tuple; - } - } - @Override public void removeLeftTuple( TupleImpl leftTuple ) { TupleImpl previous = leftTuple.getHandlePrevious(); @@ -683,6 +659,7 @@ public TupleImpl detachLeftTupleAfter(RuleBasePartitionId partitionId, ObjectTyp if (detached != null) { if (firstLeftTuple == detached) { firstLeftTuple = null; + lastLeftTuple = null; } if (lastLeftTuple == detached) { @@ -695,7 +672,6 @@ public TupleImpl detachLeftTupleAfter(RuleBasePartitionId partitionId, ObjectTyp lastLeftTuple.setHandleNext(null); } } - return detached; } @@ -711,6 +687,7 @@ public TupleImpl detachRightTupleAfter(RuleBasePartitionId partitionId, ObjectTy if (detached != null) { if (firstRightTuple == detached) { firstRightTuple = null; + lastRightTuple = null; } if (lastRightTuple == detached) { @@ -723,7 +700,6 @@ public TupleImpl detachRightTupleAfter(RuleBasePartitionId partitionId, ObjectTy lastRightTuple.setHandleNext(null); } } - return detached; } diff --git a/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java b/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java index 2c4e58d806f..15478b1a2b7 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java +++ b/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java @@ -151,8 +151,6 @@ public void removeRule(TerminalNode tn, Collection wms, I } } - Set smemsToNotify = new HashSet<>(); - if (exclBranchRoots.isEmpty()) { LeftTupleNode lian = tn.getPathNodes()[0]; processLeftTuples(lian, false, tn, wms); @@ -163,7 +161,7 @@ public void removeRule(TerminalNode tn, Collection wms, I // Process existing branches from the split points Set visited = new HashSet<>(); - exclBranchRoots.forEach(pair -> Remove.processMerges(pair.parent, tn, kBase, wms, visited, smemsToNotify)); + exclBranchRoots.forEach(pair -> Remove.processMerges(pair.parent, tn, kBase, wms, visited)); } for (InternalWorkingMemory wm : wms) { @@ -174,8 +172,6 @@ public void removeRule(TerminalNode tn, Collection wms, I pmem.getRuleAgendaItem().dequeue(); } } - - smemsToNotify.forEach(pair -> pair.sm.notifyRuleLinkSegment(pair.wm)); } public static void notifyImpactedSegments(SegmentMemory smem, InternalWorkingMemory wm, Set segmentsToNotify) { @@ -736,8 +732,7 @@ private static void removeExistingPaths(List exclBranchRoots, TerminalNode } } - - private static void processMerges(LeftTupleNode splitNode, TerminalNode tn, InternalRuleBase kBase, Collection wms, Set visited, Set smemsToNotify) { + private static void processMerges(LeftTupleNode splitNode, TerminalNode tn, InternalRuleBase kBase, Collection wms, Set visited) { // it's possible for a rule to have multiple exclBranches, pointing to the same parent. So need to ensure it's processed once. if ( !visited.add(splitNode.getId())) { return; @@ -766,10 +761,7 @@ private static void processMerges(LeftTupleNode splitNode, TerminalNode tn, Inte } SegmentPrototype proto2 = kBase.getSegmentPrototype(ltn); - mergeSegments(proto1, proto2, kBase, wms); - - notifyImpactedSegments(wms, proto1, smemsToNotify); } } @@ -1443,17 +1435,6 @@ private static void updatePaths(SegmentPrototype proto, Collection wms, SegmentPrototype proto1, Set smemsToNotify) { - // any impacted segments must be notified for potential linking - for (InternalWorkingMemory wm : wms) { - Memory mem1 = wm.getNodeMemories().peekNodeMemory(proto1.getRootNode()); - if (mem1 != null && mem1.getSegmentMemory() != null) { - // there was a split segment, both need notifying. - notifyImpactedSegments(mem1.getSegmentMemory(), wm, smemsToNotify); - } - } - } - private static void setNodeTypes(SegmentPrototype proto, LeftTupleNode[] protoNodes) { int nodeTypesInSegment = 0; for ( LeftTupleNode node : protoNodes) { diff --git a/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluator.java b/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluator.java index eef6b8ad1b8..8e8c12b4c43 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluator.java +++ b/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluator.java @@ -273,7 +273,7 @@ public void innerEval(PathMemory pmem, } boolean emptySrcTuples = srcTuples.isEmpty(); - if ( !(NodeTypeEnums.isBetaNode(node) && ((BetaNode)node).isRightInputIsRiaNode() ) ) { + if ( !(NodeTypeEnums.isBetaNode(node) && node.isRightInputIsRiaNode() ) ) { // The engine cannot skip a ria node, as the dirty might be several levels deep if ( emptySrcTuples && smem.getDirtyNodeMask() == 0) { // empty sources and segment is not dirty, skip to non empty src tuples or dirty segment. diff --git a/drools-core/src/main/java/org/drools/core/reteoo/ReteooBuilder.java b/drools-core/src/main/java/org/drools/core/reteoo/ReteooBuilder.java index 2d7ada53d35..4300fca8ce2 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/ReteooBuilder.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/ReteooBuilder.java @@ -193,9 +193,7 @@ public void removeTerminalNode(RuleRemovalContext context, TerminalNode tn, Coll tn.visitLeftTupleNodes(n -> n.removeAssociatedTerminal(tn)); - BaseNode node = (BaseNode) tn; - removeNodeAssociation(node, context.getRule(), new HashSet<>(), context); - + removeNodeAssociation((BaseNode) tn, context.getRule(), new HashSet<>(), context); resetMasks(removeNodes((AbstractTerminalNode)tn, workingMemories, context)); } diff --git a/drools-core/src/main/resources/META-INF/kie.default.properties.conf b/drools-core/src/main/resources/META-INF/kie.default.properties.conf index f3fcd0b2e69..823723c7e17 100644 --- a/drools-core/src/main/resources/META-INF/kie.default.properties.conf +++ b/drools-core/src/main/resources/META-INF/kie.default.properties.conf @@ -44,10 +44,14 @@ drools.accumulate.function.max = org.drools.core.base.accumulators.MaxAccumulate drools.accumulate.function.maxN = org.drools.core.base.accumulators.NumericMaxAccumulateFunction drools.accumulate.function.maxI = org.drools.core.base.accumulators.IntegerMaxAccumulateFunction drools.accumulate.function.maxL = org.drools.core.base.accumulators.LongMaxAccumulateFunction +drools.accumulate.function.maxBI = org.drools.core.base.accumulators.BigIntegerMaxAccumulateFunction +drools.accumulate.function.maxBD = org.drools.core.base.accumulators.BigDecimalMaxAccumulateFunction drools.accumulate.function.min = org.drools.core.base.accumulators.MinAccumulateFunction drools.accumulate.function.minN = org.drools.core.base.accumulators.NumericMinAccumulateFunction drools.accumulate.function.minI = org.drools.core.base.accumulators.IntegerMinAccumulateFunction drools.accumulate.function.minL = org.drools.core.base.accumulators.LongMinAccumulateFunction +drools.accumulate.function.minBI = org.drools.core.base.accumulators.BigIntegerMinAccumulateFunction +drools.accumulate.function.minBD = org.drools.core.base.accumulators.BigDecimalMinAccumulateFunction drools.accumulate.function.count = org.drools.core.base.accumulators.CountAccumulateFunction drools.accumulate.function.collectList = org.drools.core.base.accumulators.CollectListAccumulateFunction drools.accumulate.function.collectSet = org.drools.core.base.accumulators.CollectSetAccumulateFunction diff --git a/drools-core/src/test/resources/org/drools/core/xml/test-change-set.xml b/drools-core/src/test/resources/org/drools/core/xml/test-change-set.xml deleted file mode 100644 index b16fd5533c4..00000000000 --- a/drools-core/src/test/resources/org/drools/core/xml/test-change-set.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - diff --git a/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java b/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java index 19aa1264514..4ee8e52a28c 100644 --- a/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java +++ b/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java @@ -1,150 +1,77 @@ +/** + * 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.decisiontable.parser.csv; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** - * - * a CSV line, with all the normal CSV features. + * A simple parser for CSV (Comma-Separated Values) format. + * Supports quoted fields and escaped quotes. */ public class CsvLineParser { - private ICsvParser lineParser; - - public CsvLineParser() { - this.lineParser = new CsvParserImpl(); - } + private static final char DELIMITER = ','; /** - * Use the current lineParser implementation to return a CSV line as a List - * of cells. (Strings). + * Parses a line of CSV text into a list of fields. + * + * @param input The CSV line to parse + * @return List of fields extracted from the CSV line */ - public List parse(final CharSequence line) { - return this.lineParser.parse( line.toString() ); - } - - /** - * This is insurance incase I need to replace it with more complex Csv - * handlers in the future. - */ - static interface ICsvParser { - public List parse(String line); - } - - /** - * Parse comma-separated values (CSV), a common Windows file format. Sample - * input: "LU",86.25,"11/4/1998","2:19PM",+4.0625 - *

- * Inner logic adapted from a C++ original that was Copyright (C) 1999 - * Lucent Technologies Excerpted from 'The Practice of Programming' by Brian - * W. Kernighan and Rob Pike. - *

- * Included by permission of the http://tpop.awl.com/ web site, which says: - * "You may use this code for any purpose, as long as you leave the - * copyright notice and book citation attached." I have done so. - * - * readability) - */ - static class CsvParserImpl - implements - ICsvParser { - - public static final char DEFAULT_SEP = ','; + public List parse(CharSequence input) { + String line = input != null ? input.toString() : ""; + List fields = new ArrayList<>(); - /** Construct a CSV parser, with the default separator (','). */ - public CsvParserImpl() { - this( CsvParserImpl.DEFAULT_SEP ); + if (line.isEmpty()) { + return Collections.singletonList(""); } - /** - * Construct a CSV parser with a given separator. - * - * @param sep - * The single char for the separator (not a list of separator - * characters) - */ - public CsvParserImpl(final char sep) { - this.fieldSep = sep; - } - - /** The fields in the current String */ - protected List list = new ArrayList<>(); + StringBuilder currentField = new StringBuilder(); + boolean insideQuotes = false; - /** the separator char for this parser */ - protected char fieldSep; + for (int i = 0; i < line.length(); i++) { + char currentChar = line.charAt(i); - /** - * parse: break the input String into fields - * - * @return java.util.Iterator containing each field from the original as - * a String, in order. - */ - public List parse(final String line) { - final StringBuilder sb = new StringBuilder(); - this.list.clear(); // recycle to initial state - int i = 0; - - if ( line.length() == 0 ) { - this.list.add( line ); - return this.list; - } - - do { - sb.setLength( 0 ); - if ( i < line.length() && line.charAt( i ) == '"' ) { - i = advQuoted( line, - sb, - ++i ); // skip + if (currentChar == '"') { + if (insideQuotes && i + 1 < line.length() && line.charAt(i + 1) == '"') { + // Handle escaped quotes + currentField.append('"'); + i++; // Skip the next quote } else { - i = advPlain( line, - sb, - i ); + insideQuotes = !insideQuotes; } - this.list.add( sb.toString() ); - i++; - } while ( i < line.length() ); - - return this.list; - } - - /** advQuoted: quoted field; return index of next separator */ - protected int advQuoted(final String s, - final StringBuilder sb, - final int i) { - int j; - final int len = s.length(); - for ( j = i; j < len; j++ ) { - if ( s.charAt( j ) == '"' && j + 1 < len ) { - if ( s.charAt( j + 1 ) == '"' ) { - j++; // skip escape char - } else if ( s.charAt( j + 1 ) == this.fieldSep ) { // next delimeter - j++; // skip end quotes - break; - } - } else if ( s.charAt( j ) == '"' && j + 1 == len ) { // end quotes at end of line - break; // done - } - sb.append( s.charAt( j ) ); // regular character. + continue; } - return j; - } - /** advPlain: unquoted field; return index of next separator */ - protected int advPlain(final String s, - final StringBuilder sb, - final int i) { - int j; - - j = s.indexOf( this.fieldSep, - i ); // look for separator - if ( j == -1 ) { // none found - sb.append( s.substring( i ) ); - return s.length(); - } else { - sb.append( s.substring( i, - j ) ); - return j; + if (currentChar == DELIMITER && !insideQuotes) { + fields.add(currentField.toString()); + currentField.setLength(0); + continue; } + + currentField.append(currentChar); } + // Add the last field + fields.add(currentField.toString()); + + return fields; } -} +} \ No newline at end of file diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV.drl.csv b/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV.drl.csv deleted file mode 100644 index cef622f4cd5..00000000000 --- a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV.drl.csv +++ /dev/null @@ -1,13 +0,0 @@ -, -"RuleSet","org.drools.decisiontable" -"Import","org.drools.decisiontable.Person" -"Notes", -, -"RuleTable Age change", -"CONDITION","ACTION" -"person:Person","person" -"age == $param","setAge($param)" -"age","new Age" -0,1 -1,2 -2,3 diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV.xml b/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV.xml deleted file mode 100644 index 564c5f98bd7..00000000000 --- a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV2.drl.csv b/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV2.drl.csv deleted file mode 100644 index 8008cef8f5c..00000000000 --- a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeSetTestCSV2.drl.csv +++ /dev/null @@ -1,12 +0,0 @@ -, -"RuleSet","org.drools.decisiontable" -"Import","org.drools.decisiontable.Person" -"Notes", -, -"RuleTable Age change", -"CONDITION","ACTION" -"person:Person","person" -"age == $param","setAge($param)" -"age","new Age" -0,1 -1,2 diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeset1Test.drl b/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeset1Test.drl deleted file mode 100644 index 214d04f7fc1..00000000000 --- a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeset1Test.drl +++ /dev/null @@ -1,29 +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.test - -global java.util.List list; - -rule "rule1" - salience 10 -when -then - list.add( "rule1" ); -end diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeset1Test.xml b/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeset1Test.xml deleted file mode 100644 index 549cb25cce5..00000000000 --- a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeset1Test.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeset2Test.drl b/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeset2Test.drl deleted file mode 100644 index 512277ab1b1..00000000000 --- a/drools-decisiontables/src/test/resources/org/drools/decisiontable/changeset2Test.drl +++ /dev/null @@ -1,29 +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.test - -global java.util.List list; - -rule "rule2" - salience 5 -when -then - list.add( "rule2" ); -end diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/multipleSheets.drl.xls b/drools-decisiontables/src/test/resources/org/drools/decisiontable/multipleSheets.drl.xls deleted file mode 100644 index 25c7f469118..00000000000 Binary files a/drools-decisiontables/src/test/resources/org/drools/decisiontable/multipleSheets.drl.xls and /dev/null differ diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/multipleSheetsChangeSet.xml b/drools-decisiontables/src/test/resources/org/drools/decisiontable/multipleSheetsChangeSet.xml deleted file mode 100644 index 8b0b87fc0a0..00000000000 --- a/drools-decisiontables/src/test/resources/org/drools/decisiontable/multipleSheetsChangeSet.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/scannerChangeSetTestCSV.drl.csv b/drools-decisiontables/src/test/resources/org/drools/decisiontable/scannerChangeSetTestCSV.drl.csv deleted file mode 100644 index cef622f4cd5..00000000000 --- a/drools-decisiontables/src/test/resources/org/drools/decisiontable/scannerChangeSetTestCSV.drl.csv +++ /dev/null @@ -1,13 +0,0 @@ -, -"RuleSet","org.drools.decisiontable" -"Import","org.drools.decisiontable.Person" -"Notes", -, -"RuleTable Age change", -"CONDITION","ACTION" -"person:Person","person" -"age == $param","setAge($param)" -"age","new Age" -0,1 -1,2 -2,3 diff --git a/drools-decisiontables/src/test/resources/org/drools/decisiontable/scannerChangeSetTestCSV.xml b/drools-decisiontables/src/test/resources/org/drools/decisiontable/scannerChangeSetTestCSV.xml deleted file mode 100644 index cb638d57c97..00000000000 --- a/drools-decisiontables/src/test/resources/org/drools/decisiontable/scannerChangeSetTestCSV.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - diff --git a/drools-model/drools-model-compiler/src/main/java/org/drools/modelcompiler/CanonicalKieModule.java b/drools-model/drools-model-compiler/src/main/java/org/drools/modelcompiler/CanonicalKieModule.java index f64be9e4257..b0d55434303 100644 --- a/drools-model/drools-model-compiler/src/main/java/org/drools/modelcompiler/CanonicalKieModule.java +++ b/drools-model/drools-model-compiler/src/main/java/org/drools/modelcompiler/CanonicalKieModule.java @@ -371,7 +371,7 @@ private List findProcesses(InternalKieModule kieModule, KieBaseModelImp List processResources = kieModule.getFileNames().stream() .filter(fileName -> { ResourceType resourceType = determineResourceType(fileName); - return resourceType == ResourceType.DRF || resourceType == ResourceType.BPMN2; + return resourceType == ResourceType.BPMN2; }) .map(fileName -> { final Resource processResource = kieModule.getResource(fileName); diff --git a/drools-test-coverage/test-compiler-integration/pom.xml b/drools-test-coverage/test-compiler-integration/pom.xml index b21878a9cf4..22e6b176072 100644 --- a/drools-test-coverage/test-compiler-integration/pom.xml +++ b/drools-test-coverage/test-compiler-integration/pom.xml @@ -119,26 +119,11 @@ xstream test - - org.junit.vintage - junit-vintage-engine - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.junit.jupiter - junit-jupiter-params - test - + + org.junit.jupiter + junit-jupiter + test + org.assertj assertj-core @@ -190,17 +175,6 @@ mockito-core test - - junit - junit - test - - - org.hamcrest - hamcrest-core - - - diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java index 53b1c746f18..4213446b7b6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java @@ -22,6 +22,7 @@ import java.io.ObjectOutput; import java.io.Serializable; import java.math.BigDecimal; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -37,6 +38,7 @@ import org.drools.core.RuleSessionConfiguration; import org.drools.commands.runtime.rule.InsertElementsCommand; import org.drools.kiesession.rulebase.InternalKnowledgeBase; +import org.drools.mvel.compiler.Primitives; import org.drools.testcoverage.common.model.Cheese; import org.drools.testcoverage.common.model.Cheesery; import org.drools.testcoverage.common.model.Order; @@ -3941,4 +3943,158 @@ public void testPeerCollectWithEager(KieBaseTestConfiguration kieBaseTestConfigu kieSession.dispose(); } } + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + void minWithBigDecimalHighAccuracy(KieBaseTestConfiguration kieBaseTestConfiguration) { + final String drl = + "import " + Primitives.class.getCanonicalName() + ";\n" + + "global java.util.List results;\n" + + "rule R1 when\n" + + " accumulate(Primitives($bd : bigDecimal), $min : min($bd))\n" + + "then\n" + + " results.add($min);\n" + + " results.add($min.scale());\n" + // BigDecimal method + "end"; + + final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); + final KieSession kieSession = kieBase.newKieSession(); + try { + List results = new ArrayList<>(); + kieSession.setGlobal("results", results); + Primitives p1 = new Primitives(); + p1.setBigDecimal(new BigDecimal("2024043020240501130000")); + Primitives p2_smallest = new Primitives(); + p2_smallest.setBigDecimal(new BigDecimal("2024043020240501120000")); + Primitives p3 = new Primitives(); + p3.setBigDecimal(new BigDecimal("2024043020240501150000")); + + kieSession.insert(p1); + kieSession.insert(p2_smallest); + kieSession.insert(p3); + kieSession.fireAllRules(); + assertThat(results).hasSize(2); + assertThat(results.get(0)).isEqualTo(p2_smallest.getBigDecimal()); + assertThat(results.get(1)).isEqualTo(0); + } finally { + kieSession.dispose(); + } + } + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + void minWithBigIntegerHighAccuracy(KieBaseTestConfiguration kieBaseTestConfiguration) { + final String drl = + "import " + Primitives.class.getCanonicalName() + ";\n" + + "global java.util.List results;\n" + + "rule R1 when\n" + + " accumulate(Primitives($bi : bigInteger), $min : min($bi))\n" + + "then\n" + + " results.add($min);\n" + + " results.add($min.nextProbablePrime());\n" + // BigInteger method + "end"; + + final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); + final KieSession kieSession = kieBase.newKieSession(); + try { + List results = new ArrayList<>(); + kieSession.setGlobal("results", results); + Primitives p1 = new Primitives(); + p1.setBigInteger(new BigInteger("2024043020240501130000")); + Primitives p2_smallest = new Primitives(); + p2_smallest.setBigInteger(new BigInteger("2024043020240501120000")); + Primitives p3 = new Primitives(); + p3.setBigInteger(new BigInteger("2024043020240501150000")); + + kieSession.insert(p1); + kieSession.insert(p2_smallest); + kieSession.insert(p3); + kieSession.fireAllRules(); + assertThat(results).hasSize(2); + assertThat(results.get(0)).isEqualTo(p2_smallest.getBigInteger()); + + // nextProbablePrime value is not important. + // Just to make sure it doesn't raise a compilation error. + assertThat(results.get(1)).isNotNull(); + } finally { + kieSession.dispose(); + } + } + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + void maxWithBigDecimalHighAccuracy(KieBaseTestConfiguration kieBaseTestConfiguration) { + final String drl = + "import " + Primitives.class.getCanonicalName() + ";\n" + + "global java.util.List results;\n" + + "rule R1 when\n" + + " accumulate(Primitives($bd : bigDecimal), $max : max($bd))\n" + + "then\n" + + " results.add($max);\n" + + " results.add($max.scale());\n" + // BigDecimal method + "end"; + + final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); + final KieSession kieSession = kieBase.newKieSession(); + try { + List results = new ArrayList<>(); + kieSession.setGlobal("results", results); + Primitives p1 = new Primitives(); + p1.setBigDecimal(new BigDecimal("2024043020240501130000")); + Primitives p2_largest = new Primitives(); + p2_largest.setBigDecimal(new BigDecimal("2024043020240501150000")); + Primitives p3 = new Primitives(); + p3.setBigDecimal(new BigDecimal("2024043020240501120000")); + + kieSession.insert(p1); + kieSession.insert(p2_largest); + kieSession.insert(p3); + kieSession.fireAllRules(); + assertThat(results).hasSize(2); + assertThat(results.get(0)).isEqualTo(p2_largest.getBigDecimal()); + assertThat(results.get(1)).isEqualTo(0); + } finally { + kieSession.dispose(); + } + } + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + void maxWithBigIntegerHighAccuracy(KieBaseTestConfiguration kieBaseTestConfiguration) { + final String drl = + "import " + Primitives.class.getCanonicalName() + ";\n" + + "global java.util.List results;\n" + + "rule R1 when\n" + + " accumulate(Primitives($bi : bigInteger), $max : max($bi))\n" + + "then\n" + + " results.add($max);\n" + + " results.add($max.nextProbablePrime());\n" + // BigInteger method + "end"; + + final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); + final KieSession kieSession = kieBase.newKieSession(); + try { + List results = new ArrayList<>(); + kieSession.setGlobal("results", results); + Primitives p1 = new Primitives(); + p1.setBigInteger(new BigInteger("2024043020240501130000")); + Primitives p2_largest = new Primitives(); + p2_largest.setBigInteger(new BigInteger("2024043020240501150000")); + Primitives p3 = new Primitives(); + p3.setBigInteger(new BigInteger("2024043020240501120000")); + + kieSession.insert(p1); + kieSession.insert(p2_largest); + kieSession.insert(p3); + kieSession.fireAllRules(); + assertThat(results).hasSize(2); + assertThat(results.get(0)).isEqualTo(p2_largest.getBigInteger()); + + // nextProbablePrime value is not important. + // Just to make sure it doesn't raise a compilation error. + assertThat(results.get(1)).isNotNull(); + } finally { + kieSession.dispose(); + } + } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/AccumulateFunctionConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/AccumulateFunctionConcurrencyTest.java index 9c7a1fa4733..4c9779e085f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/AccumulateFunctionConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/AccumulateFunctionConcurrencyTest.java @@ -22,10 +22,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; -import org.kie.test.testcategory.TurtleTestCategory; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class AccumulateFunctionConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceConcurrencyTest.java index b192f160728..f8e8b62786d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceConcurrencyTest.java @@ -24,11 +24,10 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.kie.api.runtime.KieSession; -import org.kie.test.testcategory.TurtleTestCategory; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class ConsequenceConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceWithAndOrConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceWithAndOrConcurrencyTest.java index e811c70862f..8f3c47a7ccb 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceWithAndOrConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceWithAndOrConcurrencyTest.java @@ -24,12 +24,11 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; -import org.kie.test.testcategory.TurtleTestCategory; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class ConsequenceWithAndOrConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintConcurrencyTest.java index 69fd08ccf18..eec7623760b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintConcurrencyTest.java @@ -22,10 +22,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; -import org.kie.test.testcategory.TurtleTestCategory; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class ConstraintConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrConcurrencyTest.java index 50ca5d67a78..50e75e351b4 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrConcurrencyTest.java @@ -22,12 +22,11 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; -import org.kie.test.testcategory.TurtleTestCategory; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class ConstraintWithAndOrConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrJittingConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrJittingConcurrencyTest.java index af9a55a3469..5d4f0d11028 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrJittingConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrJittingConcurrencyTest.java @@ -22,12 +22,11 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; -import org.kie.test.testcategory.TurtleTestCategory; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class ConstraintWithAndOrJittingConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/EvalConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/EvalConcurrencyTest.java index 09efce8f7e7..16e81d3d60e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/EvalConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/EvalConcurrencyTest.java @@ -22,10 +22,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; -import org.kie.test.testcategory.TurtleTestCategory; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class EvalConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/FromAccumulateConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/FromAccumulateConcurrencyTest.java index 339be050d48..7f87eb32a46 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/FromAccumulateConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/FromAccumulateConcurrencyTest.java @@ -22,10 +22,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; -import org.kie.test.testcategory.TurtleTestCategory; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class FromAccumulateConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/GlobalConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/GlobalConcurrencyTest.java index 0a82bfb97fe..e93b188c1e9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/GlobalConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/GlobalConcurrencyTest.java @@ -30,18 +30,17 @@ import org.drools.testcoverage.common.model.Result; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; -import org.kie.test.testcategory.TurtleTestCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.assertj.core.api.Assertions.assertThat; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class GlobalConcurrencyTest { private static final Logger LOGGER = LoggerFactory.getLogger(GlobalConcurrencyTest.class); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELDateClassFieldReaderConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELDateClassFieldReaderConcurrencyTest.java index d751b4e4f6c..92c59a973fd 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELDateClassFieldReaderConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELDateClassFieldReaderConcurrencyTest.java @@ -23,11 +23,10 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.kie.api.runtime.KieSession; -import org.kie.test.testcategory.TurtleTestCategory; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class MVELDateClassFieldReaderConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELNumberClassFieldReaderConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELNumberClassFieldReaderConcurrencyTest.java index ea641d9f16d..24e44e21ca4 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELNumberClassFieldReaderConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELNumberClassFieldReaderConcurrencyTest.java @@ -22,11 +22,10 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.kie.api.runtime.KieSession; -import org.kie.test.testcategory.TurtleTestCategory; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class MVELNumberClassFieldReaderConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELObjectClassFieldReaderConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELObjectClassFieldReaderConcurrencyTest.java index 93a41e05874..75824f39f8e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELObjectClassFieldReaderConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELObjectClassFieldReaderConcurrencyTest.java @@ -22,11 +22,10 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.kie.api.runtime.KieSession; -import org.kie.test.testcategory.TurtleTestCategory; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class MVELObjectClassFieldReaderConcurrencyTest extends BaseConcurrencyTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AbstractAddRemoveGenerated2RulesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AbstractAddRemoveGenerated2RulesTest.java index 83820fc62e8..584e2a21200 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AbstractAddRemoveGenerated2RulesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AbstractAddRemoveGenerated2RulesTest.java @@ -26,17 +26,18 @@ import java.util.Map; import java.util.Set; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.kie.test.testcategory.TurtleTestCategory; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public abstract class AbstractAddRemoveGenerated2RulesTest { - private final String rule1; - private final String rule2; + private String rule1; + private String rule2; - public AbstractAddRemoveGenerated2RulesTest(final ConstraintsPair constraintsPair) { + private void generateRules(final ConstraintsPair constraintsPair) { final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -59,11 +60,11 @@ public AbstractAddRemoveGenerated2RulesTest(final ConstraintsPair constraintsPai // This takes only three different constraints - this is intentional, because it is needed to // keep the number of combinations at reasonable number. - public static Collection generateRulesConstraintsCombinations(final String constraint1, + public static Collection generateRulesConstraintsCombinations(final String constraint1, final String constraint2, final String constraint3) { final Set constraintsPairs = new HashSet<>(); - final List result = new ArrayList<>(); + final List result = new ArrayList<>(); final List constraintsList = new ArrayList<>(); constraintsList.add(constraint1); @@ -75,7 +76,7 @@ public static Collection generateRulesConstraintsCombinations for (final String constraintsRule2 : constraintsCombinations) { final ConstraintsPair constraintsPair = new ConstraintsPair(constraintsRule1, constraintsRule2); if (constraintsPairs.add(constraintsPair)) { - result.add(new ConstraintsPair[]{constraintsPair}); + result.add(constraintsPair); } } } @@ -98,57 +99,81 @@ private static List getConstraintsCombinations(final List constr /////////////////////////// TESTS ////////////////////////////////// - @Test(timeout = 40000) - public void testInsertFactsFireRulesRemoveRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testInsertFactsFireRulesRemoveRules(ConstraintsPair constraintsPair) { + generateRules(constraintsPair); AddRemoveTestCases.insertFactsFireRulesRemoveRules1(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); AddRemoveTestCases.insertFactsFireRulesRemoveRules2(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); AddRemoveTestCases.insertFactsFireRulesRemoveRules3(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); } - @Test(timeout = 40000) - public void testInsertFactsFireRulesRemoveRulesRevertedRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testInsertFactsFireRulesRemoveRulesRevertedRules(ConstraintsPair constraintsPair) { + generateRules(constraintsPair); AddRemoveTestCases.insertFactsFireRulesRemoveRules1(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); AddRemoveTestCases.insertFactsFireRulesRemoveRules2(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); AddRemoveTestCases.insertFactsFireRulesRemoveRules3(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); } - @Test(timeout = 40000) - public void testFireRulesInsertFactsFireRulesRemoveRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testFireRulesInsertFactsFireRulesRemoveRules(ConstraintsPair constraintsPair) { + generateRules(constraintsPair); AddRemoveTestCases.fireRulesInsertFactsFireRulesRemoveRules1(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); AddRemoveTestCases.fireRulesInsertFactsFireRulesRemoveRules2(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); AddRemoveTestCases.fireRulesInsertFactsFireRulesRemoveRules3(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); } - @Test(timeout = 40000) - public void testFireRulesInsertFactsFireRulesRemoveRulesRevertedRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testFireRulesInsertFactsFireRulesRemoveRulesRevertedRules(ConstraintsPair constraintsPair) { + generateRules(constraintsPair); AddRemoveTestCases.fireRulesInsertFactsFireRulesRemoveRules1(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); AddRemoveTestCases.fireRulesInsertFactsFireRulesRemoveRules2(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); AddRemoveTestCases.fireRulesInsertFactsFireRulesRemoveRules3(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); } - @Test(timeout = 40000) - public void testInsertFactsRemoveRulesFireRulesRemoveRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testInsertFactsRemoveRulesFireRulesRemoveRules(ConstraintsPair constraintsPair) { + generateRules(constraintsPair); AddRemoveTestCases.insertFactsRemoveRulesFireRulesRemoveRules1(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); AddRemoveTestCases.insertFactsRemoveRulesFireRulesRemoveRules2(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); AddRemoveTestCases.insertFactsRemoveRulesFireRulesRemoveRules3(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); } - @Test(timeout = 40000) - public void testInsertFactsRemoveRulesFireRulesRemoveRulesRevertedRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testInsertFactsRemoveRulesFireRulesRemoveRulesRevertedRules(ConstraintsPair constraintsPair) { + generateRules(constraintsPair); AddRemoveTestCases.insertFactsRemoveRulesFireRulesRemoveRules1(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); AddRemoveTestCases.insertFactsRemoveRulesFireRulesRemoveRules2(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); AddRemoveTestCases.insertFactsRemoveRulesFireRulesRemoveRules3(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); } - @Test(timeout = 40000) - public void testInsertFactsFireRulesRemoveRulesReinsertRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testInsertFactsFireRulesRemoveRulesReinsertRules(ConstraintsPair constraintsPair) { + generateRules(constraintsPair); AddRemoveTestCases.insertFactsFireRulesRemoveRulesReinsertRules1(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); AddRemoveTestCases.insertFactsFireRulesRemoveRulesReinsertRules2(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); AddRemoveTestCases.insertFactsFireRulesRemoveRulesReinsertRules3(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFacts()); } - @Test(timeout = 40000) - public void testInsertFactsFireRulesRemoveRulesReinsertRulesRevertedRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testInsertFactsFireRulesRemoveRulesReinsertRulesRevertedRules(ConstraintsPair constraintsPair) { + generateRules(constraintsPair); AddRemoveTestCases.insertFactsFireRulesRemoveRulesReinsertRules1(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); AddRemoveTestCases.insertFactsFireRulesRemoveRulesReinsertRules2(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); AddRemoveTestCases.insertFactsFireRulesRemoveRulesReinsertRules3(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFacts()); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesEval2Test.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesEval2Test.java index 1dc4b164ad6..72410a776ef 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesEval2Test.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesEval2Test.java @@ -18,20 +18,12 @@ */ package org.drools.compiler.integrationtests.incrementalcompilation; -import java.util.Collection; +import java.util.stream.Stream; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) public class AddRemoveGenerated2RulesEval2Test extends AbstractAddRemoveGenerated2RulesTest { - public AddRemoveGenerated2RulesEval2Test(final ConstraintsPair constraintsPair) { - super(constraintsPair); - } - @Parameterized.Parameters - public static Collection getRulesConstraints() { + public static Stream parameters() { // Placeholder is replaced by actual variable name during constraints generation. // This is needed, because when generator generates the same constraint 3-times for a rule, // in each constraint must be different variable name, so Drools can process it @@ -39,6 +31,6 @@ public static Collection getRulesConstraints() { return generateRulesConstraintsCombinations( " Integer() \n", " ${variableNamePlaceholder}: Integer() eval(${variableNamePlaceholder} == 1) \n", - " ${variableNamePlaceholder}: Integer() and (eval(true) or eval(${variableNamePlaceholder} == 1) )\n"); + " ${variableNamePlaceholder}: Integer() and (eval(true) or eval(${variableNamePlaceholder} == 1) )\n").stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesEvalTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesEvalTest.java index e94029ef2e9..9470289315c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesEvalTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesEvalTest.java @@ -18,20 +18,13 @@ */ package org.drools.compiler.integrationtests.incrementalcompilation; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; -import java.util.Collection; +import org.junit.jupiter.api.Disabled; -@RunWith(Parameterized.class) public class AddRemoveGenerated2RulesEvalTest extends AbstractAddRemoveGenerated2RulesTest { - public AddRemoveGenerated2RulesEvalTest(final ConstraintsPair constraintsPair) { - super(constraintsPair); - } - - @Parameterized.Parameters - public static Collection getRulesConstraints() { + public static Stream parameters() { // Placeholder is replaced by actual variable name during constraints generation. // This is needed, because when generator generates the same constraint 3-times for a rule, // in each constraint must be different variable name, so Drools can process it @@ -39,6 +32,6 @@ public static Collection getRulesConstraints() { return generateRulesConstraintsCombinations( " Integer() \n", " ${variableNamePlaceholder}: Integer() eval(${variableNamePlaceholder} == 1) \n", - " exists(Integer() and exists(Integer() and Integer())) \n"); + " exists(Integer() and exists(Integer() and Integer())) \n").stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesIntegerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesIntegerTest.java index ca858cceab8..2ed797c431f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesIntegerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesIntegerTest.java @@ -18,23 +18,16 @@ */ package org.drools.compiler.integrationtests.incrementalcompilation; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; -import java.util.Collection; +import org.junit.jupiter.api.Disabled; -@RunWith(Parameterized.class) public class AddRemoveGenerated2RulesIntegerTest extends AbstractAddRemoveGenerated2RulesTest { - public AddRemoveGenerated2RulesIntegerTest(final ConstraintsPair constraintsPair) { - super(constraintsPair); - } - - @Parameterized.Parameters - public static Collection getRulesConstraints() { + public static Stream parameters() { return generateRulesConstraintsCombinations( " Integer() \n", " exists(Integer() and Integer()) \n", - " exists(Integer() and exists(Integer() and Integer())) \n"); + " exists(Integer() and exists(Integer() and Integer())) \n").stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesMapContainsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesMapContainsTest.java index e8225928f75..f2188f23da7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesMapContainsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesMapContainsTest.java @@ -18,23 +18,16 @@ */ package org.drools.compiler.integrationtests.incrementalcompilation; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; -import java.util.Collection; +import org.junit.jupiter.api.Disabled; -@RunWith(Parameterized.class) public class AddRemoveGenerated2RulesMapContainsTest extends AbstractAddRemoveGenerated2RulesTest { - public AddRemoveGenerated2RulesMapContainsTest(final ConstraintsPair constraintsPair) { - super(constraintsPair); - } - - @Parameterized.Parameters - public static Collection getRulesConstraints() { + public static Stream parameters() { return generateRulesConstraintsCombinations( " java.util.Map(values() contains \"1\") \n", " Integer() \n", - " exists(Integer() and exists(Integer() and Integer())) \n"); + " exists(Integer() and exists(Integer() and Integer())) \n").stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotNotTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotNotTest.java index 9e35af06fef..161c91cd728 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotNotTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotNotTest.java @@ -18,23 +18,16 @@ */ package org.drools.compiler.integrationtests.incrementalcompilation; -import java.util.Collection; +import java.util.stream.Stream; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Disabled; -@RunWith(Parameterized.class) public class AddRemoveGenerated2RulesNotNotTest extends AbstractAddRemoveGenerated2RulesTest { - public AddRemoveGenerated2RulesNotNotTest(final ConstraintsPair constraintsPair) { - super(constraintsPair); - } - - @Parameterized.Parameters - public static Collection getRulesConstraints() { + public static Stream parameters() { return generateRulesConstraintsCombinations( " Integer() \n", " Integer() not(not(exists(Integer() and Integer()))) \n", - " exists(Integer() and exists(Integer() and Integer())) \n"); + " exists(Integer() and exists(Integer() and Integer())) \n").stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotTest.java index 86887457a05..e83554563b4 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotTest.java @@ -18,23 +18,16 @@ */ package org.drools.compiler.integrationtests.incrementalcompilation; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; -import java.util.Collection; +import org.junit.jupiter.api.Disabled; -@RunWith(Parameterized.class) public class AddRemoveGenerated2RulesNotTest extends AbstractAddRemoveGenerated2RulesTest { - public AddRemoveGenerated2RulesNotTest(final ConstraintsPair constraintsPair) { - super(constraintsPair); - } - - @Parameterized.Parameters - public static Collection getRulesConstraints() { + public static Stream parameters() { return generateRulesConstraintsCombinations( " Integer() \n", " Integer() not(exists(Double() and Double())) \n", - " exists(Integer() and exists(Integer() and Integer())) \n"); + " exists(Integer() and exists(Integer() and Integer())) \n").stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesStringIntegerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesStringIntegerTest.java index 881249e4ecb..e2b49a60133 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesStringIntegerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesStringIntegerTest.java @@ -18,23 +18,16 @@ */ package org.drools.compiler.integrationtests.incrementalcompilation; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; -import java.util.Collection; +import org.junit.jupiter.api.Disabled; -@RunWith(Parameterized.class) public class AddRemoveGenerated2RulesStringIntegerTest extends AbstractAddRemoveGenerated2RulesTest { - public AddRemoveGenerated2RulesStringIntegerTest(final ConstraintsPair constraintsPair) { - super(constraintsPair); - } - - @Parameterized.Parameters - public static Collection getRulesConstraints() { + public static Stream parameters() { return generateRulesConstraintsCombinations( " String() \n", " exists(Integer() and Integer()) \n", - " exists(Integer() and exists(Integer() and Integer())) \n"); + " exists(Integer() and exists(Integer() and Integer())) \n").stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesStringTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesStringTest.java index 6c7aedb479a..28bc702b4de 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesStringTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesStringTest.java @@ -18,23 +18,16 @@ */ package org.drools.compiler.integrationtests.incrementalcompilation; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; -import java.util.Collection; +import org.junit.jupiter.api.Disabled; -@RunWith(Parameterized.class) public class AddRemoveGenerated2RulesStringTest extends AbstractAddRemoveGenerated2RulesTest { - public AddRemoveGenerated2RulesStringTest(final ConstraintsPair constraintsPair) { - super(constraintsPair); - } - - @Parameterized.Parameters - public static Collection getRulesConstraints() { + public static Stream parameters() { return generateRulesConstraintsCombinations( " String() \n", " exists(String() and String()) \n", - " exists(String() and exists(String() and String())) \n"); + " exists(String() and exists(String() and String())) \n").stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesAddDeleteFactsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesAddDeleteFactsTest.java index b1b3fd89f11..98f490c8daf 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesAddDeleteFactsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesAddDeleteFactsTest.java @@ -24,30 +24,21 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Stream; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; -import org.kie.test.testcategory.TurtleTestCategory; import static org.assertj.core.api.Assertions.assertThat; -@Category(TurtleTestCategory.class) -@RunWith(Parameterized.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class AddRemoveRulesAddDeleteFactsTest { - private final StringPermutation rulesPermutation; - - public AddRemoveRulesAddDeleteFactsTest(final StringPermutation rulesPermutation) { - this.rulesPermutation = rulesPermutation; - } - - @Parameterized.Parameters - public static Collection getRulesPermutations() { - final Collection rulesPermutations = new HashSet<>(); + public static Stream parameters() { + final Collection rulesPermutations = new HashSet<>(); final Set parametersPermutations = new HashSet<>(); getStringPermutations( @@ -56,14 +47,15 @@ public static Collection getRulesPermutations() { parametersPermutations); for (final StringPermutation permutation : parametersPermutations) { - rulesPermutations.add(new StringPermutation[]{permutation}); + rulesPermutations.add(permutation); } - return rulesPermutations; + return rulesPermutations.stream(); } - @Test - public void testAddRemoveRulesAddRemoveFacts() { + @ParameterizedTest + @MethodSource("parameters") + public void testAddRemoveRulesAddRemoveFacts(StringPermutation rulesPermutation) { final KieSession kieSession = TestUtil.buildSessionInSteps(getRules()); try { final List resultsList = new ArrayList<>(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesAdvOperatorsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesAdvOperatorsTest.java index 28fb1e431c6..45465d3ffc7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesAdvOperatorsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesAdvOperatorsTest.java @@ -24,18 +24,18 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.kie.api.runtime.KieSession; -import org.kie.test.testcategory.TurtleTestCategory; import static org.assertj.core.api.Assertions.assertThat; /** * Tests adding and removing rules with advanced operators. */ -@Category(TurtleTestCategory.class) +@EnabledIfEnvironmentVariable(named = "runTurtleTests", matches = "*") public class AddRemoveRulesAdvOperatorsTest { @Test @@ -551,7 +551,8 @@ public void testAddRemoveRuleWithMemberOfAndNotMemberOfAndExists() { AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf(memberString), memberString, "fact"); } - @Test @Ignore + @Test + @Disabled public void testAddRemoveRuleWithContainsMatchesExists() { final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List memberList\n" + @@ -656,7 +657,8 @@ public void testAddRemoveRuleContainsExists3Rules() { } } - @Test(timeout = 10000L) + @Test + @Timeout(10000L) public void testAddRemoveRuleContainsExists3RulesDoubledExists() { final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesTest.java index e902c3d94b1..b62df047175 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesTest.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.core.common.InternalFactHandle; import org.drools.core.reteoo.LeftTuple; @@ -35,11 +36,9 @@ import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +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.ReleaseId; @@ -58,18 +57,10 @@ import static org.assertj.core.api.Assertions.fail; import static org.drools.core.util.DroolsTestUtil.rulestoMap; -@RunWith(Parameterized.class) public class AddRemoveRulesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AddRemoveRulesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private InternalKnowledgeBase base = KnowledgeBaseFactory.newKnowledgeBase(); @@ -88,8 +79,7 @@ private String getPrefix() { "end\n\n"; } - @Before - public void createEmptyKnowledgeBase() { + public void createEmptyKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieServices kieServices = KieServices.get(); final ReleaseId releaseId = kieServices.newReleaseId("org.kie", "test-add-remove-rules", "1.0"); KieUtil.getKieModuleFromDrls(releaseId, kieBaseTestConfiguration); @@ -126,8 +116,10 @@ private void addKnowledgeToBase(final Collection pkgs) { this.base.addPackages( pkgs ); } - @Test - public void test() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final KieSession knowledgeSession = base.newKieSession(); knowledgeSession.fireAllRules(); @@ -227,9 +219,11 @@ public void test() { assertThat(TestUtil.getRulesCount(base)).isEqualTo(8); } - @Test - public void testAddRemoveFromKB() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRemoveFromKB(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-328 + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String drl = "\n" + "rule A\n" + " when\n" + @@ -279,9 +273,11 @@ public void testAddRemoveFromKB() { ((InternalKnowledgeBase) kSession.getKieBase()).addPackages(kbuilder.getKnowledgePackages()); } - @Test - public void testAddRemoveDeletingFact() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRemoveDeletingFact(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-328 + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String drl = "\n" + "rule B\n" + " when\n" + @@ -304,8 +300,10 @@ public void testAddRemoveDeletingFact() { kSession.delete(fh); } - @Test - public void testAddRemoveWithPartialSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRemoveWithPartialSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String drl = "package org.drools.test; \n" + "\n" + "declare A end \n" + @@ -349,8 +347,10 @@ public void testAddRemoveWithPartialSharing() { kSession.fireAllRules(); } - @Test - public void testAddRemoveWithReloadInSamePackage_4Rules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRemoveWithReloadInSamePackage_4Rules(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String drl = "package org.drools.test;\n" + "declare Fakt enabled : boolean end \n" + @@ -391,8 +391,10 @@ public void testAddRemoveWithReloadInSamePackage_4Rules() { testAddRemoveWithReloadInSamePackage(drl); } - @Test - public void testAddRemoveWithReloadInSamePackage_3Rules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRemoveWithReloadInSamePackage_3Rules(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String drl = "package org.drools.test;\n" + "declare Fakt enabled : boolean end \n" + @@ -428,8 +430,10 @@ public void testAddRemoveWithReloadInSamePackage_3Rules() { } - @Test - public void testAddRemoveWithReloadInSamePackage_EntryPoints() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRemoveWithReloadInSamePackage_EntryPoints(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String drl = "package org.drools.test; \n" + "rule \"Input_X\"\n" + @@ -463,8 +467,10 @@ public void testAddRemoveWithReloadInSamePackage_EntryPoints() { testAddRemoveWithReloadInSamePackage(drl); } - @Test - public void testAddRemoveWithReloadInSamePackage_EntryPointsVariety() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRemoveWithReloadInSamePackage_EntryPointsVariety(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String drl = "package org.drools.test; \n" + "rule \"Input_X\"\n" + @@ -517,8 +523,10 @@ private void testAddRemoveWithReloadInSamePackage(final String drl) { assertThat(list).isEqualTo(Collections.singletonList("ok")); } - @Test - public void testRemoveWithDuplicatedCondition() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithDuplicatedCondition(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String packageName = "test_same_condition_pk" ; final String rule = "package " + packageName + ";" + "rule 'test_same_condition' \n" + @@ -533,8 +541,10 @@ public void testRemoveWithDuplicatedCondition() { base.removeKiePackage(packageName); } - @Test - public void testFireAfterRemoveDuplicatedConditionInDifferentPackages() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireAfterRemoveDuplicatedConditionInDifferentPackages(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String packageName = "test_same_condition_pk" ; final String packageName2 = "test_same_condition_pk_2" ; final String rule1 = "package " + packageName + ";" + @@ -563,8 +573,10 @@ public void testFireAfterRemoveDuplicatedConditionInDifferentPackages() { session.fireAllRules(); } - @Test - public void testAddRemoveWithExtends() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRemoveWithExtends(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String packageName = "test_same_condition_pk" ; final String rule1 = "package " + packageName + ";" + "import java.util.Map; \n" + @@ -599,9 +611,11 @@ public void testAddRemoveWithExtends() { } } - @Test - public void testRemoveHasSameConElement() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveHasSameConElement(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-891 + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String packageName = "test"; final String rule1 = "package " + packageName + ";" + "import java.util.Map; \n" + @@ -620,8 +634,9 @@ public void testRemoveHasSameConElement() { session.execute(new HashMap()); } - @Test - public void testFireAfterRemoveWithSameCondition() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireAfterRemoveWithSameCondition(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-893 final String packageName = "pk1"; final String packageName2 = "pk2"; @@ -668,9 +683,11 @@ public void testFireAfterRemoveWithSameCondition() { ksession.fireAllRules(); } - @Test - public void testSameEval() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSameEval(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-893 + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1Name = "rule1"; final String rule2Name = "rule2"; @@ -697,9 +714,11 @@ public void testSameEval() { statelessSession.execute(new Object()); } - @Test - public void testFireAfterRemoveRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireAfterRemoveRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-893 + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1Name = "rule1"; final String rule2Name = "rule2"; @@ -737,8 +756,10 @@ public void testFireAfterRemoveRule() { session.execute(fact); } - @Test - public void testRemoveWithSameRuleNameInDiffPackage() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSameRuleNameInDiffPackage(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String packageName = "pk1"; final String packageName2 = "pk2"; final String rule1Name = "rule1"; @@ -766,8 +787,10 @@ public void testRemoveWithSameRuleNameInDiffPackage() { session.fireAllRules(); } - @Test - public void testRemoveWithSplitStartAtLianAndFollowedBySubNetworkNoSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartAtLianAndFollowedBySubNetworkNoSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String packageName = "pk1"; final String rule1 = "package " + packageName + ";" + @@ -790,8 +813,10 @@ public void testRemoveWithSplitStartAtLianAndFollowedBySubNetworkNoSharing() { session.getKieBase().removeKiePackage(packageName); } - @Test - public void testRemoveExistsPopulatedByInitialFact() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveExistsPopulatedByInitialFact(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule R1 when\n" + @@ -813,8 +838,10 @@ public void testRemoveExistsPopulatedByInitialFact() { AddRemoveTestCases.insertFactsRemoveFire(base, rule1, rule2, null, TestUtil.getDefaultFacts()); } - @Test - public void testAddSplitInSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddSplitInSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule R1 when\n" + @@ -836,8 +863,10 @@ public void testAddSplitInSubnetwork() { AddRemoveTestCases. insertFactsRemoveFire(base, rule1, rule2, null, TestUtil.getDefaultFacts()); } - @Test - public void testRemoveWithSplitStartAtLianAndFollowedBySubNetworkWithSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartAtLianAndFollowedBySubNetworkWithSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "global java.util.List list\n" + @@ -863,9 +892,11 @@ public void testRemoveWithSplitStartAtLianAndFollowedBySubNetworkWithSharing() { testRemoveWithSplitStartBasicTestSet(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME); } - @Test - public void testRemoveWithSplitStartBeforeJoinAndFollowedBySubNetworkWithSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartBeforeJoinAndFollowedBySubNetworkWithSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { // moved the split start to after the Integer + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "global java.util.List list\n" + @@ -894,9 +925,11 @@ public void testRemoveWithSplitStartBeforeJoinAndFollowedBySubNetworkWithSharing testRemoveWithSplitStartBasicTestSet(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME); } - @Test - public void testRemoveWithSplitStartAtJoinAndFollowedBySubNetworkWithSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartAtJoinAndFollowedBySubNetworkWithSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { // moved the split start to after the Integer + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "global java.util.List list\n" + @@ -924,8 +957,10 @@ public void testRemoveWithSplitStartAtJoinAndFollowedBySubNetworkWithSharing() { testRemoveWithSplitStartBasicTestSet(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME); } - @Test - public void testRemoveWithSplitStartSameRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartSameRules(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "global java.util.List list\n" + @@ -953,8 +988,10 @@ public void testRemoveWithSplitStartSameRules() { testRemoveWithSplitStartBasicTestSet(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME); } - @Test //(timeout=2000) - public void testRemoveWithSplitStartDoubledExistsConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartDoubledExistsConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "global java.util.List list\n" + @@ -983,8 +1020,10 @@ public void testRemoveWithSplitStartDoubledExistsConstraint() { testRemoveWithSplitStartBasicTestSet(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME); } - @Test - public void testRemoveWithSplitStartDoubledIntegerConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartDoubledIntegerConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "global java.util.List list\n" + @@ -1013,8 +1052,10 @@ public void testRemoveWithSplitStartDoubledIntegerConstraint() { testRemoveWithSplitStartBasicTestSet(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME); } - @Test - public void testRemoveWithSplitStartAfterSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartAfterSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "global java.util.List list\n" + @@ -1043,8 +1084,10 @@ public void testRemoveWithSplitStartAfterSubnetwork() { testRemoveWithSplitStartBasicTestSet(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME); } - @Test - public void testRemoveWithSplitStartAfterSubnetwork3Rules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartAfterSubnetwork3Rules(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "global java.util.List list\n" + @@ -1100,8 +1143,10 @@ public void testRemoveWithSplitStartAfterSubnetwork3Rules() { } } - @Test - public void testRemoveWithSplitStartAfterSubnetwork3RulesAddOneAfterAnother() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartAfterSubnetwork3RulesAddOneAfterAnother(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "global java.util.List list\n" + @@ -1168,8 +1213,10 @@ public void testRemoveWithSplitStartAfterSubnetwork3RulesAddOneAfterAnother() { } } - @Test - public void testRemoveWithSplitStartAfterSubnetwork3RulesReaddRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveWithSplitStartAfterSubnetwork3RulesReaddRule(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1268,8 +1315,10 @@ private String[] getRules2Pattern() { return new String[] { rule1, rule2 }; } - @Test - public void testRemoveRuleChangeFHFirstLeftTuple() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRuleChangeFHFirstLeftTuple(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String[] rules = getRules1Pattern(); final KieSession kieSession = TestUtil.buildSessionInSteps(base, rules); @@ -1290,8 +1339,10 @@ public void testRemoveRuleChangeFHFirstLeftTuple() { } } - @Test - public void testRemoveRuleChangeFHLastLeftTuple() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRuleChangeFHLastLeftTuple(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String[] rules = getRules1Pattern(); final KieSession kieSession = TestUtil.buildSessionInSteps(base, rules); @@ -1312,8 +1363,10 @@ public void testRemoveRuleChangeFHLastLeftTuple() { } } - @Test - public void testRemoveRightTupleThatWasFirst() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRightTupleThatWasFirst(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String[] rules = getRules2Pattern(); final KieSession kieSession = TestUtil.buildSessionInSteps(base, rules); @@ -1337,8 +1390,10 @@ public void testRemoveRightTupleThatWasFirst() { } } - @Test - public void testRemoveRightTupleThatWasLast() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRightTupleThatWasLast(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String[] rules = getRules2Pattern(); final KieSession kieSession = TestUtil.buildSessionInSteps(base, rules); @@ -1400,8 +1455,10 @@ private String[] getRules3Pattern() { return new String[] { rule1, rule2, rule3 }; } - @Test - public void testRemoveChildLeftTupleThatWasFirst() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveChildLeftTupleThatWasFirst(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String[] rules = getRules3Pattern(); final KieSession kieSession = TestUtil.buildSessionInSteps(base, rules[0], rules[1]); @@ -1427,8 +1484,10 @@ public void testRemoveChildLeftTupleThatWasFirst() { } } - @Test - public void testRemoveChildLeftTupleThatWasLast() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveChildLeftTupleThatWasLast(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String[] rules = getRules3Pattern(); final KieSession kieSession = TestUtil.buildSessionInSteps(base, rules[0], rules[1]); @@ -1454,8 +1513,10 @@ public void testRemoveChildLeftTupleThatWasLast() { } } - @Test - public void testRemoveChildLeftTupleThatWasMiddle() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveChildLeftTupleThatWasMiddle(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String[] rules = getRules3Pattern(); final KieSession kieSession = TestUtil.buildSessionInSteps(base, rules); @@ -1484,8 +1545,10 @@ public void testRemoveChildLeftTupleThatWasMiddle() { } } - @Test - public void testRemoveChildLeftTupleThatWasFirstWithMultipleData() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveChildLeftTupleThatWasFirstWithMultipleData(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String[] rules = getRules3Pattern(); final KieSession kieSession = TestUtil.buildSessionInSteps(base, rules[0], rules[1]); @@ -1559,8 +1622,10 @@ public void testRemoveChildLeftTupleThatWasFirstWithMultipleData() { } } - @Test - public void testRemoveChildLeftTupleThatWasLastWithMultipleData() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveChildLeftTupleThatWasLastWithMultipleData(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String[] rules = getRules3Pattern(); final KieSession kieSession = TestUtil.buildSessionInSteps(base, rules[0], rules[1]); @@ -1643,8 +1708,10 @@ private void testRemoveWithSplitStartBasicTestSet(final String rule1, final Stri AddRemoveTestCases.runAllTestCases(base, rule2, rule1, rule2Name, rule1Name, additionalGlobals,1, 2, "1"); } - @Test - public void testMergeRTN() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMergeRTN(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1684,8 +1751,10 @@ public void testMergeRTN() { } } - @Test - public void testSubSubNetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubSubNetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1725,8 +1794,10 @@ public void testSubSubNetwork() { } } - @Test - public void testSubSubNetwork2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubSubNetwork2(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1762,8 +1833,10 @@ public void testSubSubNetwork2() { } } - @Test - public void testSubSubNetwork3() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubSubNetwork3(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1802,8 +1875,10 @@ public void testSubSubNetwork3() { } } - @Test - public void testSubSubNetwork4() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubSubNetwork4(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1839,8 +1914,10 @@ public void testSubSubNetwork4() { } } - @Test - public void testSubNetworkWithNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubNetworkWithNot(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1875,8 +1952,10 @@ public void testSubNetworkWithNot() { } } - @Test - public void testSubNetworkWithNot2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubNetworkWithNot2(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1912,8 +1991,10 @@ public void testSubNetworkWithNot2() { } } - @Test - public void testSubNetworkWithNot3() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubNetworkWithNot3(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1947,8 +2028,10 @@ public void testSubNetworkWithNot3() { } } - @Test - public void testSubNetworkWithNot4() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubNetworkWithNot4(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -1986,8 +2069,10 @@ public void testSubNetworkWithNot4() { } } - @Test - public void testInsertFireRemoveWith2Nots() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsertFireRemoveWith2Nots(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + @@ -2023,8 +2108,10 @@ public void testInsertFireRemoveWith2Nots() { } } - @Test - public void testSubSubNetwork5() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubSubNetwork5(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" + "global java.util.List list\n" + "rule " + TestUtil.RULE1_NAME + " \n" + @@ -2059,8 +2146,10 @@ public void testSubSubNetwork5() { } } - @Test - public void testInsertRemoveFireWith2Nots() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsertRemoveFireWith2Nots(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + @@ -2095,9 +2184,10 @@ public void testInsertRemoveFireWith2Nots() { } } - @Test - public void testSharedRian() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedRian(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + @@ -2131,9 +2221,10 @@ public void testSharedRian() { } } - @Test - public void testSharedRianWithFire() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedRianWithFire(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + @@ -2168,9 +2259,10 @@ public void testSharedRianWithFire() { } } - @Test - public void testSharedRian2() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedRian2(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + @@ -2208,8 +2300,10 @@ public void testSharedRian2() { } } - @Test - public void testRemoveRuleWithSharedRia() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRuleWithSharedRia(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1Name = "rule1"; final String rule2Name = "rule2"; final String rule1 = "rule " + rule1Name + " \n" + @@ -2243,9 +2337,11 @@ public void testRemoveRuleWithSharedRia() { assertThat(tuple.getPeer()).isNull(); } - @Test - public void testAddRemoveFacts() { - final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRemoveFacts(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); + final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + " when \n" + @@ -2282,9 +2378,10 @@ public void testAddRemoveFacts() { } } - @Test - public void testReaddRulesSharedRianDoubleNots() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReaddRulesSharedRianDoubleNots(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + @@ -2322,9 +2419,10 @@ public void testReaddRulesSharedRianDoubleNots() { } } - @Test - public void testOr() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOr(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + @@ -2363,9 +2461,10 @@ public void testOr() { } } - @Test - public void testOr2() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOr2(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + @@ -2411,9 +2510,10 @@ public void testOr2() { } } - @Test - public void testEvals() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvals(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = " package " + TestUtil.RULES_PACKAGE_NAME + ";\n" + " global java.util.List list\n" + " rule " + TestUtil.RULE1_NAME + " \n" + @@ -2451,9 +2551,10 @@ public void testEvals() { } } - @Test - public void testPathMemoryInitialization() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPathMemoryInitialization(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package com.rules;global java.util.List list\n" + "rule R1 \n" + " when \n" + @@ -2499,9 +2600,10 @@ public void testPathMemoryInitialization() { assertThat(globalList).isEmpty(); } - @Test - public void testBuildKieBaseIncrementally() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBuildKieBaseIncrementally(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package com.rules;global java.util.List list\n" + "rule R1 \n" + " when \n" + @@ -2538,9 +2640,10 @@ public void testBuildKieBaseIncrementally() { assertThat(globalList).contains("R1", "R2"); } - @Test - public void testBuildKieBaseIncrementally2() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBuildKieBaseIncrementally2(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package com.rules;global java.util.List list\n" + "rule R1 \n" + " when \n" + @@ -2582,9 +2685,10 @@ public void testBuildKieBaseIncrementally2() { assertThat(globalList).contains("R1", "R2"); } - @Test - public void testBuildKieBaseIncrementally3() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBuildKieBaseIncrementally3(KieBaseTestConfiguration kieBaseTestConfiguration) { + createEmptyKnowledgeBase(kieBaseTestConfiguration); final String rule1 = "package com.rules;global java.util.List list\n" + "rule R1 \n" + " when \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRuleTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRuleTest.java index 41f4bd150f6..6b898a78c94 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRuleTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRuleTest.java @@ -22,15 +22,15 @@ import java.util.Collection; import java.util.Date; import java.util.List; +import java.util.stream.Stream; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.testcoverage.common.model.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +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.definition.KiePackage; @@ -39,22 +39,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AddRuleTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AddRuleTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testMemoriesCCEWhenAddRemoveAddRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMemoriesCCEWhenAddRemoveAddRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3656 final String rule1 = "import " + AddRuleTest.class.getCanonicalName() + ".*\n" + "import java.util.Date\n" + @@ -89,8 +82,9 @@ public void testMemoriesCCEWhenAddRemoveAddRule() { kbase.addPackages(TestUtil.createKnowledgeBuilder(null, rule2).getKnowledgePackages()); } - @Test - public void testAddRuleWithFrom() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRuleWithFrom(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3499 final String str1 = "global java.util.List names;\n" + "global java.util.List list;\n"; @@ -134,8 +128,9 @@ public void testAddRuleWithFrom() { ksession.dispose(); } - @Test - public void testDynamicallyAddInitialFactRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDynamicallyAddInitialFactRule(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package org.drools.compiler.test\n" + "global java.util.List list\n" + "rule xxx when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/CasesFromGeneratedRulesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/CasesFromGeneratedRulesTest.java new file mode 100644 index 00000000000..13696bba1a3 --- /dev/null +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/CasesFromGeneratedRulesTest.java @@ -0,0 +1,87 @@ +/** + * 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.compiler.integrationtests.incrementalcompilation; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; + +public class CasesFromGeneratedRulesTest { + + @Test + @Timeout(40000) + public void testInsertFactsFireRulesRemoveRulesReinsertRulesRevertedRules() { + String rule1 = """ + package com.rules; + global java.util.List list + rule R1 + when + Integer() + then + list.add('R1'); + end + """; + + String rule2 = """ + package com.rules; + global java.util.List list + rule R2 + when + Integer() + exists(Integer() and Integer()) + exists(Integer() and Integer()) + then + list.add('R2'); + end + """; + + AddRemoveTestCases.insertFactsFireRulesRemoveRulesReinsertRules1(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, 1, 2); + } + + @Test + @Timeout(40000) + public void testInsertFactsRemoveRulesFireRulesRemoveRules() { + String rule1 = """ + package com.rules; + global java.util.List list + rule R1 + when + exists(Integer()) + not(Double() and Double()) + Integer() not(Double() and Double()) + then + list.add('R1'); + end + """; + + String rule2 = """ + package com.rules; + global java.util.List list + rule R2 + when + exists(Integer()) + not(Double() and Double()) + exists(Integer()) + then + list.add('R2'); + end + """; + + AddRemoveTestCases.insertFactsRemoveRulesFireRulesRemoveRules2(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, 1); + } +} diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/ClassLoaderLeakTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/ClassLoaderLeakTest.java index ffa8baf7628..ca699e6d5ee 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/ClassLoaderLeakTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/ClassLoaderLeakTest.java @@ -22,7 +22,7 @@ import org.drools.compiler.kie.builder.impl.KieProject; import org.drools.model.codegen.ExecutableModelProject; import org.drools.wiring.api.classloader.ProjectClassLoader; -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; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationCepTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationCepTest.java index cfe32dd596d..684fc04ceb0 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationCepTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationCepTest.java @@ -23,13 +23,13 @@ import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.base.base.ClassObjectType; import org.drools.base.base.ObjectType; @@ -45,10 +45,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +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.builder.Results; @@ -70,22 +69,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class IncrementalCompilationCepTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public IncrementalCompilationCepTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Test - public void testRemoveRuleAndThenFactInStreamMode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRuleAndThenFactInStreamMode(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-731 final String header = "package org.some.test\n" + "import " + MyFact.class.getCanonicalName() + "\n"; @@ -125,8 +117,9 @@ public void testRemoveRuleAndThenFactInStreamMode() { ksession.delete(fh); } - @Test - public void testAlphaNodeSharingIsOK() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaNodeSharingIsOK(KieBaseTestConfiguration kieBaseTestConfiguration) { // inspired by drools-usage Fmt9wZUFi8g // check timer -scheduled activations are preserved if rule untouched by incremental compilation even with alpha node sharing. @@ -215,8 +208,9 @@ public void testAlphaNodeSharingIsOK() { assertThat(list2.size()).as("1. RS is preserved").isEqualTo(1); } - @Test - public void testRemoveRuleWithNonInitializedPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRuleWithNonInitializedPath(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1177 final String drl1 = "import " + MyEvent.class.getCanonicalName() + "\n" + @@ -273,8 +267,9 @@ public long getMytime() { } } - @Test - public void testUpdateWithDeclarationPresent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateWithDeclarationPresent(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-560 final String header = "package org.drools.compiler\n" + "import " + FooEvent.class.getCanonicalName() + ";\n" @@ -326,8 +321,9 @@ public void testUpdateWithDeclarationPresent() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testChangeWindowTime() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testChangeWindowTime(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-853 final String drl1 = "import " + MyEvent.class.getCanonicalName() + "\n" + @@ -402,8 +398,9 @@ public void testChangeWindowTime() { assertThat(result.get()).isEqualTo(0); } - @Test - public void testIncrementalCompilationWithSlidingWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithSlidingWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-881 final String drl1 = "import " + MyEvent.class.getCanonicalName() + "\n" + @@ -466,8 +463,9 @@ public void testIncrementalCompilationWithSlidingWindow() { ksession.fireAllRules(); } - @Test - public void testDrlRenamingWithEvents() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDrlRenamingWithEvents(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-965 final String drl1 = "import " + SimpleEvent.class.getCanonicalName() + ";\n" + @@ -567,8 +565,9 @@ public String toString() { } } - @Test - public void testIncrementalCompilationWithTimerNode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithTimerNode(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1195 final String drl1 = "package org.drools.test\n" + "import " + DummyEvent.class.getCanonicalName() + "\n" + @@ -714,8 +713,9 @@ public void setId(final String id) { } } - @Test - public void testEventDeclarationInSeparatedDRL() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventDeclarationInSeparatedDRL(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1241 final String drl1 = "import " + SimpleEvent.class.getCanonicalName() + ";\n" + @@ -777,8 +777,9 @@ public void testEventDeclarationInSeparatedDRL() { assertThat(list.get(0)).isEqualTo("YOUR_CODE"); } - @Test - public void testKeepBuilderConfAfterIncrementalUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKeepBuilderConfAfterIncrementalUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1282 final String drl1 = "import " + DummyEvent.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -810,8 +811,9 @@ public void testKeepBuilderConfAfterIncrementalUpdate() { assertThat(results.getMessages().size()).isEqualTo(0); } - @Test - public void testIncrementalCompilationWithNewEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithNewEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1395 final String drl1 = "package org.drools.test\n" + "import " + DummyEvent.class.getCanonicalName() + "\n" + @@ -894,8 +896,9 @@ public void setEnabled(final boolean enabled) { } } - @Test - public void testAddRuleWithSlidingWindows() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddRuleWithSlidingWindows(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-2292 final String drl1 = "package org.drools.compiler\n" + "import " + List.class.getCanonicalName() + "\n" + @@ -952,8 +955,9 @@ public String toString() { } } - @Test - public void testObjectTypeNodeExpirationOffset() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testObjectTypeNodeExpirationOffset(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6296 final String drl1 = "package org.drools.test;\n" + "import " + ParentEvent.class.getCanonicalName() + "\n" + @@ -1110,17 +1114,19 @@ public void testObjectTypeNodeExpirationOffset() { kieSession2.dispose(); } - @Test - public void testIncrementalCompilationWithExpiringEvent() { - incrementalCompilationWithExpiringEventFromEntryPoint(false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithExpiringEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { + incrementalCompilationWithExpiringEventFromEntryPoint(kieBaseTestConfiguration, false); } - @Test - public void testIncrementalCompilationWithExpiringEventFromEntryPoint() { - incrementalCompilationWithExpiringEventFromEntryPoint(true); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithExpiringEventFromEntryPoint(KieBaseTestConfiguration kieBaseTestConfiguration) { + incrementalCompilationWithExpiringEventFromEntryPoint(kieBaseTestConfiguration, true); } - private void incrementalCompilationWithExpiringEventFromEntryPoint(boolean useEntryPoint) { + private void incrementalCompilationWithExpiringEventFromEntryPoint(KieBaseTestConfiguration kieBaseTestConfiguration, boolean useEntryPoint) { // DROOLS-7582 final String drl1 = "import " + ExpiringEvent.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationNonExecModelTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationNonExecModelTest.java index 535177026ec..38b578a8321 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationNonExecModelTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationNonExecModelTest.java @@ -18,15 +18,14 @@ */ package org.drools.compiler.integrationtests.incrementalcompilation; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +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,18 +41,10 @@ /** * Incremental compilation tests which don't work with exec-model. Each test should be fixed by JIRA one-by-one */ -@RunWith(Parameterized.class) public class IncrementalCompilationNonExecModelTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public IncrementalCompilationNonExecModelTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } private static final String DRL2_COMMON_SRC = "package myPkg\n" + @@ -77,8 +68,9 @@ public static Collection getParameters() { "then\n" + "end\n"; - @Test - public void testCreateFileSetWithDeclaredModel() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCreateFileSetWithDeclaredModel(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { final String drl1 = "package myPkg\n" + "declare StringWrapper\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationTest.java index 1c444aa0060..7838eb7c62b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/IncrementalCompilationTest.java @@ -37,11 +37,11 @@ import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +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.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -91,28 +91,22 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; import static org.drools.core.util.DroolsTestUtil.rulestoMap; -@RunWith(Parameterized.class) public class IncrementalCompilationTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public IncrementalCompilationTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testLoadOrderAfterRuleRemoval() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLoadOrderAfterRuleRemoval(KieBaseTestConfiguration kieBaseTestConfiguration) { final String header = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n"; @@ -141,20 +135,20 @@ public void testLoadOrderAfterRuleRemoval() { KieUtil.getKieModuleFromDrls(releaseId1, kieBaseTestConfiguration, header); final KieContainer kc = ks.newKieContainer(releaseId1); - createAndDeployAndTest(kc, "2", header, drl1 + drl2 + drl3, "R1", "R2", "R3"); + createAndDeployAndTest(kieBaseTestConfiguration, kc, "2", header, drl1 + drl2 + drl3, "R1", "R2", "R3"); - createAndDeployAndTest(kc, "3", header, drl1 + drl3, "R1", "R3"); + createAndDeployAndTest(kieBaseTestConfiguration, kc, "3", header, drl1 + drl3, "R1", "R3"); - createAndDeployAndTest(kc, "4", header, drl2 + drl1 + drl4, "R2", "R1", "R4"); + createAndDeployAndTest(kieBaseTestConfiguration, kc, "4", header, drl2 + drl1 + drl4, "R2", "R1", "R4"); - createAndDeployAndTest(kc, "5", header, drl2 + drl1, "R2", "R1"); + createAndDeployAndTest(kieBaseTestConfiguration, kc, "5", header, drl2 + drl1, "R2", "R1"); - createAndDeployAndTest(kc, "6", header, ""); + createAndDeployAndTest(kieBaseTestConfiguration, kc, "6", header, ""); - createAndDeployAndTest(kc, "7", header, drl3, "R3"); + createAndDeployAndTest(kieBaseTestConfiguration, kc, "7", header, drl3, "R3"); } - private void createAndDeployAndTest(final KieContainer kc, + private void createAndDeployAndTest(KieBaseTestConfiguration kieBaseTestConfiguration, final KieContainer kc, final String version, final String header, final String drls, @@ -178,8 +172,9 @@ private void createAndDeployAndTest(final KieContainer kc, } } - @Test - public void testKJarUpgrade() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgrade(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -227,8 +222,9 @@ public void testKJarUpgrade() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testKJarUpgradeSameSession() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeSameSession(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -273,8 +269,9 @@ public void testKJarUpgradeSameSession() { assertThat(ksession.fireAllRules()).isEqualTo(3); } - @Test - public void testDeletedFile() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeletedFile(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -320,8 +317,9 @@ public void testDeletedFile() { assertThat(ksession2.fireAllRules()).isEqualTo(2); } - @Test - public void testIncrementalCompilationWithAddedError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithAddedError(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -368,8 +366,9 @@ public void testIncrementalCompilationWithAddedError() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testIncrementalCompilationWithRemovedError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithRemovedError(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -412,8 +411,9 @@ public void testIncrementalCompilationWithRemovedError() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testIncrementalCompilationAddErrorThenRemoveError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationAddErrorThenRemoveError(KieBaseTestConfiguration kieBaseTestConfiguration) { //Valid final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -461,8 +461,9 @@ public void testIncrementalCompilationAddErrorThenRemoveError() { assertThat(removeResults.getRemovedMessages().size()).isEqualTo(1); } - @Test - public void testIncrementalCompilationAddErrorThenRemoveIt() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationAddErrorThenRemoveIt(KieBaseTestConfiguration kieBaseTestConfiguration) { //Fact Type is unknown ("NonExistentClass" not "Message") final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -511,8 +512,9 @@ public void testIncrementalCompilationAddErrorThenRemoveIt() { assertThat(removeResults.getRemovedMessages().size()).isEqualTo(1); } - @Test - public void testIncrementalCompilationWithDuplicatedRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithDuplicatedRule(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -548,8 +550,9 @@ public void testIncrementalCompilationWithDuplicatedRule() { assertThat(removeResults.getRemovedMessages().size()).isEqualTo(0); } - @Test - public void testIncrementalCompilationWithDuplicatedRuleInSameDRL() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithDuplicatedRuleInSameDRL(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -571,8 +574,9 @@ public void testIncrementalCompilationWithDuplicatedRuleInSameDRL() { assertThat(kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).isEmpty()).isFalse(); } - @Test - public void testIncrementalCompilationAddErrorBuildAllMessages() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationAddErrorBuildAllMessages(KieBaseTestConfiguration kieBaseTestConfiguration) { //Valid final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -608,8 +612,9 @@ public void testIncrementalCompilationAddErrorBuildAllMessages() { assertThat(ks.newKieBuilder(kfs).buildAll().getResults().getMessages().size()).isEqualTo(1); } - @Test - public void testIncrementalCompilationAddErrorThenEmptyWithoutError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationAddErrorThenEmptyWithoutError(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1009369 //Invalid. Type "Smurf" is unknown @@ -647,8 +652,9 @@ public void testIncrementalCompilationAddErrorThenEmptyWithoutError() { assertThat(addResults2.getRemovedMessages().size()).isEqualTo(0); } - @Test - public void testRuleRemoval() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleRemoval(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -709,30 +715,33 @@ public void testRuleRemoval() { assertThat(rules.get("R3")).isNotNull(); } - @Test - public void testIncrementalCompilationWithSnapshots() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithSnapshots(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-358 final ReleaseId releaseId = KieServices.Factory.get().newReleaseId("org.test", "test", "1.0.0-SNAPSHOT"); - testIncrementalCompilation(releaseId, releaseId, false); + testIncrementalCompilation(kieBaseTestConfiguration, releaseId, releaseId, false); } - @Test - public void testIncrementalCompilationWithFixedVersions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithFixedVersions(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-358 final ReleaseId releaseId1 = KieServices.Factory.get().newReleaseId("org.test", "test", "1.0.1"); final ReleaseId releaseId2 = KieServices.Factory.get().newReleaseId("org.test", "test", "1.0.2"); - testIncrementalCompilation(releaseId1, releaseId2, false); + testIncrementalCompilation(kieBaseTestConfiguration, releaseId1, releaseId2, false); } - @Test - public void testIncrementalCompilationWithDeclaredType() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithDeclaredType(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-358 final ReleaseId releaseId1 = KieServices.Factory.get().newReleaseId("org.test", "test", "1.0.1"); final ReleaseId releaseId2 = KieServices.Factory.get().newReleaseId("org.test", "test", "1.0.2"); - testIncrementalCompilation(releaseId1, releaseId2, true); + testIncrementalCompilation(kieBaseTestConfiguration, releaseId1, releaseId2, true); } - private void testIncrementalCompilation(final ReleaseId releaseId1, + private void testIncrementalCompilation(KieBaseTestConfiguration kieBaseTestConfiguration, final ReleaseId releaseId1, final ReleaseId releaseId2, final boolean useDeclaredType) { final String drl1 = "package org.drools.compiler\n" + @@ -797,8 +806,9 @@ private void testIncrementalCompilation(final ReleaseId releaseId1, assertThat(list.containsAll(asList("bBar", "bFoo", "aBar"))).isTrue(); } - @Test - public void testIncrementalCompilationWithRedeclares() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithRedeclares(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-363 final String drl1 = "package org.drools.compiler\n" + "global java.util.List list\n" + @@ -847,8 +857,9 @@ public void testIncrementalCompilationWithRedeclares() { assertThat(list.size()).isEqualTo(2); } - @Test - public void testIncrementalCompilationWithAmbiguousRedeclares() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithAmbiguousRedeclares(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package domestic; " + "import foreign.*; " + @@ -903,8 +914,9 @@ public void testIncrementalCompilationWithAmbiguousRedeclares() { assertThat(updateResults.getMessages().size()).isEqualTo(0); } - @Test - public void testIncrementalCompilationWithModuleOverride() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithModuleOverride(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.test.compiler; " + "global java.util.List list; " + @@ -976,8 +988,9 @@ public void testIncrementalCompilationWithModuleOverride() { assertThat(list).isEqualTo(Arrays.asList("AX", "BX", "CX")); } - @Test - public void testIncrementalCompilationWithMissingKSession() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithMissingKSession(KieBaseTestConfiguration kieBaseTestConfiguration) { //https://bugzilla.redhat.com/show_bug.cgi?id=1066059 final String pom = "\n" + "> getDeployer(final int nr, final KieB } } - @Test - public void testSegmentSplitOnIncrementalCompilation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSegmentSplitOnIncrementalCompilation(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-930 final String drl = "import " + Person.class.getCanonicalName() + "\n" + @@ -1692,8 +1718,9 @@ public void testSegmentSplitOnIncrementalCompilation() { assertThat(list.containsAll(asList("R1", "R2"))).isTrue(); } - @Test - public void testSegmentMergeOnRuleRemovalWithNotExistingSegment() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSegmentMergeOnRuleRemovalWithNotExistingSegment(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-950 final String drl1 = "rule R1 when\n" + @@ -1727,8 +1754,9 @@ public void testSegmentMergeOnRuleRemovalWithNotExistingSegment() { kc.updateToVersion(releaseId2); } - @Test - public void testRemoveRuleWithRia() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRuleWithRia(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-954 final String drl1 = "import " + List.class.getCanonicalName() + "\n" + @@ -1758,8 +1786,9 @@ public void testRemoveRuleWithRia() { } } - @Test - public void testRetractLogicalAssertedObjectOnRuleRemoval() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRetractLogicalAssertedObjectOnRuleRemoval(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-951 final String drl1 = "rule R1 when\n" + @@ -1811,8 +1840,9 @@ public void testRetractLogicalAssertedObjectOnRuleRemoval() { assertThat(ksession.getObjects(new ClassObjectFilter(String.class)).size()).isEqualTo(0); } - @Test - public void testRetractLogicalAssertedObjectOnRuleRemovalWithSameObject() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRetractLogicalAssertedObjectOnRuleRemovalWithSameObject(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-951 final String drl1 = "rule R1 when\n" + @@ -1864,8 +1894,9 @@ public void testRetractLogicalAssertedObjectOnRuleRemovalWithSameObject() { assertThat(ksession.getObjects(new ClassObjectFilter(String.class)).size()).isEqualTo(0); } - @Test - public void testUpdateWithNewDrlAndChangeInOldOne() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateWithNewDrlAndChangeInOldOne(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1275378 String drl1 = "package org.kie.test\n" + "global java.util.List list\n" + @@ -1919,8 +1950,9 @@ public void testUpdateWithNewDrlAndChangeInOldOne() { assertThat(list.contains("rule2")).isTrue(); } - @Test - public void testIncrementalCompilationWithEagerRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithEagerRules(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-978 final String drl1 = "rule R1 when\n" + @@ -1960,8 +1992,9 @@ public void testIncrementalCompilationWithEagerRules() { ksession.fireAllRules(); } - @Test - public void testMultipleIncrementalCompilationWithExistentialRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleIncrementalCompilationWithExistentialRules(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-988 final List drls = new ArrayList<>(); drls.add(getExistenzialRule("R0", "> 10")); @@ -1999,8 +2032,9 @@ private String getExistenzialRule(final String rulename, final String condition) "end"; } - @Test - public void testRuleRemovalWithOR() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleRemovalWithOR(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1007 final String drl1 = "rule R1 when\n" + @@ -2031,8 +2065,9 @@ public void testRuleRemovalWithOR() { ksession.fireAllRules(); } - @Test - public void testSplitAfterQuery() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSplitAfterQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "global java.util.List list; " + "query foo( Integer $i ) " + @@ -2114,8 +2149,9 @@ public void testSplitAfterQuery() { assertThat((int) list.get(1)).isEqualTo(22); } - @Test - public void testGetFactTypeOnIncrementalUpdate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetFactTypeOnIncrementalUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-980 - DROOLS-2195 final String drl1 = "package org.mytest\n" + @@ -2167,8 +2203,9 @@ public void testGetFactTypeOnIncrementalUpdate() throws Exception { ftype.set(fact, "address", "World"); } - @Test - public void testRuleRemovalWithSubnetworkAndOR() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleRemovalWithSubnetworkAndOR(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1025 final String drl1 = "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + @@ -2207,8 +2244,9 @@ public void testRuleRemovalWithSubnetworkAndOR() { ksession.fireAllRules(); } - @Test - public void testIncrementalCompilationWithClassFieldReader() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithClassFieldReader(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1318532 final String personSrc = "package org.test;" + "import java.util.ArrayList;" + @@ -2281,8 +2319,9 @@ public void testIncrementalCompilationWithClassFieldReader() { ksession.fireAllRules(); } - @Test - public void testIncrementalCompilationRemovingParentRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationRemovingParentRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1031 final String drl1 = "package org.drools.compiler\n" + "rule R1 when\n" + @@ -2323,8 +2362,9 @@ public void testIncrementalCompilationRemovingParentRule() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testIncrementalCompilationChangeParentRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationChangeParentRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1031 final String drl1_1 = "rule R1 when\n" + @@ -2363,8 +2403,9 @@ public void testIncrementalCompilationChangeParentRule() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testIncrementalCompilationChangeParentRuleInDifferentFile() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationChangeParentRuleInDifferentFile(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6497 final String drl1_1 = "rule R1 when\n" + @@ -2403,8 +2444,9 @@ public void testIncrementalCompilationChangeParentRuleInDifferentFile() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testRemovePackageFromKieBaseModel() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemovePackageFromKieBaseModel(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1287 final String drl1 = "global java.util.List list;\n" + "rule R1 when\n" + @@ -2456,8 +2498,9 @@ public void testRemovePackageFromKieBaseModel() { assertThat(list.contains("R2")).isTrue(); } - @Test - public void testAddPackageToKieBaseModel() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddPackageToKieBaseModel(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1287 // DROOLS-1287 final String drl1 = "global java.util.List list;\n" + @@ -2510,8 +2553,9 @@ public void testAddPackageToKieBaseModel() { assertThat(list.containsAll(asList("R1", "R2"))).isTrue(); } - @Test - public void testKJarUpgradeWithSpace() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeWithSpace(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2527,11 +2571,12 @@ public void testKJarUpgradeWithSpace() { "then\n" + "end\n"; - testKJarUpgradeDRLWithSpace(drl1, drl2, "Hello World", 1, 0); + testKJarUpgradeDRLWithSpace(kieBaseTestConfiguration, drl1, drl2, "Hello World", 1, 0); } - @Test - public void testKJarUpgradeDRLWithSpace2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeDRLWithSpace2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 bis final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2547,11 +2592,12 @@ public void testKJarUpgradeDRLWithSpace2() { "then\n" + "end\n"; - testKJarUpgradeDRLWithSpace(drl1, drl2, "Hello World", 1, 0); + testKJarUpgradeDRLWithSpace(kieBaseTestConfiguration, drl1, drl2, "Hello World", 1, 0); } - @Test - public void testKJarUpgradeDRLWithSpace3() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeDRLWithSpace3(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 ter final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2571,11 +2617,12 @@ public void testKJarUpgradeDRLWithSpace3() { " System.out.println($m); \n" + "end\n"; - testKJarUpgradeWithSpaceVariant2(drl1, drl2); + testKJarUpgradeWithSpaceVariant2(kieBaseTestConfiguration, drl1, drl2); } - @Test - public void testKJarUpgradeDRLWithSpace4() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeDRLWithSpace4(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 quater final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2591,11 +2638,12 @@ public void testKJarUpgradeDRLWithSpace4() { "then\n" + "end\n"; - testKJarUpgradeDRLWithSpace(drl1, drl2, "Hello World", 0, 1); + testKJarUpgradeDRLWithSpace(kieBaseTestConfiguration, drl1, drl2, "Hello World", 0, 1); } - @Test - public void testKJarUpgradeDRLWithSpace5() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeDRLWithSpace5(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 quinquies final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2611,11 +2659,12 @@ public void testKJarUpgradeDRLWithSpace5() { "then\n" + "end\n"; - testKJarUpgradeDRLWithSpace(drl1, drl2, "Hello' World", 0, 1); // <<- notice the ' character + testKJarUpgradeDRLWithSpace(kieBaseTestConfiguration, drl1, drl2, "Hello' World", 0, 1); // <<- notice the ' character } - @Test - public void testKJarUpgradeWithSpace_usingSingleQuote() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeWithSpace_usingSingleQuote(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 (using single quote) final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2631,11 +2680,12 @@ public void testKJarUpgradeWithSpace_usingSingleQuote() { "then\n" + "end\n"; - testKJarUpgradeDRLWithSpace(drl1, drl2, "Hello World", 1, 0); + testKJarUpgradeDRLWithSpace(kieBaseTestConfiguration, drl1, drl2, "Hello World", 1, 0); } - @Test - public void testKJarUpgradeDRLWithSpace2_usingSingleQuote() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeDRLWithSpace2_usingSingleQuote(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 bis (using single quote) final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2651,11 +2701,12 @@ public void testKJarUpgradeDRLWithSpace2_usingSingleQuote() { "then\n" + "end\n"; - testKJarUpgradeDRLWithSpace(drl1, drl2, "Hello World", 1, 0); + testKJarUpgradeDRLWithSpace(kieBaseTestConfiguration, drl1, drl2, "Hello World", 1, 0); } - @Test - public void testKJarUpgradeDRLWithSpace3_usingSingleQuote() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeDRLWithSpace3_usingSingleQuote(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 ter (using single quote) final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2675,11 +2726,12 @@ public void testKJarUpgradeDRLWithSpace3_usingSingleQuote() { " System.out.println($m); \n" + "end\n"; - testKJarUpgradeWithSpaceVariant2(drl1, drl2); + testKJarUpgradeWithSpaceVariant2(kieBaseTestConfiguration, drl1, drl2); } - @Test - public void testKJarUpgradeDRLWithSpace4_usingSingleQuote() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeDRLWithSpace4_usingSingleQuote(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 quater (using single quote) final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2695,11 +2747,12 @@ public void testKJarUpgradeDRLWithSpace4_usingSingleQuote() { "then\n" + "end\n"; - testKJarUpgradeDRLWithSpace(drl1, drl2, "Hello World", 0, 1); + testKJarUpgradeDRLWithSpace(kieBaseTestConfiguration, drl1, drl2, "Hello World", 0, 1); } - @Test - public void testKJarUpgradeDRLWithSpace5_usingSingleQuote() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeDRLWithSpace5_usingSingleQuote(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1399 quinquies (using single quote) final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -2715,10 +2768,10 @@ public void testKJarUpgradeDRLWithSpace5_usingSingleQuote() { "then\n" + "end\n"; - testKJarUpgradeDRLWithSpace(drl1, drl2, "Hello' World", 0, 1); + testKJarUpgradeDRLWithSpace(kieBaseTestConfiguration, drl1, drl2, "Hello' World", 0, 1); } - private void testKJarUpgradeDRLWithSpace(final String drl1, final String drl2, final String factString, + private void testKJarUpgradeDRLWithSpace(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl1, final String drl2, final String factString, final int firstFireCount, final int secondFireCount) { final KieServices ks = KieServices.Factory.get(); @@ -2737,7 +2790,7 @@ private void testKJarUpgradeDRLWithSpace(final String drl1, final String drl2, f assertThat(ksession.fireAllRules()).isEqualTo(secondFireCount); } - private void testKJarUpgradeWithSpaceVariant2(final String drl1, final String drl2) { + private void testKJarUpgradeWithSpaceVariant2(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl1, final String drl2) { final KieServices ks = KieServices.Factory.get(); final ReleaseId releaseId1 = ks.newReleaseId("org.kie", "test-upgrade", "1.0.0"); @@ -2772,8 +2825,9 @@ public void afterMatchFired(final AfterMatchFiredEvent event) { assertThat(fired.contains("Rx")).isFalse(); } - @Test - public void testJavaClassRedefinition() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJavaClassRedefinition(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1402 final String JAVA1 = "package org.test;" + " public class MyBean {\n" + @@ -2885,8 +2939,9 @@ public void testJavaClassRedefinition() { assertThat(fired).isEqualTo(2); } - @Test - public void testJavaClassRedefinitionJoined() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJavaClassRedefinitionJoined(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1402 final String JAVA1 = "package org.test;" + " public class MyBean {\n" + @@ -3001,8 +3056,10 @@ public void testJavaClassRedefinitionJoined() { assertThat(fired).isEqualTo(2); } - @Test(timeout = 20000L) - public void testMultipleIncrementalCompilationsWithFireUntilHalt() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000L) + public void testMultipleIncrementalCompilationsWithFireUntilHalt(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-1406 final KieServices ks = KieServices.Factory.get(); @@ -3071,8 +3128,9 @@ public synchronized boolean add(final T t) { } } - @Test - public void testIncrementalCompilationWithExtendsRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithExtendsRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1405 final String drl1 = "rule \"test1\" when then end\n"; @@ -3108,8 +3166,9 @@ public void setBaseField(final String baseField) { } } - @Test - public void testUpdateWithPojoExtensionDifferentPackages() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateWithPojoExtensionDifferentPackages(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-1491 final String drlDeclare = "package org.drools.compiler.integrationtests\n" + "declare DroolsApplications extends " + BaseClass.class.getCanonicalName() + "\n" + @@ -3174,8 +3233,9 @@ public void testUpdateWithPojoExtensionDifferentPackages() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testPropertyReactivityOfAKnownClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropertyReactivityOfAKnownClass(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "import " + TypeA.class.getCanonicalName() + "\n" + "import " + TypeB.class.getCanonicalName() + "\n" + @@ -3213,8 +3273,9 @@ public void testPropertyReactivityOfAKnownClass() { assertThat(fired).isEqualTo(1); } - @Test - public void testPropertyReactivityOfAnOriginallyUnknownClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropertyReactivityOfAnOriginallyUnknownClass(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1684 final String drl1 = "import " + TypeA.class.getCanonicalName() + "\n" + @@ -3299,8 +3360,9 @@ public void setValue(final int value) { " insert( new Message(\"HAL\", \"reply 2\" ) ); \n" + "end \n"; - @Test - public void testDeclaredTypeInDifferentPackage() throws IllegalAccessException, InstantiationException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredTypeInDifferentPackage(KieBaseTestConfiguration kieBaseTestConfiguration) throws IllegalAccessException, InstantiationException { // DROOLS-1707 final KieServices ks = KieServices.Factory.get(); @@ -3317,8 +3379,9 @@ public void testDeclaredTypeInDifferentPackage() throws IllegalAccessException, doFire(kContainer.getKieBase(), "reply 2"); } - @Test - public void testDeclaredTypeInIncludedKieBase() throws IllegalAccessException, InstantiationException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredTypeInIncludedKieBase(KieBaseTestConfiguration kieBaseTestConfiguration) throws IllegalAccessException, InstantiationException { // DROOLS-1707 final KieServices ks = KieServices.Factory.get(); @@ -3379,8 +3442,9 @@ private Object createMessage(final FactType ftype) throws IllegalAccessException return fact; } - @Test - public void testRemoveAndReaddJavaClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveAndReaddJavaClass(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1704 final String javaSource = "package org.drools.test;\n" + "public class Person { }\n"; @@ -3425,8 +3489,9 @@ public void testRemoveAndReaddJavaClass() { kContainer.updateToVersion(releaseId3); } - @Test - public void testChangedPackage() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testChangedPackage(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1742 final String drl1 = "package org.a\n" + "rule \"RG_1\"\n" + @@ -3463,8 +3528,9 @@ public void testChangedPackage() { assertThat(kieSession.fireAllRules()).isEqualTo(0); } - @Test - public void testSegmentSplitAfterMerge() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSegmentSplitAfterMerge(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1A = "package org.hightea.a\n" + "rule \"RG_1\"\n" + " when\n" + @@ -3508,8 +3574,9 @@ public void testSegmentSplitAfterMerge() { assertThat(kieSession.fireAllRules()).isEqualTo(0); } - @Test - public void testAddFieldToDeclaredType() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddFieldToDeclaredType(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2197 final String declares1 = "declare Address\n" + " streetName : String\n" + @@ -3550,8 +3617,9 @@ public void testAddFieldToDeclaredType() { assertThat(kieSession.fireAllRules()).isEqualTo(0); } - @Test - public void testIncremenatalCompilationAddingFieldToDeclaredType() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncremenatalCompilationAddingFieldToDeclaredType(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2197 final String declares1 = "declare Address\n" + " streetName : String\n" + @@ -3615,8 +3683,9 @@ public void testIncremenatalCompilationAddingFieldToDeclaredType() { assertThat(updateResults.getMessages().size()).isEqualTo(0); } - @Test - public void testUnchangedAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnchangedAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2194 final String drl1 = "import java.util.*;\n" + @@ -3658,8 +3727,9 @@ public void testUnchangedAccumulate() { ksession.fireAllRules(); } - @Test - public void testGlobalRemovedFromOneDrl() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobalRemovedFromOneDrl(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHDM-311 final String drlAWithGlobal = "package org.x.a\nglobal Boolean globalBool\n"; final String drlANoGlobal = "package org.x.a\n"; @@ -3694,8 +3764,9 @@ public void testGlobalRemovedFromOneDrl() { } } - @Test - public void testGlobalRemovedAndAdded() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobalRemovedAndAdded(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHDM-311 final String drlAWithGlobal = "package org.x.a\nglobal Boolean globalBool\n"; final String drlANoGlobal = "package org.x.a\n"; @@ -3719,8 +3790,9 @@ public void testGlobalRemovedAndAdded() { ksession.setGlobal("globalBool", Boolean.TRUE); } - @Test - public void testRuleRemovalAndEval() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleRemovalAndEval(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2276 final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + @@ -3787,8 +3859,9 @@ public void testRuleRemovalAndEval() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testGetFactTypeOnIncrementalUpdateWithNestedFacts() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetFactTypeOnIncrementalUpdateWithNestedFacts(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-2385 final String drl1 = "package org.drools.example.api.kiemodulemodel\n" + @@ -3856,8 +3929,9 @@ public void testGetFactTypeOnIncrementalUpdateWithNestedFacts() throws Exception ftype.set(fact, "nested", nestedfact); } - @Test - public void testKJarUpgradeWithNewRule() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeWithNewRule(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-2596 String drl1a = "package org.drools.incremental\n" + "global java.util.List list\n" + @@ -3914,8 +3988,9 @@ public void testKJarUpgradeWithNewRule() throws Exception { assertThat(list.get(1)).isEqualTo("1"); } - @Test - public void testKJarUpgradeWithNewRuleAndStatelessSession() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeWithNewRuleAndStatelessSession(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-2596 String drl1a = "package org.drools.incremental\n" + "global java.util.List list\n" + @@ -3973,8 +4048,9 @@ public void testKJarUpgradeWithNewRuleAndStatelessSession() throws Exception { assertThat(list.get(1)).isEqualTo("1"); } - @Test - public void testArgumentRedefinitionInStaticInvocation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testArgumentRedefinitionInStaticInvocation(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHDM-709 final String ARG1 = "package org.test;" + " public class MyArg {\n" + @@ -4054,8 +4130,9 @@ public void testArgumentRedefinitionInStaticInvocation() { assertThat(updateResults.hasMessages(Level.ERROR)).isFalse(); } - @Test - public void testRemoveRulesWithLogicalAssertions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRulesWithLogicalAssertions(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2646 final String DRL1 = "declare MyInt\n" + @@ -4130,8 +4207,9 @@ public void testRemoveRulesWithLogicalAssertions() { assertThat(kieSession.getObjects().size()).isEqualTo(4); } - @Test - public void testRemoveRulesWithAccumulateAndLogicalAssertions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRulesWithAccumulateAndLogicalAssertions(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-3554 final String DRL1 = "rule R1 when\n" + @@ -4187,17 +4265,19 @@ public void testRemoveRulesWithAccumulateAndLogicalAssertions() { assertThat(kieSession.getObjects(new ClassObjectFilter( Integer.class )).isEmpty()).isTrue(); } - @Test - public void testRemoveRulesWithSubnetworkAndOR() throws Exception { - checkRemoveRulesWithSubnetworkAndOR(false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRulesWithSubnetworkAndOR(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + checkRemoveRulesWithSubnetworkAndOR(kieBaseTestConfiguration, false); } - @Test - public void testRemoveRulesWithSubnetworkAndORWithDispose() throws Exception { - checkRemoveRulesWithSubnetworkAndOR(true); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRulesWithSubnetworkAndORWithDispose(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + checkRemoveRulesWithSubnetworkAndOR(kieBaseTestConfiguration, true); } - public void checkRemoveRulesWithSubnetworkAndOR(boolean dispose) throws Exception { + public void checkRemoveRulesWithSubnetworkAndOR(KieBaseTestConfiguration kieBaseTestConfiguration, boolean dispose) throws Exception { // DROOLS-4454 String DRL1 = " package org.drools.compiler;\n" + @@ -4324,17 +4404,19 @@ public void checkRemoveRulesWithSubnetworkAndOR(boolean dispose) throws Exceptio ks2.dispose(); } - @Test - public void testRemoveAndAddRules() throws Exception { - checkRemoveAndAddRules(false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveAndAddRules(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + checkRemoveAndAddRules(kieBaseTestConfiguration, false); } - @Test - public void testRemoveAndAddRulesWithDispose() throws Exception { - checkRemoveAndAddRules(true); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveAndAddRulesWithDispose(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + checkRemoveAndAddRules(kieBaseTestConfiguration, true); } - public void checkRemoveAndAddRules(boolean dispose) throws Exception { + public void checkRemoveAndAddRules(KieBaseTestConfiguration kieBaseTestConfiguration, boolean dispose) throws Exception { String DRL1 = "package org.kie.test\n" + "global java.util.List list\n" + @@ -4431,8 +4513,9 @@ public void checkRemoveAndAddRules(boolean dispose) throws Exception { assertThat(list2.containsAll(Arrays.asList("R2", "R3"))).isTrue(); } - @Test - public void testKJarUpgradeWithSerializedSession() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeWithSerializedSession(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "import " + Message.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -4498,8 +4581,9 @@ public void testKJarUpgradeWithSerializedSession() { assertThat(ksession2.fireAllRules()).isEqualTo(3); } - @Test - public void testGetFactTypeOnIncrementalUpdateWithNestedFactsRulesFired() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetFactTypeOnIncrementalUpdateWithNestedFactsRulesFired(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-4886 final String drl1 = "package org.drools.example.api.kiemodulemodel\n" + @@ -4577,13 +4661,15 @@ public void testGetFactTypeOnIncrementalUpdateWithNestedFactsRulesFired() throws session.dispose(); } - @Test - public void testDecisionTable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled("It fails. See issue #6190") + public void testDecisionTable(KieBaseTestConfiguration kieBaseTestConfiguration) { KieServices ks = KieServices.get(); KieResources kr = ks.getResources(); ReleaseId releaseId1 = ks.newReleaseId("org.kie", "test-dtable", "1.1.1"); - buildDTableProject( ks, kr, releaseId1, "CanDrinkAndDrive.drl.xls" ); + buildDTableProject( kieBaseTestConfiguration, ks, kr, releaseId1, "CanDrinkAndDrive.drl.xls" ); KieContainer kc = ks.newKieContainer(releaseId1); @@ -4601,7 +4687,7 @@ public void testDecisionTable() { } ReleaseId releaseId2 = ks.newReleaseId("org.kie", "test-dtable", "1.1.2"); - buildDTableProject( ks, kr, releaseId2, "CanDrinkAndDrive2.drl.xls" ); + buildDTableProject( kieBaseTestConfiguration, ks, kr, releaseId2, "CanDrinkAndDrive2.drl.xls" ); kc.updateToVersion(releaseId2); @@ -4615,7 +4701,7 @@ public void testDecisionTable() { } } - private void buildDTableProject( KieServices ks, KieResources kr, ReleaseId releaseId, String dtableFile ) { + private void buildDTableProject(KieBaseTestConfiguration kieBaseTestConfiguration, KieServices ks, KieResources kr, ReleaseId releaseId, String dtableFile ) { KieFileSystem kfs = ks.newKieFileSystem() .write( "src/main/resources/org/drools/simple/candrink/CanDrink.drl.xls", kr.newFileSystemResource( "src/test/resources/data/" + dtableFile ) ) @@ -4638,8 +4724,9 @@ private void buildDTableProject( KieServices ks, KieResources kr, ReleaseId rele } } - @Test - public void testIncrementalCompilationFromEmptyProject() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationFromEmptyProject(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-5547 final String drl1 = "rule \"test1\" when then end\n"; @@ -4664,8 +4751,9 @@ public void testIncrementalCompilationFromEmptyProject() { assertThat(addResults2.getAddedMessages().size()).isEqualTo(0); } - @Test - public void testIncrementalCompilationFromEmptyProject2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationFromEmptyProject2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-5584 final String drl1 = "package org.drools.test;\n" + @@ -4698,8 +4786,9 @@ public void testIncrementalCompilationFromEmptyProject2() { assertThat(globals.iterator().next()).isEqualTo("list"); } - @Test - public void testIncrementalCompilationWithErrorFromEmptyProject() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilationWithErrorFromEmptyProject(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-5584 final String drl_KO = "package org.drools.test;\n" + @@ -4732,8 +4821,9 @@ public void testIncrementalCompilationWithErrorFromEmptyProject() { assertThat(addResults2.getRemovedMessages().size()).isEqualTo(1); } - @Test - public void testUnusedDeclaredTypeUpdate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnusedDeclaredTypeUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-5560 final String drl1 = "package org.example.rules \n" + "\n" + @@ -4802,8 +4892,9 @@ public void testUnusedDeclaredTypeUpdate() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testConsecutiveDeclaredTypeUpdates() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConsecutiveDeclaredTypeUpdates(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-5687 final String drl1 = "package org.example.rules \n" + @@ -4874,8 +4965,9 @@ public void testConsecutiveDeclaredTypeUpdates() throws Exception { ksession = kc.newKieSession(); } - @Test - public void testUnlinkedPathUpdate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnlinkedPathUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-5982 final String drl1 = "rule R1 when\n" + @@ -4934,8 +5026,10 @@ public void testUnlinkedPathUpdate() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test(timeout = 20000L) - public void testUpdateToVersionWithFireUntilHaltWithSlowRHS() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000L) + public void testUpdateToVersionWithFireUntilHaltWithSlowRHS(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-6392 final KieServices ks = KieServices.Factory.get(); @@ -4995,8 +5089,9 @@ private String getTestRuleForFireUntilHaltSlow(final int i) { "end\n"; } - @Test - public void testAddEntryPoint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddEntryPoint(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6906 final KieServices ks = KieServices.Factory.get(); @@ -5036,8 +5131,9 @@ private static String getRule(String... entryPoints) { return rules.toString(); } - @Test - public void testRemoveSharedConstraintWithEval() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveSharedConstraintWithEval(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-6960 final String drl1 = "rule R1 when\n" + @@ -5074,8 +5170,9 @@ public void testRemoveSharedConstraintWithEval() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testReaddAllRulesWithComplexNodeSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReaddAllRulesWithComplexNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7430 final String drl1 = "import " + Message.class.getCanonicalName() + ";\n" + @@ -5169,8 +5266,9 @@ public void testReaddAllRulesWithComplexNodeSharing() { assertThat(fired).containsExactly("R6"); } - @Test - public void testReaddAllRulesWithIdenticalRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReaddAllRulesWithIdenticalRules(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7462 final String drl1 = diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/MultipleIncrementalCompilationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/MultipleIncrementalCompilationTest.java index 77eae19acd6..ed34075819b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/MultipleIncrementalCompilationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/MultipleIncrementalCompilationTest.java @@ -19,16 +19,15 @@ package org.drools.compiler.integrationtests.incrementalcompilation; import java.io.StringReader; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.compiler.kie.builder.impl.DrlProject; import org.drools.core.impl.InternalKieContainer; import org.drools.model.codegen.ExecutableModelProject; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +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; @@ -39,18 +38,10 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class MultipleIncrementalCompilationTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MultipleIncrementalCompilationTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private final String PERSON_LIST_COMMON_SRC = "package org.test;\n" + @@ -73,8 +64,9 @@ public static Collection getParameters() { " this.persons = persons;\n" + " }\n"; - @Test - public void testSnapshotUpdateWithFrom() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSnapshotUpdateWithFrom(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6492 final String personListSrc1 = PERSON_LIST_COMMON_SRC + "}"; @@ -92,22 +84,22 @@ public void testSnapshotUpdateWithFrom() { final ReleaseId releaseId = ks.newReleaseId("org.test", "myTest", "1.0.0-SNAPSHOT"); // 1st run - buildKjar(releaseId, personListSrc1); + buildKjar(kieBaseTestConfiguration, releaseId, personListSrc1); final KieContainer kc = ks.newKieContainer(releaseId); runRules(kc); // 2nd run - buildKjar(releaseId, personListSrc2); + buildKjar(kieBaseTestConfiguration, releaseId, personListSrc2); kc.updateToVersion(releaseId); runRules(kc); // 3rd run - buildKjar(releaseId, personListSrc3); + buildKjar(kieBaseTestConfiguration, releaseId, personListSrc3); kc.updateToVersion(releaseId); runRules(kc); } - private void buildKjar(ReleaseId releaseId, String personListSrc) { + private void buildKjar(KieBaseTestConfiguration kieBaseTestConfiguration, ReleaseId releaseId, String personListSrc) { final String personSrc = "package org.test;\n" + "public class Person {\n" + " private String name;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/RemoveRuleTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/RemoveRuleTest.java index a761bfdd7a7..0c886992c98 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/RemoveRuleTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/RemoveRuleTest.java @@ -19,11 +19,10 @@ package org.drools.compiler.integrationtests.incrementalcompilation; import java.util.Arrays; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.core.common.DefaultFactHandle; import org.drools.core.reteoo.EntryPointNode; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.ObjectSink; import org.drools.core.reteoo.ObjectTypeNode; import org.drools.core.reteoo.TupleImpl; @@ -34,10 +33,9 @@ import org.drools.testcoverage.common.model.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +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.ReleaseId; @@ -47,22 +45,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class RemoveRuleTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RemoveRuleTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testRemoveBigRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveBigRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3496 final String str = "package org.drools.compiler.test\n" + @@ -164,8 +155,9 @@ public void testRemoveBigRule() { } } - @Test - public void testRemoveRuleWithFromNode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveRuleWithFromNode(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3631 final String str = "package org.drools.compiler;\n" + @@ -192,8 +184,9 @@ public void testRemoveRuleWithFromNode() { assertThat(kbase.getKiePackage("org.drools.compiler").getRules().size()).isEqualTo(1); } - @Test - public void testRuleRemovalWithJoinedRootPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleRemovalWithJoinedRootPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.drools.compiler \n"; str += "import " + Person.class.getCanonicalName() + ";\n"; @@ -229,8 +222,9 @@ public void testRuleRemovalWithJoinedRootPattern() { assertThat((Tuple) leftTuple.getHandleNext()).isNull(); } - @Test - public void testRemoveAccumulateRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveAccumulateRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4864 final String str = "package org.drools.compiler.test\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/operators/EnabledTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/operators/EnabledTest.java index 38d63f05d14..c9b7fce1249 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/operators/EnabledTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/operators/EnabledTest.java @@ -30,7 +30,6 @@ import org.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.junit.runners.Parameterized; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; @@ -47,7 +46,6 @@ public class EnabledTest { - @Parameterized.Parameters(name = "KieBase type={0}") public static Stream parameters() { return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/RuleBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/RuleBuilderTest.java index 9c6b77c8320..fed36978579 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/RuleBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/RuleBuilderTest.java @@ -48,7 +48,7 @@ import org.kie.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FakeDRFAssemblerService.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FakeDRFAssemblerService.java deleted file mode 100644 index 8519aa265d7..00000000000 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FakeDRFAssemblerService.java +++ /dev/null @@ -1,50 +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.drools.mvel.integrationtests; - -import java.io.StringReader; - -import org.drools.compiler.builder.impl.KnowledgeBuilderImpl; -import org.kie.api.internal.assembler.KieAssemblerService; -import org.kie.api.io.Resource; -import org.kie.api.io.ResourceConfiguration; -import org.kie.api.io.ResourceType; - -public class FakeDRFAssemblerService implements KieAssemblerService { - - private static final String GATEWAY_RULE = "package com.example.rules\n" + - "import com.example.*;\n" + - "rule \"RuleFlow-Split-example-xxx-DROOLS_DEFAULT\" @Propagation(EAGER)\n" + - " ruleflow-group \"DROOLS_SYSTEM\"\n" + - " when\n" + - " exists String(this == \"Left\")\n" + - " then\n" + - "end"; - - @Override - public ResourceType getResourceType() { - return ResourceType.DRF; - } - - @Override - public void addResourceAfterRules(Object kbuilder, Resource resource, ResourceType type, ResourceConfiguration configuration) throws Exception { - // Just add one fake gateway drl rule. Not for process capability testing - ((KnowledgeBuilderImpl) kbuilder).addPackageFromDrl(new StringReader(GATEWAY_RULE), resource); - } -} diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBuilderTest.java index 8a38692c5d5..9beb2166246 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBuilderTest.java @@ -497,7 +497,7 @@ private void checkKModule(KieBaseTestConfiguration kieBaseTestConfiguration , fi public void testAddMissingResourceToPackageBuilder(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); - assertThatThrownBy(() -> kbuilder.add(ResourceFactory.newClassPathResource("some.rf"), ResourceType.DRL)) + assertThatThrownBy(() -> kbuilder.add(ResourceFactory.newClassPathResource("some.drl"), ResourceType.DRL)) .isInstanceOf(RuntimeException.class); assertThatThrownBy(() -> kbuilder.add(ResourceFactory.newClassPathResource("some.bpmn"), ResourceType.BPMN2)) diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Misc2Test.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Misc2Test.java index 0c594ef1600..3a91b6698dd 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Misc2Test.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Misc2Test.java @@ -131,9 +131,9 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assumptions.assumeThat; import static org.assertj.core.api.Assertions.fail; import static org.drools.mvel.compiler.TestUtil.assertDrlHasCompilationError; -import static org.junit.Assume.assumeTrue; /** * Run all the tests with the ReteOO engine implementation @@ -7910,7 +7910,7 @@ public void testMethodReferenceInRHS(KieBaseTestConfiguration kieBaseTestConfigu } private void checkJava8InRhs(KieBaseTestConfiguration kieBaseTestConfiguration, String expr) { - assumeTrue(System.getProperty("java.version").startsWith( "1.8" )); + assumeThat(System.getProperty("java.version").startsWith( "1.8" )); // BZ-1199965 String drl = diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PackageInMultipleResourcesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PackageInMultipleResourcesTest.java deleted file mode 100644 index 665f16b7143..00000000000 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PackageInMultipleResourcesTest.java +++ /dev/null @@ -1,72 +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.drools.mvel.integrationtests; - -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil2; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; -import org.kie.api.KieBase; -import org.kie.api.definition.KiePackage; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PackageInMultipleResourcesTest { - - public static Stream parameters() { - return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); - } - - @ParameterizedTest(name = "KieBase type={0}") - @MethodSource("parameters") - public void testSamePackageRulesInDRLAndRF(KieBaseTestConfiguration kieBaseTestConfiguration) { - // DROOLS-6785 - KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "rf_test_rules.drl", "rf_test_rueflow.rf"); - - KiePackage kiePackage = kbase.getKiePackage("com.example.rules"); - List ruleNames = kiePackage.getRules().stream().map(rule -> rule.getName()).collect(Collectors.toList()); - - assertThat(ruleNames.size()).isEqualTo(3); - assertThat(ruleNames).contains("RuleFlow-Split-example-xxx-DROOLS_DEFAULT", "Left Rule", "Right Rule"); - } - - @ParameterizedTest(name = "KieBase type={0}") - @MethodSource("parameters") - public void testDifferentPackagesRulesInDRLAndRF(KieBaseTestConfiguration kieBaseTestConfiguration) { - // DROOLS-6797 - KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "rf_test_rules_different_pkg.drl", "rf_test_rueflow.rf"); - - KiePackage kiePackage = kbase.getKiePackage("com.example.rules"); - List ruleNames = kiePackage.getRules().stream().map(rule -> rule.getName()).collect(Collectors.toList()); - - assertThat(ruleNames.size()).isEqualTo(1); - assertThat(ruleNames).contains("RuleFlow-Split-example-xxx-DROOLS_DEFAULT"); - - KiePackage kiePackageDiffPkg = kbase.getKiePackage("com.example.rules.different.pkg"); - List ruleNamesDiffPkg = kiePackageDiffPkg.getRules().stream().map(rule -> rule.getName()).collect(Collectors.toList()); - - assertThat(ruleNamesDiffPkg.size()).isEqualTo(2); - assertThat(ruleNamesDiffPkg).contains("Left Rule", "Right Rule"); - } -} diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/META-INF/services/org.kie.api.internal.assembler.KieAssemblerService b/drools-test-coverage/test-compiler-integration/src/test/resources/META-INF/services/org.kie.api.internal.assembler.KieAssemblerService deleted file mode 100644 index 1870ad6f091..00000000000 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/META-INF/services/org.kie.api.internal.assembler.KieAssemblerService +++ /dev/null @@ -1,20 +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. -# - -org.drools.mvel.integrationtests.FakeDRFAssemblerService \ No newline at end of file diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/compiler/xml/changeset/changeset1Test.drl b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/compiler/xml/changeset/changeset1Test.drl deleted file mode 100644 index dfa480c6b68..00000000000 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/compiler/xml/changeset/changeset1Test.drl +++ /dev/null @@ -1,28 +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.drools.compiler.test - -global java.util.List list; - -rule "rule1" -when -then - list.add( "rule1" ); -end \ No newline at end of file diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/compiler/xml/changeset/changeset1Test.xml b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/compiler/xml/changeset/changeset1Test.xml deleted file mode 100644 index 3598ab25b0e..00000000000 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/compiler/xml/changeset/changeset1Test.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/compiler/xml/changeset/changeset2Test.drl b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/compiler/xml/changeset/changeset2Test.drl deleted file mode 100644 index b15b4e58e1a..00000000000 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/compiler/xml/changeset/changeset2Test.drl +++ /dev/null @@ -1,28 +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.drools.compiler.test - -global java.util.List list; - -rule "rule2" -when -then - list.add( "rule2" ); -end \ No newline at end of file diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rf_test_ruleflow.rf b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rf_test_ruleflow.rf deleted file mode 100644 index c21ca9b59bd..00000000000 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rf_test_ruleflow.rf +++ /dev/null @@ -1,64 +0,0 @@ - - - - - -

- - - -
- - - - - - - - _jbpm-unique-3 - - - exists Values(this == Values.LEFT) - exists Values(this == Values.RIGHT) - eval(true) - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/test_modifyWithRuleflowAndSubnetwork.rf b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/test_modifyWithRuleflowAndSubnetwork.rf deleted file mode 100644 index b08a8b14a95..00000000000 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/test_modifyWithRuleflowAndSubnetwork.rf +++ /dev/null @@ -1,42 +0,0 @@ - - - - - -
-
- - - - - - - - - - - - -
\ No newline at end of file diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/ResourcesTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/ResourcesTest.java index a042326508b..b1cf2959b31 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/ResourcesTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/ResourcesTest.java @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Tests loading of different types of resources (DRL, DSL, DRF, BPMN2, DTABLE). + * Tests loading of different types of resources (DRL, DSL, BPMN2, DTABLE). * Packages are loaded and built using KnowledgeBuilder. */ public class ResourcesTest { diff --git a/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/sample.rf b/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/sample.rf deleted file mode 100644 index 6a511d3e509..00000000000 --- a/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/sample.rf +++ /dev/null @@ -1,97 +0,0 @@ - - - - - -
- - - - -
- - - - - - - - - - - Message ( message == "XOR" ) - Message ( message == "OR" ) - eval(true) - Message ( message == "AND" ) - - - - - - - - - - - - Person ( id >= 5 ) - Person ( id <= 5 ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/kie-api/src/main/java/org/kie/api/io/ResourceType.java b/kie-api/src/main/java/org/kie/api/io/ResourceType.java index 868e2698537..5d0ed93353d 100644 --- a/kie-api/src/main/java/org/kie/api/io/ResourceType.java +++ b/kie-api/src/main/java/org/kie/api/io/ResourceType.java @@ -135,12 +135,6 @@ public static ResourceType addResourceTypeToRegistry(final String resourceType, "src/main/resources", "rdslr"); - /** Drools Rule Flow Language */ - public static final ResourceType DRF = addResourceTypeToRegistry("DRF", - "Drools Rule Flow Language", - "src/main/resources", - "rf"); - /** jBPM BPMN2 Language */ public static final ResourceType BPMN2 = addResourceTypeToRegistry("BPMN2", "jBPM BPMN2 Language", diff --git a/kie-api/src/main/resources/change-set-1.0.0.xsd b/kie-api/src/main/resources/change-set-1.0.0.xsd deleted file mode 100644 index 87d6f7e747d..00000000000 --- a/kie-api/src/main/resources/change-set-1.0.0.xsd +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/kie-api/src/main/resources/change-set.xsd b/kie-api/src/main/resources/change-set.xsd deleted file mode 100644 index c58579bae6e..00000000000 --- a/kie-api/src/main/resources/change-set.xsd +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/kie-internal/src/main/java/org/kie/internal/builder/CompositeKnowledgeBuilder.java b/kie-internal/src/main/java/org/kie/internal/builder/CompositeKnowledgeBuilder.java index ee7e28a9e51..911f836c1a6 100644 --- a/kie-internal/src/main/java/org/kie/internal/builder/CompositeKnowledgeBuilder.java +++ b/kie-internal/src/main/java/org/kie/internal/builder/CompositeKnowledgeBuilder.java @@ -56,7 +56,7 @@ public interface CompositeKnowledgeBuilder { /** * Add a resource of the given ResourceType, using the provided ResourceConfiguration. * Resources can be created by calling any of the "newX" factory methods of - * ResourceFactory. The kind of resource (DRL, XDRL, DSL,... CHANGE_SET) must be + * ResourceFactory. The kind of resource (DRL, XDRL, DSL,... ) must be * indicated by the second argument. * * @param resource the Resource to add diff --git a/kie-internal/src/main/java/org/kie/internal/builder/KnowledgeBuilder.java b/kie-internal/src/main/java/org/kie/internal/builder/KnowledgeBuilder.java index 315e5eb2bca..542079f9811 100644 --- a/kie-internal/src/main/java/org/kie/internal/builder/KnowledgeBuilder.java +++ b/kie-internal/src/main/java/org/kie/internal/builder/KnowledgeBuilder.java @@ -95,34 +95,6 @@ * log.exception( kbuilder.getErrors().toString() ) * } * - * - *

- * The KnowledgeBuilder can also be built from a configuration using the XML change-set format and - * the ResourceType.CHANGE_SET value. While change-set supports add, remove, and modify as elements. - * KnowledgeBuilder will only process add. If the resource element provided points to a directory, all - * files found in that directory will be added. Currently the knowledge type is not derived from the - * file extension and must be explicitly set in the XML for the resource. It is expected that all - * resources in a directory given resource are of the specified type. - *

- *
- * <change-set xmlns='http://drools.org/drools-5.0/change-set'
- *             xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
- *             xs:schemaLocation='http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd' >
- *  <add>
- *       <resource source='http:org/domain/myrules.drl' type='DRL' />
- *       <resource source='classpath:data/IntegrationExampleTest.xls' type="DTABLE">
- *           <decisiontable-conf input-type="XLS" worksheet-name="Tables_2" />
- *       </resource>
- *       <resource source='file:org/drools/decisiontable/myflow.drf' type='DRF' />
- *   </add>
- * </change-set>
- * 
- * - *
- * KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "test agent", // the name of the agent
- *                                                                  kaconf );
- * kagent.applyChangeSet( ResourceFactory.newUrlResource( url ) ); // resource to the change-set xml for the resources to add
- * 
*/ public interface KnowledgeBuilder extends @@ -142,7 +114,7 @@ void add(Resource resource, /** * Add a resource of the given ResourceType, using the provided ResourceConfiguration. * Resources can be created by calling any of the "newX" factory methods of - * ResourceFactory. The kind of resource (DRL, XDRL, DSL,... CHANGE_SET) must be + * ResourceFactory. The kind of resource (DRL, XDRL, DSL,... ) must be * indicated by the second argument. * * @param resource the Resource to add