From 1c5bec90bbd84063aaf35935b8cf95fb5e16cfc6 Mon Sep 17 00:00:00 2001 From: Matteo Mortari Date: Mon, 17 Jul 2023 15:22:27 +0200 Subject: [PATCH] DROOLS-7503 simplify testing of the Quarkus BuildItems (#5386) * DROOLS-7503 simplify testing of the Quarkus BuildItems * code review: implement feedback * code review feedback --- .../drools-drl-quarkus-deployment/pom.xml | 5 + .../quarkus/deployment/BuildItemsTest.java | 132 ++++++++++++++++++ .../otn/model/ASubclassOfMeasurement.java | 0 .../examples/otn/model/Measurement.java | 0 .../examples/otn/model/MyImplementation.java | 0 .../examples/otn/model/MyInterface.java | 0 .../examples/otn/model/MyUnusedClass.java | 0 .../src/test/resources/rules.txt | 0 .../pom.xml | 116 --------------- .../DroolsTestExtAssetsProcessor.java | 86 ------------ .../quarkus/testext/test/ExtensionTest.java | 75 ---------- .../pom.xml | 76 ---------- .../deployment/GlobalsMetadataRecorder.java | 33 ----- .../testext/deployment/GlobalsSingleton.java | 46 ------ .../deployment/OtnClassesSingleton.java | 56 -------- .../deployment/OtnMetadataRecorder.java | 35 ----- .../resources/META-INF/quarkus-extension.yaml | 7 - drools-drl-quarkus-extension/pom.xml | 2 - 18 files changed, 137 insertions(+), 532 deletions(-) create mode 100644 drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/drl/quarkus/deployment/BuildItemsTest.java rename drools-drl-quarkus-extension/{example-drools-drl-quarkus-testext-deployment => drools-drl-quarkus-deployment}/src/test/java/org/drools/quarkus/examples/otn/model/ASubclassOfMeasurement.java (100%) rename drools-drl-quarkus-extension/{example-drools-drl-quarkus-testext-deployment => drools-drl-quarkus-deployment}/src/test/java/org/drools/quarkus/examples/otn/model/Measurement.java (100%) rename drools-drl-quarkus-extension/{example-drools-drl-quarkus-testext-deployment => drools-drl-quarkus-deployment}/src/test/java/org/drools/quarkus/examples/otn/model/MyImplementation.java (100%) rename drools-drl-quarkus-extension/{example-drools-drl-quarkus-testext-deployment => drools-drl-quarkus-deployment}/src/test/java/org/drools/quarkus/examples/otn/model/MyInterface.java (100%) rename drools-drl-quarkus-extension/{example-drools-drl-quarkus-testext-deployment => drools-drl-quarkus-deployment}/src/test/java/org/drools/quarkus/examples/otn/model/MyUnusedClass.java (100%) rename drools-drl-quarkus-extension/{example-drools-drl-quarkus-testext-deployment => drools-drl-quarkus-deployment}/src/test/resources/rules.txt (100%) delete mode 100644 drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/pom.xml delete mode 100644 drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/main/java/org/drools/drl/quarkus/testext/deployment/DroolsTestExtAssetsProcessor.java delete mode 100644 drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/testext/test/ExtensionTest.java delete mode 100644 drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/pom.xml delete mode 100644 drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/GlobalsMetadataRecorder.java delete mode 100644 drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/GlobalsSingleton.java delete mode 100644 drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/OtnClassesSingleton.java delete mode 100644 drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/OtnMetadataRecorder.java delete mode 100644 drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/resources/META-INF/quarkus-extension.yaml diff --git a/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/pom.xml b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/pom.xml index bf29559cc5d..b608e9ad335 100644 --- a/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/pom.xml +++ b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/pom.xml @@ -85,6 +85,11 @@ mockito-core test + + org.assertj + assertj-core + test + diff --git a/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/drl/quarkus/deployment/BuildItemsTest.java b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/drl/quarkus/deployment/BuildItemsTest.java new file mode 100644 index 00000000000..a46bd106a5a --- /dev/null +++ b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/drl/quarkus/deployment/BuildItemsTest.java @@ -0,0 +1,132 @@ +/* + * Copyright 2023 Red Hat, Inc. and/or its affiliates. + * + * Licensed 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.drl.quarkus.deployment; + +import static org.assertj.core.api.Assertions.as; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; + +import java.lang.reflect.Type; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.assertj.core.api.InstanceOfAssertFactories; +import org.drools.drl.quarkus.util.deployment.GlobalsBuildItem; +import org.drools.drl.quarkus.util.deployment.PatternsTypesBuildItem; +import org.drools.quarkus.examples.otn.model.ASubclassOfMeasurement; +import org.drools.quarkus.examples.otn.model.Measurement; +import org.drools.quarkus.examples.otn.model.MyImplementation; +import org.drools.quarkus.examples.otn.model.MyInterface; +import org.drools.quarkus.examples.otn.model.MyUnusedClass; +import org.jboss.jandex.ClassInfo; +import org.jboss.jandex.DotName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.quarkus.arc.deployment.AdditionalBeanBuildItem; +import io.quarkus.builder.BuildContext; +import io.quarkus.builder.BuildStep; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.test.QuarkusUnitTest; + +/* + * The scope of these tests is to check the resulting BuildItems as produced by this drools-drl-quarkus-extension. + */ +public class BuildItemsTest { + + static final Logger LOG = LoggerFactory.getLogger(BuildItemsTest.class); + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addAsResource("rules.txt", "src/main/resources/org/drools/quarkus/examples/otn/rules.drl") + .addClasses(ASubclassOfMeasurement.class, Measurement.class, MyImplementation.class, MyInterface.class, MyUnusedClass.class)) + .addBuildChainCustomizer(b -> { + b.addBuildStep(new BuildStep() { + @Override + public void execute(BuildContext context) { + GlobalsBuildItem gbi = context.consume(GlobalsBuildItem.class); + assertGlobals(gbi.getGlobals()); + + CombinedIndexBuildItem indexBI = context.consume(CombinedIndexBuildItem.class); + PatternsTypesBuildItem otnClasesBI = context.consume(PatternsTypesBuildItem.class); + Set allKnown = computeAllKnown(otnClasesBI, indexBI); + assertAllKnownOTNs(allKnown); + } + }) + .consumes(GlobalsBuildItem.class) + .consumes(PatternsTypesBuildItem.class) + .consumes(CombinedIndexBuildItem.class) + .produces(AdditionalBeanBuildItem.class) + .build(); + }); + + @Test + public void testQuarkusUTByAddBuildChainCustomizer() { + assertThatNoException().isThrownBy(() -> LOG.info("looking for a successfully executed QuarkusUnitTest" + + "with custom .addBuildChainCustomizer() containing assertions")); + } + + /* + * Compute all related indexed classes, from the known OTN/Pattern classes. + */ + private static Set computeAllKnown(PatternsTypesBuildItem otnClasesBI, CombinedIndexBuildItem indexBI) { + Set allKnown = new HashSet<>(); + for (Class c : otnClasesBI.getPatternsClasses().values().stream().flatMap(x -> x.stream()).collect(Collectors.toList())) { + allKnown.add(c.getCanonicalName()); + if (c.isInterface()) { + allKnown.addAll(indexBI.getIndex().getAllKnownImplementors(c).stream().map(ClassInfo::name).map(DotName::toString).collect(Collectors.toList())); + } else { + allKnown.addAll(indexBI.getIndex().getAllKnownSubclasses(c).stream().map(ClassInfo::name).map(DotName::toString).collect(Collectors.toList())); + } + } + return allKnown; + } + + /* + * check the DRL globals, given the defined rules. + */ + private static void assertGlobals(Map> globals) { + LOG.info("GlobalsBuildItem.globals: {}", globals); + + assertThat(globals).containsKey("org.drools.quarkus.examples.otn") + .extractingByKey("org.drools.quarkus.examples.otn", as(InstanceOfAssertFactories.MAP)) + .containsKey("controlSet"); + } + + /* + * check the known Patterns/OTNs classes, given the defined DRL rules. + */ + private static void assertAllKnownOTNs(Set allKnown) { + LOG.info("allKnown: {}", allKnown); + + assertThat(allKnown) + .as("these classes or subclasses are derived from OTNs in the rules.") + .contains(ASubclassOfMeasurement.class.getCanonicalName(), + Measurement.class.getCanonicalName(), + MyImplementation.class.getCanonicalName(), + MyInterface.class.getCanonicalName() + ); + + assertThat(allKnown) + .as("this class is unused in the rules despite star-import") + .doesNotContain(MyUnusedClass.class.getCanonicalName()); + } +} diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/ASubclassOfMeasurement.java b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/ASubclassOfMeasurement.java similarity index 100% rename from drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/ASubclassOfMeasurement.java rename to drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/ASubclassOfMeasurement.java diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/Measurement.java b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/Measurement.java similarity index 100% rename from drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/Measurement.java rename to drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/Measurement.java diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyImplementation.java b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyImplementation.java similarity index 100% rename from drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyImplementation.java rename to drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyImplementation.java diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyInterface.java b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyInterface.java similarity index 100% rename from drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyInterface.java rename to drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyInterface.java diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyUnusedClass.java b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyUnusedClass.java similarity index 100% rename from drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyUnusedClass.java rename to drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/java/org/drools/quarkus/examples/otn/model/MyUnusedClass.java diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/resources/rules.txt b/drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/resources/rules.txt similarity index 100% rename from drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/resources/rules.txt rename to drools-drl-quarkus-extension/drools-drl-quarkus-deployment/src/test/resources/rules.txt diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/pom.xml b/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/pom.xml deleted file mode 100644 index 6af3413eb3c..00000000000 --- a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/pom.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - 4.0.0 - - org.drools - drools-drl-quarkus-extension - 8.42.0-SNAPSHOT - - - Drools :: Quarkus Testing Extension Example :: Deployment - example-drools-drl-quarkus-testext-deployment - An example extension consuming the drools-drl-quarkus extension - - - org.drools.drl.quarkus.testext.deployment - - - - - - org.drools - example-drools-drl-quarkus-testext - ${project.version} - - - - - - - org.drools - example-drools-drl-quarkus-testext - - - org.drools - drools-drl-quarkus-util-deployment - - - - - io.quarkus - quarkus-core-deployment - - - org.jboss - jandex - - - - - io.quarkus - quarkus-arc-deployment - - - - - org.drools - drools-drl-quarkus - test - - - io.quarkus - quarkus-junit5-internal - test - - - org.assertj - assertj-core - test - - - - - - - maven-deploy-plugin - - true - - - - maven-compiler-plugin - - - - io.quarkus - quarkus-extension-processor - ${version.io.quarkus} - - - - - - maven-surefire-plugin - - - default-test - test - - test - - - - org.jboss.logmanager.LogManager - - - - - - - org.jboss.logmanager.LogManager - - - - - - \ No newline at end of file diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/main/java/org/drools/drl/quarkus/testext/deployment/DroolsTestExtAssetsProcessor.java b/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/main/java/org/drools/drl/quarkus/testext/deployment/DroolsTestExtAssetsProcessor.java deleted file mode 100644 index 21147da8940..00000000000 --- a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/main/java/org/drools/drl/quarkus/testext/deployment/DroolsTestExtAssetsProcessor.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed 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.drl.quarkus.testext.deployment; - -import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -import javax.inject.Inject; - -import org.drools.drl.quarkus.util.deployment.GlobalsBuildItem; -import org.drools.drl.quarkus.util.deployment.KmoduleKieBaseModelsBuiltItem; -import org.drools.drl.quarkus.util.deployment.PatternsTypesBuildItem; -import org.jboss.jandex.ClassInfo; -import org.jboss.jandex.DotName; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import io.quarkus.arc.deployment.AdditionalBeanBuildItem; -import io.quarkus.arc.deployment.BeanContainerListenerBuildItem; -import io.quarkus.deployment.annotations.BuildProducer; -import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.CombinedIndexBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; - -public class DroolsTestExtAssetsProcessor { - - private static final Logger LOGGER = LoggerFactory.getLogger(DroolsTestExtAssetsProcessor.class); - - private static final String FEATURE = "drools-drl-quarkus-testext-extension"; - - @Inject - CombinedIndexBuildItem indexBI; - - @BuildStep - public FeatureBuildItem feature() { - return new FeatureBuildItem(FEATURE); - } - - @Record(STATIC_INIT) - @BuildStep - public void generateSources( PatternsTypesBuildItem otnClasesBI, Optional kbaseModelsBI, - OtnMetadataRecorder recorder, BuildProducer additionalBeanProducer, BuildProducer containerListenerProducer ) { - LOGGER.info("{}", otnClasesBI.getPatternsClasses()); - Set allKnown = new HashSet<>(); - for (Class c : otnClasesBI.getPatternsClasses().values().stream().flatMap(x -> x.stream()).collect(Collectors.toList())) { - allKnown.add(c.getCanonicalName()); - if (c.isInterface()) { - allKnown.addAll(indexBI.getIndex().getAllKnownImplementors(c).stream().map(ClassInfo::name).map(DotName::toString).collect(Collectors.toList())); - } else { - allKnown.addAll(indexBI.getIndex().getAllKnownSubclasses(c).stream().map(ClassInfo::name).map(DotName::toString).collect(Collectors.toList())); - } - } - additionalBeanProducer.produce(AdditionalBeanBuildItem.unremovableOf(OtnClassesSingleton.class)); - containerListenerProducer.produce(new BeanContainerListenerBuildItem(recorder.setContent(otnClasesBI.getPatternsClasses(), allKnown))); - if (kbaseModelsBI.isPresent()) { - LOGGER.info("{}", kbaseModelsBI.get().getKieBaseModels()); - } - } - - @Record(STATIC_INIT) - @BuildStep - public void manageGlobalsSingleton( GlobalsBuildItem globalsBI, GlobalsMetadataRecorder recorder, - BuildProducer additionalBeanProducer, BuildProducer containerListenerProducer ) { - LOGGER.info("{}", globalsBI.getGlobals()); - additionalBeanProducer.produce(AdditionalBeanBuildItem.unremovableOf(GlobalsSingleton.class)); - containerListenerProducer.produce(new BeanContainerListenerBuildItem(recorder.setContent(globalsBI.getGlobals()))); - } -} diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/testext/test/ExtensionTest.java b/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/testext/test/ExtensionTest.java deleted file mode 100644 index 624a0ce29b6..00000000000 --- a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext-deployment/src/test/java/org/drools/quarkus/testext/test/ExtensionTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates. - * - * Licensed 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.quarkus.testext.test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.as; - -import javax.inject.Inject; - -import org.assertj.core.api.InstanceOfAssertFactories; -import org.drools.drl.quarkus.testext.deployment.GlobalsSingleton; -import org.drools.drl.quarkus.testext.deployment.OtnClassesSingleton; -import org.drools.quarkus.examples.otn.model.ASubclassOfMeasurement; -import org.drools.quarkus.examples.otn.model.Measurement; -import org.drools.quarkus.examples.otn.model.MyImplementation; -import org.drools.quarkus.examples.otn.model.MyInterface; -import org.drools.quarkus.examples.otn.model.MyUnusedClass; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import io.quarkus.test.QuarkusUnitTest; - -public class ExtensionTest { - - @RegisterExtension - final static QuarkusUnitTest test = new QuarkusUnitTest() - .setArchiveProducer(() -> - ShrinkWrap.create(JavaArchive.class) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") - .addClasses(ASubclassOfMeasurement.class, - Measurement.class, - MyImplementation.class, - MyInterface.class, - MyUnusedClass.class) - .addAsResource("rules.txt", "src/main/resources/org/drools/quarkus/examples/otn/rules.drl") - ); - - @Inject - OtnClassesSingleton myBean; - - @Inject - GlobalsSingleton globalBean; - - @Test - public void test() { - assertThat(myBean.getAllKnown()).contains(ASubclassOfMeasurement.class.getCanonicalName(), - Measurement.class.getCanonicalName(), - MyImplementation.class.getCanonicalName(), - MyInterface.class.getCanonicalName()) - .as("these classes or subclasses are derived from OTNs in the rules."); - - assertThat(myBean.getAllKnown()).doesNotContain(MyUnusedClass.class.getCanonicalName()) - .as("this class is unused in the rules despite star-import"); - - assertThat(globalBean.getGlobals()).containsKey("org.drools.quarkus.examples.otn") - .extractingByKey("org.drools.quarkus.examples.otn", as(InstanceOfAssertFactories.MAP)) - .containsKey("controlSet"); - } -} diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/pom.xml b/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/pom.xml deleted file mode 100644 index 5165c123713..00000000000 --- a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - 4.0.0 - - org.drools - drools-drl-quarkus-extension - 8.42.0-SNAPSHOT - - - Drools :: Quarkus Testing Extension Example :: Runtime - example-drools-drl-quarkus-testext - An example extension consuming the drools-drl-quarkus extension - - - org.drools.drl.quarkus.testext.runtime - - - - - - io.quarkus - quarkus-core - - - io.quarkus - quarkus-arc - - - - - - - maven-deploy-plugin - - true - - - - io.quarkus - quarkus-bootstrap-maven-plugin - ${version.io.quarkus} - - - compile - - extension-descriptor - - - ${project.groupId}:${project.artifactId}-deployment:${project.version} - - org.drools.drl.testext - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - io.quarkus - quarkus-extension-processor - ${version.io.quarkus} - - - - - - ${jandex-maven-plugin.group-id} - jandex-maven-plugin - - - - \ No newline at end of file diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/GlobalsMetadataRecorder.java b/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/GlobalsMetadataRecorder.java deleted file mode 100644 index 68e057821b5..00000000000 --- a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/GlobalsMetadataRecorder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates. - * - * Licensed 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.drl.quarkus.testext.deployment; - -import java.util.Map; - -import io.quarkus.arc.runtime.BeanContainerListener; -import io.quarkus.runtime.annotations.Recorder; - -@Recorder -public class GlobalsMetadataRecorder { - - public BeanContainerListener setContent(Map> contentValue) { - return beanContainer -> { - GlobalsSingleton bean = beanContainer.beanInstance(GlobalsSingleton.class); - bean.setGlobals(contentValue); - }; - } -} diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/GlobalsSingleton.java b/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/GlobalsSingleton.java deleted file mode 100644 index 0deaa79713d..00000000000 --- a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/GlobalsSingleton.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates. - * - * Licensed 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.drl.quarkus.testext.deployment; - -import java.util.Map; - -import javax.enterprise.event.Observes; -import javax.inject.Singleton; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import io.quarkus.runtime.StartupEvent; - -@Singleton -public class GlobalsSingleton { - private static final Logger LOGGER = LoggerFactory.getLogger(GlobalsSingleton.class); - - private Map> globals; - - void onStart(@Observes StartupEvent ev) { - LOGGER.info("The application is starting..."); - } - - public Map> getGlobals() { - return globals; - } - - public void setGlobals(Map> globals) { - this.globals = globals; - } -} diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/OtnClassesSingleton.java b/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/OtnClassesSingleton.java deleted file mode 100644 index 21a9a016503..00000000000 --- a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/OtnClassesSingleton.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates. - * - * Licensed 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.drl.quarkus.testext.deployment; - -import java.util.Map; -import java.util.Set; - -import javax.enterprise.event.Observes; -import javax.inject.Singleton; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import io.quarkus.runtime.StartupEvent; - -@Singleton -public class OtnClassesSingleton { - private static final Logger LOGGER = LoggerFactory.getLogger(OtnClassesSingleton.class); - - private Map>> patternsTypesClasses; - private Set allKnown; - - void onStart(@Observes StartupEvent ev) { - LOGGER.info("The application is starting..."); - } - - public Map>> getPatternsTypesClasses() { - return patternsTypesClasses; - } - - public void setPatternsTypesClasses(Map>> patternsTypesClasses) { - this.patternsTypesClasses = patternsTypesClasses; - } - - public Set getAllKnown() { - return allKnown; - } - - public void setAllKnown(Set allKnown) { - this.allKnown = allKnown; - } -} diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/OtnMetadataRecorder.java b/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/OtnMetadataRecorder.java deleted file mode 100644 index 9ec69775ec3..00000000000 --- a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/java/org/drools/drl/quarkus/testext/deployment/OtnMetadataRecorder.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates. - * - * Licensed 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.drl.quarkus.testext.deployment; - -import java.util.Map; -import java.util.Set; - -import io.quarkus.arc.runtime.BeanContainerListener; -import io.quarkus.runtime.annotations.Recorder; - -@Recorder -public class OtnMetadataRecorder { - - public BeanContainerListener setContent(Map>> contentValue, Set allKnown) { - return beanContainer -> { - OtnClassesSingleton bean = beanContainer.beanInstance(OtnClassesSingleton.class); - bean.setPatternsTypesClasses(contentValue); - bean.setAllKnown(allKnown); - }; - } -} diff --git a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/resources/META-INF/quarkus-extension.yaml b/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/resources/META-INF/quarkus-extension.yaml deleted file mode 100644 index b32763902a4..00000000000 --- a/drools-drl-quarkus-extension/example-drools-drl-quarkus-testext/src/main/resources/META-INF/quarkus-extension.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -name: "Example Drools-DRL-testext" -metadata: - keywords: - - "drools" - - "rules" - - "DRL" diff --git a/drools-drl-quarkus-extension/pom.xml b/drools-drl-quarkus-extension/pom.xml index 64824219ff2..faaefd2ceca 100644 --- a/drools-drl-quarkus-extension/pom.xml +++ b/drools-drl-quarkus-extension/pom.xml @@ -47,8 +47,6 @@ drools-drl-quarkus-ruleunit-integration-test drools-drl-quarkus-quickstart-test drools-drl-quarkus-examples - example-drools-drl-quarkus-testext - example-drools-drl-quarkus-testext-deployment