tkobayas commented on code in PR #7186:
URL: https://github.com/apache/incubator-kie/pull/7186#discussion_r4268614092


##########
drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/AlignAnnotationTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.model.codegen.execmodel;
+
+import org.drools.base.rule.TypeDeclaration;
+import org.drools.core.impl.InternalRuleBase;
+import org.drools.model.codegen.execmodel.domain.AnnotatedEvent;
+import org.drools.model.codegen.execmodel.domain.PropertyChangeSupportFact;
+import org.drools.model.codegen.execmodel.domain.PropertyReactiveFact;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.kie.api.KieServices;
+import org.kie.api.builder.model.KieModuleModel;
+import org.kie.api.definition.type.Role;
+import org.kie.api.runtime.KieSession;
+import org.kie.internal.builder.conf.PropertySpecificOption;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Reproduces the annotation-precedence discrepancy between classic and 
executable
+ * models when an empty DRL {@code declare} block exists for a Java class.
+ *
+ * <p>{@code @TypeSafe} is not covered here: neither model reads it from Java 
annotations
+ * (only from DRL {@code @typesafe}), so there is no inheritance discrepancy 
to test.
+ *
+ * @see <a 
href="https://github.com/apache/incubator-kie/issues/7185";>incubator-kie#7185</a>
+ */
+public class AlignAnnotationTest extends BaseModelTest {
+
+    private static final String ANNOTATED_EVENT_NO_DECLARE_DRL =
+            "import " + AnnotatedEvent.class.getCanonicalName() + ";\n" +
+            "rule R when AnnotatedEvent() then end\n";
+
+    private static final String ANNOTATED_EVENT_EMPTY_DECLARE_DRL =
+            "import " + AnnotatedEvent.class.getCanonicalName() + ";\n" +
+            "declare AnnotatedEvent end\n" +
+            "rule R when AnnotatedEvent() then end\n";
+
+    private static final String ANNOTATED_EVENT_OVERRIDE_DRL =
+            "import " + AnnotatedEvent.class.getCanonicalName() + ";\n" +
+            "declare AnnotatedEvent\n" +
+            "  @role(FACT)\n" +
+            "  @expires(5s)\n" +
+            "  @propertyReactive\n" +
+            "end\n" +
+            "rule R when AnnotatedEvent() then end\n";
+
+    private TypeDeclaration getTypeDeclaration(RUN_TYPE runType, String drl, 
Class<?> clazz) {
+        return getTypeDeclaration(runType, null, drl, clazz);
+    }
+
+    private TypeDeclaration getTypeDeclaration(RUN_TYPE runType, 
KieModuleModel model, String drl, Class<?> clazz) {
+        KieSession ksession = getKieSession(runType, model, drl);
+        return ((InternalRuleBase) 
ksession.getKieBase()).getTypeDeclaration(clazz);

Review Comment:
   "without dispose" is a usual practice in our test cases, but I will review 
it in https://github.com/apache/incubator-kie/issues/7187



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to