summaryrefslogtreecommitdiffstats
path: root/policy-domains
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 /policy-domains
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 'policy-domains')
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java5
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java5
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java13
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java13
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java19
5 files changed, 44 insertions, 11 deletions
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java
index 92372765..b16af396 100644
--- a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java
@@ -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;
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java
index 780c20dc..b55e4344 100644
--- a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java
@@ -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;
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java
index c4772f3b..57c07f2d 100644
--- a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java
@@ -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();
+ }
}
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java
index 97a21e6c..3c7f1f03 100644
--- a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java
@@ -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();
+ }
}
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
index bb28a45f..d7692fc0 100644
--- a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.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.
@@ -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 {