Fix Drools-Apps executing policies 19/138619/1
authoradheli.tavares <adheli.tavares@est.tech>
Thu, 1 Aug 2024 13:00:57 +0000 (14:00 +0100)
committeradheli.tavares <adheli.tavares@est.tech>
Thu, 1 Aug 2024 13:03:21 +0000 (14:03 +0100)
- hibernate dependencies were causing conflicts; updated to
latest hibernate-core with all the required deps.
- adjusted some variables to be correctly read by properties
parser.
- added STDOUT option to logback.xml to be able to get logs
from controllers/features when using docker logs command.

Issue-ID: POLICY-4955
Change-Id: Id3475fc77a63c46697c437bd413ebc1f97b731af
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
feature-distributed-locking/pom.xml
feature-pooling-messages/src/main/feature/config/feature-pooling-messages.properties
packages/base/src/files/bin/configure-maven
policy-core/pom.xml
policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerTopicTest.java [new file with mode: 0644]
policy-management/pom.xml
policy-management/src/main/server/config/logback.xml
policy-utils/pom.xml
policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java
pom.xml

index 04f0678..24d3e04 100644 (file)
@@ -3,7 +3,7 @@
   ONAP Policy Engine - Drools PDP
   ================================================================================
   Copyright (C) 2018-2022 AT&T Intellectual Property. All rights reserved.
-  Modifications Copyright (C) 2020,2023 Nordix Foundation.
+  Modifications Copyright (C) 2020, 2023-2024 Nordix Foundation.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-dbcp2</artifactId>
-            <version>2.9.0</version>
+            <version>2.12.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-pool2</artifactId>
-            <version>2.11.1</version>
+            <version>2.12.0</version>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
index 8497538..3870ede 100644 (file)
 # be enabled at the same time.
 
 pooling.usecases.enabled=true
-pooling.usecases.topic=${envd:POOLING_TOPIC}
+pooling.usecases.topic=${env:POOLING_TOPIC}
 
 # the list of sources and sinks should be identical
-kafka.source.topics=${envd:POOLING_TOPIC}
-kafka.sink.topics=${envd:POOLING_TOPIC}
+kafka.source.topics=${env:POOLING_TOPIC}
+kafka.sink.topics=${env:POOLING_TOPIC}
 
-kafka.source.topics.policy-pdp-pooling.servers=${envd:KAFKA_SERVERS}
-kafka.source.topics.policy-pdp-pooling.effectiveTopic=${envd:POOLING_TOPIC}
+kafka.source.topics.policy-pdp-pooling.servers=${env:KAFKA_SERVERS}
+kafka.source.topics.policy-pdp-pooling.effectiveTopic=${env:POOLING_TOPIC}
 kafka.source.topics.policy-pdp-pooling.apiKey=
 kafka.source.topics.policy-pdp-pooling.apiSecret=
 
-kafka.sink.topics.policy-pdp-pooling.servers=${envd:KAFKA_SERVERS}
-kafka.sink.topics.policy-pdp-pooling.effectiveTopic=${envd:POOLING_TOPIC}
+kafka.sink.topics.policy-pdp-pooling.servers=${env:KAFKA_SERVERS}
+kafka.sink.topics.policy-pdp-pooling.effectiveTopic=${env:POOLING_TOPIC}
 kafka.sink.topics.policy-pdp-pooling.apiKey=
 kafka.sink.topics.policy-pdp-pooling.apiSecret=
index 70c3d0c..c62da81 100644 (file)
@@ -4,6 +4,7 @@
 # ONAP
 # ================================================================================
 # Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+# Modifications Copyright (C) 2024 Nordix Foundation.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -24,11 +25,11 @@ if [ "${DEBUG}" = "y" ]; then
     set -x
 fi
 
-HOME_M2="${HOME}"/.m2
-mkdir -p "${HOME_M2}" 2> /dev/null
+export M2_HOME="${HOME}"/.m2
+mkdir -p "${M2_HOME}" 2> /dev/null
 
 if [ -z "${SNAPSHOT_REPOSITORY_URL}" ] && [ -z "${RELEASE_REPOSITORY_URL}" ]; then
-    ln -s -f "${POLICY_HOME}"/etc/m2/standalone-settings.xml "${HOME_M2}"/settings.xml
+    ln -s -f "${POLICY_HOME}"/etc/m2/standalone-settings.xml "${M2_HOME}"/settings.xml
 else
-    ln -s -f "${POLICY_HOME}"/etc/m2/settings.xml "${HOME_M2}"/settings.xml
+    ln -s -f "${POLICY_HOME}"/etc/m2/settings.xml "${M2_HOME}"/settings.xml
 fi
index 6f1052e..57fd613 100644 (file)
             <scope>provided</scope>
         </dependency>
 
-        <!-- Provided dependencies -->
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-xjc</artifactId>
         </dependency>
         <dependency>
             <groupId>org.glassfish.hk2.external</groupId>
-            <artifactId>javax.inject</artifactId>
+            <artifactId>jakarta.inject</artifactId>
         </dependency>
     </dependencies>
 
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerTopicTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerTopicTest.java
new file mode 100644 (file)
index 0000000..aae1aec
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.controller;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class ControllerTopicTest {
+
+    @Test
+    void testSinkTopic() {
+        var topic = new ControllerSinkTopic(ControllerSinkTopic.builder()
+            .topicName("SINK_TOPIC_NAME"));
+        Assertions.assertEquals("sink_topic_name", topic.getTopicName());
+        topic.setTopicName("NEW_TOPIC_NAME");
+        Assertions.assertEquals("new_topic_name", topic.getTopicName());
+    }
+
+    @Test
+    void testSourceTopic() {
+        var topic = new ControllerSourceTopic(ControllerSourceTopic.builder()
+            .topicName("SOURCE_TOPIC_NAME"));
+        Assertions.assertEquals("source_topic_name", topic.getTopicName());
+        topic.setTopicName("NEW_TOPIC_NAME");
+        Assertions.assertEquals("new_topic_name", topic.getTopicName());
+    }
+}
index ed776b5..c2a3b37 100644 (file)
             <artifactId>mariadb-java-client</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.hibernate.orm</groupId>
-            <artifactId>hibernate-core</artifactId>
+            <groupId>org.postgresql</groupId>
+            <artifactId>postgresql</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.hibernate.common</groupId>
-            <artifactId>hibernate-commons-annotations</artifactId>
+            <groupId>org.hibernate.orm</groupId>
+            <artifactId>hibernate-core</artifactId>
         </dependency>
         <dependency>
             <groupId>commons-io</groupId>
index 1bd7770..4e6756d 100644 (file)
@@ -3,6 +3,7 @@
   policy-management
   ================================================================================
   Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+  Modifications Copyright (C) 2024 Nordix Foundation.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
         <appender-ref ref="AsyncNetworkOut" />
     </logger>
 
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${debugPattern}</pattern>
+        </encoder>
+    </appender>
+
     <root level="INFO">
         <appender-ref ref="AsyncDebugOut" />
         <appender-ref ref="AsyncErrorOut" />
         <appender-ref ref="AsyncMetricOut" />
         <appender-ref ref="AsyncTransactionOut" />
+        <appender-ref ref="STDOUT" />
     </root>
 
 </configuration>
index 1483241..319711a 100644 (file)
@@ -45,7 +45,7 @@
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-configuration2</artifactId>
-            <version>2.8.0</version>
+            <version>2.11.0</version>
         </dependency>
         <dependency>
             <groupId>org.onap.policy.common</groupId>
index ee32cb2..f8ffa50 100644 (file)
@@ -71,6 +71,9 @@ class DomainMakerTest {
 
         policy.setType("policy.type.Z");
         assertFalse(domainMaker.isConformant(policy));
+
+        assertThatThrownBy(() -> domainMaker.isConformant(null))
+            .hasMessageContaining("policy is marked non-null but is null");
     }
 
     @Test
@@ -108,6 +111,12 @@ class DomainMakerTest {
         domainAPolicy.getProperties().getNested().setNested1("");
         ToscaConceptIdentifier ident1 = policy1.getTypeIdentifier();
         assertFalse(domainMaker.conformance(ident1, domainAPolicy));
+
+        var policy2 = getToscaPolicy("src/test/resources/policyA.json");
+        policy2.setType("not.registered.type");
+        policy2.setTypeVersion("4.2.5");
+        assertFalse(domainMaker.conformance(policy2));
+        assertFalse(domainMaker.conformance(policy2.getTypeIdentifier(), domainAPolicy));
     }
 
     @Test
@@ -125,6 +134,8 @@ class DomainMakerTest {
 
         policy.setTypeVersion("1.0.0");
         assertFalse(domainMaker.isConformant(policy));
+
+        assertFalse(domainMaker.registerValidator(policy.getTypeIdentifier(), "$schema"));
     }
 
     @Test
diff --git a/pom.xml b/pom.xml
index e80ff12..bc18855 100644 (file)
--- a/pom.xml
+++ b/pom.xml
             </dependency>
             <dependency>
                 <groupId>org.glassfish.hk2.external</groupId>
-                <artifactId>javax.inject</artifactId>
-                <version>2.5.0-b62</version>
+                <artifactId>jakarta.inject</artifactId>
+                <version>2.6.1</version>
             </dependency>
             <dependency>
                 <groupId>com.jayway.jsonpath</groupId>
                 <artifactId>json-path</artifactId>
                 <version>${version.json-path}</version>
             </dependency>
-            <dependency>
-                <groupId>org.hibernate.common</groupId>
-                <artifactId>hibernate-commons-annotations</artifactId>
-                <version>${hibernate.commons.annotations.version}</version>
-            </dependency>
             <dependency>
                 <groupId>xml-apis</groupId>
                 <artifactId>xml-apis</artifactId>