Make drools-pdp work with drools and java versions compatible 15/137515/1
authoradheli.tavares <adheli.tavares@est.tech>
Thu, 14 Mar 2024 21:52:12 +0000 (21:52 +0000)
committeradheli.tavares <adheli.tavares@est.tech>
Fri, 15 Mar 2024 09:49:55 +0000 (09:49 +0000)
with current DRL rules files syntax.

Issue-ID: POLICY-4857
Change-Id: I40889288828da9aea757087e2c74004008336e41
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
14 files changed:
controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java
controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
controlloop/common/controller-usecases/src/main/resources/usecases.drl
controlloop/common/eventmanager/pom.xml
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/drl/legacy/ControlLoopParams.java
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java
controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java
controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/SimulatorException.java
pom.xml

index 29689ed..8341be1 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -93,11 +93,16 @@ public class GetTargetEntityOperation2 extends OperationPartial {
             throw new IllegalArgumentException("The target type is null");
         }
 
-        return switch (targetType) {
-            case PNF -> detmPnfTarget();
-            case VM, VNF, VFMODULE -> detmVfModuleTarget();
-            default -> throw new IllegalArgumentException("The target type is not supported");
-        };
+        switch (targetType) {
+            case PNF:
+                return detmPnfTarget();
+            case VM:
+            case VNF:
+            case VFMODULE:
+                return detmVfModuleTarget();
+            default:
+                throw new IllegalArgumentException("The target type is not supported");
+        }
     }
 
     /**
index 86a189d..62d5f70 100644 (file)
@@ -37,7 +37,6 @@ import static org.onap.policy.drools.apps.controller.usecases.UsecasesConstants.
 import static org.onap.policy.drools.apps.controller.usecases.UsecasesConstants.VSERVER_PROV_STATUS;
 import static org.onap.policy.drools.apps.controller.usecases.UsecasesConstants.VSERVER_VSERVER_NAME;
 
-import java.io.Serial;
 import java.util.Deque;
 import java.util.Map;
 import java.util.Set;
@@ -72,7 +71,6 @@ import org.onap.policy.sdnr.PciMessage;
  */
 public class UsecasesEventManager extends ClEventManagerWithEvent<Step2> implements StepContext {
 
-    @Serial
     private static final long serialVersionUID = -1216568161322872641L;
 
     /**
@@ -255,7 +253,8 @@ public class UsecasesEventManager extends ClEventManagerWithEvent<Step2> impleme
             throw new ControlLoopException("The Target type is null");
         }
         switch (event.getTargetType()) {
-            case VM, VNF:
+            case VM:
+            case VNF:
                 validateAaiVmVnfData(eventAai);
                 return;
             case PNF:
index 70a1cd8..f337f21 100644 (file)
@@ -741,7 +741,7 @@ rule "EVENT.MANAGER.PROCESS.FINAL.FAILURE.ACCEPTED"
         notification.setPolicyName($manager.getPolicyName());
         notification.setPolicyVersion($manager.getPolicyVersion());
         notification.setHistory($manager.getPartialHistory().stream().map(OperationOutcome2::getClOperation)
-                                .toList());
+                                .collect(Collectors.toList()));
 
         // trigger move to the next policy - clear all steps
         $manager.getSteps().clear();
@@ -800,7 +800,7 @@ rule "EVENT.MANAGER.PROCESS.FINAL.FAILURE.REJECTED"
         notification.setPolicyName($manager.getPolicyName());
         notification.setPolicyVersion($manager.getPolicyVersion());
         notification.setHistory($manager.getPartialHistory().stream().map(OperationOutcome2::getClOperation)
-                                .toList());
+                                .collect(Collectors.toList()));
 
         $manager.deliver("policy-cl-mgt", notification, "notification", drools.getRule().getName());
 
@@ -1004,7 +1004,7 @@ rule "EVENT.MANAGER.FINAL"
         notification.setPolicyName($manager.getPolicyName());
         notification.setPolicyVersion($manager.getPolicyVersion());
         notification.setHistory($manager.getFullHistory().stream().map(OperationOutcome2::getClOperation)
-                                    .toList());
+                    .collect(Collectors.toList()));
 
         OperationFinalResult finalResult = $manager.getFinalResult();
         if (finalResult == null) {
index 92b6e7d..e69054a 100644 (file)
@@ -3,7 +3,7 @@
   eventmanager
   ================================================================================
   Copyright (C) 2017-2022 AT&T Intellectual Property. All rights reserved.
-  Modifications Copyright (C) 2019,2023 Nordix Foundation.
+  Modifications Copyright (C) 2019, 2023-2024 Nordix Foundation.
   Modifications Copyright (C) 2019-2020 Bell Canada.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
             <version>${policy.models.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
index 014ccd4..2eb6c4a 100644 (file)
@@ -21,7 +21,6 @@
 
 package org.onap.policy.controlloop.drl.legacy;
 
-import java.io.Serial;
 import java.io.Serializable;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -31,7 +30,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
 @NoArgsConstructor
 public class ControlLoopParams implements Serializable {
 
-    @Serial
     private static final long serialVersionUID = 970755684770982776L;
 
     private String closedLoopControlName;
index bb322f8..43742df 100644 (file)
@@ -21,7 +21,6 @@
 
 package org.onap.policy.controlloop.eventmanager;
 
-import java.io.Serial;
 import java.util.HashMap;
 import lombok.AccessLevel;
 import lombok.Getter;
@@ -47,7 +46,6 @@ public abstract class ClEventManagerWithEvent<T extends Step> extends ClEventMan
                 implements StepContext {
 
     private static final Logger logger = LoggerFactory.getLogger(ClEventManagerWithEvent.class);
-    @Serial
     private static final long serialVersionUID = -1216568161322872641L;
 
     public enum NewEventStatus {
index 84389b8..3fdb5d6 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -21,7 +21,6 @@
 
 package org.onap.policy.controlloop.eventmanager;
 
-import java.io.Serial;
 import java.util.Deque;
 import java.util.LinkedList;
 import java.util.UUID;
@@ -46,7 +45,6 @@ import org.onap.policy.drools.domain.models.operational.OperationalTarget;
 public abstract class ClEventManagerWithOutcome<T extends Step> extends ClEventManagerWithSteps<T>
                 implements StepContext {
 
-    @Serial
     private static final long serialVersionUID = -1216568161322872641L;
 
     /**
index 511d93b..31d8c93 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -21,7 +21,6 @@
 
 package org.onap.policy.controlloop.eventmanager;
 
-import java.io.Serial;
 import java.util.ArrayDeque;
 import java.util.Deque;
 import java.util.LinkedHashMap;
@@ -57,7 +56,6 @@ import org.slf4j.LoggerFactory;
 public abstract class ClEventManagerWithSteps<T extends Step> extends ControlLoopEventManager implements StepContext {
 
     private static final Logger logger = LoggerFactory.getLogger(ClEventManagerWithSteps.class);
-    @Serial
     private static final long serialVersionUID = -1216568161322872641L;
 
     /**
index f93b2ac..72d498a 100644 (file)
@@ -21,7 +21,6 @@
 
 package org.onap.policy.controlloop.eventmanager;
 
-import java.io.Serial;
 import java.io.Serializable;
 import java.time.Instant;
 import java.util.Deque;
@@ -63,7 +62,6 @@ import org.slf4j.LoggerFactory;
 public class ControlLoopEventManager implements StepContext, Serializable {
 
     private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManager.class);
-    @Serial
     private static final long serialVersionUID = -1216568161322872641L;
 
     /**
index 5caca45..b9ec075 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2021, 2023 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -38,7 +38,6 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import java.io.Serial;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
@@ -401,7 +400,6 @@ class ClEventManagerWithStepsTest {
 
 
     private class MyManager extends ClEventManagerWithSteps<MyStep> {
-        @Serial
         private static final long serialVersionUID = 1L;
 
         public MyManager(EventManagerServices services, ControlLoopParams params, UUID requestId, WorkingMemory workMem)
@@ -435,7 +433,6 @@ class ClEventManagerWithStepsTest {
 
 
     private static class RealManager extends ClEventManagerWithSteps<MyStep> {
-        @Serial
         private static final long serialVersionUID = 1L;
 
         public RealManager(EventManagerServices services, ControlLoopParams params, UUID requestId,
index 93f204d..23133f5 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -167,10 +167,16 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
         setNotificationValues(controller, notification);
 
         switch (notification.getNotification()) {
-            case REJECTED, FINAL_FAILURE, FINAL_SUCCESS, FINAL_OPENLOOP:
+            case REJECTED:
+            case FINAL_FAILURE:
+            case FINAL_SUCCESS:
+            case FINAL_OPENLOOP:
                 endTransaction(controller, notification);
                 break;
-            case ACTIVE, OPERATION, OPERATION_SUCCESS, OPERATION_FAILURE:
+            case ACTIVE:
+            case OPERATION:
+            case OPERATION_SUCCESS:
+            case OPERATION_FAILURE:
                 /* any other value is an in progress transaction */
                 inProgressTransaction(notification);
                 break;
@@ -353,14 +359,14 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
                 .setEndTime(notification.getNotificationTime().toInstant());
 
         switch (notification.getNotification()) {
-            case FINAL_OPENLOOP,
+            case FINAL_OPENLOOP:
                  /* fall through */
-                 FINAL_SUCCESS:
+            case FINAL_SUCCESS:
                 trans.setStatusCode(true);
                 break;
-            case FINAL_FAILURE,
+            case FINAL_FAILURE:
                  /* fall through */
-                 REJECTED:
+            case REJECTED:
                 trans.setStatusCode(false);
                 break;
             default:
index 15e03e6..a4d1739 100644 (file)
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Supplier;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import lombok.AccessLevel;
 import lombok.Getter;
@@ -209,7 +210,7 @@ public abstract class BaseTest {
     /**
      * Service123 with Tosca Compliant Policy.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void testService123Compliant() {
         policyClMgt = createNoficationTopicListener();
         appcLcmRead = topics.createListener(APPC_LCM_READ_TOPIC, AppcLcmMessageWrapper.class, APPC_LCM_CODER);
@@ -255,7 +256,7 @@ public abstract class BaseTest {
      * to obtain a lock since it is a different target. After processing of all events
      * there should only be the policy and params objects left in memory.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void testDuplicatesEvents() {
         policyClMgt = createNoficationTopicListener();
         appcLcmRead = topics.createListener(APPC_LCM_READ_TOPIC, AppcLcmMessageWrapper.class, APPC_LCM_CODER);
@@ -288,7 +289,7 @@ public abstract class BaseTest {
 
         // get the list of target names, so we can ensure there's one of each
         List<String> actual = Stream.of(notif1, notif2).map(notif -> notif.getAai().get("generic-vnf.vnf-id"))
-                        .sorted().toList();
+                        .sorted().collect(Collectors.toList());
 
         assertEquals(List.of("duplicate-VNF", "vCPE_Infrastructure_vGMUX_demo_app").toString(), actual.toString());
 
@@ -303,7 +304,7 @@ public abstract class BaseTest {
     /**
      * Sunny Day with Tosca Compliant Policy.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void testVcpeSunnyDayCompliant() {
         appcLcmSunnyDay(VCPE_TOSCA_COMPLIANT_POLICY, VCPE_ONSET_1, APPC_RESTART_OP);
     }
@@ -313,7 +314,7 @@ public abstract class BaseTest {
      * simulate the flooding behavior of the DCAE TCA microservice. TCA could blast tens
      * or hundreds of ONSETs within sub-second intervals.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void testVcpeOnsetFloodPrevention() {
         appcLcmSunnyDay(VCPE_TOSCA_COMPLIANT_POLICY, List.of(VCPE_ONSET_1, VCPE_ONSET_2, VCPE_ONSET_3),
                         APPC_RESTART_OP);
@@ -324,7 +325,7 @@ public abstract class BaseTest {
     /**
      * Sunny Day with Tosca Compliant Policy.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void testVdnsSunnyDayCompliant() {
         httpSunnyDay(VDNS_TOSCA_COMPLIANT_POLICY, VDNS_ONSET);
     }
@@ -343,7 +344,7 @@ public abstract class BaseTest {
     /**
      * VFW Sunny Day with Tosca Compliant Policy.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void testVfwSunnyDayCompliant() {
         appcLegacySunnyDay(VFW_TOSCA_COMPLIANT_POLICY, VFW_ONSET, APPC_MODIFY_CONFIG_OP);
     }
@@ -367,7 +368,7 @@ public abstract class BaseTest {
     /**
      * VPCI Sunny Day Tosca Policy.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void testVpciSunnyDayCompliant() {
         sdnrSunnyDay(VPCI_TOSCA_COMPLIANT_POLICY, VPCI_ONSET, VPCI_SDNR_SUCCESS,
             SDNR_MODIFY_CONFIG_OP, SDNR_CL_TOPIC, SDNR_CL_RSP_TOPIC);
@@ -378,7 +379,7 @@ public abstract class BaseTest {
     /**
      * VSONH Sunny Day with Tosca Policy.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void testVsonhSunnyDayCompliant() {
         sdnrSunnyDay(VSONH_TOSCA_COMPLIANT_POLICY, VSONH_ONSET, VSONH_SDNR_SUCCESS,
             SNDR_MODIFY_CONFIG_ANR_OP, SDNR_CL_TOPIC, SDNR_CL_RSP_TOPIC);
@@ -387,7 +388,7 @@ public abstract class BaseTest {
     /**
      * Sunny day 5G SON 01 Modify01Config Operational Policy.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void test5gSonO1SunnyDayCompliant() {
         sdnrSunnyDay(V5G_SON_O1_TOSCA_POLICY, V5G_SON_O1_ONSET, V5G_SON_O1_SDNR_SUCCESS,
             MODIFY_O1_CONFIG_OPERATION, SDNR_CL_TOPIC, SDNR_CL_RSP_TOPIC);
@@ -396,7 +397,7 @@ public abstract class BaseTest {
     /**
      * Sunny day 5G SON A1 ModifyA1Policy Operational Policy.
      */
-    //TODO This test needs to be enabled in java-17 branch
+    @Test
     public void test5gSonA1SunnyDayCompliant() {
         sdnrSunnyDay(V5G_SON_A1_TOSCA_POLICY, V5G_SON_A1_ONSET, V5G_SON_A1_SDNR_SUCCESS,
             PUT_A1_POLICY_OPERATION, A1P_CL_TOPIC, A1P_CL_RSP_TOPIC);
index 73dd2b3..7b886a4 100644 (file)
 
 package org.onap.policy.controlloop.common.rules.test;
 
-import java.io.Serial;
-
 /**
  * Exception thrown by <i>Simulators</i>.
  */
 public class SimulatorException extends RuntimeException {
-    @Serial
     private static final long serialVersionUID = 1L;
 
     public SimulatorException() {
diff --git a/pom.xml b/pom.xml
index 89f405b..2bd54a0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -69,7 +69,7 @@
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
                     <encoding>${project.build.sourceEncoding}</encoding>
-                    <release>${java.version}</release>
+                    <release>11</release>
                 </configuration>
             </plugin>
             <plugin>