aboutsummaryrefslogtreecommitdiffstats
path: root/feature-lifecycle
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-01-09 15:19:07 +0000
committeradheli.tavares <adheli.tavares@est.tech>2024-01-09 16:20:10 +0000
commitcce79248655f484e007769ba81b092148f940d27 (patch)
tree58f493bb4732b7411feb20ddf1c2095d7bf15356 /feature-lifecycle
parent36d9699056890640daeaa2fef2f2e4d469b433cb (diff)
Drools support for kafka topics
Issue-ID: POLICY-4201 Change-Id: I91676c168c676018aa1079943747f16917f50a49 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'feature-lifecycle')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java4
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java7
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java7
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java63
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java60
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/TestConstants.java31
6 files changed, 107 insertions, 65 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
index 8e62e2a8..6973745c 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
@@ -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;
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
index 3fa8ac9f..0ab9f888 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
@@ -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;
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
index 67efa72a..653a4694 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
@@ -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));
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
index b6f354e4..95f0ff55 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
@@ -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"));
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
index 29ef5a77..37c1e8d8 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
@@ -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
index 00000000..adf8d7a8
--- /dev/null
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/TestConstants.java
@@ -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";
+}