summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy/org
diff options
context:
space:
mode:
authoremaclee <lee.anjella.macabuhay@est.tech>2022-08-19 09:26:39 +0100
committerLee Anjella Macabuhay <lee.anjella.macabuhay@est.tech>2022-09-01 09:37:42 +0000
commitd340047f82a8301453fc3872e474090366b68472 (patch)
treedda61a5c559dceb2aa7d26beb7ed292d23b77175 /cps-ncmp-service/src/test/groovy/org
parentc1915b5af27e4ee3ff89fd881e753e029a0bf5da (diff)
Get all cm handles by DMI plugin Identifier
- api added to get cm handles by dmi plugin identifier - response object refactored from RestOutputCmHandle to collection of Strings (cm handle ids) - added public and private methods in CmHandleQueries to get cm handle ID by dmi plugin - added unit tests including test to show that there are no duplicates on response Issue-ID: CPS-1136 Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech> Change-Id: Ia3bdc16172a90ad3a3f9ae11cddcad1352188726
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy6
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy16
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesSpec.groovy14
3 files changed, 34 insertions, 2 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
index 8d8b3b45c..ed985ec00 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
@@ -29,6 +29,7 @@ import org.onap.cps.ncmp.api.impl.event.lcm.LcmEventsCmHandleStateHandler
import org.onap.cps.ncmp.api.impl.exception.DmiRequestException
import org.onap.cps.ncmp.api.impl.operations.DmiDataOperations
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
+import org.onap.cps.ncmp.api.inventory.CmHandleQueries
import org.onap.cps.ncmp.api.inventory.CmHandleState
import org.onap.cps.ncmp.api.inventory.InventoryPersistence
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse
@@ -59,6 +60,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def mockDmiDataOperations = Mock(DmiDataOperations)
def mockNetworkCmProxyDataServicePropertyHandler = Mock(NetworkCmProxyDataServicePropertyHandler)
def mockInventoryPersistence = Mock(InventoryPersistence)
+ def mockCmhandleQueries = Mock(CmHandleQueries)
def stubbedNetworkCmProxyCmHandlerQueryService = Stub(NetworkCmProxyCmHandlerQueryService)
def mockLcmEventsCmHandleStateHandler = Mock(LcmEventsCmHandleStateHandler)
def mockCpsDataService = Mock(CpsDataService)
@@ -352,7 +354,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def getObjectUnderTest() {
return Spy(new NetworkCmProxyDataServiceImpl(spiedJsonObjectMapper, mockDmiDataOperations,
- mockNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence, stubbedNetworkCmProxyCmHandlerQueryService,
- mockLcmEventsCmHandleStateHandler, mockCpsDataService))
+ mockNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence, mockCmhandleQueries,
+ stubbedNetworkCmProxyCmHandlerQueryService, mockLcmEventsCmHandleStateHandler, mockCpsDataService))
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
index a114b61e9..02cfb152c 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
@@ -25,6 +25,7 @@ package org.onap.cps.ncmp.api.impl
import org.onap.cps.ncmp.api.NetworkCmProxyCmHandlerQueryService
import org.onap.cps.ncmp.api.impl.event.lcm.LcmEventsCmHandleStateHandler
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
+import org.onap.cps.ncmp.api.inventory.CmHandleQueries
import org.onap.cps.ncmp.api.inventory.CmHandleState
import org.onap.cps.ncmp.api.inventory.CompositeState
import org.onap.cps.ncmp.api.inventory.InventoryPersistence
@@ -63,6 +64,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
def mockDmiDataOperations = Mock(DmiDataOperations)
def nullNetworkCmProxyDataServicePropertyHandler = null
def mockInventoryPersistence = Mock(InventoryPersistence)
+ def mockCmHandleQueries = Mock(CmHandleQueries)
def mockDmiPluginRegistration = Mock(DmiPluginRegistration)
def mockCpsCmHandlerQueryService = Mock(NetworkCmProxyCmHandlerQueryService)
def mockLcmEventsCmHandleStateHandler = Mock(LcmEventsCmHandleStateHandler)
@@ -79,6 +81,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
mockDmiDataOperations,
nullNetworkCmProxyDataServicePropertyHandler,
mockInventoryPersistence,
+ mockCmHandleQueries,
mockCpsCmHandlerQueryService,
mockLcmEventsCmHandleStateHandler,
mockCpsDataService)
@@ -370,6 +373,19 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
0 * mockInventoryPersistence.saveCmHandleState(_, _)
}
+ def 'Get all cm handle IDs by DMI plugin identifier.' () {
+ given: 'cm handle queries service returns cm handles'
+ 1 * mockCmHandleQueries.getCmHandlesByDmiPluginIdentifier('some-dmi-plugin-identifier')
+ >> [new NcmpServiceCmHandle(cmHandleId: 'cm-handle-1'),
+ new NcmpServiceCmHandle(cmHandleId: 'cm-handle-2')]
+ when: 'cm handle Ids are requested with dmi plugin identifier'
+ def result = objectUnderTest.getAllCmHandleIdsByDmiPluginIdentifier('some-dmi-plugin-identifier')
+ then: 'the result size is correct'
+ assert result.size() == 2
+ and: 'the result returns the correct details'
+ assert result.containsAll('cm-handle-1','cm-handle-2')
+ }
+
def dataStores() {
CompositeState.DataStores.builder()
.operationalDataStore(CompositeState.Operational.builder()
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesSpec.groovy
index 21aa1643d..26b3613cd 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesSpec.groovy
@@ -135,6 +135,17 @@ class CmHandleQueriesSpec extends Specification {
assert result.contains(cmHandleDataNode)
}
+ def 'Get all cm handles by dmi plugin identifier'() {
+ given: 'the DataNodes queried for a given cpsPath are returned from the persistence service.'
+ mockResponses()
+ when: 'cm Handles are fetched for a given dmi plugin identifier'
+ def result = objectUnderTest.getCmHandlesByDmiPluginIdentifier('my-dmi-plugin-identifier')
+ then: 'result is the correct size'
+ assert result.size() == 3
+ and: 'result contains the correct cm handles'
+ assert result.cmHandleId.containsAll('PNFDemo', 'PNFDemo2', 'PNFDemo4')
+ }
+
void mockResponses() {
cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties[@name=\"Contact\" and @value=\"newemailforstore@bookstore.com\"]/ancestor::cm-handles', _) >> [pnfDemo, pnfDemo2, pnfDemo4]
cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties[@name=\"wont_match\" and @value=\"wont_match\"]/ancestor::cm-handles', _) >> []
@@ -142,6 +153,9 @@ class CmHandleQueriesSpec extends Specification {
cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties[@name=\"Contact2\" and @value=\"\"]/ancestor::cm-handles', _) >> []
cpsDataPersistenceService.queryDataNodes(_, _, '//state[@cm-handle-state=\"READY\"]/ancestor::cm-handles', _) >> [pnfDemo, pnfDemo3]
cpsDataPersistenceService.queryDataNodes(_, _, '//state[@cm-handle-state=\"LOCKED\"]/ancestor::cm-handles', _) >> [pnfDemo2, pnfDemo4]
+ cpsDataPersistenceService.queryDataNodes('NCMP-Admin','ncmp-dmi-registry','/dmi-registry/cm-handles[@dmi-service-name=\'my-dmi-plugin-identifier\']',OMIT_DESCENDANTS) >> [pnfDemo, pnfDemo2]
+ cpsDataPersistenceService.queryDataNodes('NCMP-Admin','ncmp-dmi-registry','/dmi-registry/cm-handles[@dmi-data-service-name=\'my-dmi-plugin-identifier\']',OMIT_DESCENDANTS) >> [pnfDemo,pnfDemo4]
+ cpsDataPersistenceService.queryDataNodes('NCMP-Admin','ncmp-dmi-registry','/dmi-registry/cm-handles[@dmi-model-service-name=\'my-dmi-plugin-identifier\']',OMIT_DESCENDANTS) >> [pnfDemo2,pnfDemo4]
}
def static createDataNode(dataNodeId) {