summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorniranjana <niranjana.y60@wipro.com>2020-02-27 18:24:48 +0530
committerniranjana <niranjana.y60@wipro.com>2020-02-27 18:24:48 +0530
commitfcd3a920e7c4f1bea70797caef5d0a14e26f9269 (patch)
tree5fa8ef7a8a1e4402e44c572f5ff998102fe49a8c /src
parent4df89dfce2ef6ad2a0d28e8750822c594529ae25 (diff)
Increase code coverage
Issue-ID: DCAEGEN2-2023 Signed-off-by: niranjana <niranjana.y60@wipro.com> Change-Id: Ifbc6817108fbbdfe21a4aa0f94cbb67c422c73c6
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Application.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java2
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java2
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java2
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java4
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java171
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java8
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/NewFmNotificationTest.java36
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/NewPmNotificationTest.java37
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/NewSdnrNotificationTest.java38
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/TimerTest.java46
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallbackDuplicate.java98
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallbackTest.java147
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/entity/FixedPciCellsTest.java46
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciUpdateTest.java46
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotificationsTest.java42
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/model/AnrInputTest.java43
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/model/ClusterMapTest.java48
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/model/FlagTest.java39
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/model/StatusTest.java39
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfoTest.java26
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplateTest.java149
-rw-r--r--src/test/resources/faultNotification.json35
23 files changed, 1086 insertions, 19 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
index 71dabff..af98814 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
@@ -94,6 +94,7 @@ public class Application {
Thread.sleep(10000);
} catch (InterruptedException e) {
log.debug("InterruptedException : {}", e);
+ Thread.currentThread().interrupt();
}
log.info("after 10s sleep");
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java b/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java
index 3c7d6ac..54f9b8f 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java
@@ -39,7 +39,7 @@ public class SonController {
SonRequestsComponent pciRequestsComponent;
@RequestMapping(value = "/callbackUrl", method = RequestMethod.POST)
- String callBackUrl(@RequestBody AsyncResponseBody callback) {
+ public String callBackUrl(@RequestBody AsyncResponseBody callback) {
log.debug("received request to callback url");
String async = callback.toString();
log.debug("AsyncResponseBody{}", async);
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java
index 322c113..4a7f8ce 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java
@@ -30,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class HealthCheck {
@RequestMapping(value = "/healthcheck", method = RequestMethod.GET)
- ResponseEntity<HttpStatus> healthCheck() {
+ public ResponseEntity<HttpStatus> healthCheck() {
return new ResponseEntity<>(HttpStatus.OK);
}
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
index 1a8456f..0a9d329 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
@@ -103,9 +103,9 @@ public class PolicyDmaapClient {
int status = payloadObject.getConfiguration().get(0).getStatus().getCode();
String statusToString = Integer.toString(status);
log.info("response from policy, status code {}", statusToString);
+ return true;
}
- return true;
}
} catch (IOException e) {
log.info("caught io exception while fetching policy response");
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
index 8fb4087..ed023e2 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
@@ -72,6 +72,8 @@ public class ConfigurationTest {
configuration.setPollingTimeout(100);
configuration.setConfigDbService("sdnrService");
configuration.setSourceId("sourceId");
+ configuration.setPolicyNegativeAckThreshold(3);
+ configuration.setPolicyFixedPciTimeInterval(5000);
assertEquals(60, configuration.getBufferTime());
assertEquals("/callbackUrl", configuration.getCallbackUrl());
assertEquals("cg", configuration.getCg());
@@ -103,5 +105,7 @@ public class ConfigurationTest {
assertEquals(3, configuration.getPoorCountThreshold());
assertEquals(subscribes, configuration.getStreamsSubscribes());
assertEquals(subscribes, configuration.getStreamsPublishes());
+ assertEquals(3,configuration.getPolicyNegativeAckThreshold());
+ assertEquals(5000, configuration.getPolicyFixedPciTimeInterval());
}
}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java
index 8f161a7..0972661 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java
@@ -46,8 +46,15 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.onap.dcaegen2.services.sonhms.child.Graph;
import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
+import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell;
+import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse;
import org.onap.dcaegen2.services.sonhms.model.Notification;
+import org.onap.dcaegen2.services.sonhms.model.NotificationCellConfig;
+import org.onap.dcaegen2.services.sonhms.model.NotificationLte;
+import org.onap.dcaegen2.services.sonhms.model.NotificationRan;
+import org.onap.dcaegen2.services.sonhms.model.X0005b9Lte;
import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest;
import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils;
@@ -68,7 +75,7 @@ public class EventHandlerTest {
private static Notification notification;
private static List<ClusterDetails> clusterDetails = new ArrayList<>();
-
+ private static FaultEvent faultEvent;
@InjectMocks
EventHandler eventHandler;
@@ -76,15 +83,20 @@ public class EventHandlerTest {
public void setup() {
notification = new Notification();
+ faultEvent = new FaultEvent();
+
String notificationString = readFromFile("/notification3.json");
String clusterInfo1 = readFromFile("/clusterInfo1.json");
String clusterInfo2 = readFromFile("/clusterInfo2.json");
String clusterInfo3 = readFromFile("/clusterInfo3.json");
String clusterInfo4 = readFromFile("/clusterInfo4.json");
+ String faultInfo = readFromFile("/faultNotification.json");
ObjectMapper mapper = new ObjectMapper();
try {
notification = mapper.readValue(notificationString, Notification.class);
+ faultEvent = mapper.readValue(faultInfo, FaultEvent.class);
+
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -98,7 +110,7 @@ public class EventHandlerTest {
}
- @Test
+ @Test
public void handleSdnrNotificationTest() {
String clusterInfo7 = readFromFile("/clusterInfo7.json");
@@ -130,7 +142,160 @@ public class EventHandlerTest {
}
-
+
+ @Test
+ public void handleMatchingCellsTest() {
+
+ FapServiceList fapServiceList = notification.getPayload().getRadioAccess().getFapServiceList().get(0);
+ Map<FapServiceList, String> cellsinCluster = new HashMap<>();
+ cellsinCluster.put(fapServiceList, "value1");
+ String clusterInfo = readFromFile("/clusterInfo7.json");
+ Graph cluster = new Graph(clusterInfo);
+ NotificationToClusterMapping mapping = new NotificationToClusterMapping();
+ List<FapServiceList> newCells = new ArrayList<>();
+ newCells.add(notification.getPayload().getRadioAccess().getFapServiceList().get(0));
+ mapping.setCellsinCluster(cellsinCluster);
+ mapping.setNewCells(newCells);
+ Either<Graph, Integer> existingCluster = Either.right(404);
+ Either<ClusterDetails, Integer> clusterDetail = Either.right(404);
+
+ Mockito.when(clusterutilsMock.getAllClusters()).thenReturn(clusterDetails);
+ Mockito.when(clusterutilsMock.getClustersForNotification(notification, clusterDetails)).thenReturn(mapping);
+ Mockito.when(clusterutilsMock.getClusterForCell(Mockito.any(), Mockito.any())).thenReturn(existingCluster);
+ Mockito.when(threadUtilsMock.createNewThread(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(),
+ Mockito.anyString())).thenReturn(true);
+ Mockito.when(clusterutilsMock.getClusterDetailsFromClusterId(Mockito.any(), Mockito.any()))
+ .thenReturn(clusterDetail);
+
+ try {
+ Mockito.when(clusterutilsMock.createCluster(Mockito.any())).thenReturn(cluster);
+ } catch (ConfigDbNotFoundException e1) {
+ e1.printStackTrace();
+ }
+ Assert.assertEquals(true, eventHandler.handleSdnrNotification(notification));
+
+ }
+
+ @Test
+ public void handleFaultNotificationTest() {
+ List<FaultEvent> fmNotification = new ArrayList<FaultEvent>();
+ fmNotification.add(faultEvent);
+ Map<String, String> cellsinCluster = new HashMap<String, String>();
+ cellsinCluster.put("45", "0");
+ cellsinCluster.put("46", "1");
+ List<String> newCells = new ArrayList<>();
+ newCells.add(notification.getPayload().getRadioAccess().getFapServiceList().get(0).toString());
+ FaultNotificationtoClusterMapping faultNotificationtoClusterMapping = new FaultNotificationtoClusterMapping();
+ faultNotificationtoClusterMapping.setCellsinCluster(cellsinCluster);
+ faultNotificationtoClusterMapping.setNewCells(newCells);
+ Mockito.when(clusterutilsMock.getAllClusters()).thenReturn(clusterDetails);
+ Mockito.when(clusterutilsMock.getClustersForFmNotification(Mockito.any(), Mockito.any()))
+ .thenReturn(faultNotificationtoClusterMapping);
+ HashMap<CellPciPair, ArrayList<CellPciPair>> clusterMap = new HashMap<CellPciPair, ArrayList<CellPciPair>>();
+ ArrayList<CellPciPair> cellPciPairList = new ArrayList<CellPciPair>();
+ CellPciPair cellPciPair = new CellPciPair();
+ cellPciPair.setCellId("45");
+ cellPciPair.setPhysicalCellId(310);
+ cellPciPairList.add(cellPciPair);
+ clusterMap.put(cellPciPair, cellPciPairList);
+
+ try {
+ Mockito.when(clusterutilsMock.findClusterMap(Mockito.any())).thenReturn(clusterMap);
+ } catch (ConfigDbNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ HashMap<Long, String> childStatus = new HashMap<Long, String>();
+ childStatus.put((long) 1, "triggeredOof");
+ ArrayList<Integer> collisionConfusionCount = new ArrayList<Integer>();
+ collisionConfusionCount.add(1);
+ collisionConfusionCount.add(2);
+ HashMap<String, ArrayList<Integer>> collisionConfusionMap = new HashMap<String, ArrayList<Integer>>();
+ collisionConfusionMap.put("45", collisionConfusionCount);
+ Graph graph = new Graph();
+ graph.setCollisionConfusionMap(collisionConfusionMap);
+ ClusterDetails clusterDetails = new ClusterDetails();
+ clusterDetails.setChildThreadId(1);
+ Either<ClusterDetails, Integer> clusterDetail = Either.right(404);
+ Mockito.when(clusterutilsMock.getClusterDetailsFromClusterId(Mockito.any(), Mockito.any()))
+ .thenReturn(clusterDetail);
+ Either<Graph, Integer> existingCluster = Either.left(graph);
+ Mockito.when(clusterutilsMock.getClusterForFmCell(Mockito.any(), Mockito.any())).thenReturn(existingCluster);
+
+ try {
+ Mockito.when(clusterutilsMock.findClusterMap(Mockito.any())).thenReturn(clusterMap);
+ Mockito.when(clusterutilsMock.createCluster(Mockito.any())).thenReturn(graph);
+ Mockito.when(clusterutilsMock.modifyCluster(Mockito.any(), Mockito.any())).thenReturn(graph);
+ Mockito.when(clusterutilsMock.getClusterForCell(Mockito.any(), Mockito.any())).thenReturn(existingCluster);
+
+ } catch (ConfigDbNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ Assert.assertEquals(true, eventHandler.handleFaultNotification(fmNotification));
+
+ }
+
+ @Test
+ public void handleFaultNotificationtest() {
+
+ List<FaultEvent> fmNotification = new ArrayList<FaultEvent>();
+ fmNotification.add(faultEvent);
+ Map<String, String> cellsinCluster = new HashMap<String, String>();
+ cellsinCluster.put("45", "0");
+ cellsinCluster.put("46", "1");
+ List<String> newCells = new ArrayList<>();
+ newCells.add(notification.getPayload().getRadioAccess().getFapServiceList().get(0).toString());
+ FaultNotificationtoClusterMapping faultNotificationtoClusterMapping = new FaultNotificationtoClusterMapping();
+ faultNotificationtoClusterMapping.setCellsinCluster(cellsinCluster);
+ faultNotificationtoClusterMapping.setNewCells(newCells);
+ Mockito.when(clusterutilsMock.getAllClusters()).thenReturn(clusterDetails);
+ Mockito.when(clusterutilsMock.getClustersForFmNotification(Mockito.any(), Mockito.any()))
+ .thenReturn(faultNotificationtoClusterMapping);
+ HashMap<CellPciPair, ArrayList<CellPciPair>> clusterMap = new HashMap<CellPciPair, ArrayList<CellPciPair>>();
+ ArrayList<CellPciPair> cellPciPairList = new ArrayList<CellPciPair>();
+ CellPciPair cellPciPair = new CellPciPair();
+ cellPciPair.setCellId("45");
+ cellPciPair.setPhysicalCellId(310);
+ cellPciPairList.add(cellPciPair);
+ clusterMap.put(cellPciPair, cellPciPairList);
+
+ try {
+ Mockito.when(clusterutilsMock.findClusterMap(Mockito.any())).thenReturn(clusterMap);
+ } catch (ConfigDbNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ ArrayList<Integer> collisionConfusionCount = new ArrayList<Integer>();
+ collisionConfusionCount.add(1);
+ collisionConfusionCount.add(2);
+ HashMap<String, ArrayList<Integer>> collisionConfusionMap = new HashMap<String, ArrayList<Integer>>();
+ collisionConfusionMap.put("45", collisionConfusionCount);
+ Graph graph = new Graph();
+ graph.setCollisionConfusionMap(collisionConfusionMap);
+ ClusterDetails clusterDetails = new ClusterDetails();
+ clusterDetails.setChildThreadId((long) 1);
+ Either<ClusterDetails, Integer> clusterDetail = Either.right(404);
+
+ Mockito.when(clusterutilsMock.getClusterDetailsFromClusterId(Mockito.any(), Mockito.any()))
+ .thenReturn(clusterDetail);
+ Either<Graph, Integer> existingCluster = Either.right(404);
+ Mockito.when(clusterutilsMock.getClusterForFmCell(Mockito.any(), Mockito.any())).thenReturn(existingCluster);
+
+ try {
+ Mockito.when(clusterutilsMock.findClusterMap(Mockito.any())).thenReturn(clusterMap);
+ Mockito.when(clusterutilsMock.createCluster(Mockito.any())).thenReturn(graph);
+ Mockito.when(clusterutilsMock.modifyCluster(Mockito.any(), Mockito.any())).thenReturn(graph);
+ Mockito.when(clusterutilsMock.getClusterForCell(Mockito.any(), Mockito.any())).thenReturn(existingCluster);
+
+ } catch (ConfigDbNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ Assert.assertEquals(true, eventHandler.handleFaultNotification(fmNotification));
+
+ }
+
private static String readFromFile(String file) {
String content = new String();
try {
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java
index 4bc4a33..56f1fba 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java
@@ -99,6 +99,14 @@ public class HoMetricsComponentTest {
when(handOverMetricsRepositoryMock.findAll()).thenReturn(null);
assertTrue(hoMetricsComponent.getAll().isRight());
}
+
+ @Test
+ public void update() {
+ PowerMockito.mockStatic(BeanUtil.class);
+ PowerMockito.when(BeanUtil.getBean(HandOverMetricsRepository.class)).thenReturn(handOverMetricsRepositoryMock);
+ assertEquals(true, hoMetricsComponent.update("HODetails", "12"));
+ }
+
private static String readFromFile(String file) {
String content = new String();
try {
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/NewFmNotificationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/NewFmNotificationTest.java
new file mode 100644
index 0000000..ba4dc45
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/NewFmNotificationTest.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class NewFmNotificationTest {
+
+ @Test
+ public void test() {
+ NewFmNotification newFmNotification = new NewFmNotification(true);
+ newFmNotification.setNewNotif(true);
+ assertTrue(newFmNotification.getNewNotif());
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/NewPmNotificationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/NewPmNotificationTest.java
new file mode 100644
index 0000000..1bb581c
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/NewPmNotificationTest.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class NewPmNotificationTest {
+
+ @Test
+ public void test() {
+ NewPmNotification newPmNotification = new NewPmNotification();
+ newPmNotification.setNewNotif(true);
+ assertTrue(newPmNotification.getNewNotif());
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/NewSdnrNotificationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/NewSdnrNotificationTest.java
new file mode 100644
index 0000000..48398f7
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/NewSdnrNotificationTest.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class NewSdnrNotificationTest {
+
+ @Test
+ public void test() {
+
+ NewSdnrNotification newSdnrNotification = new NewSdnrNotification();
+ newSdnrNotification.setNewNotif(true);
+ assertTrue(newSdnrNotification.getNewNotif());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/TimerTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/TimerTest.java
new file mode 100644
index 0000000..34df573
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/TimerTest.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms;
+
+import static org.junit.Assert.*;
+
+import java.sql.Timestamp;
+
+import org.junit.Test;
+
+public class TimerTest {
+
+ @Test
+ public void test() {
+ Timestamp timestamp = null;
+ Timer timer = new Timer();
+ timer.setCount(2);
+ timer.setCurrentTime(timestamp);
+ timer.setIsTimer(true);
+ timer.setStartTime(timestamp);
+ assertEquals(2, timer.getCount());
+ assertEquals(timestamp, timer.getCurrentTime());
+ assertEquals(timestamp, timer.getStartTime());
+ assertEquals(true, timer.getIsTimer());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallbackDuplicate.java b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallbackDuplicate.java
new file mode 100644
index 0000000..7d3edf6
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallbackDuplicate.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.dmaap;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.List;
+
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.dao.FixedPciCellsRepository;
+import org.onap.dcaegen2.services.sonhms.dao.PciUpdateRepository;
+import org.onap.dcaegen2.services.sonhms.entity.FixedPciCells;
+import org.onap.dcaegen2.services.sonhms.model.Configurations;
+import org.onap.dcaegen2.services.sonhms.model.Payload;
+import org.onap.dcaegen2.services.sonhms.model.PolicyNotification;
+import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.slf4j.Logger;
+
+public class PolicyNotificationCallbackDuplicate extends NotificationCallback {
+
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(PolicyNotificationCallback.class);
+
+ @Override
+ public void activateCallBack(String msg) {
+ handlePolicyNotification(msg);
+ }
+
+ private static FixedPciCells cell;
+
+ public FixedPciCells returnResult() {
+ return cell;
+ }
+
+ public void setDefaultResult() {
+ cell =null;;
+ }
+
+ private void handlePolicyNotification(String msg) {
+ PciUpdateRepository pciUpdateRepository = BeanUtil.getBean(PciUpdateRepository.class);
+ Configuration configuration = Configuration.getInstance();
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ PolicyNotification policyResponse = mapper.readValue(msg, PolicyNotification.class);
+ String payload = policyResponse.getPayload();
+ Payload payloadObject = mapper.readValue(payload, Payload.class);
+ List<Configurations> configurationList = payloadObject.getConfiguration();
+ for (Configurations config : configurationList) {
+ int status = config.getStatus().getCode();
+ if (status != 200) {
+ String cellId = config.getData().getFapservice().getAlias();
+ int negativeAckCount = pciUpdateRepository.getNegativeAckCountforCellId(cellId);
+ if (negativeAckCount > configuration.getPolicyNegativeAckThreshold()) {
+ long fixedPci = pciUpdateRepository.getOldPciforCellId(cellId);
+ FixedPciCellsRepository fixedPciCellsRepository = BeanUtil
+ .getBean(FixedPciCellsRepository.class);
+ FixedPciCells fixedPciCells = new FixedPciCells();
+ fixedPciCells.setCellId(cellId);
+ fixedPciCells.setFixedPci(fixedPci);
+ cell = fixedPciCellsRepository.save(fixedPciCells);
+ pciUpdateRepository.deleterecordforCellId(cellId);
+ } else {
+
+ pciUpdateRepository.increaseNegativeAckCountforCellId(++negativeAckCount, cellId);
+ }
+ } else {
+
+ String cellId = config.getData().getFapservice().getAlias();
+ pciUpdateRepository.deleterecordforCellId(cellId);
+ }
+
+ String statusToString = Integer.toString(status);
+ log.info("Handled response from policy, status code {}", statusToString);
+ }
+ } catch (IOException e) {
+ log.info("caught io exception while fetching policy response");
+
+ }
+ }
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallbackTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallbackTest.java
new file mode 100644
index 0000000..8e2b0e9
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallbackTest.java
@@ -0,0 +1,147 @@
+
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.dmaap;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.dao.FixedPciCellsRepository;
+import org.onap.dcaegen2.services.sonhms.dao.PciUpdateRepository;
+import org.onap.dcaegen2.services.sonhms.entity.FixedPciCells;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(SpringRunner.class)
+@SpringBootTest(classes = PolicyNotificationCallbackDuplicate.class)
+@PrepareForTest({ BeanUtil.class, PolicyNotificationCallbackDuplicate.class, Configuration.class })
+public class PolicyNotificationCallbackTest {
+
+ @Mock
+ PciUpdateRepository pciUpdateRepositoryMock;
+ @Mock
+ FixedPciCellsRepository fixedPciCellsRepositoryMock;
+
+ @Test
+ public void policyNotificationCallbackTest() {
+ PolicyNotificationCallbackDuplicate policyCallBackMock = PowerMockito
+ .spy(new PolicyNotificationCallbackDuplicate());
+ PowerMockito.mockStatic(BeanUtil.class);
+
+ Configuration configuration = Configuration.getInstance();
+ configuration = Configuration.getInstance();
+ configuration.setBufferTime(60);
+ configuration.setCallbackUrl("/callbackUrl");
+ List<String> list = new ArrayList<String>();
+ list.add("server");
+ configuration.setDmaapServers(list);
+ configuration.setCg("cg");
+ configuration.setCid("cid");
+ configuration.setMaximumClusters(5);
+ configuration.setMinCollision(5);
+ configuration.setMinConfusion(5);
+ configuration.setNumSolutions(1);
+ configuration.setOofService("oofService");
+ configuration.setPollingInterval(30);
+ configuration.setPollingTimeout(100);
+ configuration.setConfigDbService("sdnrService");
+ configuration.setSourceId("sourceId");
+ configuration.setPolicyNegativeAckThreshold(3);
+
+ PowerMockito.mockStatic(Configuration.class);
+
+ Mockito.when(Configuration.getInstance()).thenReturn(configuration);
+
+ PowerMockito.when(BeanUtil.getBean(PciUpdateRepository.class)).thenReturn(pciUpdateRepositoryMock);
+ Mockito.when(pciUpdateRepositoryMock.getNegativeAckCountforCellId(Mockito.any())).thenReturn(5);
+ Mockito.when(pciUpdateRepositoryMock.getOldPciforCellId(Mockito.any())).thenReturn((long) 9);
+ PowerMockito.when(BeanUtil.getBean(FixedPciCellsRepository.class)).thenReturn(fixedPciCellsRepositoryMock);
+
+ String positivePolicyNotification = "{\"closedLoopControlName\":null,\"closedLoopAlarmStart\":0,\"closedLoopEventClient\":null,\"closedLoopEventStatus\":null,\"target\":null,\"from\":null,\"version\":null,\"policyName\":null,\"policyVersion\":null,\"payload\":\"{\\\"Configurations\\\":[{\\\"data\\\":{\\\"FAPService\\\":{\\\"alias\\\":\\\"Chn0001\\\",\\\"X0005b9Lte\\\":{\\\"phyCellIdInUse\\\":999,\\\"pnfName\\\":\\\"ncsServer-1\\\"},\\\"CellConfig\\\":{\\\"LTE\\\":{\\\"RAN\\\":{\\\"Common\\\":{\\\"CellIdentity\\\":\\\"Chn0001\\\"},\\\"NeighborListInUse\\\":null}}}}},\\\"Status\\\":{\\\"Code\\\":200,\\\"Value\\\":\\\"fail\\\"}}]}\",\"target_type\":null,\"requestID\":null,\"AAI\":null,\"Action\":null}";
+ policyCallBackMock.activateCallBack(positivePolicyNotification);
+ assertNull(policyCallBackMock.returnResult());
+
+ }
+
+ public void negativePolicyNotificationCallbackTest() {
+
+ PolicyNotificationCallbackDuplicate policyCallBackMock = PowerMockito
+ .spy(new PolicyNotificationCallbackDuplicate());
+
+ PowerMockito.mockStatic(BeanUtil.class);
+
+ Configuration configuration = Configuration.getInstance();
+
+ configuration = Configuration.getInstance();
+ configuration.setBufferTime(60);
+ configuration.setCallbackUrl("/callbackUrl");
+ List<String> list = new ArrayList<String>();
+ list.add("server");
+ configuration.setDmaapServers(list);
+ configuration.setCg("cg");
+ configuration.setCid("cid");
+ configuration.setMaximumClusters(5);
+ configuration.setMinCollision(5);
+ configuration.setMinConfusion(5);
+ configuration.setNumSolutions(1);
+ configuration.setOofService("oofService");
+ configuration.setPollingInterval(30);
+ configuration.setPollingTimeout(100);
+ configuration.setConfigDbService("sdnrService");
+ configuration.setSourceId("sourceId");
+ configuration.setPolicyNegativeAckThreshold(3);
+
+ PowerMockito.mockStatic(Configuration.class);
+
+ Mockito.when(Configuration.getInstance()).thenReturn(configuration);
+
+ PowerMockito.when(BeanUtil.getBean(PciUpdateRepository.class)).thenReturn(pciUpdateRepositoryMock);
+ Mockito.when(pciUpdateRepositoryMock.getOldPciforCellId(Mockito.any())).thenReturn((long) 9);
+ PowerMockito.when(BeanUtil.getBean(FixedPciCellsRepository.class)).thenReturn(fixedPciCellsRepositoryMock);
+
+ Mockito.when(pciUpdateRepositoryMock.getNegativeAckCountforCellId(Mockito.any())).thenReturn(2);
+ String negativePolicyNotificationNegCount = "{\"closedLoopControlName\":null,\"closedLoopAlarmStart\":0,\"closedLoopEventClient\":null,\"closedLoopEventStatus\":null,\"target\":null,\"from\":null,\"version\":null,\"policyName\":null,\"policyVersion\":null,\"payload\":\"{\\\"Configurations\\\":[{\\\"data\\\":{\\\"FAPService\\\":{\\\"alias\\\":\\\"Chn0001\\\",\\\"X0005b9Lte\\\":{\\\"phyCellIdInUse\\\":999,\\\"pnfName\\\":\\\"ncsServer-1\\\"},\\\"CellConfig\\\":{\\\"LTE\\\":{\\\"RAN\\\":{\\\"Common\\\":{\\\"CellIdentity\\\":\\\"Chn0001\\\"},\\\"NeighborListInUse\\\":null}}}}},\\\"Status\\\":{\\\"Code\\\":400,\\\"Value\\\":\\\"fail\\\"}}]}\",\"target_type\":null,\"requestID\":null,\"AAI\":null,\"Action\":null}";
+ policyCallBackMock.activateCallBack(negativePolicyNotificationNegCount);
+ assertNull(policyCallBackMock.returnResult());
+
+ Mockito.when(pciUpdateRepositoryMock.getNegativeAckCountforCellId(Mockito.any())).thenReturn(7);
+ Mockito.when(fixedPciCellsRepositoryMock.save(Mockito.any())).thenReturn(new FixedPciCells());
+ String negativePolicyNotification = "{\"closedLoopControlName\":null,\"closedLoopAlarmStart\":0,\"closedLoopEventClient\":null,\"closedLoopEventStatus\":null,\"target\":null,\"from\":null,\"version\":null,\"policyName\":null,\"policyVersion\":null,\"payload\":\"{\\\"Configurations\\\":[{\\\"data\\\":{\\\"FAPService\\\":{\\\"alias\\\":\\\"Chn0001\\\",\\\"X0005b9Lte\\\":{\\\"phyCellIdInUse\\\":999,\\\"pnfName\\\":\\\"ncsServer-1\\\"},\\\"CellConfig\\\":{\\\"LTE\\\":{\\\"RAN\\\":{\\\"Common\\\":{\\\"CellIdentity\\\":\\\"Chn0001\\\"},\\\"NeighborListInUse\\\":null}}}}},\\\"Status\\\":{\\\"Code\\\":400,\\\"Value\\\":\\\"fail\\\"}}]}\",\"target_type\":null,\"requestID\":null,\"AAI\":null,\"Action\":null}";
+ policyCallBackMock.activateCallBack(negativePolicyNotification);
+ assertNotNull(policyCallBackMock.returnResult());
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/entity/FixedPciCellsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/FixedPciCellsTest.java
new file mode 100644
index 0000000..b278ee9
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/FixedPciCellsTest.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019-2020 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.entity;
+
+import static org.junit.Assert.*;
+
+import java.sql.Timestamp;
+
+import org.junit.Test;
+
+public class FixedPciCellsTest {
+
+ private Timestamp createdAt;
+
+ @Test
+ public void test() {
+ FixedPciCells fixedPciCells = new FixedPciCells();
+ fixedPciCells.setCellId("Chn0001");
+ fixedPciCells.setFixedPci(5000);
+ fixedPciCells.setCreatedAt(createdAt);
+ assertEquals("Chn0001", fixedPciCells.getCellId());
+ assertEquals(5000, fixedPciCells.getFixedPci());
+ assertEquals(createdAt, fixedPciCells.getCreatedAt());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciUpdateTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciUpdateTest.java
new file mode 100644
index 0000000..b66e2ec
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciUpdateTest.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019-2020 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.entity;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class PciUpdateTest {
+
+ @Test
+ public void test() {
+
+ PciUpdate pciUpdate = new PciUpdate();
+ pciUpdate.setCellId("Chn0001");
+ pciUpdate.setNewPci(5000);
+ pciUpdate.setOldPci(3000);
+ pciUpdate.setNegativeAckCount(3);
+
+ assertEquals("Chn0001", pciUpdate.getCellId());
+ assertEquals(5000, pciUpdate.getNewPci());
+ assertEquals(3000, pciUpdate.getOldPci());
+ assertEquals(3, pciUpdate.getNegativeAckCount());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotificationsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotificationsTest.java
new file mode 100644
index 0000000..4e82eaf
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotificationsTest.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.entity;
+
+import static org.junit.Assert.*;
+
+import java.sql.Timestamp;
+
+import org.junit.Test;
+
+public class PerformanceNotificationsTest {
+
+ private Timestamp createdAt;
+
+ @Test
+ public void test() {
+
+ PerformanceNotifications performanceNotifications = new PerformanceNotifications();
+ performanceNotifications.setNotification("notification");
+ performanceNotifications.setCreatedAt(createdAt);
+ assertEquals("notification", performanceNotifications.getNotification());
+ assertEquals(createdAt, performanceNotifications.getCreatedAt()); }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/AnrInputTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/AnrInputTest.java
new file mode 100644
index 0000000..b319c12
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/AnrInputTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.model;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+
+import org.junit.Test;
+
+public class AnrInputTest {
+
+ @Test
+ public void test() {
+
+ AnrInput anrInput = new AnrInput();
+ anrInput.setCellId("20");
+ ArrayList<String> removeableNeighbors = new ArrayList<String>();
+ anrInput.setRemoveableNeighbors(removeableNeighbors);
+ assertEquals("20", anrInput.getCellId());
+ assertEquals(removeableNeighbors,anrInput.getRemoveableNeighbors());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/ClusterMapTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/ClusterMapTest.java
new file mode 100644
index 0000000..c9b8019
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/ClusterMapTest.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.model;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+
+import org.junit.Test;
+
+public class ClusterMapTest {
+
+ @Test
+ public void test() {
+
+ ClusterMap clusterMap = new ClusterMap();
+ CellPciPair cellPciPair = new CellPciPair();
+ cellPciPair.setCellId("45");
+ cellPciPair.setPhysicalCellId(310);
+ ArrayList<CellPciPair> cellPciPairList = new ArrayList<CellPciPair>();
+ cellPciPairList.add(cellPciPair);
+
+ clusterMap.setCell(cellPciPair);
+ clusterMap.setNeighbourList(cellPciPairList);
+ assertEquals(cellPciPair, clusterMap.getCell());
+ assertEquals(cellPciPairList, clusterMap.getNeighbourList());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/FlagTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/FlagTest.java
new file mode 100644
index 0000000..e5fa3a4
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/FlagTest.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.model;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class FlagTest {
+
+ @Test
+ public void test() {
+ Flag flag = new Flag();
+ flag.setHolder("Holder");
+ flag.setNumChilds(2);
+ assertEquals("Holder",flag.getHolder());
+ assertEquals(2,flag.getNumChilds());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/StatusTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/StatusTest.java
new file mode 100644
index 0000000..c81c065
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/StatusTest.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.model;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class StatusTest {
+
+ @Test
+ public void test() {
+
+ Status status = new Status();
+ status.setCode(200);
+ status.setValue("success");
+ assertEquals(200,status.getCode());
+ assertEquals("success",status.getValue());
+ }
+
+}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfoTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfoTest.java
index 9f21f8d..674965c 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfoTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfoTest.java
@@ -28,18 +28,18 @@ import java.util.List;
import org.junit.Test;
-
public class CellInfoTest {
- @Test
- public void cellInfoTest() {
- List<String> cellIdLists = new ArrayList<>();
- cellIdLists.add("cell1");
-
- CellInfo cellInfo = new CellInfo();
- cellInfo.setNetworkId("NTWK001");
- cellInfo.setCellIdList(cellIdLists);
- assertEquals("NTWK001", cellInfo.getNetworkId());
- assertEquals(cellIdLists, cellInfo.getCellIdList());
-
- }
+ @Test
+ public void cellInfoTest() {
+ List<String> cellIdLists = new ArrayList<>();
+ cellIdLists.add("cell1");
+ CellInfo cellInfo = new CellInfo();
+ cellInfo.setNetworkId("NTWK001");
+ cellInfo.setCellIdList(cellIdLists);
+ cellInfo.setFixedPCICells(cellIdLists);
+ assertEquals("NTWK001", cellInfo.getNetworkId());
+ assertEquals(cellIdLists, cellInfo.getCellIdList());
+ assertEquals(cellIdLists, cellInfo.getFixedPCICells());
+
+ }
}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplateTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplateTest.java
new file mode 100644
index 0000000..a1c9472
--- /dev/null
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplateTest.java
@@ -0,0 +1,149 @@
+
+
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * 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.dcaegen2.services.sonhms.utils;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.client.RestTemplate;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(SpringRunner.class)
+@PrepareForTest({ BeanUtil.class })
+@SpringBootTest(classes = SonHandlerRestTemplate.class)
+public class SonHandlerRestTemplateTest {
+
+ @Mock
+ RestTemplate restTemplatemock;
+
+ @InjectMocks
+ SonHandlerRestTemplate sonHandlerRestTemplate;
+
+ @SuppressWarnings({ "static-access", "unchecked", "rawtypes" })
+ @Test
+ public void sendPostRequestTest() {
+
+ PowerMockito.mockStatic(BeanUtil.class);
+ PowerMockito.when(BeanUtil.getBean(RestTemplate.class)).thenReturn(restTemplatemock);
+ ParameterizedTypeReference<String> responseType = null;
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ String requestUrl = "Url"; String requestBody = null;
+ HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
+ when(restTemplatemock.exchange(requestUrl, HttpMethod.POST,requestEntity,responseType)).thenReturn(new ResponseEntity(HttpStatus.OK));
+ ResponseEntity<String> resp = sonHandlerRestTemplate.sendPostRequest(requestUrl,requestBody,responseType);
+ assertEquals(resp.getStatusCode(), HttpStatus.OK);
+
+ }
+
+ @SuppressWarnings({ "static-access", "rawtypes", "unchecked" })
+ @Test
+ public void sendPostRequestTest2() {
+
+ ParameterizedTypeReference<String> responseType = null;
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ String requestUrl = "Url"; String requestBody = null;
+ HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
+ when(restTemplatemock.exchange(requestUrl, HttpMethod.POST,requestEntity,responseType)).thenReturn(new ResponseEntity(HttpStatus.NOT_FOUND));
+ ResponseEntity<String> resp = sonHandlerRestTemplate.sendPostRequest(requestUrl,requestBody,responseType);
+ assertEquals(resp.getStatusCode(), HttpStatus.NOT_FOUND);
+
+ }
+
+ @SuppressWarnings({ "static-access", "unchecked", "rawtypes" })
+ @Test
+ public void sendGetRequest() {
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
+ ParameterizedTypeReference<String> responseType = null;
+ String requestUrl = "Url";
+ PowerMockito.mockStatic(BeanUtil.class);
+ PowerMockito.when(BeanUtil.getBean(RestTemplate.class)).thenReturn(restTemplatemock);
+ when(restTemplatemock.exchange(requestUrl, HttpMethod.GET,requestEntity,responseType)).thenReturn(new ResponseEntity(HttpStatus.OK));
+ ResponseEntity<String> resp = sonHandlerRestTemplate.sendGetRequest(requestUrl,responseType);
+ assertEquals(resp.getStatusCode(), HttpStatus.OK);
+
+ }
+
+ @SuppressWarnings({ "static-access", "rawtypes", "unchecked" })
+ @Test
+ public void sendGetRequest2() {
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.TEXT_PLAIN));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Authorization", "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==");
+ String requestBody = "RequestBody";
+ HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
+ ParameterizedTypeReference<String> responseType = null;
+ String requestUrl = "Url";
+ PowerMockito.mockStatic(BeanUtil.class);
+ PowerMockito.when(BeanUtil.getBean(RestTemplate.class)).thenReturn(restTemplatemock);
+ when(restTemplatemock.exchange(requestUrl, HttpMethod.POST,requestEntity,responseType)).thenReturn(new ResponseEntity(HttpStatus.OK));
+ ResponseEntity<String> resp = sonHandlerRestTemplate.sendGetRequest(requestUrl,requestBody,responseType);
+ assertEquals(resp.getStatusCode(), HttpStatus.OK);
+
+ }
+
+ @SuppressWarnings({ "static-access", "rawtypes", "unchecked" })
+ @Test
+ public void sendPostRequestToOof() {
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Authorization", "Basic cGNpX3Rlc3Q6cGNpX3Rlc3Rwd2Q=");
+ String requestUrl = null; String requestBody = null;
+ HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
+ ParameterizedTypeReference<String> responseType = null;
+ PowerMockito.mockStatic(BeanUtil.class);
+ PowerMockito.when(BeanUtil.getBean(RestTemplate.class)).thenReturn(restTemplatemock);
+ when(restTemplatemock.exchange(requestUrl, HttpMethod.POST,requestEntity,responseType)).thenReturn(new ResponseEntity(HttpStatus.NOT_FOUND));
+ ResponseEntity<String> resp = sonHandlerRestTemplate.sendPostRequestToOof(requestUrl,requestBody,responseType);
+ assertEquals(resp.getStatusCode(), HttpStatus.NOT_FOUND);
+
+ }
+}
diff --git a/src/test/resources/faultNotification.json b/src/test/resources/faultNotification.json
new file mode 100644
index 0000000..803302a
--- /dev/null
+++ b/src/test/resources/faultNotification.json
@@ -0,0 +1,35 @@
+{
+ "event":{
+ "commonEventHeader":{
+ "version":"4.0.1",
+ "vesEventListenerVersion":"7.0.1",
+ "domain":"fault",
+ "eventName":"Fault_RansimAgent-Wipro_RanPCIProblem",
+ "eventId":"fault000001",
+ "sequence":1,
+ "priority":"High",
+ "reportingEntityId":"de305d54-75b4-431b-adb2-eb6b9e546014",
+ "reportingEntityName":"ncserver1",
+ "sourceId":"cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "sourceName":"Chn0001",
+ "startEpochMicrosec":1451772223000000,
+ "lastEpochMicrosec":1451772403000000,
+ "timeZoneOffset":"UTC-05:30",
+ "nfNamingCode":"RansimAgent",
+ "nfVendorName":"Wipro"
+ },
+ "faultFields":{
+ "faultFieldsVersion":"4.0",
+ "alarmCondition":"RanPciCollisionConfusionOccurred",
+ "eventSourceType":"other",
+ "specificProblem":"Collision",
+ "eventSeverity":"CRITICAL",
+ "vfStatus":"Active",
+ "alarmAdditionalInformation":{
+ "networkId":"NTWK005",
+ "collisions":"2",
+ "confusions":"0"
+ }
+ }
+ }
+ }