From 1e4d359d458493cf615f151e4fa4a8f300490067 Mon Sep 17 00:00:00 2001 From: Niranjana Date: Fri, 17 Dec 2021 14:46:22 +0000 Subject: [DCAEGEN2] Switch CBS client library to 1.8.7 and fix null pointer exception while fetching slice-config Issue-ID: DCAEGEN2-2966 Issue-ID: DCAEGEN2-3025 Signed-off-by: Niranjana Change-Id: I2fb459d461676243e2648be129e71ee51af30d0d --- .../ms/configdb/ConfigDbInterfaceServiceTest.java | 179 +++++++++++---------- 1 file changed, 95 insertions(+), 84 deletions(-) (limited to 'components/slice-analysis-ms/src/test/java/org/onap/slice/analysis') diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java index 3cb0a3b7..885a9171 100644 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java @@ -41,89 +41,100 @@ import org.springframework.http.ResponseEntity; @RunWith(org.mockito.junit.MockitoJUnitRunner.class) public class ConfigDbInterfaceServiceTest { - @InjectMocks - ConfigDbInterfaceService configdbservice; - - @Mock - ConfigDbRestClient restclient; - - @Test - public void fetchCurrentConfigurationOfSlice() { - - Map responsemap=new HashMap<>(); - responsemap.put("dLThptPerSlice", 1); - responsemap.put("uLThptPerSlice", 2); - Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity(responsemap, HttpStatus.OK)); - assertEquals(responsemap, configdbservice.fetchCurrentConfigurationOfSlice("snssai")); - } - - @Test - public void fetchCurrentConfigurationOfRIC() { - Map map=new HashMap<>(); - Map> responsemap=new HashMap<>(); - map.put("dLThptPerSlice", 45); - map.put("uLThptPerSlice", 50); - responsemap.put("1", map); - - Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity(responsemap, HttpStatus.OK)); - assertEquals(responsemap, configdbservice.fetchCurrentConfigurationOfRIC("snssai")); - - } - @Test - public void fetchRICsOfSnssai() { - Map> response=new HashMap<>(); - List cellslist=new ArrayList<>(); - List cellslist1=new ArrayList<>(); - CellsModel cellsmodel1=new CellsModel(); - cellsmodel1.setCellLocalId("1111"); - CellsModel cellsmodel2=new CellsModel(); - cellsmodel2.setCellLocalId("2222"); - cellslist.add(cellsmodel1); - cellslist.add(cellsmodel2); - response.put("1", cellslist); - CellsModel cellsmodel3=new CellsModel(); - cellsmodel3.setCellLocalId("3333"); - CellsModel cellsmodel4=new CellsModel(); - cellsmodel4.setCellLocalId("4444"); - cellslist1.add(cellsmodel3); - cellslist1.add(cellsmodel4); - response.put("2", cellslist1); - Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity(response, HttpStatus.OK)); - List outputlist=new ArrayList<>(); - outputlist.add("1111"); - outputlist.add("2222"); - Map> output= configdbservice.fetchRICsOfSnssai("snssai"); - assertEquals(outputlist, output.get("1")); - - } - - @Test - public void fetchNetworkFunctionsOfSnssai() { - - List responsemap=new ArrayList<>(); - List networkfunctionslist=new ArrayList(); - NetworkFunctionModel nf1=new NetworkFunctionModel(); - nf1.setgNBDUId("1111"); - NetworkFunctionModel nf2=new NetworkFunctionModel(); - nf2.setgNBDUId("2222"); - NetworkFunctionModel nf3=new NetworkFunctionModel(); - nf3.setgNBDUId("3333"); - networkfunctionslist.add(nf1); - networkfunctionslist.add(nf2); - networkfunctionslist.add(nf3); - Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity(networkfunctionslist, HttpStatus.OK)); - responsemap=configdbservice.fetchNetworkFunctionsOfSnssai("snssai"); - assertEquals(3, responsemap.size()); - - } - public void fetchServiceProfile() { - Map responseMap=new HashMap(); - responseMap.put("sNSSAI", "001-010"); - responseMap.put("ranNFNSSIId","1111"); - responseMap.put("sliceProfileId","2222"); - responseMap.put("globalSubscriberId","110-345"); - Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity(responseMap, HttpStatus.OK)); - assertEquals(responseMap, configdbservice.fetchServiceDetails("snssai")); - } + @InjectMocks + ConfigDbInterfaceService configdbservice; + + @Mock + ConfigDbRestClient restclient; + + @Test + public void fetchCurrentConfigurationOfSlice() { + + Map responsemap=new HashMap<>(); + responsemap.put("dLThptPerSlice", 1); + responsemap.put("uLThptPerSlice", 2); + Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity(responsemap, HttpStatus.OK)); + assertEquals(responsemap, configdbservice.fetchCurrentConfigurationOfSlice("snssai")); + } + + @Test + public void fetchCurrentConfigurationOfRIC() { + Map map=new HashMap<>(); + Map> responsemap=new HashMap<>(); + Map>> result =new HashMap>>(); + map.put("dLThptPerSlice", 45); + map.put("uLThptPerSlice", 60); + map.put("nearRTRICId",1); + responsemap.put("1", map); + List> list = new ArrayList>(); + list.add(map); + result.put("data",list); + Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity(result, HttpStatus.OK)); + assertEquals(responsemap, configdbservice.fetchCurrentConfigurationOfRIC("snssai")); + + } + + @Test + public void fetchRICsOfSnssai() { + Map> response=new HashMap<>(); + List cellslist=new ArrayList<>(); + List cellslist1=new ArrayList<>(); + CellsModel cellsmodel1=new CellsModel(); + cellsmodel1.setCellLocalId("1111"); + CellsModel cellsmodel2=new CellsModel(); + cellsmodel2.setCellLocalId("2222"); + cellslist.add(cellsmodel1); + cellslist.add(cellsmodel2); + response.put("1", cellslist); + CellsModel cellsmodel3=new CellsModel(); + cellsmodel3.setCellLocalId("3333"); + CellsModel cellsmodel4=new CellsModel(); + cellsmodel4.setCellLocalId("4444"); + cellslist1.add(cellsmodel3); + cellslist1.add(cellsmodel4); + response.put("2", cellslist1); + Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity(response, HttpStatus.OK)); + List outputlist=new ArrayList<>(); + outputlist.add("1111"); + outputlist.add("2222"); + Map> output= configdbservice.fetchRICsOfSnssai("snssai"); + assertEquals(outputlist, output.get("1")); + + } + + @Test + public void fetchNetworkFunctionsOfSnssai() { + + List responsemap=new ArrayList<>(); + List networkfunctionslist=new ArrayList(); + NetworkFunctionModel nf1=new NetworkFunctionModel(); + nf1.setgNBDUId("1111"); + NetworkFunctionModel nf2=new NetworkFunctionModel(); + nf2.setgNBDUId("2222"); + NetworkFunctionModel nf3=new NetworkFunctionModel(); + nf3.setgNBDUId("3333"); + networkfunctionslist.add(nf1); + networkfunctionslist.add(nf2); + networkfunctionslist.add(nf3); + Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity(networkfunctionslist, HttpStatus.OK)); + responsemap=configdbservice.fetchNetworkFunctionsOfSnssai("snssai"); + assertEquals(3, responsemap.size()); + + } + + public void fetchServiceProfile() { + Map responseMap=new HashMap(); + responseMap.put("sNSSAI", "001-010"); + responseMap.put("ranNFNSSIId","1111"); + responseMap.put("sliceProfileId","2222"); + responseMap.put("globalSubscriberId","110-345"); + Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity(responseMap, HttpStatus.OK)); + assertEquals(responseMap, configdbservice.fetchServiceDetails("snssai")); + } } -- cgit 1.2.3-korg