diff options
9 files changed, 31 insertions, 18 deletions
diff --git a/Changelog.md b/Changelog.md index d2e3f47..02649a6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [2.1.4] - 21/06/2021 +## [2.1.4] - 2021/06/21 - [DCAEGEN2-2711](https://jira.onap.org/browse/DCAEGEN2-2711) - Update sdk version to load policies from a file mounted by policy sidecar container - [DCAEGEN2-2809](https://jira.onap.org/browse/DCAEGEN2-2809) - Remove security vulnerabilities - [DCAEGEN2-2884](https://jira.onap.org/browse/DCAEGEN2-2884) - Update FM message spec to VES 7.2 - [DCAEGEN2-2883](https://jira.onap.org/browse/DCAEGEN2-2883) - Implement CPS Client in SON Handler + - [DCAEGEN2-2905](https://jira.onap.org/browse/DCAEGEN2-2905) - Refactored code for standardizing configuration retrieval through common method -## [2.1.3] - 03/02/2021 +## [2.1.3] - 2021/02/03 - [DCAEGEN2-2599](https://jira.onap.org/browse/DCAEGEN2-2599) - Remove security vulnerabilities diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java index 8b05f8c..d0a8702 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java @@ -30,6 +30,8 @@ import java.lang.reflect.Type; import java.util.List; import java.util.Map; +import org.onap.dcaegen2.services.sonhms.restclient.ConfigInterface; +import org.onap.dcaegen2.services.sonhms.restclient.ConfigurationClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -463,6 +465,12 @@ public class Configuration { Configuration.instance = instance; } + public ConfigInterface getConfigurationClient() + { + ConfigInterface conf = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()); + return conf; + } + @Override public String toString() { return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" @@ -491,6 +499,7 @@ public class Configuration { Type mapType = new TypeToken<Map<String, Object>>() { }.getType(); + JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes"); streamsSubscribes = new Gson().fromJson(subscribes, mapType); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java index 3964927..5e98eb4 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java @@ -61,6 +61,7 @@ import org.onap.dcaegen2.services.sonhms.model.Flag; import org.onap.dcaegen2.services.sonhms.model.HoDetails; import org.onap.dcaegen2.services.sonhms.model.ThreadId; import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody; +import org.onap.dcaegen2.services.sonhms.restclient.ConfigInterface; import org.onap.dcaegen2.services.sonhms.restclient.ConfigurationClient; import org.onap.dcaegen2.services.sonhms.restclient.PciSolutions; import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; @@ -82,6 +83,7 @@ public class ChildThread implements Runnable { private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThread.class); private static Timestamp startTime; private static String networkId; + Configuration config = Configuration.getInstance(); /** @@ -176,7 +178,7 @@ public class ChildThread implements Runnable { FixedPciCellsRepository fixedPciCellsRepository = BeanUtil.getBean(FixedPciCellsRepository.class); List<String> fixedPciCells = fixedPciCellsRepository.getFixedPciCells(); String cellId = fixedPciCells.get(0); - JSONObject cellData = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getCellData(cellId); + JSONObject cellData = config.getConfigurationClient().getCellData(cellId); networkId = cellData.getJSONObject("Cell").getString("networkId"); } @@ -320,7 +322,7 @@ public class ChildThread implements Runnable { for (PciSolutions pcisolutions : pciSolutionsList) { String cellId = pcisolutions.getCellId(); - int oldPci = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPci(cellId); + int oldPci = config.getConfigurationClient().getPci(cellId); int newPci = pcisolutions.getPci(); PciUpdate pciUpdate = new PciUpdate(); pciUpdate.setCellId(cellId); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java index 5876d2b..6b60992 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java @@ -68,6 +68,7 @@ public class ChildThreadUtils { private PnfUtils pnfUtils; private PolicyDmaapClient policyDmaapClient; private HoMetricsComponent hoMetricsComponent; + Configuration configuration = Configuration.getInstance(); /** * Parameterized constructor. @@ -98,7 +99,6 @@ public class ChildThreadUtils { public Boolean triggerOrWait(Map<String, ArrayList<Integer>> collisionConfusionResult) { // determine collision or confusion - Configuration configuration = Configuration.getInstance(); int collisionSum = 0; int confusionSum = 0; @@ -226,7 +226,7 @@ public class ChildThreadUtils { lteCell.setBlacklisted("true"); lteCell.setPlmnId(solutions.getNetworkId()); lteCell.setCid(removeableNeighbor); - int pci = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPci(cellId); + int pci = configuration.getConfigurationClient().getPci(cellId); lteCell.setPhyCellId(pci); lteCell.setPnfName(pnfName); lteCellList.add(lteCell); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java index 1787b3f..5a2eaa5 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java @@ -45,6 +45,7 @@ import org.slf4j.Logger; public class PnfUtils { private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThreadUtils.class); + Configuration config = Configuration.getInstance(); /** * get pnfs. @@ -64,7 +65,7 @@ public class PnfUtils { if (cellInfo.isPresent()) { pnfName = cellInfo.get().getPnfName(); } else { - pnfName = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPnfName(cellId); + pnfName = config.getConfigurationClient().getPnfName(cellId); cellInfoRepository.save(new CellInfo(cellId, pnfName)); } if (pnfs.containsKey(pnfName)) { @@ -91,7 +92,7 @@ public class PnfUtils { List<String> removeableNeighbors; for (AnrSolutions anrSolution : anrSolutions) { String cellId = anrSolution.getCellId(); - String pnfName = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPnfName(cellId); + String pnfName = config.getConfigurationClient().getPnfName(cellId); removeableNeighbors = anrSolution.getRemoveableNeighbors(); Map<String, List<String>> cellRemNeighborsPair = new HashMap<>(); cellRemNeighborsPair.put(cellId, removeableNeighbors); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java index 7198fce..7ac3b9e 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java @@ -45,6 +45,7 @@ import org.onap.dcaegen2.services.sonhms.model.CellPciPair; import org.onap.dcaegen2.services.sonhms.model.FapServiceList; import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell; import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.restclient.ConfigInterface; import org.onap.dcaegen2.services.sonhms.restclient.ConfigurationClient; import org.onap.dcaegen2.services.sonhms.restclient.CpsClient; import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient; @@ -54,6 +55,7 @@ import org.slf4j.LoggerFactory; public class ClusterUtils { private static Logger log = LoggerFactory.getLogger(ClusterUtils.class); + Configuration config = Configuration.getInstance(); public List<ClusterDetails> getAllClusters() { ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); @@ -250,7 +252,7 @@ public class ClusterUtils { val1.setPhysicalCellId(phy); cluster.addEdge(val, val1); - List<CellPciPair> nbrList = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getNbrList(cell); + List<CellPciPair> nbrList = config.getConfigurationClient().getNbrList(cell); for (CellPciPair nbr : nbrList) { String cid = nbr.getCellId(); @@ -303,12 +305,12 @@ public class ClusterUtils { */ public Map<CellPciPair, ArrayList<CellPciPair>> findClusterMap(String cellId) throws ConfigDbNotFoundException, CpsNotFoundException { log.info("indide clusterMap"); - int phyCellId = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPci(cellId); + int phyCellId = config.getConfigurationClient().getPci(cellId); CellPciPair main = new CellPciPair(); main.setCellId(cellId); main.setPhysicalCellId(phyCellId); ArrayList<CellPciPair> cellPciPairs; - cellPciPairs = (ArrayList<CellPciPair>) ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getNbrList(cellId); + cellPciPairs = (ArrayList<CellPciPair>) config.getConfigurationClient().getNbrList(cellId); Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = new HashMap<>(); clusterMap.put(main, cellPciPairs); log.info("clusterMap{}", clusterMap); diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java index 8baed64..ba3d4c0 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java @@ -201,8 +201,7 @@ public class TestChildThreadUtils { } PowerMockito.whenNew(SdnrRestClient.class).withAnyArguments().thenReturn(sdnr); - PowerMockito.when(ConfigurationClient.configClient(config.getConfigClientType())) - .thenReturn(sdnr); + PowerMockito.when(config.getConfigurationClient()).thenReturn(sdnr); PowerMockito.doReturn(3).when(sdnr, "getPci", Mockito.anyString()); PowerMockito.doReturn("pnfName").when(sdnr, "getPnfName", Mockito.anyString()); when(policyDmaapClient.sendNotificationToPolicy(Mockito.anyString())).thenReturn(true); diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java index e54748b..607f0c0 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java @@ -136,7 +136,7 @@ public class TestPnfUtils { .thenReturn(cellInfoNull); try { PowerMockito.whenNew(SdnrRestClient.class).withAnyArguments().thenReturn(sdnr); - PowerMockito.when(ConfigurationClient.configClient(config.getConfigClientType())) + PowerMockito.when(config.getConfigurationClient()) .thenReturn(sdnr); PowerMockito.doReturn(pnfName).when(sdnr, "getPnfName", Mockito.anyString()); PowerMockito.when(cellInfoRepositoryMock.save(new CellInfo(cellId, pnfName))).thenReturn(new CellInfo()); @@ -169,8 +169,7 @@ public class TestPnfUtils { try { PowerMockito.whenNew(SdnrRestClient.class).withAnyArguments().thenReturn(sdnr); - PowerMockito.when(ConfigurationClient.configClient(config.getConfigClientType())) - .thenReturn(sdnr); + PowerMockito.when(config.getConfigurationClient()).thenReturn(sdnr); PowerMockito.doReturn("ncServer1").when(sdnr, "getPnfName", Mockito.anyString()); actual = pnfUtils.getPnfsForAnrSolutions(anrSolutions); } catch (ConfigDbNotFoundException e) { 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 32d2a47..104ec88 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 @@ -57,6 +57,7 @@ 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.ConfigInterface; import org.onap.dcaegen2.services.sonhms.restclient.ConfigurationClient; import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient; import org.powermock.api.mockito.PowerMockito; @@ -172,8 +173,7 @@ public class ClusterUtilsTest { Configuration config = Configuration.getInstance(); PowerMockito.whenNew(SdnrRestClient.class).withAnyArguments().thenReturn(sdnr); - PowerMockito.when(ConfigurationClient.configClient(config.getConfigClientType())) - .thenReturn(sdnr); + PowerMockito.when(config.getConfigurationClient()).thenReturn(sdnr); PowerMockito.doReturn(nbrList).when(sdnr, "getNbrList", Mockito.anyString()); clusterMap.put(new CellPciPair("45", 310), (ArrayList<CellPciPair>) firstNbrList); |