Incorrect response to {} for cmhandle id-searches 59/130059/2
authorlukegleeson <luke.gleeson@est.tech>
Thu, 28 Jul 2022 16:00:46 +0000 (17:00 +0100)
committeraditya puthuparambil <aditya.puthuparambil@bell.ca>
Tue, 2 Aug 2022 11:14:35 +0000 (11:14 +0000)
An empty body for the CmHandles id-searches api returns an anchor instead of all cm-handles
Now returns all childnode ids for the dmi-registry

Issue-ID: CPS-1175
Signed-off-by: lukegleeson <luke.gleeson@est.tech>
Change-Id: I358970170a4eb7905e9646605f0f373fbcd78945

cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy

index d784bcd..6696f8e 100644 (file)
@@ -217,7 +217,9 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
     }
 
     private Set<String> getAllCmHandleIds() {
-        return inventoryPersistence.getAnchors().parallelStream().map(Anchor::getName).collect(Collectors.toSet());
+        return inventoryPersistence.getDataNode("/dmi-registry")
+            .getChildDataNodes().stream().map(dataNode -> dataNode.getLeaves().get("id").toString())
+            .collect(Collectors.toSet());
     }
 
     private NcmpServiceCmHandle createNcmpServiceCmHandle(final DataNode dataNode) {
index 40ec12d..19c5049 100644 (file)
@@ -156,8 +156,6 @@ class NetworkCmProxyCmHandlerQueryServiceSpec extends Specification {
             def cmHandleQueryParameters = new CmHandleQueryServiceParameters()
         and: 'the inventory persistence returns the dmi registry datanode'
             inventoryPersistence.getDataNode("/dmi-registry") >> dmiRegistry
-        and: 'the inventory persistence returns anchors for get anchors'
-            inventoryPersistence.getAnchors() >> [new Anchor(name: 'PNFDemo1'), new Anchor(name: 'PNFDemo2'), new Anchor(name: 'PNFDemo3'), new Anchor(name: 'PNFDemo4')]
         when: 'the query is executed for both cm handle ids and details'
             def returnedCmHandlesJustIds = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters)
             def returnedCmHandlesWithData = objectUnderTest.queryCmHandles(cmHandleQueryParameters)