aboutsummaryrefslogtreecommitdiffstats
path: root/intentanalysis
diff options
context:
space:
mode:
authorChuanyuChen <chenchuanyu@huawei.com>2023-04-11 16:43:51 +0800
committerChuanyuChen <chenchuanyu@huawei.com>2023-04-11 16:43:51 +0800
commitd126dba33d4033e9f5af5e00d3830d2e05474b26 (patch)
tree6e141634a49ed58acf73a33bfe7584aaa447d3d0 /intentanalysis
parentef6560bbb9bfa6248bf2afead5a9d02338aaf02f (diff)
Fix some issues and Add UT
Fix some issues and add UT Issue-ID: USECASEUI-794 Signed-off-by: ChuanyuChen <chenchuanyu@huawei.com> Change-Id: I013553ded90ff342653f01383cf4512885939479
Diffstat (limited to 'intentanalysis')
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java7
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/MRTopicMonitor.java3
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java6
-rw-r--r--intentanalysis/src/main/resources/dmaapConfig/dcae_dmaap_config.json2
-rw-r--r--intentanalysis/src/main/resources/dmaapConfig/policy_dmaap_config.json2
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/util/DmaapUtilTest.java56
7 files changed, 71 insertions, 7 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java
index 158cf91..04f06ce 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java
@@ -18,13 +18,16 @@ package org.onap.usecaseui.intentanalysis.adapters.dcae.dmaap;
import com.google.gson.Gson;
import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationCallback;
import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationEventModel;
+import org.onap.usecaseui.intentanalysis.adapters.policy.dmaap.PolicyNotificationCallback;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DCAENotificationCallback implements NotificationCallback {
-
+ private static final Logger logger = LoggerFactory.getLogger(DCAENotificationCallback.class);
@Override
public void activateCallBack(String msg) {
+ logger.info("Received event from DCAE: \n" + msg);
NotificationEventModel event = (new Gson()).fromJson(msg, NotificationEventModel.class);
-
//Todo analyze the event and Report to the Intent Flow;
}
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/MRTopicMonitor.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/MRTopicMonitor.java
index 528805d..48047e1 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/MRTopicMonitor.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/MRTopicMonitor.java
@@ -100,10 +100,9 @@ public class MRTopicMonitor implements Runnable {
public void run() {
while (running) {
try {
- logger.debug("Topic: {} getting new msg...", consumerWrapper.getTopicName());
List<JsonElement> dmaapMsgs = consumerWrapper.fetch();
for (JsonElement msg : dmaapMsgs) {
- logger.debug("Received message: {}" + "\r\n and processing start", msg);
+ logger.debug("Event {} Received message: {}" + "\r\n and processing start", consumerWrapper.getTopicName(), msg);
process(msg.toString());
}
} catch (IOException | RuntimeException e) {
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java
index 2b4c44f..d465eba 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java
@@ -21,7 +21,7 @@ public class NotificationEventModel {
private String source;
- private Date timestamp;
+ private String timestamp;
private NotificationEventEntity entity;
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java
index a93aac9..44ad9ca 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java
@@ -18,10 +18,16 @@ package org.onap.usecaseui.intentanalysis.adapters.policy.dmaap;
import com.google.gson.Gson;
import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationCallback;
import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationEventModel;
+import org.onap.usecaseui.intentanalysis.adapters.policy.impl.PolicyServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PolicyNotificationCallback implements NotificationCallback {
+
+ private static final Logger logger = LoggerFactory.getLogger(PolicyNotificationCallback.class);
@Override
public void activateCallBack(String msg) {
+ logger.info("Received event from Policy: \n" + msg);
NotificationEventModel event = (new Gson()).fromJson(msg, NotificationEventModel.class);
//Todo analyze the event and Report to the Intent Flow;
diff --git a/intentanalysis/src/main/resources/dmaapConfig/dcae_dmaap_config.json b/intentanalysis/src/main/resources/dmaapConfig/dcae_dmaap_config.json
index 892d77e..a7b5a07 100644
--- a/intentanalysis/src/main/resources/dmaapConfig/dcae_dmaap_config.json
+++ b/intentanalysis/src/main/resources/dmaapConfig/dcae_dmaap_config.json
@@ -10,7 +10,7 @@
"fetch_timeout" : 15000,
"fetch_limit" : 100,
"dmaap_info":{
- "topic_url":"http://message-router:3904/events/CCVPN-CL-DCAE-EVENT",
+ "topic_url":"http://message-router:3904/events/unauthenticated.CCVPN_CL_DCAE_EVENT",
"client_role":"org.onap.uui.intentanalysisSub",
"location":"onap",
"client_id":"intent-analysis-1"
diff --git a/intentanalysis/src/main/resources/dmaapConfig/policy_dmaap_config.json b/intentanalysis/src/main/resources/dmaapConfig/policy_dmaap_config.json
index e4d06b1..6a97c28 100644
--- a/intentanalysis/src/main/resources/dmaapConfig/policy_dmaap_config.json
+++ b/intentanalysis/src/main/resources/dmaapConfig/policy_dmaap_config.json
@@ -10,7 +10,7 @@
"fetch_timeout" : 15000,
"fetch_limit" : 100,
"dmaap_info": {
- "topic_url":"http://message-router:3904/events/CCVPN-CL-POLICY-EVENT",
+ "topic_url":"http://message-router:3904/events/unauthenticated.CCVPN_CL_POLICY_EVENT",
"client_role":"org.onap.uui.intentanalysisSub",
"location":"onap",
"client_id":"intent-analysis-1"
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/util/DmaapUtilTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/util/DmaapUtilTest.java
new file mode 100644
index 0000000..be2a020
--- /dev/null
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/util/DmaapUtilTest.java
@@ -0,0 +1,56 @@
+package org.onap.usecaseui.intentanalysis.util;
+
+import java.io.IOException;
+import org.apache.http.util.Asserts;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRouterPublisher;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRouterSubscriber;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishRequest;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterSubscribeRequest;
+import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@SpringBootTest(classes = IntentAnalysisApplicationTests.class)
+@RunWith(SpringRunner.class)
+public class DmaapUtilTest {
+
+ private static final String testMRURl = "http://mrhost:30607/events/unauthenticated.CCVPN_CL_DCAE_EVENT";
+
+ private static final String testConsumerGroup = "testGroup";
+
+ private static final String testConsumerId = "testUd";
+
+ private static final String testSubscriberName = "testName";
+
+ private static final String testPublisherName = "testName";
+
+ private static final String testTopicUrl = "http://mrhost:30607/topics/create";
+
+ @Test
+ public void testBuildSubscriberSuccess() {
+ MessageRouterSubscriber subscriber = DmaapUtil.buildSubscriber();
+ Assert.assertNotNull(subscriber);
+ }
+
+ @Test
+ public void testBuildSubscriberRequestSuccess() {
+ MessageRouterSubscribeRequest request = DmaapUtil.buildSubscriberRequest(testSubscriberName, testMRURl,
+ testConsumerGroup, testConsumerId);
+ Assert.assertNotNull(request);
+ }
+
+ @Test
+ public void testBuildPublisherSuccess(){
+ MessageRouterPublisher publisher = DmaapUtil.buildPublisher();
+ Assert.assertNotNull(publisher);
+ }
+
+ @Test
+ public void testBuildPublisherRequestSuccess(){
+ MessageRouterPublishRequest publishRequest = DmaapUtil.buildPublisherRequest(testPublisherName,testTopicUrl);
+ Assert.assertNotNull(publishRequest);
+ }
+}