diff options
author | malar <malarvizhi.44@wipro.com> | 2021-08-29 17:17:21 +0000 |
---|---|---|
committer | malar <malarvizhi.44@wipro.com> | 2021-08-29 17:17:21 +0000 |
commit | afb7bc0c146474e2492d29a70fa1c82689e8e3ed (patch) | |
tree | 7e5b536066e189e51e38a5fa81adb4dbe2479389 /src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java | |
parent | d9b2a6fef81bf657eac6224dba75254db49c926b (diff) |
Implement CPS Client in SON Handler
Issue-ID: DCAEGEN2-2883
Signed-off-by: Malarvizhi Paramasivam <malarvizhi.44@wipro.com>
Change-Id: Ife63f6eeb9e277c472a4773fe78345e18b753511
Diffstat (limited to 'src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java')
-rw-r--r-- | src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java index 53539c5..32d2a47 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2019-2020 Wipro Limited. + * Copyright (C) 2019-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. @@ -55,6 +55,9 @@ import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; import org.onap.dcaegen2.services.sonhms.model.CellPciPair; import org.onap.dcaegen2.services.sonhms.model.FapServiceList; import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.exceptions.CpsNotFoundException; +import org.onap.dcaegen2.services.sonhms.restclient.ConfigurationClient; import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; @@ -67,7 +70,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(PowerMockRunner.class) @PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) @PowerMockRunnerDelegate(SpringRunner.class) -@PrepareForTest({ SdnrRestClient.class, BeanUtil.class }) +@PrepareForTest({ SdnrRestClient.class, BeanUtil.class, ConfigurationClient.class }) @SpringBootTest(classes = ClusterUtils.class) public class ClusterUtilsTest { @@ -86,6 +89,8 @@ public class ClusterUtilsTest { @BeforeClass public static void setup() { + Configuration config = Configuration.getInstance(); + config.setConfigClientType("ConfigDB"); notification1 = new Notification(); notification2 = new Notification(); clusterDetailsForGetClusterDetailsFromClusterIdTest = new ArrayList<ClusterDetails>(); @@ -150,7 +155,7 @@ public class ClusterUtilsTest { } @Test - public void createClusterTest() throws ConfigDbNotFoundException { + public void createClusterTest() throws Exception { Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = new HashMap<CellPciPair, ArrayList<CellPciPair>>(); @@ -161,8 +166,15 @@ public class ClusterUtilsTest { nbrList.add(new CellPciPair("44", 3)); PowerMockito.mockStatic(SdnrRestClient.class); + PowerMockito.mockStatic(ConfigurationClient.class); - PowerMockito.when(SdnrRestClient.getNbrList(Mockito.anyString())).thenReturn(nbrList); + SdnrRestClient sdnr = PowerMockito.spy(new SdnrRestClient()); + Configuration config = Configuration.getInstance(); + + PowerMockito.whenNew(SdnrRestClient.class).withAnyArguments().thenReturn(sdnr); + PowerMockito.when(ConfigurationClient.configClient(config.getConfigClientType())) + .thenReturn(sdnr); + PowerMockito.doReturn(nbrList).when(sdnr, "getNbrList", Mockito.anyString()); clusterMap.put(new CellPciPair("45", 310), (ArrayList<CellPciPair>) firstNbrList); |