diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-03-14 21:52:12 +0000 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2024-03-15 09:49:55 +0000 |
commit | 9da69f932b1378e1d16a9206a3aa5b3acbb1d38a (patch) | |
tree | dccb457b96fe520f98f089d494a9ed174310ebce /controlloop | |
parent | e3f23281573c0e75d281709bfdd74b01c2900313 (diff) |
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>
Diffstat (limited to 'controlloop')
13 files changed, 47 insertions, 52 deletions
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 29689edf7..8341be1d3 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 @@ 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"); + } } /** 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 86a189dd3..62d5f70a9 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. 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: diff --git a/controlloop/common/controller-usecases/src/main/resources/usecases.drl b/controlloop/common/controller-usecases/src/main/resources/usecases.drl index 70a1cd8a1..f337f2179 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 @@ 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) { diff --git a/controlloop/common/eventmanager/pom.xml b/controlloop/common/eventmanager/pom.xml index 92b6e7d7d..e69054a18 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 014ccd497..2eb6c4a25 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 @@ 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; 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 bb322f825..43742df4f 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 @@ 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 { 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 84389b8c5..3fdb5d6b9 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 @@ 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; /** 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 511d93b9d..31d8c93b7 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 @@ 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; /** 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 f93b2acf5..72d498a7a 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 @@ 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; /** 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 5caca45c3..b9ec0757e 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.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, 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 93f204df3..23133f538 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 @@ 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: 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 15e03e634..a4d1739f3 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.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); 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 73dd2b348..7b886a485 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() { |