aboutsummaryrefslogtreecommitdiffstats
path: root/ransim/ransimctrlr/RANSIM-CTRLR/src/test
diff options
context:
space:
mode:
authorNiranjana <niranjana.y60@wipro.com>2021-03-22 11:39:08 +0000
committerNiranjana <niranjana.y60@wipro.com>2021-03-24 11:31:03 +0000
commit9764b6bb545a8edd4979c481627c38c1892f207e (patch)
treec6b6133144fa7812710f76ced95bbcb243bb9446 /ransim/ransimctrlr/RANSIM-CTRLR/src/test
parent43e39ceab8e35a0a54ae72252b46491f362a0749 (diff)
Update schema and format java files
Issue-ID: INT-1892 Signed-off-by: Niranjana <niranjana.y60@wipro.com> Change-Id: Ib35c35cf7ac7a858311618e741c9327d7630aed6
Diffstat (limited to 'ransim/ransimctrlr/RANSIM-CTRLR/src/test')
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java436
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimControllerServices.java22
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/models/TestApiModels.java2
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/services/TestRANSliceConfigServices.java690
4 files changed, 583 insertions, 567 deletions
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java
index 89cfb86..4c886e3 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java
@@ -17,11 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.ransim.rest.api.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.HashMap;
@@ -32,10 +34,10 @@ import java.util.Set;
import mockit.Mock;
import mockit.MockUp;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import static org.mockito.Mockito.when;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.ransim.rest.api.models.CellDetails;
import org.onap.ransim.rest.api.models.CellNeighbor;
@@ -60,253 +62,251 @@ import org.springframework.http.ResponseEntity;
@RunWith(MockitoJUnitRunner.class)
@PropertySource("classpath:ransim.properties")
public class TestRansimController {
-
- @Test
- public void testGetRansimController() {
- RansimControllerServices rc = Mockito.mock(RansimControllerServices.class);
- assertNotNull(rc);
- }
-
- @Test
- public void testsetNetconfServers() {
- // fail("Not yet implemented");
- RansimControllerServices rscontroller = Mockito.mock(RansimControllerServices.class);
- CellDetails cell1 = new CellDetails("Chn01", 1, "nc1");
- CellDetails cell2 = new CellDetails("Chn02", 2, "nc1");
- CellDetails cell3 = new CellDetails("Chn03", 3, "nc1");
- CellDetails cell4 = new CellDetails("Chn04", 4, "nc1");
-
- Set<CellDetails> cells = new HashSet<CellDetails>();
- cells.add(cell1);
- cells.add(cell2);
- cells.add(cell3);
- cells.add(cell4);
-
- NetconfServers server = new NetconfServers("nc1", null, null, cells);
-
- new MockUp<RansimRepositoryService>() {
- @Mock
- NetconfServers getNetconfServer(String serverId) {
-
- return server;
- }
- };
- new MockUp<RansimRepositoryService>() {
- @Mock
- CellDetails getCellDetail(String nodeId) {
-
- return cell4;
- }
- };
- new MockUp<RansimRepositoryService>() {
- @Mock
- void mergeNetconfServers(NetconfServers netconfServers) {
-
- }
- };
-
- rscontroller.setNetconfServers("Chn04");
-
- boolean check = server.getCells().contains(cell4);
-
- assertTrue(check);
-
- }
-
- @Test
- public void testGenerateNeighborList() {
- // fail("Not yet implemented");
- RansimControllerServices rscontroller = Mockito.mock(RansimControllerServices.class);
- Set<NeighborDetails> neighborList = new HashSet<NeighborDetails>();
- NeighborDetails nbr1 = new NeighborDetails(new NeihborId("Chn00", "Chn01"), false);
- NeighborDetails nbr2 = new NeighborDetails(new NeihborId("Chn00", "Chn02"), false);
- NeighborDetails nbr3 = new NeighborDetails(new NeihborId("Chn00", "Chn03"), true);
-
- neighborList.add(nbr1);
- neighborList.add(nbr2);
- neighborList.add(nbr3);
-
- CellDetails cell0 = new CellDetails("Chn00", 4, "nc1");
- CellDetails cell1 = new CellDetails("Chn01", 1, "nc1");
- CellDetails cell2 = new CellDetails("Chn02", 2, "nc1");
- CellDetails cell3 = new CellDetails("Chn03", 3, "nc1");
-
- CellNeighbor cellNbr = new CellNeighbor();
- cellNbr.setNodeId("Chn00");
- cellNbr.setNeighborList(neighborList);
-
- new MockUp<RansimRepositoryService>() {
- @Mock
- CellNeighbor getCellNeighbor(String nodeId) {
- if (nodeId.equals("Chn00")) {
- return cellNbr;
- } else {
- return null;
- }
-
- }
- };
-
- new MockUp<RansimRepositoryService>() {
- @Mock
- CellDetails getCellDetail(String nodeId) {
- if (nodeId.equals("Chn00")) {
- return cell0;
- } else if (nodeId.equals("Chn01")) {
- return cell1;
- } else if (nodeId.equals("Chn02")) {
- return cell2;
- } else if (nodeId.equals("Chn03")) {
- return cell3;
- } else {
- return null;
- }
-
- }
- };
-
- /*
- * GetNeighborList nbrListFct = rscontroller.generateNeighborList("Chn00");
- *
- * boolean result = false;
- *
- * if (nbrListFct.getCellsWithHo().contains(cell1)) { if
- * (nbrListFct.getCellsWithHo().contains(cell2)) { if
- * (nbrListFct.getCellsWithNoHo().contains(cell3)) { result = true; } } }
- *
- * assertTrue(result);
- */
-
- }
-
- @Test
- public void testSetEventFm() {
- // fail("Not yet implemented");
- RansimControllerServices rscontroller = Mockito.mock(RansimControllerServices.class);
- Map<String, String> alarmAdditionalInformation = new HashMap<String, String>();
- alarmAdditionalInformation.put("networkId", "abc");
- alarmAdditionalInformation.put("collisions", "1");
- alarmAdditionalInformation.put("confusions", "0");
- CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm("Chn00", "", "nc1", 0, 0);
- FaultFields faultFields = new FaultFields("RanPciCollisionConfusionOccurred", "other", "Collision", "CRITICAL",
- alarmAdditionalInformation);
- EventFm checkObj = new EventFm(commonEventHeader, faultFields);
-
- new MockUp<RansimControllerServices>() {
- @Mock
- String getUuid() {
- return "";
- }
- };
- new MockUp<System>() {
- @Mock
- public long currentTimeMillis() {
- return (long) 0;
- }
- };
-
- String networkId = "abc";
- String ncServer = "nc1";
- String cellId = "Chn00";
- FmAlarmInfo issue = new FmAlarmInfo("Collision", "1", "0");
- /*
- * EventFm eventObj = rscontroller.setEventFm(networkId, ncServer, cellId,
- * issue);
- *
- * boolean result = false;
- *
- * Gson gson = new Gson(); String eventStr = gson.toJson(eventObj); String
- * checkStr = gson.toJson(checkObj);
- *
- * System.out.println("eventStr: " + eventStr); System.out.println("checkStr: "
- * + checkStr);
- *
- * if (eventStr.equals(checkStr)) { result = true; }
- *
- * assertTrue(result);
- */
- }
-
-
-
- //@Test
- public void testStopAllCells() {
- RansimControllerServices rscontroller = Mockito.mock(RansimControllerServices.class);
-
- new MockUp<RansimRepositoryService>() {
- @Mock
- List<NetconfServers> getNetconfServersList() {
- System.out.println("getNetconfServersList");
- List<NetconfServers> ns = new ArrayList<NetconfServers>();
- NetconfServers n1 = new NetconfServers("nc1", null, null, null);
- NetconfServers n2 = new NetconfServers("nc2", null, null, null);
- ns.add(n1);
- ns.add(n2);
- return ns;
- }
- };
-
- new MockUp<RestClient>() {
- @Mock
- public String sendUnmountRequestToSdnr(String serverId, String ip, int port, String sdnrUsername,
- String sdnrPassword) {
- System.out.println("sendUnmountRequestToSdnr");
- return "";
- }
- };
-
- String result = rscontroller.stopAllSimulation();
- System.out.println("testStopAllCells: " + result);
- assertEquals("Netconf servers unmounted.", result);
- }
-
- @Test
- public void testStartRanSimulation() throws Exception {
+
+ @Test
+ public void testGetRansimController() {
+ RansimControllerServices rc = Mockito.mock(RansimControllerServices.class);
+ assertNotNull(rc);
+ }
+
+ @Test
+ public void testsetNetconfServers() {
+ // fail("Not yet implemented");
+ RansimControllerServices rscontroller = Mockito.mock(RansimControllerServices.class);
+ CellDetails cell1 = new CellDetails("Chn01", 1, "nc1");
+ CellDetails cell2 = new CellDetails("Chn02", 2, "nc1");
+ CellDetails cell3 = new CellDetails("Chn03", 3, "nc1");
+ CellDetails cell4 = new CellDetails("Chn04", 4, "nc1");
+
+ Set<CellDetails> cells = new HashSet<CellDetails>();
+ cells.add(cell1);
+ cells.add(cell2);
+ cells.add(cell3);
+ cells.add(cell4);
+
+ NetconfServers server = new NetconfServers("nc1", null, null, cells);
+
+ new MockUp<RansimRepositoryService>() {
+ @Mock
+ NetconfServers getNetconfServer(String serverId) {
+
+ return server;
+ }
+ };
+ new MockUp<RansimRepositoryService>() {
+ @Mock
+ CellDetails getCellDetail(String nodeId) {
+
+ return cell4;
+ }
+ };
+ new MockUp<RansimRepositoryService>() {
+ @Mock
+ void mergeNetconfServers(NetconfServers netconfServers) {
+
+ }
+ };
+
+ rscontroller.setNetconfServers("Chn04");
+
+ boolean check = server.getCells().contains(cell4);
+
+ assertTrue(check);
+
+ }
+
+ @Test
+ public void testGenerateNeighborList() {
+ // fail("Not yet implemented");
+ RansimControllerServices rscontroller = Mockito.mock(RansimControllerServices.class);
+ Set<NeighborDetails> neighborList = new HashSet<NeighborDetails>();
+ NeighborDetails nbr1 = new NeighborDetails(new NeihborId("Chn00", "Chn01"), false);
+ NeighborDetails nbr2 = new NeighborDetails(new NeihborId("Chn00", "Chn02"), false);
+ NeighborDetails nbr3 = new NeighborDetails(new NeihborId("Chn00", "Chn03"), true);
+
+ neighborList.add(nbr1);
+ neighborList.add(nbr2);
+ neighborList.add(nbr3);
+
+ CellDetails cell0 = new CellDetails("Chn00", 4, "nc1");
+ CellDetails cell1 = new CellDetails("Chn01", 1, "nc1");
+ CellDetails cell2 = new CellDetails("Chn02", 2, "nc1");
+ CellDetails cell3 = new CellDetails("Chn03", 3, "nc1");
+
+ CellNeighbor cellNbr = new CellNeighbor();
+ cellNbr.setNodeId("Chn00");
+ cellNbr.setNeighborList(neighborList);
+
+ new MockUp<RansimRepositoryService>() {
+ @Mock
+ CellNeighbor getCellNeighbor(String nodeId) {
+ if (nodeId.equals("Chn00")) {
+ return cellNbr;
+ } else {
+ return null;
+ }
+
+ }
+ };
+
+ new MockUp<RansimRepositoryService>() {
+ @Mock
+ CellDetails getCellDetail(String nodeId) {
+ if (nodeId.equals("Chn00")) {
+ return cell0;
+ } else if (nodeId.equals("Chn01")) {
+ return cell1;
+ } else if (nodeId.equals("Chn02")) {
+ return cell2;
+ } else if (nodeId.equals("Chn03")) {
+ return cell3;
+ } else {
+ return null;
+ }
+
+ }
+ };
+
+ /*
+ * GetNeighborList nbrListFct = rscontroller.generateNeighborList("Chn00");
+ *
+ * boolean result = false;
+ *
+ * if (nbrListFct.getCellsWithHo().contains(cell1)) { if
+ * (nbrListFct.getCellsWithHo().contains(cell2)) { if
+ * (nbrListFct.getCellsWithNoHo().contains(cell3)) { result = true; } } }
+ *
+ * assertTrue(result);
+ */
+
+ }
+
+ @Test
+ public void testSetEventFm() {
+ // fail("Not yet implemented");
+ RansimControllerServices rscontroller = Mockito.mock(RansimControllerServices.class);
+ Map<String, String> alarmAdditionalInformation = new HashMap<String, String>();
+ alarmAdditionalInformation.put("networkId", "abc");
+ alarmAdditionalInformation.put("collisions", "1");
+ alarmAdditionalInformation.put("confusions", "0");
+ CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm("Chn00", "", "nc1", 0, 0);
+ FaultFields faultFields = new FaultFields("RanPciCollisionConfusionOccurred", "other", "Collision", "CRITICAL",
+ alarmAdditionalInformation);
+ EventFm checkObj = new EventFm(commonEventHeader, faultFields);
+
+ new MockUp<RansimControllerServices>() {
+ @Mock
+ String getUuid() {
+ return "";
+ }
+ };
+ new MockUp<System>() {
+ @Mock
+ public long currentTimeMillis() {
+ return (long) 0;
+ }
+ };
+
+ String networkId = "abc";
+ String ncServer = "nc1";
+ String cellId = "Chn00";
+ FmAlarmInfo issue = new FmAlarmInfo("Collision", "1", "0");
+ /*
+ * EventFm eventObj = rscontroller.setEventFm(networkId, ncServer, cellId,
+ * issue);
+ *
+ * boolean result = false;
+ *
+ * Gson gson = new Gson(); String eventStr = gson.toJson(eventObj); String
+ * checkStr = gson.toJson(checkObj);
+ *
+ * System.out.println("eventStr: " + eventStr); System.out.println("checkStr: "
+ * + checkStr);
+ *
+ * if (eventStr.equals(checkStr)) { result = true; }
+ *
+ * assertTrue(result);
+ */
+ }
+
+ // @Test
+ public void testStopAllCells() {
+ RansimControllerServices rscontroller = Mockito.mock(RansimControllerServices.class);
+
+ new MockUp<RansimRepositoryService>() {
+ @Mock
+ List<NetconfServers> getNetconfServersList() {
+ System.out.println("getNetconfServersList");
+ List<NetconfServers> ns = new ArrayList<NetconfServers>();
+ NetconfServers n1 = new NetconfServers("nc1", null, null, null);
+ NetconfServers n2 = new NetconfServers("nc2", null, null, null);
+ ns.add(n1);
+ ns.add(n2);
+ return ns;
+ }
+ };
+
+ new MockUp<RestClient>() {
+ @Mock
+ public String sendUnmountRequestToSdnr(String serverId, String ip, int port, String sdnrUsername,
+ String sdnrPassword) {
+ System.out.println("sendUnmountRequestToSdnr");
+ return "";
+ }
+ };
+
+ String result = rscontroller.stopAllSimulation();
+ System.out.println("testStopAllCells: " + result);
+ assertEquals("Netconf servers unmounted.", result);
+ }
+
+ @Test
+ public void testStartRanSimulation() throws Exception {
ResponseEntity<String> rsEntity = new ResponseEntity<>("Simulation started", HttpStatus.OK);
RansimController rscontroller = Mockito.mock(RansimController.class);
when(rscontroller.startRanSliceSimulation()).thenReturn(rsEntity);
assertEquals(rscontroller.startRanSliceSimulation(), rsEntity);
- }
+ }
- @Test
- public void testFailureStartRanSimulation() throws Exception {
+ @Test
+ public void testFailureStartRanSimulation() throws Exception {
RansimController rscontroller = new RansimController();
- ResponseEntity<String> result = rscontroller.startRanSliceSimulation();
+ ResponseEntity<String> result = rscontroller.startRanSliceSimulation();
assertEquals(result.getStatusCode(), HttpStatus.INTERNAL_SERVER_ERROR);
- }
+ }
+
+ @Test
+ public void testStopRanSimulation() throws Exception {
- @Test
- public void testStopRanSimulation() throws Exception {
-
ResponseEntity<String> rsEntity = new ResponseEntity<>("Simulation stopped", HttpStatus.OK);
RansimController rscontroller = Mockito.mock(RansimController.class);
when(rscontroller.stopRanSliceSimulation()).thenReturn(rsEntity);
assertEquals(rscontroller.stopRanSliceSimulation(), rsEntity);
- }
+ }
- @Test
- public void testGenerateIntelligentSlicingPmData() throws Exception {
+ @Test
+ public void testGenerateIntelligentSlicingPmData() throws Exception {
ResponseEntity<String> rsEntity = new ResponseEntity<>("IntelligentSlicing PM data generated", HttpStatus.OK);
RansimController rscontroller = Mockito.mock(RansimController.class);
when(rscontroller.generateIntelligentSlicingPmData()).thenReturn(rsEntity);
assertEquals(rscontroller.generateIntelligentSlicingPmData(), rsEntity);
- }
+ }
- @Test
- public void testStopIntelligentSlicingPmData() throws Exception {
+ @Test
+ public void testStopIntelligentSlicingPmData() throws Exception {
ResponseEntity<String> rsEntity = new ResponseEntity<>("Stopped PM data generation.", HttpStatus.OK);
RansimController rscontroller = Mockito.mock(RansimController.class);
when(rscontroller.stopIntelligentSlicingPmData()).thenReturn(rsEntity);
assertEquals(rscontroller.stopIntelligentSlicingPmData(), rsEntity);
- }
+ }
}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimControllerServices.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimControllerServices.java
index af3659e..567f28d 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimControllerServices.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimControllerServices.java
@@ -42,34 +42,32 @@ public class TestRansimControllerServices {
@Test
public void testGetOperationLog() {
ResponseEntity<String> rsEntity = Mockito.mock(ResponseEntity.class);
-
+
EntityManagerFactory emfactory = Mockito.mock(EntityManagerFactory.class);
EntityManager entityManager = Mockito.mock(EntityManager.class);
Mockito.when(emfactory.createEntityManager()).thenReturn(entityManager);
-
+
TypedQuery<CellDetails> query = Mockito.mock(TypedQuery.class);
Mockito.when(entityManager.createQuery("from CellDetails cd", CellDetails.class)).thenReturn(query);
-
+
List<CellDetails> cellDetailList = new ArrayList<CellDetails>();
Mockito.when(query.getResultList()).thenReturn(cellDetailList);
assertNotNull(rsEntity);
-
+
}
-
+
@Test
public void testModifyACell() {
-
+
ResponseEntity<String> rsEntity = Mockito.mock(ResponseEntity.class);
-
+
EntityManagerFactory emfactory = Mockito.mock(EntityManagerFactory.class);
EntityManager entityManager = Mockito.mock(EntityManager.class);
Mockito.when(emfactory.createEntityManager()).thenReturn(entityManager);
-
+
TypedQuery<CellDetails> query = Mockito.mock(TypedQuery.class);
Mockito.when(entityManager.createQuery("from CellDetails cd", CellDetails.class)).thenReturn(query);
-
-
+
}
-
-} \ No newline at end of file
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/models/TestApiModels.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/models/TestApiModels.java
index b9e24fd..c5ad032 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/models/TestApiModels.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/models/TestApiModels.java
@@ -35,7 +35,7 @@ public class TestApiModels {
mcell.setNewPhysicalCellId(001L);
assertTrue(mcell.getNewPhysicalCellId() == 001);
}
-
+
@Test
public void testsetNewPhysicalCellId1() {
ModifyACellReq mcell = new ModifyACellReq();
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/services/TestRANSliceConfigServices.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/services/TestRANSliceConfigServices.java
index dbea6d0..3ffea5b 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/services/TestRANSliceConfigServices.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/services/TestRANSliceConfigServices.java
@@ -1,336 +1,354 @@
-/*
- * ============LICENSE_START=======================================================
- * Ran Simulator Controller
- * ================================================================================
- * Copyright (C) 2020-2021 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.ransim.rest.api.services;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.ransim.rest.api.models.NSSAIConfig;
-import org.onap.ransim.rest.api.services.RANSliceConfigService;
-import org.onap.ransim.rest.web.mapper.GNBCUCPModel;
-import org.onap.ransim.rest.web.mapper.GNBCUUPModel;
-import org.onap.ransim.rest.web.mapper.GNBDUModel;
-import org.onap.ransim.rest.web.mapper.NRCellCUModel;
-import org.onap.ransim.rest.web.mapper.NRCellDUModel;
-import org.onap.ransim.rest.web.mapper.NearRTRICModel;
-import org.onap.ransim.rest.web.mapper.RANSliceInfoModel;
-import org.springframework.context.annotation.PropertySource;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@RunWith(MockitoJUnitRunner.class)
-@PropertySource("classpath:ransim.properties")
-public class TestRANSliceConfigServices {
-
- @Mock
- RANSliceConfigService rANSliceConfigService;
-
- ObjectMapper objectMapper = new ObjectMapper();
-
- @Test
- public void testSaveGNBCUCP() {
- String input = "{\"gNBCUName\":\"cucpserver1\",\"gNBId\":98763,\"gNBIdLength\":5,\"pLMNId\":\"310-410\",\"nFType\":\"CUCP\",\"nearRTRICId\":11,\"cellCUList\":[{\"cellLocalId\":103594000,\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-093\",\"status\":\"ACTIVE\",\"configData\":{\"maxNumberOfConns\":3000}}}]}]}";
- GNBCUCPModel gNBCUCPModel = new GNBCUCPModel();
- try {
- gNBCUCPModel = objectMapper.readValue(input, GNBCUCPModel.class);
- }catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- Mockito.doReturn(gNBCUCPModel).when(rANSliceConfigService).saveGNBCUCP(gNBCUCPModel);
- assertEquals(gNBCUCPModel, rANSliceConfigService.saveGNBCUCP(gNBCUCPModel));
- }
-
- @Test
- public void testFetchGNBCUCPData() {
- String cuCPName = "cucpserver1";
- GNBCUCPModel gNBCUCPModel = new GNBCUCPModel();
- Mockito.doReturn(gNBCUCPModel).when(rANSliceConfigService).fetchGNBCUCPData(cuCPName);
- assertEquals(gNBCUCPModel, rANSliceConfigService.fetchGNBCUCPData(cuCPName));
- }
-
- @Test
- public void testSaveGNBDU() {
- String input="{\"gNBDUId\":1,\"gNBId\":98763,\"gNBIdLength\":5,\"pLMNId\":\"310-410\",\"gNBDUName\":\"gnduserver1\",\"nFType\":\"DU\",\"nearRTRICId\":11,\"cellDUList\":[{\"cellLocalId\":103593999,\"operationalState\":\"ENABLED\",\"administrativeState\":\"UNLOCKED\",\"cellState\":\"ACTIVE\",\"nRPCI\":12,\"nRTAC\":310,\"resourceType\":\"PRB\",\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":50,\"uLThptPerSlice\":40}}}]}]}";
- GNBDUModel gNBDUModel = new GNBDUModel();
- try {
- gNBDUModel = objectMapper.readValue(input, GNBDUModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Mockito.doReturn(gNBDUModel).when(rANSliceConfigService).saveGNBDU(gNBDUModel);
- assertEquals(gNBDUModel, rANSliceConfigService.saveGNBDU(gNBDUModel));
- }
-
- @Test
- public void testFetchGNBDUData() {
- int gNBDUId=1;
- GNBDUModel gNBDUModel = new GNBDUModel();
- Mockito.doReturn(gNBDUModel).when(rANSliceConfigService).fetchGNBDUData(gNBDUId);
- assertEquals(gNBDUModel, rANSliceConfigService.fetchGNBDUData(gNBDUId));
- }
-
- @Test
- public void testSaveGNBCUUP() {
- String input = "{\"gNBCUUPId\":1111,\"gNBId\":98763,\"gNBIdLength\":2,\"resourceType\":\"DRB\",\"nearRTRICId\":11,\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"maxNumberOfConns\":3000}}}]}";
- GNBCUUPModel gNBCUUPModel = new GNBCUUPModel();
- try {
- gNBCUUPModel=objectMapper.readValue(input, GNBCUUPModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Mockito.doReturn(gNBCUUPModel).when(rANSliceConfigService).saveGNBCUUP(gNBCUUPModel);
- assertEquals(gNBCUUPModel, rANSliceConfigService.saveGNBCUUP(gNBCUUPModel));
- }
-
- @Test
- public void testFetchGNBCUUPData() {
- Integer gNBCUUPId = 1111;
- String response = "{\"gNBCUUPId\":1111,\"gNBId\":98763,\"gNBIdLength\":2,\"resourceType\":\"DRB\",\"nearRTRICId\":11,\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"maxNumberOfConns\":3000}}}]}";
- GNBCUUPModel gNBCUUPModel = new GNBCUUPModel();
- try {
- gNBCUUPModel=objectMapper.readValue(response, GNBCUUPModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Mockito.doReturn(gNBCUUPModel).when(rANSliceConfigService).fetchGNBCUUPData(gNBCUUPId);
- assertEquals(gNBCUUPModel, rANSliceConfigService.fetchGNBCUUPData(gNBCUUPId));
-
- }
-
- @Test
- public void testSaveNearRTRIC() {
- NearRTRICModel nearRTRIC = new NearRTRICModel();
- String input = "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
- try {
- nearRTRIC=objectMapper.readValue(input, NearRTRICModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Mockito.doReturn(nearRTRIC).when(rANSliceConfigService).saveNearRTRIC(nearRTRIC);
- assertEquals(nearRTRIC, rANSliceConfigService.saveNearRTRIC(nearRTRIC));
- }
-
- @Test
- public void testFetchNearRTRICData() {
- int nearRTRICId = 11;
- String response = "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
- NearRTRICModel nearRTRIC = new NearRTRICModel();
- try {
- nearRTRIC=objectMapper.readValue(response, NearRTRICModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Mockito.doReturn(nearRTRIC).when(rANSliceConfigService).fetchNearRTRICData(nearRTRICId);
- assertEquals(nearRTRIC, rANSliceConfigService.fetchNearRTRICData(nearRTRICId));
- }
-
- @Test
- public void testFindRICsInTA() {
- String nSSAI="01-000100";
- List<NearRTRICModel> ricsList = new ArrayList<>();
- String ricModel = "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
- NearRTRICModel nearRTRIC = new NearRTRICModel();
- try {
- nearRTRIC=objectMapper.readValue(ricModel, NearRTRICModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- ricsList.add(nearRTRIC);
- Mockito.doReturn(ricsList).when(rANSliceConfigService).findRICsInTA(Mockito.anyString());
- assertEquals(ricsList, rANSliceConfigService.findRICsInTA(nSSAI));
- }
-
- @Test
- public void testfindNearRTRICofCells() {
- List<Integer> cellIds=new ArrayList<Integer>();cellIds.add(23456);cellIds.add(45785);
- List<NearRTRICModel> ricsList = new ArrayList<>();
- String ricModel = "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
- NearRTRICModel nearRTRIC = new NearRTRICModel();
- try {
- nearRTRIC=objectMapper.readValue(ricModel, NearRTRICModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- ricsList.add(nearRTRIC);
- Mockito.doReturn(ricsList).when(rANSliceConfigService).findNearRTRICofCells(Mockito.anyList());
- assertEquals(ricsList, rANSliceConfigService.findNearRTRICofCells(cellIds));
- }
-
- @Test
- public void testUpdateRANInventory() {
- String input = "{\"ranNFNSSIId\":\"11\",\"ranNSSIList\":[\"ran3\"],\"nSSAIList\":[\"001-003\",\"001-001\"],\"sliceProfilesList\":[{\"sliceProfileId\":12,\"dLThptPerSlice\":1,\"uLThptPerSlice\":2,\"maxNumberofConns\":3,\"sNSSAI\":\"001-003\"}],\"trackingAreaList\":\"Chennai\",\"subnetStatus\":\"ACTIVE\",\"nsstId\":\"NSSTID1\",\"sliceType\":\"eMBB\",\"isShareable\":\"true\"}";
- RANSliceInfoModel inventorynfo = new RANSliceInfoModel();
- try {
- inventorynfo=objectMapper.readValue(input, RANSliceInfoModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Mockito.doReturn(inventorynfo).when(rANSliceConfigService).updateRANInventory(Mockito.anyObject());
- assertEquals(inventorynfo, rANSliceConfigService.updateRANInventory(inventorynfo));
- }
-
- @Test
- public void testFetchRANSlice() {
- String ranNFNSSIId="11";
- String input = "{\"ranNFNSSIId\":\"11\",\"ranNSSIList\":[\"ran3\"],\"nSSAIList\":[\"001-003\",\"001-001\"],\"sliceProfilesList\":[{\"sliceProfileId\":12,\"dLThptPerSlice\":1,\"uLThptPerSlice\":2,\"maxNumberofConns\":3,\"sNSSAI\":\"001-003\"}],\"trackingAreaList\":\"Chennai\",\"subnetStatus\":\"ACTIVE\",\"nsstId\":\"NSSTID1\",\"sliceType\":\"eMBB\",\"isShareable\":\"true\"}";
- RANSliceInfoModel inventorynfo = new RANSliceInfoModel();
- try {
- inventorynfo=objectMapper.readValue(input, RANSliceInfoModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Mockito.doReturn(inventorynfo).when(rANSliceConfigService).fetchRANSlice(ranNFNSSIId);
- assertEquals(inventorynfo, rANSliceConfigService.fetchRANSlice(ranNFNSSIId));
- }
-
- @Test
- public void testFetchCellsofTA() {
- String trackingArea = "Kingston";
- List<String> cellIds=new ArrayList<String>();cellIds.add("23456");cellIds.add("45785");
- Mockito.doReturn(cellIds).when(rANSliceConfigService).fetchCellsofTA(Mockito.anyString());
- assertEquals(cellIds, rANSliceConfigService.fetchCellsofTA(trackingArea));
- }
-
- @Test
- public void testFetchCUCellsofRIC() {
- Integer nearRTRICId=1;
- List<NRCellCUModel> cellCUList= new ArrayList<>();
- Mockito.doReturn(cellCUList).when(rANSliceConfigService).fetchCUCellsofRIC(Mockito.anyInt());
- assertEquals(cellCUList, rANSliceConfigService.fetchCUCellsofRIC(nearRTRICId));;
- }
-
- @Test
- public void testFetchDUCellsofRIC() {
- String sNSSAI = "001-00001";
- Map<Integer, List<NRCellDUModel>> cellsMap = new HashMap<Integer, List<NRCellDUModel>>();
- Mockito.doReturn(cellsMap).when(rANSliceConfigService).fetchDUCellsofRIC(Mockito.anyString());
- assertEquals(cellsMap, rANSliceConfigService.fetchDUCellsofRIC(sNSSAI));;
- }
-
- @Test
- public void testFindNearRTRICByNSSI() {
- String ranNFNSSIID="11";
- List<NearRTRICModel> ricsList = new ArrayList<>();
- String ricModel = "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
- NearRTRICModel nearRTRIC = new NearRTRICModel();
- try {
- nearRTRIC=objectMapper.readValue(ricModel, NearRTRICModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- ricsList.add(nearRTRIC);
- Mockito.doReturn(ricsList).when(rANSliceConfigService).findNearRTRICByNSSI(Mockito.anyString());
- assertEquals(ricsList, rANSliceConfigService.findNearRTRICByNSSI(ranNFNSSIID));
- }
-
- @Test
- public void testFindRICsByNSSAI() {
- String sNSSAI = "001-00001";
- List<NearRTRICModel> ricsList = new ArrayList<>();
- String ricModel = "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
- NearRTRICModel nearRTRIC = new NearRTRICModel();
- try {
- nearRTRIC=objectMapper.readValue(ricModel, NearRTRICModel.class);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- ricsList.add(nearRTRIC);
- Mockito.doReturn(ricsList).when(rANSliceConfigService).findRICsByNSSAI(Mockito.anyString());
- assertEquals(ricsList, rANSliceConfigService.findRICsByNSSAI(sNSSAI));
- }
-
- @Test
- public void testFindSliceProfileconfig() {
- String sNSSAI = "001-00001";
- Map<String,Integer> configDetails = new HashMap<String, Integer>();
- configDetails.put("dLThptPerSlice",40);
- configDetails.put("uLThptPerSlice",50);
- Mockito.doReturn(configDetails).when(rANSliceConfigService).findSliceProfileconfig(Mockito.anyString());
- assertEquals(configDetails, rANSliceConfigService.findSliceProfileconfig(sNSSAI));
- }
- @Test
- public void testFindSliceeconfig() {
- String sNSSAI = "001-00001";Map<Integer, NSSAIConfig> configMap = new HashMap<Integer, NSSAIConfig>();
- Mockito.doReturn(configMap).when(rANSliceConfigService).findSliceConfig(Mockito.anyString());
- assertEquals(configMap, rANSliceConfigService.findSliceConfig(sNSSAI));
- }
-
- @Test
- public void testFindDUsofSNssai() {
- String sNSSAI = "001-00001";
- List<GNBDUModel> duModels = new ArrayList<GNBDUModel>();
- Mockito.doReturn(duModels).when(rANSliceConfigService).findDUsofSNssai(Mockito.anyString());
- assertEquals(duModels, rANSliceConfigService.findDUsofSNssai(sNSSAI));
- }
-
- @Test
- public void testFindCUsofSNssai() {
- String sNSSAI = "001-00001";
- List<GNBCUCPModel> cuModels = new ArrayList<GNBCUCPModel>();
- Mockito.doReturn(cuModels).when(rANSliceConfigService).findCUsofSNssai(Mockito.anyString());
- assertEquals(cuModels, rANSliceConfigService.findCUsofSNssai(sNSSAI));
- }
-
- @Test
- public void testGetSubscriberDetails() {
- String sNSSAI = "001-00001";
- Map<String, String> details = new HashMap<String, String>();
- Mockito.doReturn(details).when(rANSliceConfigService).getSubscriberDetails(Mockito.anyString());
- assertEquals(details, rANSliceConfigService.getSubscriberDetails(sNSSAI));
- }
-
- @Test
- public void testFindAllCUCPFunctions() {
- List<GNBCUCPModel> cucpModels = new ArrayList<GNBCUCPModel>();
- Mockito.doReturn(cucpModels).when(rANSliceConfigService).findAllCUCPFunctions();
- assertEquals(cucpModels, rANSliceConfigService.findAllCUCPFunctions());
- }
-
- @Test
- public void testFindAllDUFunctions() {
- List<GNBDUModel> duModels = new ArrayList<GNBDUModel>();
- Mockito.doReturn(duModels).when(rANSliceConfigService).findAllDUFunctions();
- assertEquals(duModels, rANSliceConfigService.findAllDUFunctions());
- }
-
-}
+/*
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020-2021 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.ransim.rest.api.services;
+
+import static org.junit.Assert.assertEquals;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ransim.rest.api.models.NSSAIConfig;
+import org.onap.ransim.rest.api.services.RANSliceConfigService;
+import org.onap.ransim.rest.web.mapper.GNBCUCPModel;
+import org.onap.ransim.rest.web.mapper.GNBCUUPModel;
+import org.onap.ransim.rest.web.mapper.GNBDUModel;
+import org.onap.ransim.rest.web.mapper.NRCellCUModel;
+import org.onap.ransim.rest.web.mapper.NRCellDUModel;
+import org.onap.ransim.rest.web.mapper.NearRTRICModel;
+import org.onap.ransim.rest.web.mapper.RANSliceInfoModel;
+import org.springframework.context.annotation.PropertySource;
+
+@RunWith(MockitoJUnitRunner.class)
+@PropertySource("classpath:ransim.properties")
+public class TestRANSliceConfigServices {
+
+ @Mock
+ RANSliceConfigService rANSliceConfigService;
+
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ @Test
+ public void testSaveGNBCUCP() {
+ String input =
+ "{\"gNBCUName\":\"cucpserver1\",\"gNBId\":98763,\"gNBIdLength\":5,\"pLMNId\":\"310-410\",\"nFType\":\"CUCP\",\"nearRTRICId\":11,\"cellCUList\":[{\"cellLocalId\":103594000,\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-093\",\"status\":\"ACTIVE\",\"configData\":{\"maxNumberOfConns\":3000}}}]}]}";
+ GNBCUCPModel gNBCUCPModel = new GNBCUCPModel();
+ try {
+ gNBCUCPModel = objectMapper.readValue(input, GNBCUCPModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ Mockito.doReturn(gNBCUCPModel).when(rANSliceConfigService).saveGNBCUCP(gNBCUCPModel);
+ assertEquals(gNBCUCPModel, rANSliceConfigService.saveGNBCUCP(gNBCUCPModel));
+ }
+
+ @Test
+ public void testFetchGNBCUCPData() {
+ String cuCPName = "cucpserver1";
+ GNBCUCPModel gNBCUCPModel = new GNBCUCPModel();
+ Mockito.doReturn(gNBCUCPModel).when(rANSliceConfigService).fetchGNBCUCPData(cuCPName);
+ assertEquals(gNBCUCPModel, rANSliceConfigService.fetchGNBCUCPData(cuCPName));
+ }
+
+ @Test
+ public void testSaveGNBDU() {
+ String input =
+ "{\"gNBDUId\":1,\"gNBId\":98763,\"gNBIdLength\":5,\"pLMNId\":\"310-410\",\"gNBDUName\":\"gnduserver1\",\"nFType\":\"DU\",\"nearRTRICId\":11,\"cellDUList\":[{\"cellLocalId\":103593999,\"operationalState\":\"ENABLED\",\"administrativeState\":\"UNLOCKED\",\"cellState\":\"ACTIVE\",\"nRPCI\":12,\"nRTAC\":310,\"resourceType\":\"PRB\",\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":50,\"uLThptPerSlice\":40}}}]}]}";
+ GNBDUModel gNBDUModel = new GNBDUModel();
+ try {
+ gNBDUModel = objectMapper.readValue(input, GNBDUModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Mockito.doReturn(gNBDUModel).when(rANSliceConfigService).saveGNBDU(gNBDUModel);
+ assertEquals(gNBDUModel, rANSliceConfigService.saveGNBDU(gNBDUModel));
+ }
+
+ @Test
+ public void testFetchGNBDUData() {
+ int gNBDUId = 1;
+ GNBDUModel gNBDUModel = new GNBDUModel();
+ Mockito.doReturn(gNBDUModel).when(rANSliceConfigService).fetchGNBDUData(gNBDUId);
+ assertEquals(gNBDUModel, rANSliceConfigService.fetchGNBDUData(gNBDUId));
+ }
+
+ @Test
+ public void testSaveGNBCUUP() {
+ String input =
+ "{\"gNBCUUPId\":1111,\"gNBId\":98763,\"gNBIdLength\":2,\"resourceType\":\"DRB\",\"nearRTRICId\":11,\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"maxNumberOfConns\":3000}}}]}";
+ GNBCUUPModel gNBCUUPModel = new GNBCUUPModel();
+ try {
+ gNBCUUPModel = objectMapper.readValue(input, GNBCUUPModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Mockito.doReturn(gNBCUUPModel).when(rANSliceConfigService).saveGNBCUUP(gNBCUUPModel);
+ assertEquals(gNBCUUPModel, rANSliceConfigService.saveGNBCUUP(gNBCUUPModel));
+ }
+
+ @Test
+ public void testFetchGNBCUUPData() {
+ Integer gNBCUUPId = 1111;
+ String response =
+ "{\"gNBCUUPId\":1111,\"gNBId\":98763,\"gNBIdLength\":2,\"resourceType\":\"DRB\",\"nearRTRICId\":11,\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"maxNumberOfConns\":3000}}}]}";
+ GNBCUUPModel gNBCUUPModel = new GNBCUUPModel();
+ try {
+ gNBCUUPModel = objectMapper.readValue(response, GNBCUUPModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Mockito.doReturn(gNBCUUPModel).when(rANSliceConfigService).fetchGNBCUUPData(gNBCUUPId);
+ assertEquals(gNBCUUPModel, rANSliceConfigService.fetchGNBCUUPData(gNBCUUPId));
+
+ }
+
+ @Test
+ public void testSaveNearRTRIC() {
+ NearRTRICModel nearRTRIC = new NearRTRICModel();
+ String input =
+ "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
+ try {
+ nearRTRIC = objectMapper.readValue(input, NearRTRICModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Mockito.doReturn(nearRTRIC).when(rANSliceConfigService).saveNearRTRIC(nearRTRIC);
+ assertEquals(nearRTRIC, rANSliceConfigService.saveNearRTRIC(nearRTRIC));
+ }
+
+ @Test
+ public void testFetchNearRTRICData() {
+ int nearRTRICId = 11;
+ String response =
+ "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
+ NearRTRICModel nearRTRIC = new NearRTRICModel();
+ try {
+ nearRTRIC = objectMapper.readValue(response, NearRTRICModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Mockito.doReturn(nearRTRIC).when(rANSliceConfigService).fetchNearRTRICData(nearRTRICId);
+ assertEquals(nearRTRIC, rANSliceConfigService.fetchNearRTRICData(nearRTRICId));
+ }
+
+ @Test
+ public void testFindRICsInTA() {
+ String nSSAI = "01-000100";
+ List<NearRTRICModel> ricsList = new ArrayList<>();
+ String ricModel =
+ "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
+ NearRTRICModel nearRTRIC = new NearRTRICModel();
+ try {
+ nearRTRIC = objectMapper.readValue(ricModel, NearRTRICModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ricsList.add(nearRTRIC);
+ Mockito.doReturn(ricsList).when(rANSliceConfigService).findRICsInTA(Mockito.anyString());
+ assertEquals(ricsList, rANSliceConfigService.findRICsInTA(nSSAI));
+ }
+
+ @Test
+ public void testfindNearRTRICofCells() {
+ List<Integer> cellIds = new ArrayList<Integer>();
+ cellIds.add(23456);
+ cellIds.add(45785);
+ List<NearRTRICModel> ricsList = new ArrayList<>();
+ String ricModel =
+ "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
+ NearRTRICModel nearRTRIC = new NearRTRICModel();
+ try {
+ nearRTRIC = objectMapper.readValue(ricModel, NearRTRICModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ricsList.add(nearRTRIC);
+ Mockito.doReturn(ricsList).when(rANSliceConfigService).findNearRTRICofCells(Mockito.anyList());
+ assertEquals(ricsList, rANSliceConfigService.findNearRTRICofCells(cellIds));
+ }
+
+ @Test
+ public void testUpdateRANInventory() {
+ String input =
+ "{\"ranNFNSSIId\":\"11\",\"ranNSSIList\":[\"ran3\"],\"nSSAIList\":[\"001-003\",\"001-001\"],\"sliceProfilesList\":[{\"sliceProfileId\":12,\"dLThptPerSlice\":1,\"uLThptPerSlice\":2,\"maxNumberofConns\":3,\"sNSSAI\":\"001-003\"}],\"trackingAreaList\":\"Chennai\",\"subnetStatus\":\"ACTIVE\",\"nsstId\":\"NSSTID1\",\"sliceType\":\"eMBB\",\"isShareable\":\"true\"}";
+ RANSliceInfoModel inventorynfo = new RANSliceInfoModel();
+ try {
+ inventorynfo = objectMapper.readValue(input, RANSliceInfoModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Mockito.doReturn(inventorynfo).when(rANSliceConfigService).updateRANInventory(Mockito.anyObject());
+ assertEquals(inventorynfo, rANSliceConfigService.updateRANInventory(inventorynfo));
+ }
+
+ @Test
+ public void testFetchRANSlice() {
+ String ranNFNSSIId = "11";
+ String input =
+ "{\"ranNFNSSIId\":\"11\",\"ranNSSIList\":[\"ran3\"],\"nSSAIList\":[\"001-003\",\"001-001\"],\"sliceProfilesList\":[{\"sliceProfileId\":12,\"dLThptPerSlice\":1,\"uLThptPerSlice\":2,\"maxNumberofConns\":3,\"sNSSAI\":\"001-003\"}],\"trackingAreaList\":\"Chennai\",\"subnetStatus\":\"ACTIVE\",\"nsstId\":\"NSSTID1\",\"sliceType\":\"eMBB\",\"isShareable\":\"true\"}";
+ RANSliceInfoModel inventorynfo = new RANSliceInfoModel();
+ try {
+ inventorynfo = objectMapper.readValue(input, RANSliceInfoModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Mockito.doReturn(inventorynfo).when(rANSliceConfigService).fetchRANSlice(ranNFNSSIId);
+ assertEquals(inventorynfo, rANSliceConfigService.fetchRANSlice(ranNFNSSIId));
+ }
+
+ @Test
+ public void testFetchCellsofTA() {
+ String trackingArea = "Kingston";
+ List<String> cellIds = new ArrayList<String>();
+ cellIds.add("23456");
+ cellIds.add("45785");
+ Mockito.doReturn(cellIds).when(rANSliceConfigService).fetchCellsofTA(Mockito.anyString());
+ assertEquals(cellIds, rANSliceConfigService.fetchCellsofTA(trackingArea));
+ }
+
+ @Test
+ public void testFetchCUCellsofRIC() {
+ Integer nearRTRICId = 1;
+ List<NRCellCUModel> cellCUList = new ArrayList<>();
+ Mockito.doReturn(cellCUList).when(rANSliceConfigService).fetchCUCellsofRIC(Mockito.anyInt());
+ assertEquals(cellCUList, rANSliceConfigService.fetchCUCellsofRIC(nearRTRICId));;
+ }
+
+ @Test
+ public void testFetchDUCellsofRIC() {
+ String sNSSAI = "001-00001";
+ Map<Integer, List<NRCellDUModel>> cellsMap = new HashMap<Integer, List<NRCellDUModel>>();
+ Mockito.doReturn(cellsMap).when(rANSliceConfigService).fetchDUCellsofRIC(Mockito.anyString());
+ assertEquals(cellsMap, rANSliceConfigService.fetchDUCellsofRIC(sNSSAI));;
+ }
+
+ @Test
+ public void testFindNearRTRICByNSSI() {
+ String ranNFNSSIID = "11";
+ List<NearRTRICModel> ricsList = new ArrayList<>();
+ String ricModel =
+ "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
+ NearRTRICModel nearRTRIC = new NearRTRICModel();
+ try {
+ nearRTRIC = objectMapper.readValue(ricModel, NearRTRICModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ricsList.add(nearRTRIC);
+ Mockito.doReturn(ricsList).when(rANSliceConfigService).findNearRTRICByNSSI(Mockito.anyString());
+ assertEquals(ricsList, rANSliceConfigService.findNearRTRICByNSSI(ranNFNSSIID));
+ }
+
+ @Test
+ public void testFindRICsByNSSAI() {
+ String sNSSAI = "001-00001";
+ List<NearRTRICModel> ricsList = new ArrayList<>();
+ String ricModel =
+ "{\"nearRTRICId\":11,\"gNBId\":98763,\"trackingArea\":[\"Kingston\"],\"resourceType\":\"NearRTRIC\",\"ranNFNSSIList\":[\"11\",\"22\"],\"pLMNInfoList\":[{\"pLMNId\":\"310-410\",\"sNSSAI\":{\"sNSSAI\":\"001-003\",\"status\":\"ACTIVE\",\"configData\":{\"dLThptPerSlice\":55,\"uLThptPerSlice\":40}}}]}";
+ NearRTRICModel nearRTRIC = new NearRTRICModel();
+ try {
+ nearRTRIC = objectMapper.readValue(ricModel, NearRTRICModel.class);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ricsList.add(nearRTRIC);
+ Mockito.doReturn(ricsList).when(rANSliceConfigService).findRICsByNSSAI(Mockito.anyString());
+ assertEquals(ricsList, rANSliceConfigService.findRICsByNSSAI(sNSSAI));
+ }
+
+ @Test
+ public void testFindSliceProfileconfig() {
+ String sNSSAI = "001-00001";
+ Map<String, Integer> configDetails = new HashMap<String, Integer>();
+ configDetails.put("dLThptPerSlice", 40);
+ configDetails.put("uLThptPerSlice", 50);
+ Mockito.doReturn(configDetails).when(rANSliceConfigService).findSliceProfileconfig(Mockito.anyString());
+ assertEquals(configDetails, rANSliceConfigService.findSliceProfileconfig(sNSSAI));
+ }
+
+ @Test
+ public void testFindSliceeconfig() {
+ String sNSSAI = "001-00001";
+ Map<Integer, NSSAIConfig> configMap = new HashMap<Integer, NSSAIConfig>();
+ Mockito.doReturn(configMap).when(rANSliceConfigService).findSliceConfig(Mockito.anyString());
+ assertEquals(configMap, rANSliceConfigService.findSliceConfig(sNSSAI));
+ }
+
+ @Test
+ public void testFindDUsofSNssai() {
+ String sNSSAI = "001-00001";
+ List<GNBDUModel> duModels = new ArrayList<GNBDUModel>();
+ Mockito.doReturn(duModels).when(rANSliceConfigService).findDUsofSNssai(Mockito.anyString());
+ assertEquals(duModels, rANSliceConfigService.findDUsofSNssai(sNSSAI));
+ }
+
+ @Test
+ public void testFindCUsofSNssai() {
+ String sNSSAI = "001-00001";
+ List<GNBCUCPModel> cuModels = new ArrayList<GNBCUCPModel>();
+ Mockito.doReturn(cuModels).when(rANSliceConfigService).findCUsofSNssai(Mockito.anyString());
+ assertEquals(cuModels, rANSliceConfigService.findCUsofSNssai(sNSSAI));
+ }
+
+ @Test
+ public void testGetSubscriberDetails() {
+ String sNSSAI = "001-00001";
+ Map<String, String> details = new HashMap<String, String>();
+ Mockito.doReturn(details).when(rANSliceConfigService).getSubscriberDetails(Mockito.anyString());
+ assertEquals(details, rANSliceConfigService.getSubscriberDetails(sNSSAI));
+ }
+
+ @Test
+ public void testFindAllCUCPFunctions() {
+ List<GNBCUCPModel> cucpModels = new ArrayList<GNBCUCPModel>();
+ Mockito.doReturn(cucpModels).when(rANSliceConfigService).findAllCUCPFunctions();
+ assertEquals(cucpModels, rANSliceConfigService.findAllCUCPFunctions());
+ }
+
+ @Test
+ public void testFindAllDUFunctions() {
+ List<GNBDUModel> duModels = new ArrayList<GNBDUModel>();
+ Mockito.doReturn(duModels).when(rANSliceConfigService).findAllDUFunctions();
+ assertEquals(duModels, rANSliceConfigService.findAllDUFunctions());
+ }
+
+}