Drools support for kafka topics 52/136952/1
authoradheli.tavares <adheli.tavares@est.tech>
Tue, 9 Jan 2024 15:19:07 +0000 (15:19 +0000)
committeradheli.tavares <adheli.tavares@est.tech>
Tue, 9 Jan 2024 16:20:10 +0000 (16:20 +0000)
Issue-ID: POLICY-4201
Change-Id: I91676c168c676018aa1079943747f16917f50a49
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
13 files changed:
feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigTest.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/TestConstants.java [new file with mode: 0644]
policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java
policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java
policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java
policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java
policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java

index d970585..eb8860d 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 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.
@@ -35,6 +36,8 @@ import org.onap.policy.drools.persistence.SystemPersistenceConstants;
 
 public class LegacyConfigTest {
 
+    private static final String PDPD_CONFIGURATION_TOPIC = "pdpd-configuration";
+
     /**
      * Set up.
      */
@@ -61,7 +64,7 @@ public class LegacyConfigTest {
         assertTrue(config.start());
         assertTrue(config.isAlive());
 
-        config.onTopicEvent(Topic.CommInfrastructure.NOOP, "PDPD-CONFIGURATION", "{}");
+        config.onTopicEvent(Topic.CommInfrastructure.NOOP, PDPD_CONFIGURATION_TOPIC, "{}");
         assertTrue(config.isAlive());
 
         assertTrue(config.stop());
@@ -75,7 +78,7 @@ public class LegacyConfigTest {
     public void testConstructors() {
         LegacyConfig config = new LegacyConfig();
         assertNotNull(config.getProperties());
-        assertEquals("PDPD-CONFIGURATION", config.getSource().getTopic());
+        assertEquals(PDPD_CONFIGURATION_TOPIC, config.getSource().getTopic());
 
         SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes/bad-properties-1");
         assertThatIllegalStateException().isThrownBy(LegacyConfig::new);
index 8e62e2a..6973745 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -156,7 +156,7 @@ public class PolicyTypeNativeDroolsController implements PolicyTypeController {
             List<TopicSource> sources =
                     TopicEndpointManager.getManager().getTopicSources(List.of(configSourceTopic.getTopicName()));
             if (sources.size() != 1) {
-                logger.warn("Topic {} is not present or ambigous {}", configSourceTopic.getTopicName(), sources);
+                logger.warn("Topic {} is not present or ambiguous {}", configSourceTopic.getTopicName(), sources);
                 return false;
             }
 
index 3fa8ac9..0ab9f88 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  * Copyright (C) 2021-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -53,6 +53,7 @@ import org.onap.policy.common.utils.time.TestTimeMulti;
 import org.onap.policy.drools.domain.models.artifact.NativeArtifactPolicy;
 import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
 import org.onap.policy.drools.persistence.SystemPersistenceConstants;
+import org.onap.policy.drools.server.restful.TestConstants;
 import org.onap.policy.drools.system.PolicyControllerConstants;
 import org.onap.policy.drools.system.PolicyEngineConstants;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
@@ -138,8 +139,8 @@ public class LifecycleFsmUpdateTest {
         // @formatter:on
 
         Properties noopTopicProperties = new Properties();
-        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS, "DCAE_TOPIC");
-        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL");
+        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS, TestConstants.DCAE_TOPIC);
+        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, TestConstants.APPC_CL_TOPIC);
         TopicEndpointManager.getManager().addTopics(noopTopicProperties);
 
         savedFsm = LifecycleFeature.fsm;
index 67efa72..653a469 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -40,6 +40,7 @@ import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.drools.server.restful.TestConstants;
 import org.onap.policy.drools.system.PolicyEngineConstants;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
 import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -127,8 +128,8 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest
         // add topics
 
         Properties noopTopicProperties = new Properties();
-        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS, "DCAE_TOPIC");
-        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL");
+        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS, TestConstants.DCAE_TOPIC);
+        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, TestConstants.APPC_CL_TOPIC);
         TopicEndpointManager.getManager().addTopics(noopTopicProperties);
 
         assertTrue(fsm.update(update));
index b6f354e..95f0ff5 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020-2022 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.
@@ -35,6 +36,7 @@ import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
+import org.onap.policy.drools.server.restful.TestConstants;
 import org.onap.policy.drools.system.PolicyControllerConstants;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
 
@@ -79,8 +81,8 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
             () -> PolicyControllerConstants.getFactory().get(controllerPolicy.getName()));
 
         Properties noopTopicProperties = new Properties();
-        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS, "DCAE_TOPIC");
-        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL");
+        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS, TestConstants.DCAE_TOPIC);
+        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, TestConstants.APPC_CL_TOPIC);
         TopicEndpointManager.getManager().addTopics(noopTopicProperties);
 
         assertTrue(controller.deploy(policy));
@@ -91,10 +93,13 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
     @Test
     public void testControllerProperties() throws CoderException {
         Properties noopTopicProperties = new Properties();
-        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS,
-                "DCAE_TOPIC,APPC-CL,APPC-LCM-WRITE,SDNR-CL-RSP");
-        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS,
-                "APPC-CL,APPC-LCM-READ,POLICY-CL-MGT,DCAE_CL_RSP");
+        String noopSources = String.join(",", TestConstants.DCAE_TOPIC, TestConstants.APPC_CL_TOPIC,
+            TestConstants.APPC_LCM_WRITE_TOPIC, TestConstants.SDNR_CL_RSP_TOPIC);
+        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS, noopSources);
+
+        String noopSinks = String.join(",", TestConstants.APPC_CL_TOPIC, TestConstants.APPC_LCM_READ_TOPIC,
+            TestConstants.POLICY_CL_MGT_TOPIC, TestConstants.DCAE_CL_RSP_TOPIC);
+        noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, noopSinks);
         TopicEndpointManager.getManager().addTopics(noopTopicProperties);
 
         ToscaPolicy nativeControllerPolicy =
@@ -110,66 +115,66 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
         assertNull(properties.getProperty("rules.artifactId"));
         assertNull(properties.getProperty("rules.version"));
 
-        assertEquals("DCAE_TOPIC,APPC-CL,APPC-LCM-WRITE,SDNR-CL-RSP",
+        assertEquals("dcae_topic,appc-cl,appc-lcm-write,sdnr-cl-rsp",
                 properties.getProperty("noop.source.topics"));
-        assertEquals("APPC-CL,APPC-LCM-READ,POLICY-CL-MGT,DCAE_CL_RSP",
+        assertEquals("appc-cl,appc-lcm-read,policy-cl-mgt,dcae_cl_rsp",
                 properties.getProperty("noop.sink.topics"));
 
         assertEquals("org.onap.policy.controlloop.CanonicalOnset,org.onap.policy.controlloop.CanonicalAbated",
-                properties.getProperty("noop.source.topics.DCAE_TOPIC.events"));
+                properties.getProperty("noop.source.topics.dcae_topic.events"));
         assertEquals("[?($.closedLoopEventStatus == 'ONSET')]",
             properties
-                .getProperty("noop.source.topics.DCAE_TOPIC.events.org.onap.policy.controlloop.CanonicalOnset.filter"));
+                .getProperty("noop.source.topics.dcae_topic.events.org.onap.policy.controlloop.CanonicalOnset.filter"));
         assertEquals("[?($.closedLoopEventStatus == 'ABATED')]",
             properties
-                .getProperty("noop.source.topics.DCAE_TOPIC.events."
+                .getProperty("noop.source.topics.dcae_topic.events."
                                      + "org.onap.policy.controlloop.CanonicalAbated.filter"));
         assertEquals("org.onap.policy.controlloop.util.Serialization,gson",
-                properties.getProperty("noop.source.topics.DCAE_TOPIC.events.custom.gson"));
+                properties.getProperty("noop.source.topics.dcae_topic.events.custom.gson"));
 
-        assertEquals("org.onap.policy.appc.Response", properties.getProperty("noop.source.topics.APPC-CL.events"));
+        assertEquals("org.onap.policy.appc.Response", properties.getProperty("noop.source.topics.appc-cl.events"));
         assertEquals("[?($.CommonHeader && $.Status)]",
                 properties
-                        .getProperty("noop.source.topics.APPC-CL.events.org.onap.policy.appc.Response.filter"));
+                        .getProperty("noop.source.topics.appc-cl.events.org.onap.policy.appc.Response.filter"));
         assertEquals("org.onap.policy.appc.util.Serialization,gsonPretty",
-                properties.getProperty("noop.source.topics.APPC-CL.events.custom.gson"));
+                properties.getProperty("noop.source.topics.appc-cl.events.custom.gson"));
 
         assertEquals("org.onap.policy.appclcm.AppcLcmDmaapWrapper",
-                properties.getProperty("noop.source.topics.APPC-LCM-WRITE.events"));
+                properties.getProperty("noop.source.topics.appc-lcm-write.events"));
         assertEquals("[?($.type == 'response')]",
             properties
-                .getProperty("noop.source.topics.APPC-LCM-WRITE.events."
+                .getProperty("noop.source.topics.appc-lcm-write.events."
                         + "org.onap.policy.appclcm.AppcLcmDmaapWrapper.filter"));
         assertEquals("org.onap.policy.appclcm.util.Serialization,gson",
-                properties.getProperty("noop.source.topics.APPC-LCM-WRITE.events.custom.gson"));
+                properties.getProperty("noop.source.topics.appc-lcm-write.events.custom.gson"));
 
         assertEquals("org.onap.policy.sdnr.PciResponseWrapper",
-                properties.getProperty("noop.source.topics.SDNR-CL-RSP.events"));
+                properties.getProperty("noop.source.topics.sdnr-cl-rsp.events"));
         assertEquals("[?($.type == 'response')]",
                 properties
-                        .getProperty("noop.source.topics.SDNR-CL-RSP.events."
+                        .getProperty("noop.source.topics.sdnr-cl-rsp.events."
                                              + "org.onap.policy.sdnr.PciResponseWrapper.filter"));
         assertEquals("org.onap.policy.sdnr.util.Serialization,gson",
-                properties.getProperty("noop.source.topics.SDNR-CL-RSP.events.custom.gson"));
+                properties.getProperty("noop.source.topics.sdnr-cl-rsp.events.custom.gson"));
 
-        assertEquals("org.onap.policy.appc.Request", properties.getProperty("noop.sink.topics.APPC-CL.events"));
+        assertEquals("org.onap.policy.appc.Request", properties.getProperty("noop.sink.topics.appc-cl.events"));
         assertEquals("org.onap.policy.appc.util.Serialization,gsonPretty",
-                properties.getProperty("noop.sink.topics.APPC-CL.events.custom.gson"));
+                properties.getProperty("noop.sink.topics.appc-cl.events.custom.gson"));
 
         assertEquals("org.onap.policy.appclcm.AppcLcmDmaapWrapper",
-                properties.getProperty("noop.sink.topics.APPC-LCM-READ.events"));
+                properties.getProperty("noop.sink.topics.appc-lcm-read.events"));
         assertEquals("org.onap.policy.appclcm.util.Serialization,gson",
-                properties.getProperty("noop.sink.topics.APPC-LCM-READ.events.custom.gson"));
+                properties.getProperty("noop.sink.topics.appc-lcm-read.events.custom.gson"));
 
         assertEquals("org.onap.policy.controlloop.VirtualControlLoopNotification",
-                properties.getProperty("noop.sink.topics.POLICY-CL-MGT.events"));
+                properties.getProperty("noop.sink.topics.policy-cl-mgt.events"));
         assertEquals("org.onap.policy.controlloop.util.Serialization,gsonPretty",
-                properties.getProperty("noop.sink.topics.POLICY-CL-MGT.events.custom.gson"));
+                properties.getProperty("noop.sink.topics.policy-cl-mgt.events.custom.gson"));
 
         assertEquals("org.onap.policy.controlloop.ControlLoopResponse",
-                properties.getProperty("noop.sink.topics.DCAE_CL_RSP.events"));
+                properties.getProperty("noop.sink.topics.dcae_cl_rsp.events"));
         assertEquals("org.onap.policy.controlloop.util.Serialization,gsonPretty",
-                properties.getProperty("noop.sink.topics.DCAE_CL_RSP.events.custom.gson"));
+                properties.getProperty("noop.sink.topics.dcae_cl_rsp.events.custom.gson"));
 
         assertEquals("test", properties.getProperty("notes"));
         assertEquals("auto", properties.getProperty("persistence.type"));
index 29ef5a7..37c1e8d 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2022 Nordix Foundation.
+ * Modifications Copyright (C) 2022, 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.
@@ -69,34 +69,34 @@ public class RestLifecycleManagerTest {
     // Native Drools Policy
     private static final String EXAMPLE_NATIVE_CONTROLLER_POLICY_NAME = "example.controller";
     private static final String EXAMPLE_NATIVE_CONTROLLER_POLICY_JSON =
-            "src/test/resources/tosca-policy-native-controller-example.json";
+        "src/test/resources/tosca-policy-native-controller-example.json";
 
     private static final String EXAMPLE_NATIVE_ARTIFACT_POLICY_NAME = "example.artifact";
     private static final String EXAMPLE_NATIVE_ARTIFACT_POLICY_JSON =
-            "src/test/resources/tosca-policy-native-artifact-example.json";
+        "src/test/resources/tosca-policy-native-artifact-example.json";
 
     private static final String EXAMPLE_OTHER_UNVAL_POLICY_NAME = "other-unvalidated";
     private static final String EXAMPLE_OTHER_UNVAL_POLICY_JSON =
-            "src/test/resources/tosca-policy-other-unvalidated.json";
+        "src/test/resources/tosca-policy-other-unvalidated.json";
 
     private static final String EXAMPLE_OTHER_VAL_POLICY_NAME = "other-validated";
     private static final String EXAMPLE_OTHER_VAL_POLICY_JSON =
-            "src/test/resources/tosca-policy-other-validated.json";
+        "src/test/resources/tosca-policy-other-validated.json";
 
     private static final String EXAMPLE_OTHER_VAL_ERROR_POLICY_NAME = "other-validation-error";
     private static final String EXAMPLE_OTHER_VAL_ERROR_POLICY_JSON =
-            "src/test/resources/tosca-policy-other-validation-error.json";
+        "src/test/resources/tosca-policy-other-validation-error.json";
 
     private static final String OP_POLICY_NAME_VCPE = "operational.restart";
     private static final String VCPE_OPERATIONAL_DROOLS_POLICY_JSON =
-            "policies/vCPE.policy.operational.input.tosca.json";
+        "policies/vCPE.policy.operational.input.tosca.json";
 
     public static final String PROM_DEPLOY_REQUESTS_TOTAL_UNDEPLOY_ACCEPTED =
-            "pdpd_policy_deployments_total{state=\"ACTIVE\",operation=\"undeploy\",status=\"SUCCESS\",}";
+        "pdpd_policy_deployments_total{state=\"ACTIVE\",operation=\"undeploy\",status=\"SUCCESS\",}";
     public static final String PDPD_DEPLOY_REQUESTS_TOTAL_DEPLOY_ACCEPTED =
-            "pdpd_policy_deployments_total{state=\"ACTIVE\",operation=\"deploy\",status=\"SUCCESS\",}";
+        "pdpd_policy_deployments_total{state=\"ACTIVE\",operation=\"deploy\",status=\"SUCCESS\",}";
     public static final String PDPD_DEPLOY_REQUESTS_TOTAL_DEPLOY_DECLINED =
-            "pdpd_policy_deployments_total{state=\"ACTIVE\",operation=\"deploy\",status=\"FAIL\",}";
+        "pdpd_policy_deployments_total{state=\"ACTIVE\",operation=\"deploy\",status=\"FAIL\",}";
 
     private static final StandardCoder coder = new StandardCoder();
     private static final ControllerSupport controllerSupport = new ControllerSupport("lifecycle");
@@ -108,7 +108,7 @@ public class RestLifecycleManagerTest {
      * Set up.
      */
     @Before
-     public void setUp() throws Exception {
+    public void setUp() throws Exception {
 
         SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
         fsm = newFsmInstance();
@@ -132,10 +132,10 @@ public class RestLifecycleManagerTest {
 
         HttpServletServer server =
             HttpServletServerFactoryInstance.getServerFactory().build("lifecycle", "localhost", 8765, "/",
-                                        true, true);
+                true, true);
         server.setPrometheus("/policy/pdp/engine/lifecycle/metrics");
         server.setSerializationProvider(
-                        String.join(",", JacksonHandler.class.getName(), YamlJacksonHandler.class.getName()));
+            String.join(",", JacksonHandler.class.getName(), YamlJacksonHandler.class.getName()));
         server.addServletClass("/*", RestLifecycleManager.class.getName());
         server.waitedStart(5000L);
 
@@ -145,9 +145,11 @@ public class RestLifecycleManagerTest {
 
         Properties noopTopicProperties = new Properties();
         noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS,
-                "DCAE_TOPIC,APPC-CL,APPC-LCM-WRITE,SDNR-CL-RSP");
+            String.join(",", TestConstants.DCAE_TOPIC, TestConstants.APPC_CL_TOPIC,
+                TestConstants.APPC_LCM_WRITE_TOPIC, TestConstants.SDNR_CL_RSP_TOPIC));
         noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS,
-                "APPC-CL,APPC-LCM-READ,POLICY-CL-MGT,SDNR-CL,DCAE_CL_RSP");
+            String.join(",", TestConstants.APPC_CL_TOPIC, TestConstants.APPC_LCM_READ_TOPIC,
+                TestConstants.POLICY_CL_MGT_TOPIC, TestConstants.SDNR_CL_TOPIC, TestConstants.DCAE_CL_RSP_TOPIC));
         TopicEndpointManager.getManager().addTopics(noopTopicProperties);
 
         client = HttpClientFactoryInstance.getClientFactory().get("lifecycle");
@@ -204,7 +206,7 @@ public class RestLifecycleManagerTest {
 
         booleanPut("state/ACTIVE", "", Status.OK.getStatusCode(), Boolean.TRUE);
         assertEquals(PdpState.ACTIVE,
-                HttpClient.getBody(get("state", Status.OK.getStatusCode()), PdpState.class));
+            HttpClient.getBody(get("state", Status.OK.getStatusCode()), PdpState.class));
 
         /* add native controller policy */
 
@@ -248,7 +250,7 @@ public class RestLifecycleManagerTest {
 
         /* add tosca compliant operational policy */
 
-        ToscaPolicy opPolicy = getExamplesPolicy(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, OP_POLICY_NAME_VCPE);
+        ToscaPolicy opPolicy = getExamplesPolicy();
         opPolicy.getProperties().put("controllerName", "lifecycle");
         if (StringUtils.isBlank(opPolicy.getName())) {
             opPolicy.setName("" + opPolicy.getMetadata().get("policy-id"));
@@ -266,13 +268,13 @@ public class RestLifecycleManagerTest {
         /* try to add invalid tosca policy "other-validation-error" of policy type "typeA" */
 
         ToscaPolicy toscaPolicyValError =
-                getPolicyFromFile(EXAMPLE_OTHER_VAL_ERROR_POLICY_JSON, EXAMPLE_OTHER_VAL_ERROR_POLICY_NAME);
+            getPolicyFromFile(EXAMPLE_OTHER_VAL_ERROR_POLICY_JSON, EXAMPLE_OTHER_VAL_ERROR_POLICY_NAME);
         assertThat(
-                listPost("policies/operations/validation", toString(toscaPolicyValError),
-                        Status.NOT_ACCEPTABLE.getStatusCode())).isNotEmpty();
+            listPost("policies/operations/validation", toString(toscaPolicyValError),
+                Status.NOT_ACCEPTABLE.getStatusCode())).isNotEmpty();
 
         booleanPost("policies", toString(toscaPolicyValError),
-                Status.NOT_ACCEPTABLE.getStatusCode(), Boolean.FALSE);
+            Status.NOT_ACCEPTABLE.getStatusCode(), Boolean.FALSE);
 
         /* individual deploy/undeploy operations */
 
@@ -289,7 +291,7 @@ public class RestLifecycleManagerTest {
         get("policies/example.artifact/1.0.0", Status.OK.getStatusCode());
 
         booleanPost(
-                "policies/operations/undeployment", toString(opPolicy), Status.OK.getStatusCode(), Boolean.TRUE);
+            "policies/operations/undeployment", toString(opPolicy), Status.OK.getStatusCode(), Boolean.TRUE);
         assertEquals(0,
             PolicyControllerConstants
                 .getFactory().get("lifecycle").getDrools().facts("junits", ToscaPolicy.class).size());
@@ -337,7 +339,7 @@ public class RestLifecycleManagerTest {
         opPolicy.getMetadata().remove("policy-id");
         assertThat(
             listPost("policies/operations/validation", toString(opPolicy),
-                    Status.NOT_ACCEPTABLE.getStatusCode())).isNotEmpty();
+                Status.NOT_ACCEPTABLE.getStatusCode())).isNotEmpty();
 
         metrics();
     }
@@ -345,7 +347,7 @@ public class RestLifecycleManagerTest {
     private void testNotNativePolicy(ToscaPolicy toscaPolicy) throws CoderException {
         assertThat(
             listPost("policies/operations/validation", toString(toscaPolicy),
-                    Status.OK.getStatusCode())).isEmpty();
+                Status.OK.getStatusCode())).isEmpty();
 
         booleanPost("policies", toString(toscaPolicy), Status.OK.getStatusCode(), Boolean.TRUE);
         assertTrue(PolicyControllerConstants.getFactory().get("lifecycle").isAlive());
@@ -360,7 +362,7 @@ public class RestLifecycleManagerTest {
         get("policies/example.artifact/1.0.0", Status.OK.getStatusCode());
 
         booleanDelete("policies/" + toscaPolicy.getName() + "/" + toscaPolicy.getVersion(),
-                Status.OK.getStatusCode(), Boolean.TRUE);
+            Status.OK.getStatusCode(), Boolean.TRUE);
         assertEquals(0,
             PolicyControllerConstants
                 .getFactory().get("lifecycle").getDrools().facts("junits", ToscaPolicy.class).size());
@@ -475,9 +477,11 @@ public class RestLifecycleManagerTest {
         return coder.encode(policy);
     }
 
-    private ToscaPolicy getExamplesPolicy(String resourcePath, String policyName) throws CoderException {
-        String policyJson = ResourceUtils.getResourceAsString(resourcePath);
+    private ToscaPolicy getExamplesPolicy() throws CoderException {
+        String policyJson = ResourceUtils.getResourceAsString(
+            RestLifecycleManagerTest.VCPE_OPERATIONAL_DROOLS_POLICY_JSON);
         ToscaServiceTemplate serviceTemplate = new StandardCoder().decode(policyJson, ToscaServiceTemplate.class);
-        return serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(policyName);
+        return serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(
+            RestLifecycleManagerTest.OP_POLICY_NAME_VCPE);
     }
 }
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/TestConstants.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/TestConstants.java
new file mode 100644 (file)
index 0000000..adf8d7a
--- /dev/null
@@ -0,0 +1,31 @@
+/*-
+ * ============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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.server.restful;
+
+public class TestConstants {
+
+    public static final String DCAE_TOPIC = "dcae_topic";
+    public static final String APPC_CL_TOPIC = "appc-cl";
+    public static final String APPC_LCM_WRITE_TOPIC = "appc-lcm-write";
+    public static final String APPC_LCM_READ_TOPIC = "appc-lcm-read";
+    public static final String SDNR_CL_RSP_TOPIC = "sdnr-cl-rsp";
+    public static final String POLICY_CL_MGT_TOPIC = "policy-cl-mgt";
+    public static final String SDNR_CL_TOPIC = "sdnr-cl";
+    public static final String DCAE_CL_RSP_TOPIC = "dcae_cl_rsp";
+}
index 9237276..b16af39 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -20,6 +21,7 @@
 
 package org.onap.policy.drools.domain.models.controller;
 
+import java.io.Serial;
 import java.io.Serializable;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -35,6 +37,7 @@ import org.onap.policy.drools.domain.models.DroolsPolicy;
 @EqualsAndHashCode(callSuper = true)
 public class ControllerPolicy extends DroolsPolicy implements Serializable {
 
+    @Serial
     private static final long serialVersionUID = -8171337852833516581L;
 
     private ControllerProperties properties;
index 780c20d..b55e434 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -20,6 +21,7 @@
 
 package org.onap.policy.drools.domain.models.controller;
 
+import java.io.Serial;
 import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
@@ -34,6 +36,7 @@ import lombok.Data;
 @Data
 @Builder
 public class ControllerProperties implements Serializable {
+    @Serial
     private static final long serialVersionUID = 1259434187110418986L;
 
     private String controllerName;
index c4772f3..57c07f2 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 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.
@@ -20,6 +21,7 @@
 
 package org.onap.policy.drools.domain.models.controller;
 
+import java.io.Serial;
 import java.io.Serializable;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -34,5 +36,16 @@ import lombok.experimental.SuperBuilder;
 @SuperBuilder
 @EqualsAndHashCode(callSuper = true)
 public class ControllerSinkTopic extends ControllerTopic implements Serializable {
+    @Serial
     private static final long serialVersionUID = 8770353732981476267L;
+
+    @Override
+    public void setTopicName(String topicName) {
+        this.topicName = topicName.toLowerCase();
+    }
+
+    @Override
+    public String getTopicName() {
+        return topicName.toLowerCase();
+    }
 }
index 97a21e6..3c7f1f0 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 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.
@@ -20,6 +21,7 @@
 
 package org.onap.policy.drools.domain.models.controller;
 
+import java.io.Serial;
 import java.io.Serializable;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -34,5 +36,16 @@ import lombok.experimental.SuperBuilder;
 @SuperBuilder
 @EqualsAndHashCode(callSuper = true)
 public class ControllerSourceTopic extends ControllerTopic implements Serializable {
+    @Serial
     private static final long serialVersionUID = -1732598566914643612L;
+
+    @Override
+    public void setTopicName(String topicName) {
+        this.topicName = topicName.toLowerCase();
+    }
+
+    @Override
+    public String getTopicName() {
+        return topicName.toLowerCase();
+    }
 }
index bb28a45..d7692fc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020,2022 AT&T Intellectual Property. All rights reserved.
- *  Modifications Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021, 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.
@@ -72,7 +72,7 @@ public class DomainPolicyTypesTest {
     @Test
     public void testToscaNativeDroolsPolicy() throws CoderException, IOException {
         String rawNativeDroolsPolicy =
-            getPolicyFromFileString(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
+            getPolicyFromFileString();
         ToscaPolicy toscaPolicy =
             getExamplesPolicy(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
 
@@ -135,7 +135,7 @@ public class DomainPolicyTypesTest {
         assertEquals("1.0.0", controllerPolicy.getTypeVersion());
         assertEquals("example", controllerPolicy.getMetadata().getPolicyId());
         assertEquals("lifecycle", controllerPolicy.getProperties().getControllerName());
-        assertEquals("DCAE_TOPIC", controllerPolicy.getProperties().getSourceTopics().get(0).getTopicName());
+        assertEquals("dcae_topic", controllerPolicy.getProperties().getSourceTopics().get(0).getTopicName());
         assertEquals("org.onap.policy.controlloop.CanonicalOnset",
             controllerPolicy.getProperties().getSourceTopics().get(0).getEvents().get(0).getEventClass());
         assertEquals("[?($.closedLoopEventStatus == 'ONSET')]",
@@ -146,7 +146,7 @@ public class DomainPolicyTypesTest {
         assertEquals("gson",
                 controllerPolicy.getProperties().getSourceTopics().get(0).getEvents().get(0)
                         .getCustomSerialization().getJsonParser());
-        assertEquals("APPC-CL", controllerPolicy.getProperties().getSinkTopics().get(0).getTopicName());
+        assertEquals("appc-cl", controllerPolicy.getProperties().getSinkTopics().get(0).getTopicName());
         assertEquals("org.onap.policy.appc.Response",
                 controllerPolicy.getProperties().getSinkTopics().get(0).getEvents().get(0).getEventClass());
         assertEquals("[?($.CommonHeader && $.Status)]",
@@ -160,18 +160,19 @@ public class DomainPolicyTypesTest {
         assertEquals("value1", controllerPolicy.getProperties().getCustomConfig().get("field1"));
     }
 
-    private String getJsonFromFile(String filePath) throws IOException {
-        return Files.readString(Paths.get(filePath));
+    private String getJsonFromFile() throws IOException {
+        return Files.readString(Paths.get(DomainPolicyTypesTest.EXAMPLE_NATIVE_DROOLS_POLICY_JSON));
     }
 
     private String getJsonFromResource(String resourcePath) {
         return ResourceUtils.getResourceAsString(resourcePath);
     }
 
-    private String getPolicyFromFileString(String filePath, String policyName) throws CoderException, IOException {
-        String policyJson = getJsonFromFile(filePath);
+    private String getPolicyFromFileString() throws CoderException, IOException {
+        String policyJson = getJsonFromFile();
         ToscaServiceTemplate serviceTemplate = new StandardCoder().decode(policyJson, ToscaServiceTemplate.class);
-        return nonValCoder.encode(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(policyName));
+        return nonValCoder.encode(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(
+            DomainPolicyTypesTest.EXAMPLE_NATIVE_DROOLS_POLICY_NAME));
     }
 
     private ToscaPolicy getExamplesPolicy(String resourcePath, String policyName) throws CoderException {
index b8561c5..ad0d1af 100644 (file)
@@ -3,6 +3,7 @@
  * policy-management
  * ================================================================================
  * Copyright (C) 2017-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.
@@ -69,9 +70,9 @@ public class RestManagerTest {
     private static final String TELEMETRY_PASSWORD = "y";
     private static final String FOO_CONTROLLER = "foo";
 
-    private static final String UEB_TOPIC = "UEB-TOPIC-TEST";
-    private static final String DMAAP_TOPIC = "DMAAP-TOPIC-TEST";
-    private static final String NOOP_TOPIC = "NOOP_TOPIC";
+    private static final String UEB_TOPIC = "ueb-topic-test";
+    private static final String DMAAP_TOPIC = "dmaap-topic-test";
+    private static final String NOOP_TOPIC = "noop_topic";
 
     private static final String UEB_SOURCE_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_UEB_SOURCE_TOPICS + "."
             + UEB_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;