Make drools-pdp work with drools and java versions compatible
with current DRL rules files syntax.
Issue-ID: POLICY-4857
Change-Id: I40889288828da9aea757087e2c74004008336e41
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java
index 29689ed..8341be1 100644
--- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java
+++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java
@@ -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 @@
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");
+ }
}
/**
diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
index 86a189d..62d5f70 100644
--- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
+++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
@@ -37,7 +37,6 @@
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 @@
*/
public class UsecasesEventManager extends ClEventManagerWithEvent<Step2> implements StepContext {
- @Serial
private static final long serialVersionUID = -1216568161322872641L;
/**
@@ -255,7 +253,8 @@
throw new ControlLoopException("The Target type is null");
}
switch (event.getTargetType()) {
- case VM, VNF:
+ case VM:
+ case VNF:
validateAaiVmVnfData(eventAai);
return;
case PNF:
diff --git a/controlloop/common/controller-usecases/src/main/resources/usecases.drl b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
index 70a1cd8..f337f21 100644
--- a/controlloop/common/controller-usecases/src/main/resources/usecases.drl
+++ b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
@@ -741,7 +741,7 @@
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 @@
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 @@
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) {
diff --git a/controlloop/common/eventmanager/pom.xml b/controlloop/common/eventmanager/pom.xml
index 92b6e7d..e69054a 100644
--- a/controlloop/common/eventmanager/pom.xml
+++ b/controlloop/common/eventmanager/pom.xml
@@ -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");
@@ -186,8 +186,8 @@
<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>
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/drl/legacy/ControlLoopParams.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/drl/legacy/ControlLoopParams.java
index 014ccd4..2eb6c4a 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/drl/legacy/ControlLoopParams.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/drl/legacy/ControlLoopParams.java
@@ -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 @@
@NoArgsConstructor
public class ControlLoopParams implements Serializable {
- @Serial
private static final long serialVersionUID = 970755684770982776L;
private String closedLoopControlName;
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java
index bb322f8..43742df 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java
@@ -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 @@
implements StepContext {
private static final Logger logger = LoggerFactory.getLogger(ClEventManagerWithEvent.class);
- @Serial
private static final long serialVersionUID = -1216568161322872641L;
public enum NewEventStatus {
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java
index 84389b8..3fdb5d6 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java
@@ -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 @@
public abstract class ClEventManagerWithOutcome<T extends Step> extends ClEventManagerWithSteps<T>
implements StepContext {
- @Serial
private static final long serialVersionUID = -1216568161322872641L;
/**
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java
index 511d93b..31d8c93 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java
@@ -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 @@
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;
/**
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index f93b2ac..72d498a 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -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 @@
public class ControlLoopEventManager implements StepContext, Serializable {
private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManager.class);
- @Serial
private static final long serialVersionUID = -1216568161322872641L;
/**
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java
index 5caca45..b9ec075 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java
@@ -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.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 @@
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 @@
private static class RealManager extends ClEventManagerWithSteps<MyStep> {
- @Serial
private static final long serialVersionUID = 1L;
public RealManager(EventManagerServices services, ControlLoopParams params, UUID requestId,
diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
index 93f204d..23133f5 100644
--- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
+++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
@@ -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 @@
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 @@
.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:
diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java
index 15e03e6..a4d1739 100644
--- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java
+++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java
@@ -29,6 +29,7 @@
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 @@
/**
* 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 @@
* 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 @@
// 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 @@
/**
* 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 @@
* 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 @@
/**
* 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 @@
/**
* 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 @@
/**
* 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 @@
/**
* 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 @@
/**
* 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 @@
/**
* 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);
diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/SimulatorException.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/SimulatorException.java
index 73dd2b3..7b886a4 100644
--- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/SimulatorException.java
+++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/SimulatorException.java
@@ -21,13 +21,10 @@
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
--- 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>