From d126dba33d4033e9f5af5e00d3830d2e05474b26 Mon Sep 17 00:00:00 2001 From: ChuanyuChen Date: Tue, 11 Apr 2023 16:43:51 +0800 Subject: Fix some issues and Add UT Fix some issues and add UT Issue-ID: USECASEUI-794 Signed-off-by: ChuanyuChen Change-Id: I013553ded90ff342653f01383cf4512885939479 --- .../adapters/dcae/dmaap/DCAENotificationCallback.java | 7 +++++-- .../usecaseui/intentanalysis/adapters/dmaap/MRTopicMonitor.java | 3 +-- .../intentanalysis/adapters/dmaap/NotificationEventModel.java | 2 +- .../adapters/policy/dmaap/PolicyNotificationCallback.java | 6 ++++++ .../src/main/resources/dmaapConfig/dcae_dmaap_config.json | 2 +- .../src/main/resources/dmaapConfig/policy_dmaap_config.json | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) (limited to 'intentanalysis/src/main') 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 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" -- cgit 1.2.3-korg