From 43467ecc6a1624b7fd695883c5c6c214782f6bcd Mon Sep 17 00:00:00 2001 From: Ramya Ravichandran Date: Fri, 15 Feb 2019 16:26:45 +0530 Subject: Son-handler microservice seed code Change-Id: If4000e26044fe267bdd5fae3a1b2599182423950 Issue-ID: DCAEGEN2-1219 Signed-off-by: Ramya Ravichandran --- .../java/com/wipro/www/sonhms/ApplicationTest.java | 24 +++ .../sonhms/BufferNotificationComponentTest.java | 115 +++++++++++++ .../www/sonhms/ChildStatusUpdateStateTest.java | 25 +++ .../www/sonhms/ClusterDetailsComponentTest.java | 118 +++++++++++++ .../com/wipro/www/sonhms/ConfigPolicyTest.java | 43 +++++ .../com/wipro/www/sonhms/ConfigurationTest.java | 88 ++++++++++ .../sonhms/SdnrNotificationHandlingStateTest.java | 31 ++++ .../java/com/wipro/www/sonhms/SonContextTest.java | 59 +++++++ .../java/com/wipro/www/sonhms/WaitStateTest.java | 24 +++ .../java/com/wipro/www/sonhms/child/GraphTest.java | 63 +++++++ .../www/sonhms/child/TestClusterModification.java | 188 +++++++++++++++++++++ .../com/wipro/www/sonhms/child/TestDetection.java | 117 +++++++++++++ .../com/wipro/www/sonhms/model/CellConfigTest.java | 44 +++++ .../www/sonhms/model/CellNeighbourListTest.java | 41 +++++ .../www/sonhms/model/NotificationPayloadTest.java | 32 ++++ .../wipro/www/sonhms/model/NotificationTest.java | 127 ++++++++++++++ .../com/wipro/www/sonhms/model/PayloadTest.java | 71 ++++++++ .../com/wipro/www/sonhms/model/ResponseTest.java | 38 +++++ .../sonhms/restclient/AsyncResponseBodyTest.java | 57 +++++++ .../wipro/www/sonhms/restclient/CellInfoTest.java | 45 +++++ .../www/sonhms/restclient/OofRequestBodyTest.java | 62 +++++++ .../www/sonhms/restclient/OofRestClientTest.java | 25 +++ .../www/sonhms/restclient/PciSolutionsTest.java | 40 +++++ .../sonhms/restclient/PolicyRequestBodyTest.java | 43 +++++ .../www/sonhms/restclient/RequestInfoTest.java | 57 +++++++ .../wipro/www/sonhms/restclient/SolutionsTest.java | 55 ++++++ 26 files changed, 1632 insertions(+) create mode 100644 src/test/java/com/wipro/www/sonhms/ApplicationTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/BufferNotificationComponentTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/ChildStatusUpdateStateTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/ClusterDetailsComponentTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/ConfigPolicyTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/ConfigurationTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/SdnrNotificationHandlingStateTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/SonContextTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/WaitStateTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/child/GraphTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/child/TestClusterModification.java create mode 100644 src/test/java/com/wipro/www/sonhms/child/TestDetection.java create mode 100644 src/test/java/com/wipro/www/sonhms/model/CellConfigTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/model/CellNeighbourListTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/model/NotificationPayloadTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/model/NotificationTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/model/PayloadTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/model/ResponseTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/restclient/AsyncResponseBodyTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/restclient/CellInfoTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/restclient/OofRequestBodyTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/restclient/OofRestClientTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/restclient/PciSolutionsTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/restclient/PolicyRequestBodyTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/restclient/RequestInfoTest.java create mode 100644 src/test/java/com/wipro/www/sonhms/restclient/SolutionsTest.java (limited to 'src/test/java/com/wipro/www/sonhms') diff --git a/src/test/java/com/wipro/www/sonhms/ApplicationTest.java b/src/test/java/com/wipro/www/sonhms/ApplicationTest.java new file mode 100644 index 0000000..892e0c2 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ApplicationTest.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms; + +public class ApplicationTest { + +} diff --git a/src/test/java/com/wipro/www/sonhms/BufferNotificationComponentTest.java b/src/test/java/com/wipro/www/sonhms/BufferNotificationComponentTest.java new file mode 100644 index 0000000..08779e4 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/BufferNotificationComponentTest.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.wipro.www.sonhms.dao.BufferedNotificationsRepository; +import com.wipro.www.sonhms.entity.BufferedNotifications; +import com.wipro.www.sonhms.utils.BeanUtil; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +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.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.data.web.ProjectedPayload; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ BeanUtil.class }) +@SpringBootTest(classes = BufferNotificationComponent.class) +public class BufferNotificationComponentTest { + + @Mock + private BufferedNotificationsRepository bufferedNotificationsRepositoryMock; + + @InjectMocks + private BufferNotificationComponent bufferNotificationComponent; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void bufferNotificationTest() { + BufferedNotifications bufferedNotifications = new BufferedNotifications(); + bufferedNotifications.setClusterId("clusterId"); + bufferedNotifications.setNotification("notification"); + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(BufferedNotificationsRepository.class)) + .thenReturn(bufferedNotificationsRepositoryMock); + when(bufferedNotificationsRepositoryMock.save(bufferedNotifications)).thenReturn(bufferedNotifications); + BufferedNotifications bufferedNotificationsResult = new BufferedNotifications(); + bufferNotificationComponent.bufferNotification("notification", "clusterId"); + assertEquals(bufferedNotifications, bufferedNotificationsRepositoryMock.save(bufferedNotifications)); + + } + + @Test + public void getBufferedNotificationTest() { + List notificationsList = new ArrayList(); + notificationsList.add("NOTIF1"); + notificationsList.add("NOTIF2"); + String clusterId = "clusterId"; + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(BufferedNotificationsRepository.class)) + .thenReturn(bufferedNotificationsRepositoryMock); + when(bufferedNotificationsRepositoryMock.getNotificationsFromQueue(clusterId)).thenReturn((notificationsList)); + + List testResult = new ArrayList(); + testResult = bufferNotificationComponent.getBufferedNotification(clusterId); + for (int i = 1; i <= testResult.size(); i++) { + assertEquals("NOTIF" + i, testResult.get(i - 1)); + } + } + + @Test + public void getClusterIdTest() { + String notification = "NOTIF1"; + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(BufferedNotificationsRepository.class)) + .thenReturn(bufferedNotificationsRepositoryMock); + when(bufferedNotificationsRepositoryMock.getClusterIdForNotification(notification)).thenReturn(("clusterId")); + String clusterId = bufferNotificationComponent.getClusterId(notification); + assertEquals("clusterId", clusterId); + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/ChildStatusUpdateStateTest.java b/src/test/java/com/wipro/www/sonhms/ChildStatusUpdateStateTest.java new file mode 100644 index 0000000..ea426bf --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ChildStatusUpdateStateTest.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms; + +public class ChildStatusUpdateStateTest { + +} diff --git a/src/test/java/com/wipro/www/sonhms/ClusterDetailsComponentTest.java b/src/test/java/com/wipro/www/sonhms/ClusterDetailsComponentTest.java new file mode 100644 index 0000000..4be6339 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ClusterDetailsComponentTest.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +import com.wipro.www.sonhms.dao.ClusterDetailsRepository; +import com.wipro.www.sonhms.entity.ClusterDetails; +import com.wipro.www.sonhms.utils.BeanUtil; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +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.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.data.web.ProjectedPayload; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({BeanUtil.class}) +@SpringBootTest(classes = ClusterDetailsComponent.class) +public class ClusterDetailsComponentTest { + + @Mock + private ClusterDetailsRepository clusterDetailsRepositorymock; + + + @InjectMocks + private ClusterDetailsComponent clusterDetailsComponent; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void getClusterDetailsTest() { + ClusterDetails clusterDetails = new ClusterDetails("clusterId", "clusterInfo", 1); + List list = new ArrayList(); + list.add(clusterDetails); + + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositorymock); + System.out.println(clusterDetailsRepositorymock); + when(clusterDetailsRepositorymock.getAllClusterDetails()).thenReturn((list)); + + List resultList = new ArrayList(); + resultList = clusterDetailsComponent.getClusterDetails(); + for (ClusterDetails each : resultList) { + assertEquals("clusterId", each.getClusterId()); + assertEquals("clusterInfo", each.getClusterInfo()); + assertEquals(1, each.getChildThreadId()); + + } + + } + + @Test + public void getChildThreadTest() { + String clusterId = "clusterId"; + + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositorymock); + when(clusterDetailsRepositorymock.getChildThreadForCluster(clusterId)).thenReturn((long)1); + long childThreadId = clusterDetailsComponent.getChildThread(clusterId); + assertEquals(1, childThreadId); + + } + + @Test + public void getClusterIdTest() { + long childThreadId = 1; + + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositorymock); + when(clusterDetailsRepositorymock.getClusterIdForChildThread(childThreadId)) + .thenReturn("clusterId"); + String clusterId = clusterDetailsComponent.getClusterId(childThreadId); + assertEquals("clusterId", clusterId); + } +} diff --git a/src/test/java/com/wipro/www/sonhms/ConfigPolicyTest.java b/src/test/java/com/wipro/www/sonhms/ConfigPolicyTest.java new file mode 100644 index 0000000..85b1c44 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ConfigPolicyTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms; + +import static org.junit.Assert.assertEquals; + +import com.wipro.www.sonhms.ConfigPolicy; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + + +public class ConfigPolicyTest { + + @Test + public void configPolicyTest() { + ConfigPolicy configPolicy = ConfigPolicy.getInstance(); + Map config = new HashMap(); + config.put("policyName", "pcims_policy"); + configPolicy.setConfig(config); + assertEquals(config, configPolicy.getConfig()); + } +} diff --git a/src/test/java/com/wipro/www/sonhms/ConfigurationTest.java b/src/test/java/com/wipro/www/sonhms/ConfigurationTest.java new file mode 100644 index 0000000..06294dd --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ConfigurationTest.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms; + +import static org.junit.Assert.assertEquals; + +import com.wipro.www.sonhms.Configuration; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + + +public class ConfigurationTest { + Configuration configuration = Configuration.getInstance(); + + @Test + public void configurationTest() { + configuration.setBufferTime(60); + configuration.setCallbackUrl("/callbackUrl"); + configuration.setConfigName("configName"); + + List list = new ArrayList(); + list.add("server"); + configuration.setServers(list); + configuration.setCg("cg"); + configuration.setCid("cid"); + configuration.setManagerApiKey("managerApiKey"); + configuration.setManagerSecretKey("managerSecretKey"); + configuration.setMaximumClusters(5); + configuration.setMinCollision(5); + configuration.setMinConfusion(5); + configuration.setNumSolutions(1); + configuration.setOofService("oofService"); + configuration.setOptimizers(list); + configuration.setPcimsApiKey("pcimsApiKey"); + configuration.setPcimsSecretKey("pcimsSecretKey"); + configuration.setPolicyName("policyName"); + configuration.setPolicyService("policyService"); + configuration.setPolicyTopic("policyTopic"); + configuration.setPollingInterval(30); + configuration.setPollingTimeout(100); + configuration.setSdnrService("sdnrService"); + configuration.setSdnrTopic("sdnrTopic"); + configuration.setSourceId("sourceId"); + assertEquals(60, configuration.getBufferTime()); + assertEquals("/callbackUrl", configuration.getCallbackUrl()); + assertEquals("cg", configuration.getCg()); + assertEquals("cid", configuration.getCid()); + assertEquals("managerApiKey", configuration.getManagerApiKey()); + assertEquals("managerSecretKey", configuration.getManagerSecretKey()); + assertEquals(5, configuration.getMaximumClusters()); + assertEquals(5, configuration.getMinCollision()); + assertEquals(5, configuration.getMinConfusion()); + assertEquals(1, configuration.getNumSolutions()); + assertEquals("oofService", configuration.getOofService()); + assertEquals(list, configuration.getOptimizers()); + assertEquals("pcimsApiKey", configuration.getPcimsApiKey()); + assertEquals("pcimsSecretKey", configuration.getPcimsSecretKey()); + assertEquals("policyName", configuration.getPolicyName()); + assertEquals("policyService", configuration.getPolicyService()); + assertEquals("policyTopic", configuration.getPolicyTopic()); + assertEquals(30, configuration.getPollingInterval()); + assertEquals(100, configuration.getPollingTimeout()); + assertEquals("sdnrService", configuration.getSdnrService()); + assertEquals("sdnrTopic", configuration.getSdnrTopic()); + assertEquals(list, configuration.getServers()); + assertEquals("sourceId", configuration.getSourceId()); + } +} diff --git a/src/test/java/com/wipro/www/sonhms/SdnrNotificationHandlingStateTest.java b/src/test/java/com/wipro/www/sonhms/SdnrNotificationHandlingStateTest.java new file mode 100644 index 0000000..d6e2dfc --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/SdnrNotificationHandlingStateTest.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms; + +import org.junit.Test; + +public class SdnrNotificationHandlingStateTest { + + @Test + public void sdnrNotificationHandlingState() { + + } +} diff --git a/src/test/java/com/wipro/www/sonhms/SonContextTest.java b/src/test/java/com/wipro/www/sonhms/SonContextTest.java new file mode 100644 index 0000000..e7e6790 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/SonContextTest.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.wipro.www.sonhms.SdnrNotificationHandlingState; +import com.wipro.www.sonhms.SonContext; + +import java.util.List; +import java.util.concurrent.BlockingQueue; + +import org.junit.Test; + + + +public class SonContextTest { + + private BlockingQueue> childStatusUpdate; + + @Test + public void sonContextTest() { + SonContext sonContext = new SonContext(); + sonContext.setChildThreadId(1); + sonContext.setNotifToBeProcessed(true); + sonContext.setSdnrNotification("notification"); + sonContext.setChildStatusUpdate(childStatusUpdate); + NewNotification newNotification = new NewNotification(true); + sonContext.setNewNotification(newNotification); + SdnrNotificationHandlingState pciState = new SdnrNotificationHandlingState(); + sonContext.setPciState(pciState); + assertEquals(1, sonContext.getChildThreadId()); + assertTrue(sonContext.isNotifToBeProcessed()); + assertEquals("notification", sonContext.getSdnrNotification()); + assertEquals(pciState, sonContext.getPciState()); + assertEquals(childStatusUpdate, sonContext.getChildStatusUpdate()); + assertEquals(newNotification, sonContext.getNewNotification()); + + } +} diff --git a/src/test/java/com/wipro/www/sonhms/WaitStateTest.java b/src/test/java/com/wipro/www/sonhms/WaitStateTest.java new file mode 100644 index 0000000..10ae3d7 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/WaitStateTest.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms; + +public class WaitStateTest { + +} diff --git a/src/test/java/com/wipro/www/sonhms/child/GraphTest.java b/src/test/java/com/wipro/www/sonhms/child/GraphTest.java new file mode 100644 index 0000000..2132f22 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/child/GraphTest.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.child; + +import static org.junit.Assert.assertNotEquals; + +import com.wipro.www.sonhms.child.Graph; +import com.wipro.www.sonhms.model.CellPciPair; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.slf4j.Logger; + + + +public class GraphTest { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(GraphTest.class); + + @Test + public void graphTest() { + + CellPciPair cpPair1 = new CellPciPair(); + cpPair1.setCellId("25"); + cpPair1.setPhysicalCellId(32); + + CellPciPair cpPair2 = new CellPciPair(); + cpPair2.setCellId("29"); + cpPair2.setPhysicalCellId(209); + + Graph graph = new Graph(); + + graph.addEdge(cpPair1, cpPair2); + + Map> map = new HashMap<>(); + + log.debug("graph {}", graph.getCellPciNeighbourMap()); + System.out.println("graph" + graph.getCellPciNeighbourMap()); + assertNotEquals(map, graph.getCellPciNeighbourMap()); + + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/child/TestClusterModification.java b/src/test/java/com/wipro/www/sonhms/child/TestClusterModification.java new file mode 100644 index 0000000..148663e --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/child/TestClusterModification.java @@ -0,0 +1,188 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.child; + +import static org.junit.Assert.assertNotEquals; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.wipro.www.sonhms.child.ClusterModification; +import com.wipro.www.sonhms.child.Graph; +import com.wipro.www.sonhms.model.CellPciPair; +import com.wipro.www.sonhms.model.FapServiceList; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.ConcurrentModificationException; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class TestClusterModification { + @Test + public void testClusterModification() { + + CellPciPair cpPair = new CellPciPair(); + cpPair.setCellId("32"); + cpPair.setPhysicalCellId(26); + + CellPciPair cpPair1 = new CellPciPair(); + cpPair1.setCellId("25"); + cpPair1.setPhysicalCellId(23); + + CellPciPair cpPair2 = new CellPciPair(); + cpPair2.setCellId("42"); + cpPair2.setPhysicalCellId(12); + + CellPciPair cpPair3 = new CellPciPair(); + cpPair3.setCellId("56"); + cpPair3.setPhysicalCellId(200); + + CellPciPair cpPair4 = new CellPciPair(); + cpPair4.setCellId("21"); + cpPair4.setPhysicalCellId(6); + + CellPciPair cpPair5 = new CellPciPair(); + cpPair5.setCellId("24"); + cpPair5.setPhysicalCellId(5); + + CellPciPair cpPair6 = new CellPciPair(); + cpPair6.setCellId("38"); + cpPair6.setPhysicalCellId(126); + + CellPciPair cpPair7 = new CellPciPair(); + cpPair7.setCellId("67"); + cpPair7.setPhysicalCellId(300); + + CellPciPair cpPair8 = new CellPciPair(); + cpPair8.setCellId("69"); + cpPair8.setPhysicalCellId(129); + + CellPciPair cpPair9 = new CellPciPair(); + cpPair9.setCellId("78"); + cpPair9.setPhysicalCellId(147); + + ArrayList al = new ArrayList(); + al.add(cpPair1); + al.add(cpPair2); + al.add(cpPair3); + + ArrayList al1 = new ArrayList(); + al1.add(cpPair4); + al1.add(cpPair5); + al1.add(cpPair6); + + ArrayList al2 = new ArrayList(); + al2.add(cpPair7); + al2.add(cpPair8); + al2.add(cpPair9); + + Map> map = new HashMap>(); + + map.put(cpPair, al); + map.put(cpPair1, al1); + map.put(cpPair2, al2); + map.put(cpPair3, new ArrayList()); + map.put(cpPair4, new ArrayList()); + map.put(cpPair5, new ArrayList()); + map.put(cpPair6, new ArrayList()); + map.put(cpPair7, new ArrayList()); + map.put(cpPair8, new ArrayList()); + map.put(cpPair9, new ArrayList()); + Graph cluster = new Graph(); + + cluster.setCellPciNeighbourMap(map); + + System.out.println("map before" + cluster.getCellPciNeighbourMap()); + + String notif = "{ \n" + "\"alias\":\"Cell1\",\n" + "\"X0005b9Lte\":{ \n" + "\"phyCellIdInUse\":\"89\",\n" + + "\"pnfName\":\"DU-1\"\n" + "},\n" + "\"CellConfig\":{ \n" + "\"LTE\":{ \n" + "\"RAN\":{ \n" + + "\"CellIdentity\":\"6\",\n" + "\"NeighborListInUse\":{ \n" + "\"LTECellNumberOfEntries\":\"2\",\n" + + "\"LTENeighborListInUseLTECell\":[ \n" + "{ \n" + "\"pnfName\":\"DU-2\",\n" + + "\"enable\":\"true\",\n" + "\"alias\":\"Cell10\",\n" + "\"mustInclude\":\"true\",\n" + + "\"plmnid\":\"123456\",\n" + "\"cid\":\"2\",\n" + "\"phyCellId\":\"22\",\n" + + "\"blacklisted\":\"false\"\n" + "},\n" + "{ \n" + "\"pnfName\":\"DU-3\",\n" + + "\"enable\":\"true\",\n" + "\"alias\":\"Cell15\",\n" + "\"mustInclude\":\"true\",\n" + + "\"plmnid\":\"123456\",\n" + "\"cid\":\"25\",\n" + "\"phyCellId\":\"35\",\n" + + "\"blacklisted\":\"false\"\n" + "}\n" + "]\n" + "}\n" + "}\n" + "}\n" + "}\n" + "}"; + + ObjectMapper mapper = new ObjectMapper(); + FapServiceList fapser = new FapServiceList(); + try { + fapser = mapper.readValue(notif, FapServiceList.class); + } catch (JsonParseException e) { + e.printStackTrace(); + } catch (JsonMappingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + CellPciPair cpPair11 = new CellPciPair(); + cpPair11.setCellId("2"); + cpPair11.setPhysicalCellId(22); + + CellPciPair cpPair12 = new CellPciPair(); + + cpPair12.setCellId("5"); + cpPair12.setPhysicalCellId(24); + + ArrayList al4 = new ArrayList(); + + al4.add(cpPair11); + al4.add(cpPair12); + + Map> newMap = new HashMap>(); + newMap.put(cpPair, al); + newMap.put(cpPair1, al4); + newMap.put(cpPair2, al2); + newMap.put(cpPair3, new ArrayList()); + newMap.put(cpPair4, new ArrayList()); + newMap.put(cpPair5, new ArrayList()); + newMap.put(cpPair6, new ArrayList()); + newMap.put(cpPair7, new ArrayList()); + newMap.put(cpPair8, new ArrayList()); + newMap.put(cpPair9, new ArrayList()); + newMap.put(cpPair11, new ArrayList()); + newMap.put(cpPair12, new ArrayList()); + + Graph newCluster = new Graph(); + newCluster.setCellPciNeighbourMap(newMap); + System.out.print("newCluster" + newCluster.getCellPciNeighbourMap()); + + ClusterModification mod = new ClusterModification(); + try { + // System.out.print("Cluster" + mod.clustermod(cluster, + // fapser).getCellPciNeighbourMap().toString()); + + assertNotEquals(newCluster, mod.clustermod(cluster, fapser)); + + } catch (NullPointerException e) { + e.printStackTrace(); + } catch (ConcurrentModificationException e) { + System.out.println("Concureent execption" + e); + + } + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/child/TestDetection.java b/src/test/java/com/wipro/www/sonhms/child/TestDetection.java new file mode 100644 index 0000000..03ed787 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/child/TestDetection.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.child; + + +import com.wipro.www.sonhms.child.Detection; +import com.wipro.www.sonhms.child.Graph; +import com.wipro.www.sonhms.model.CellPciPair; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + + +public class TestDetection { + @Test + public void testDetection() { + + CellPciPair cpPair = new CellPciPair(); + cpPair.setCellId("32"); + cpPair.setPhysicalCellId(26); + + CellPciPair cpPair1 = new CellPciPair(); + cpPair1.setCellId("25"); + cpPair1.setPhysicalCellId(23); + + CellPciPair cpPair2 = new CellPciPair(); + cpPair2.setCellId("42"); + cpPair2.setPhysicalCellId(26); + + CellPciPair cpPair3 = new CellPciPair(); + cpPair3.setCellId("56"); + cpPair3.setPhysicalCellId(200); + + CellPciPair cpPair4 = new CellPciPair(); + cpPair4.setCellId("21"); + cpPair4.setPhysicalCellId(5); + + CellPciPair cpPair5 = new CellPciPair(); + cpPair5.setCellId("24"); + cpPair5.setPhysicalCellId(5); + + CellPciPair cpPair6 = new CellPciPair(); + cpPair6.setCellId("38"); + cpPair6.setPhysicalCellId(126); + + CellPciPair cpPair7 = new CellPciPair(); + cpPair7.setCellId("67"); + cpPair7.setPhysicalCellId(300); + + CellPciPair cpPair8 = new CellPciPair(); + cpPair8.setCellId("69"); + cpPair8.setPhysicalCellId(129); + + CellPciPair cpPair9 = new CellPciPair(); + cpPair9.setCellId("78"); + cpPair9.setPhysicalCellId(147); + + ArrayList al = new ArrayList(); + al.add(cpPair1); + al.add(cpPair2); + al.add(cpPair3); + + ArrayList al1 = new ArrayList(); + al1.add(cpPair4); + al1.add(cpPair5); + al1.add(cpPair6); + + ArrayList al2 = new ArrayList(); + al2.add(cpPair7); + al2.add(cpPair8); + al2.add(cpPair9); + + Map> map = new HashMap>(); + + map.put(cpPair, al); + map.put(cpPair1, al1); + map.put(cpPair2, al2); + map.put(cpPair3, new ArrayList()); + map.put(cpPair4, new ArrayList()); + map.put(cpPair5, new ArrayList()); + map.put(cpPair6, new ArrayList()); + map.put(cpPair7, new ArrayList()); + map.put(cpPair8, new ArrayList()); + map.put(cpPair9, new ArrayList()); + Graph cluster = new Graph(); + + cluster.setCellPciNeighbourMap(map); + + System.out.println("mapsssssss" + cluster.getCellPciNeighbourMap()); + Detection detect = new Detection(); + detect.detectCollisionConfusion(cluster); + System.out.println("result" + detect.detectCollisionConfusion(cluster)); + + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/model/CellConfigTest.java b/src/test/java/com/wipro/www/sonhms/model/CellConfigTest.java new file mode 100644 index 0000000..68f8b40 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/CellConfigTest.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.model; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class CellConfigTest { + + @Test + public void cellConfigTest() { + + Common common = new Common(); + common.setCellIdentity("cellIdentity"); + Ran ran = new Ran(); + ran.setCommon(common); + Lte lte = new Lte(); + lte.setRan(ran); + CellConfig cellConfig = new CellConfig(); + cellConfig.setLte(lte); + assertEquals(lte, cellConfig.getLte()); + assertEquals(ran, lte.getRan()); + assertEquals(common, ran.getCommon()); + } +} diff --git a/src/test/java/com/wipro/www/sonhms/model/CellNeighbourListTest.java b/src/test/java/com/wipro/www/sonhms/model/CellNeighbourListTest.java new file mode 100644 index 0000000..8acc0e8 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/CellNeighbourListTest.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.model; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class CellNeighbourListTest { + + @Test + public void cellNeighbourListTest() { + CellNeighbourList cellNeighbourList = new CellNeighbourList(); + cellNeighbourList.setCellId("cellId"); + cellNeighbourList.setNeighbours("neighbour"); + cellNeighbourList.setPhysicalCellId(1); + assertEquals("cellId",cellNeighbourList.getCellId() ); + assertEquals("neighbour",cellNeighbourList.getNeighbours() ); + assertEquals(1,cellNeighbourList.getPhysicalCellId() ); + + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/model/NotificationPayloadTest.java b/src/test/java/com/wipro/www/sonhms/model/NotificationPayloadTest.java new file mode 100644 index 0000000..d1134fa --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/NotificationPayloadTest.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.model; + +import org.junit.Test; + +public class NotificationPayloadTest { + + @Test + public void notificationPayloadTest() { + + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/model/NotificationTest.java b/src/test/java/com/wipro/www/sonhms/model/NotificationTest.java new file mode 100644 index 0000000..09c6c0a --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/NotificationTest.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.wipro.www.sonhms.model.FapServiceList; +import com.wipro.www.sonhms.model.LteNeighborListInUseLteCell; +import com.wipro.www.sonhms.model.NeighborListInUse; +import com.wipro.www.sonhms.model.Notification; +import com.wipro.www.sonhms.model.NotificationCellConfig; +import com.wipro.www.sonhms.model.NotificationLte; +import com.wipro.www.sonhms.model.NotificationPayload; +import com.wipro.www.sonhms.model.NotificationRan; +import com.wipro.www.sonhms.model.RadioAccess; +import com.wipro.www.sonhms.model.X0005b9Lte; + +import java.io.IOException; +import java.util.ArrayList; + +import org.junit.Test; + +public class NotificationTest { + + @Test + public void notificationTest() { + + Notification notif = new Notification(); + LteNeighborListInUseLteCell lteNeighborListInUseLteCell = new LteNeighborListInUseLteCell("pnf1", "true", + "Cell10", "true", "123456", "5", 22, "false"); + + ArrayList list = new ArrayList<>(); + list.add(lteNeighborListInUseLteCell); + + NeighborListInUse neighborListInUse = new NeighborListInUse(list, "1"); + + NotificationRan notificationRan = new NotificationRan(neighborListInUse, "Cell25"); + NotificationLte notificationLte = new NotificationLte(notificationRan); + NotificationCellConfig notificationCell = new NotificationCellConfig(notificationLte); + X0005b9Lte lte = new X0005b9Lte(126, "pnf2"); + FapServiceList fap = new FapServiceList("Cell1", lte, notificationCell); + + ArrayList al = new ArrayList<>(); + al.add(fap); + + RadioAccess radioAccess = new RadioAccess("1", al); + NotificationPayload payload = new NotificationPayload(radioAccess); + + notif.setRequestId("9d2d790e-a5f0-11e8-98d0-529269fb1459"); + notif.setAai("{}"); + notif.setAction("NeighborListModified"); + notif.setFrom("SDNR"); + notif.setVersion("1.0.2"); + notif.setPayload(payload); + assertNotEquals("159", notif.getRequestId()); + + String test = "{\n" + " \"requestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" + " \"AAI\": {},\n" + + " \"from\": \"SDNR\",\n" + " \"version\": \"1.0.2\",\n" + + " \"Action\": \"NeighborListModified\",\n" + " \"Payload\": {\n" + "\n" + " \"RadioAccess\":{ \n" + + " \"FAPServiceNumberOfEntries\":\"2\",\n" + " \"FAPServiceList\":[ \n" + " { \n" + + " \"alias\":\"Cell1\",\n" + " \"X0005b9Lte\":{ \n" + + " \"phyCellIdInUse\":\"35\",\n" + " \"pnfName\":\"DU-1\"\n" + + " },\n" + " \"CellConfig\":{ \n" + " \"LTE\":{ \n" + + " \"RAN\":{ \n" + " \"CellIdentity\":\"Cell1\",\n" + + " \"NeighborListInUse\":{ \n" + + " \"LTECellNumberOfEntries\":\"2\",\n" + + " \"LTENeighborListInUseLTECell\":[ \n" + " { \n" + + " \"pnfName\":\"DU-2\",\n" + + " \"enable\":\"true\",\n" + + " \"alias\":\"Cell10\",\n" + + " \"mustInclude\":\"true\",\n" + + " \"plmnid\":\"123456\",\n" + + " \"cid\":\"2\",\n" + + " \"phyCellId\":\"22\",\n" + + " \"blacklisted\":\"false\"\n" + " },\n" + + " { \n" + " \"pnfName\":\"DU-3\",\n" + + " \"enable\":\"true\",\n" + + " \"alias\":\"Cell15\",\n" + + " \"mustInclude\":\"true\",\n" + + " \"plmnid\":\"123456\",\n" + + " \"cid\":\"5\",\n" + + " \"phyCellId\":\"24\",\n" + + " \"blacklisted\":\"false\"\n" + " }\n" + + " ]\n" + " }\n" + " }\n" + + " }\n" + " }\n" + " }\n" + " ]\n" + " }\n" + "}\n" + "}"; + + ObjectMapper mapper = new ObjectMapper(); + Notification notif1 = new Notification(); + try { + notif1 = mapper.readValue(test, Notification.class); + } catch (JsonParseException e) { + e.printStackTrace(); + } catch (JsonMappingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + assertNotEquals(notif, notif1); + assertEquals(notif.getAction(), notif1.getAction()); + assertEquals(notif.getAai().toString(), notif1.getAai().toString()); + + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/model/PayloadTest.java b/src/test/java/com/wipro/www/sonhms/model/PayloadTest.java new file mode 100644 index 0000000..1c006f9 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/PayloadTest.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.model; + +import static org.junit.Assert.assertEquals; + +import com.wipro.www.sonhms.model.CellConfig; +import com.wipro.www.sonhms.model.Common; +import com.wipro.www.sonhms.model.Configurations; +import com.wipro.www.sonhms.model.Data; +import com.wipro.www.sonhms.model.FapService; +import com.wipro.www.sonhms.model.Lte; +import com.wipro.www.sonhms.model.Payload; +import com.wipro.www.sonhms.model.Ran; +import com.wipro.www.sonhms.model.X0005b9Lte; + +import java.util.ArrayList; + +import org.junit.Test; + + + +public class PayloadTest { + + @Test + public void payloadTest() { + Common common = new Common("cell1"); + + Ran ran = new Ran(common); + + Lte lte = new Lte(ran); + + CellConfig cellConfig = new CellConfig(lte); + + X0005b9Lte x0005b9Lte = new X0005b9Lte(0, "pnf2"); + + FapService fapService = new FapService("cell6", x0005b9Lte, cellConfig); + + Data data = new Data(fapService); + + Configurations config = new Configurations(data); + ArrayList al = new ArrayList<>(); + al.add(config); + + Payload payload = new Payload(al); + + assertEquals("pnf2", payload.getConfiguration().get(0).getData().getFapservice().getX0005b9Lte().getPnfName()); + + assertEquals("cell6", payload.getConfiguration().get(0).getData().getFapservice().getAlias()); + + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/model/ResponseTest.java b/src/test/java/com/wipro/www/sonhms/model/ResponseTest.java new file mode 100644 index 0000000..c413791 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/ResponseTest.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.model; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class ResponseTest { + + @Test + public void respomseTest() { + Response response = new Response(); + response.setCellId("cellId"); + response.setPci(1); + assertEquals("cellId", response.getCellId()); + assertEquals(1, response.getPci()); + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/AsyncResponseBodyTest.java b/src/test/java/com/wipro/www/sonhms/restclient/AsyncResponseBodyTest.java new file mode 100644 index 0000000..95afd77 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/AsyncResponseBodyTest.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; + +import com.wipro.www.sonhms.restclient.AsyncResponseBody; +import com.wipro.www.sonhms.restclient.Solution; +import com.wipro.www.sonhms.restclient.SonSolution; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + + + +public class AsyncResponseBodyTest { + + @Test + public void asyncResponseBodyTest() { + AsyncResponseBody asyncResponseBody = new AsyncResponseBody(); + asyncResponseBody.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); + asyncResponseBody.setRequestStatus("completed"); + SonSolution pciSolutions = new SonSolution(); + pciSolutions.setCellId("EXP001"); + pciSolutions.setPci(101); + List pciSolutionsList = new ArrayList(); + pciSolutionsList.add(pciSolutions); + Solution solutions = new Solution(); + solutions.setFinishTime("2018-10-01T00:40+01.00"); + solutions.setNetworkId("EXP001"); + solutions.setPciSolutions(pciSolutionsList); + solutions.setStartTime("2018-10-01T00:30+01:00"); + ArrayList solutionsList = new ArrayList(); + solutionsList.add(solutions); + asyncResponseBody.setSolutions(solutionsList); + asyncResponseBody.setStatusMessage("success"); + asyncResponseBody.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); + } +} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/CellInfoTest.java b/src/test/java/com/wipro/www/sonhms/restclient/CellInfoTest.java new file mode 100644 index 0000000..b686f93 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/CellInfoTest.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; + +import static org.junit.Assert.assertEquals; + +import com.wipro.www.sonhms.restclient.CellInfo; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; + + +public class CellInfoTest { + @Test + public void cellInfoTest() { + List cellIdLists = new ArrayList<>(); + cellIdLists.add("cell1"); + + CellInfo cellInfo = new CellInfo(); + cellInfo.setNetworkId("NTWK001"); + cellInfo.setCellIdList(cellIdLists); + assertEquals("NTWK001", cellInfo.getNetworkId()); + assertEquals(cellIdLists, cellInfo.getCellIdList()); + + } +} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/OofRequestBodyTest.java b/src/test/java/com/wipro/www/sonhms/restclient/OofRequestBodyTest.java new file mode 100644 index 0000000..493095b --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/OofRequestBodyTest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; + +import static org.junit.Assert.assertEquals; + +import com.wipro.www.sonhms.restclient.CellInfo; +import com.wipro.www.sonhms.restclient.OofRequestBody; +import com.wipro.www.sonhms.restclient.RequestInfo; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; + + + +public class OofRequestBodyTest { + @Test + public void oofRequestBodyTest() { + + List cellIdLists = new ArrayList<>(); + cellIdLists.add("cell1"); + CellInfo cellInfo = new CellInfo(); + cellInfo.setNetworkId("NTWK001"); + cellInfo.setCellIdList(cellIdLists); + RequestInfo requestInfo = new RequestInfo(); + List optimizers = new ArrayList(); + optimizers.add("PCI"); + requestInfo.setCallbackUrl(""); + requestInfo.setNumSolutions(1); + requestInfo.setOptimizers(optimizers); + requestInfo.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); + requestInfo.setRequestType("create"); + requestInfo.setSourceId("PCIHMS"); + requestInfo.setTimeout(60); + requestInfo.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); + + OofRequestBody oofRequestBody = new OofRequestBody(); + oofRequestBody.setCellInfo(cellInfo); + oofRequestBody.setRequestInfo(requestInfo); + assertEquals(requestInfo, oofRequestBody.getRequestInfo()); + assertEquals(cellInfo, oofRequestBody.getCellInfo()); + } +} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/OofRestClientTest.java b/src/test/java/com/wipro/www/sonhms/restclient/OofRestClientTest.java new file mode 100644 index 0000000..2f06f0a --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/OofRestClientTest.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; + +public class OofRestClientTest { + +} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/PciSolutionsTest.java b/src/test/java/com/wipro/www/sonhms/restclient/PciSolutionsTest.java new file mode 100644 index 0000000..e7aac21 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/PciSolutionsTest.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; + +import static org.junit.Assert.assertEquals; + +import com.wipro.www.sonhms.restclient.SonSolution; + +import org.junit.Test; + + +public class PciSolutionsTest { + @Test + public void pciSolutionsTest() { + SonSolution pciSolutions = new SonSolution(); + pciSolutions.setCellId("EXP001"); + pciSolutions.setPci(101); + assertEquals("EXP001", pciSolutions.getCellId()); + assertEquals(101, pciSolutions.getPci()); + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/PolicyRequestBodyTest.java b/src/test/java/com/wipro/www/sonhms/restclient/PolicyRequestBodyTest.java new file mode 100644 index 0000000..0726c31 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/PolicyRequestBodyTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; + +import static org.junit.Assert.assertEquals; + +import com.wipro.www.sonhms.restclient.PolicyRequestBody; + +import org.junit.Test; + + +public class PolicyRequestBodyTest { + @Test + public void policyRequestBodyTest() { + PolicyRequestBody policyRequestBody = new PolicyRequestBody(); + policyRequestBody.setConfigName("PCIMS_CONFIG_POLICY"); + policyRequestBody.setPolicyName("com.PCIMS_CONFIG_POLICY"); + policyRequestBody.setRequestId("60fe7fe6-2649-4f6c-8468-30eb03fd0527"); + assertEquals("PCIMS_CONFIG_POLICY", policyRequestBody.getConfigName()); + assertEquals("com.PCIMS_CONFIG_POLICY", policyRequestBody.getPolicyName()); + assertEquals("60fe7fe6-2649-4f6c-8468-30eb03fd0527", policyRequestBody.getRequestId()); + + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/RequestInfoTest.java b/src/test/java/com/wipro/www/sonhms/restclient/RequestInfoTest.java new file mode 100644 index 0000000..f21971b --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/RequestInfoTest.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; + +import static org.junit.Assert.assertEquals; + +import com.wipro.www.sonhms.restclient.RequestInfo; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + + +public class RequestInfoTest { + @Test + public void requestInfoTest() { + RequestInfo requestInfo = new RequestInfo(); + List optimizers = new ArrayList(); + optimizers.add("PCI"); + requestInfo.setCallbackUrl(""); + requestInfo.setNumSolutions(1); + requestInfo.setOptimizers(optimizers); + requestInfo.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); + requestInfo.setRequestType("create"); + requestInfo.setSourceId("PCIHMS"); + requestInfo.setTimeout(60); + requestInfo.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); + assertEquals(1, requestInfo.getNumSolutions()); + assertEquals(optimizers, requestInfo.getOptimizers()); + assertEquals("create", requestInfo.getRequestType()); + assertEquals("PCIHMS", requestInfo.getSourceId()); + assertEquals("3df7b0e9-26d1-4080-ba42-28e8a3139689", requestInfo.getTransactionId()); + assertEquals("e44a4165-3cf4-4362-89de-e2375eed97e7", requestInfo.getRequestId()); + assertEquals(60, requestInfo.getTimeout()); + assertEquals("", requestInfo.getCallbackUrl()); + } + +} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/SolutionsTest.java b/src/test/java/com/wipro/www/sonhms/restclient/SolutionsTest.java new file mode 100644 index 0000000..64985f6 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/SolutionsTest.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; + +import static org.junit.Assert.assertEquals; + +import com.wipro.www.sonhms.restclient.Solution; +import com.wipro.www.sonhms.restclient.SonSolution; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; + + + +public class SolutionsTest { + + @Test + public void solutionsTest() { + + SonSolution pciSolutions = new SonSolution(); + pciSolutions.setCellId("EXP001"); + pciSolutions.setPci(101); + List pciSolutionsList = new ArrayList(); + pciSolutionsList.add(pciSolutions); + Solution solutions = new Solution(); + solutions.setFinishTime("2018-10-01T00:40+01.00"); + solutions.setNetworkId("EXP001"); + solutions.setPciSolutions(pciSolutionsList); + solutions.setStartTime("2018-10-01T00:30+01:00"); + assertEquals("2018-10-01T00:40+01.00", solutions.getFinishTime()); + assertEquals("EXP001", solutions.getNetworkId()); + assertEquals(pciSolutionsList, solutions.getPciSolutions()); + assertEquals("2018-10-01T00:30+01:00", solutions.getStartTime()); + + } + +} -- cgit 1.2.3-korg