From f7371ed8b15bd23d5b63ca4808da7d1673bac46a Mon Sep 17 00:00:00 2001 From: qingshuting Date: Mon, 18 Jul 2022 19:56:15 +0800 Subject: Fix bug in handleNotification function and improve test code coverage Issue-ID: DCAEGEN2-3208 Change-Id: I5edc573b169ef45735951d2f691e4e80a00f33df Signed-off-by: qingshuting --- components/slice-analysis-ms/ChangeLog.md | 3 +++ components/slice-analysis-ms/pom.xml | 2 +- .../analysis/ms/dmaap/VesNotificationCallback.java | 7 +++--- .../ms/dmaap/VesNotificationCallbackTest.java | 26 ++++++++++++++-------- components/slice-analysis-ms/version.properties | 2 +- 5 files changed, 26 insertions(+), 14 deletions(-) (limited to 'components/slice-analysis-ms') diff --git a/components/slice-analysis-ms/ChangeLog.md b/components/slice-analysis-ms/ChangeLog.md index 13209eda..2a72018b 100644 --- a/components/slice-analysis-ms/ChangeLog.md +++ b/components/slice-analysis-ms/ChangeLog.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.1.4] - 2022/07/15 + - [DCAEGEN2-3208](https://jira.onap.org/browse/DCAEGEN2-3208) - Fix bug in Vesnotification Callback + ## [1.1.3] - 2022/05/11 - [DCAEGEN2-3156](https://jira.onap.org/browse/DCAEGEN2-3156) - Fix bug in fetching PM data from DES diff --git a/components/slice-analysis-ms/pom.xml b/components/slice-analysis-ms/pom.xml index 21c62aab..ca4b9848 100644 --- a/components/slice-analysis-ms/pom.xml +++ b/components/slice-analysis-ms/pom.xml @@ -34,7 +34,7 @@ org.onap.dcaegen2.services.components slice-analysis-ms - 1.1.3-SNAPSHOT + 1.1.4-SNAPSHOT dcaegen2-services-slice-analysis-ms Network slice PM analyser jar diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallback.java index 584da7b7..485c3d96 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallback.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallback.java @@ -59,6 +59,7 @@ public class VesNotificationCallback implements NotificationCallback { @PostConstruct public void init(){ configuration = Configuration.getInstance(); + ccvpnPmDatastore = new CCVPNPmDatastore(); vesNotifChangeIdentifier = configuration.getVesNotifChangeIdentifier(); vesNotfiChangeType = configuration.getVesNotifChangeType(); } @@ -73,7 +74,7 @@ public class VesNotificationCallback implements NotificationCallback { } /** - * Parse Performance dmaap notification and save to DB + * Parse Performance dmaap notification and save to DB * @param msg incoming message */ private void handleNotification(String msg) { @@ -94,7 +95,7 @@ public class VesNotificationCallback implements NotificationCallback { notifChangeIdentifier = output.getChangeIdentifier(); notifChangeType = output.getChangeType(); if (notifChangeType.equals(vesNotfiChangeType) - && notifChangeIdentifier.equals(vesNotifChangeIdentifier)) { + && notifChangeIdentifier.equals(vesNotifChangeIdentifier)) { cllId = output.getArrayOfNamedHashMap().get(0).getHashMap().getCllId(); uniId = output.getArrayOfNamedHashMap().get(0).getHashMap().getUniId(); bw = output.getArrayOfNamedHashMap().get(0).getHashMap().getBandwidthValue(); @@ -111,4 +112,4 @@ public class VesNotificationCallback implements NotificationCallback { } -} +} \ No newline at end of file diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallbackTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallbackTest.java index 74f75a8c..beb11998 100644 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallbackTest.java +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallbackTest.java @@ -22,14 +22,17 @@ package org.onap.slice.analysis.ms.dmaap; import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mockito; import org.mockito.Spy; +import org.onap.slice.analysis.ms.models.Configuration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; - +import com.google.gson.Gson; +import com.google.gson.JsonObject; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -43,21 +46,26 @@ public class VesNotificationCallbackTest { @InjectMocks VesNotificationCallback vesNotificationCallback; + @Before + public void init() throws IOException { + Configuration configuration = Configuration.getInstance(); + String configAllJson = new String(Files.readAllBytes(Paths.get("src/test/resources/config_all.json"))); + JsonObject configAll = new Gson().fromJson(configAllJson, JsonObject.class); + JsonObject config = configAll.getAsJsonObject("config"); + configuration.updateConfigurationFromJsonObject(config); + vesNotificationCallback.init(); + } + @Test public void initTest() { - vesNotificationCallback.init(); Mockito.verify(vesNotificationCallback, Mockito.atLeastOnce()).init(); } @Test - public void activateCallBackTest() { - String input = null; - try { - input = new String(Files.readAllBytes(Paths.get("src/test/resources/vesCCVPNNotiModel.json"))); - } catch (IOException e) { - e.printStackTrace(); - } + public void activateCallBackTest() throws Exception{ + String input = new String(Files.readAllBytes(Paths.get("src/test/resources/vesCCVPNNotiModel.json"))); vesNotificationCallback.activateCallBack(input); Mockito.verify(vesNotificationCallback, Mockito.atLeastOnce()).activateCallBack(Mockito.anyString()); } + } diff --git a/components/slice-analysis-ms/version.properties b/components/slice-analysis-ms/version.properties index 5844fb14..c7388553 100644 --- a/components/slice-analysis-ms/version.properties +++ b/components/slice-analysis-ms/version.properties @@ -21,7 +21,7 @@ ############################################################################### major=1 minor=1 -patch=3 +patch=4 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg