summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test
diff options
context:
space:
mode:
authorkissand <andras.zoltan.kiss@est.tech>2022-06-28 16:08:33 +0100
committerkissand <andras.zoltan.kiss@est.tech>2022-06-30 08:58:32 +0200
commit2321538db22de683c137299b45a6d6fe9e8d52ce (patch)
tree97c398903d97e843e678b654691b1121a03ae562 /cps-ncmp-service/src/test
parent78062a1c3f4e303714103dfcb7d9552a0b081eb0 (diff)
Fix performance degradation bug
- do NOT use cpsPath query for gettign individual CM Handles - change order of queries for more efficency (property query first) Issue-ID: CPS-1085 Change-Id: Ia3bdf4f0d245a2b128557352685d2aa17c1f939c Signed-off-by: kissand <andras.zoltan.kiss@est.tech> Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/test')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy91
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy5
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy43
3 files changed, 74 insertions, 65 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy
index 46c866282a..6e60979c34 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy
@@ -20,7 +20,6 @@
package org.onap.cps.ncmp.api.impl
-import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.api.NetworkCmProxyCmHandlerQueryService
import org.onap.cps.spi.CpsAdminPersistenceService
import org.onap.cps.spi.CpsDataPersistenceService
@@ -28,7 +27,6 @@ import org.onap.cps.spi.model.Anchor
import org.onap.cps.spi.model.CmHandleQueryServiceParameters
import org.onap.cps.spi.model.ConditionProperties
import org.onap.cps.spi.model.DataNode
-import org.onap.cps.utils.JsonObjectMapper
import spock.lang.Specification
import java.util.stream.Collectors
@@ -39,8 +37,7 @@ class NetworkCmProxyCmHandlerQueryServiceSpec extends Specification {
def cpsAdminPersistenceService = Mock(CpsAdminPersistenceService)
NetworkCmProxyCmHandlerQueryService objectUnderTest = new NetworkCmProxyCmHandlerQueryServiceImpl(
- cpsDataPersistenceService, cpsAdminPersistenceService, new JsonObjectMapper(new ObjectMapper())
- )
+ cpsDataPersistenceService, cpsAdminPersistenceService)
def 'Retrieve cm handles with public properties when #scenario.'() {
given: 'a condition property'
@@ -51,16 +48,19 @@ class NetworkCmProxyCmHandlerQueryServiceSpec extends Specification {
cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties])
and: 'mock services'
mockResponses()
- when: 'the service is invoked'
- def returnedCmHandles = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
- then: 'the correct expected cm handles are returned'
- returnedCmHandles.stream().map(d -> d.leaves.get('id').toString()).collect(Collectors.toSet()) == expectedCmHandleIds as Set
+ when: 'a query is execute (with and without Data)'
+ def returnedCmHandlesJustIds = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters)
+ def returnedCmHandlesWithData = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
+ then: 'the correct expected cm handles ids are returned'
+ returnedCmHandlesJustIds == expectedCmHandleIds as Set
+ and: 'the correct cm handle data objects are returned'
+ returnedCmHandlesWithData.stream().map(dataNode -> dataNode.cmHandleId).collect(Collectors.toSet()) == expectedCmHandleIds as Set
where: 'the following data is used'
- scenario | publicProperties || expectedCmHandleIds
- 'single matching property' | [['Contact' : 'newemailforstore@bookstore.com']] || ['PNFDemo', 'PNFDemo2', 'PNFDemo4']
- 'public property dont match' | [['wont_match' : 'wont_match']] || []
- '2 properties, only one match (and)' | [['Contact' : 'newemailforstore@bookstore.com'], ['Contact2': 'newemailforstore2@bookstore.com']] || ['PNFDemo4']
- '2 properties, no match (and)' | [['Contact' : 'newemailforstore@bookstore.com'], ['Contact2': '']] || []
+ scenario | publicProperties || expectedCmHandleIds
+ 'single property matches' | [['Contact' : 'newemailforstore@bookstore.com']] || ['PNFDemo1', 'PNFDemo2', 'PNFDemo4']
+ 'public property does not match' | [['wont_match' : 'wont_match']] || []
+ '2 properties, only one match' | [['Contact' : 'newemailforstore@bookstore.com'], ['Contact2': 'newemailforstore2@bookstore.com']] || ['PNFDemo4']
+ '2 properties, no matches' | [['Contact' : 'newemailforstore@bookstore.com'], ['Contact2': '']] || []
}
def 'Retrieve cm handles with module names when #scenario.'() {
@@ -73,15 +73,17 @@ class NetworkCmProxyCmHandlerQueryServiceSpec extends Specification {
and: 'mock services'
mockResponses()
when: 'the service is invoked'
- def returnedCmHandles = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
+ def returnedCmHandlesJustIds = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters)
+ def returnedCmHandlesWithData = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
then: 'the correct expected cm handles are returned'
- returnedCmHandles.stream().map(d -> d.leaves.get('id').toString()).collect(Collectors.toSet()) == expectedCmHandleIds as Set
+ returnedCmHandlesJustIds == expectedCmHandleIds as Set
+ returnedCmHandlesWithData.stream().map(dataNode -> dataNode.cmHandleId).collect(Collectors.toSet()) == expectedCmHandleIds as Set
where: 'the following data is used'
- scenario | moduleNames || expectedCmHandleIds
- 'single matching module name' | [['moduleName' : 'MODULE-NAME-001']] || ['PNFDemo3', 'PNFDemo', 'PNFDemo2']
- 'module name dont match' | [['moduleName' : 'MODULE-NAME-004']] || []
- '2 module names, only one match (and)' | [['moduleName' : 'MODULE-NAME-002'], ['moduleName': 'MODULE-NAME-003']] || ['PNFDemo4']
- '2 module names, no match (and)' | [['moduleName' : 'MODULE-NAME-002'], ['moduleName': 'MODULE-NAME-004']] || []
+ scenario | moduleNames || expectedCmHandleIds
+ 'single matching module name' | [['moduleName' : 'MODULE-NAME-001']] || ['PNFDemo3', 'PNFDemo1', 'PNFDemo2']
+ 'module name dont match' | [['moduleName' : 'MODULE-NAME-004']] || []
+ '2 module names, only one match' | [['moduleName' : 'MODULE-NAME-002'], ['moduleName': 'MODULE-NAME-003']] || ['PNFDemo4']
+ '2 module names, no matches' | [['moduleName' : 'MODULE-NAME-002'], ['moduleName': 'MODULE-NAME-004']] || []
}
def 'Retrieve cm handles with combined queries when #scenario.'() {
@@ -97,12 +99,14 @@ class NetworkCmProxyCmHandlerQueryServiceSpec extends Specification {
and: 'mock services'
mockResponses()
when: 'the service is invoked'
- def returnedCmHandles = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
+ def returnedCmHandlesJustIds = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters)
+ def returnedCmHandlesWithData = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
then: 'the correct expected cm handles are returned'
- returnedCmHandles.stream().map(d -> d.leaves.get('id').toString()).collect(Collectors.toSet()) == expectedCmHandleIds as Set
+ returnedCmHandlesJustIds == expectedCmHandleIds as Set
+ returnedCmHandlesWithData.stream().map(d -> d.cmHandleId).collect(Collectors.toSet()) == expectedCmHandleIds as Set
where: 'the following data is used'
scenario | moduleNames | publicProperties || expectedCmHandleIds
- 'particularly intersect' | [['moduleName' : 'MODULE-NAME-001']] | [['Contact' : 'newemailforstore@bookstore.com']] || ['PNFDemo2', 'PNFDemo']
+ 'particularly intersect' | [['moduleName' : 'MODULE-NAME-001']] | [['Contact' : 'newemailforstore@bookstore.com']] || ['PNFDemo1', 'PNFDemo2']
'empty intersect' | [['moduleName' : 'MODULE-NAME-004']] | [['Contact' : 'newemailforstore@bookstore.com']] || []
'total intersect' | [['moduleName' : 'MODULE-NAME-002']] | [['Contact2' : 'newemailforstore2@bookstore.com']] || ['PNFDemo4']
}
@@ -112,38 +116,37 @@ class NetworkCmProxyCmHandlerQueryServiceSpec extends Specification {
mockResponses()
when: 'the service is invoked'
def cmHandleQueryParameters = new CmHandleQueryServiceParameters()
- def returnedCmHandles = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
+ def returnedCmHandlesJustIds = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters)
+ def returnedCmHandlesWithData = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
then: 'the correct expected cm handles are returned'
- returnedCmHandles.stream().map(d -> d.leaves.get('id').toString()).collect(Collectors.toSet()) == ['PNFDemo', 'PNFDemo2', 'PNFDemo3', 'PNFDemo4'] as Set
+ returnedCmHandlesJustIds == ['PNFDemo1', 'PNFDemo2', 'PNFDemo3', 'PNFDemo4'] as Set
+ returnedCmHandlesWithData.stream().map(d -> d.cmHandleId).collect(Collectors.toSet()) == ['PNFDemo1', 'PNFDemo2', 'PNFDemo3', 'PNFDemo4'] as Set
}
void mockResponses() {
- def pNFDemo = new DataNode(xpath: 'cmHandle/id[\'PNFDemo\']', leaves: ['id':'PNFDemo'])
- def pNFDemo2 = new DataNode(xpath: 'cmHandle/id[\'PNFDemo2\']', leaves: ['id':'PNFDemo2'])
- def pNFDemo3 = new DataNode(xpath: 'cmHandle/id[\'PNFDemo3\']', leaves: ['id':'PNFDemo3'])
- def pNFDemo4 = new DataNode(xpath: 'cmHandle/id[\'PNFDemo4\']', leaves: ['id':'PNFDemo4'])
+ def pNFDemo1 = new DataNode(xpath: '/dmi-registry/cm-handles[@id=\'PNFDemo1\']', leaves: ['id':'PNFDemo1'])
+ def pNFDemo2 = new DataNode(xpath: '/dmi-registry/cm-handles[@id=\'PNFDemo2\']', leaves: ['id':'PNFDemo2'])
+ def pNFDemo3 = new DataNode(xpath: '/dmi-registry/cm-handles[@id=\'PNFDemo3\']', leaves: ['id':'PNFDemo3'])
+ def pNFDemo4 = new DataNode(xpath: '/dmi-registry/cm-handles[@id=\'PNFDemo4\']', leaves: ['id':'PNFDemo4'])
+
+ cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties[@name=\'Contact\' and @value=\'newemailforstore@bookstore.com\']/ancestor::cm-handles', _) >> [pNFDemo1, pNFDemo2, pNFDemo4]
+ cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties[@name=\'wont_match\' and @value=\'wont_match\']/ancestor::cm-handles', _) >> []
+ cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties[@name=\'Contact2\' and @value=\'newemailforstore2@bookstore.com\']/ancestor::cm-handles', _) >> [pNFDemo4]
+ cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties[@name=\'Contact2\' and @value=\'\']/ancestor::cm-handles', _) >> []
+ cpsDataPersistenceService.queryDataNodes(_, _, '/dmi-registry/cm-handles', _) >> [pNFDemo1, pNFDemo2, pNFDemo3, pNFDemo4]
- 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', _)
- >> []
- cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties[@name=\'Contact2\' and @value=\'newemailforstore2@bookstore.com\']/ancestor::cm-handles', _)
- >> [pNFDemo4]
- cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties[@name=\'Contact2\' and @value=\'\']/ancestor::cm-handles', _)
- >> []
- cpsDataPersistenceService.queryDataNodes(_, _, '//public-properties/ancestor::cm-handles', _)
- >> [pNFDemo, pNFDemo2, pNFDemo3, pNFDemo4]
- cpsDataPersistenceService.queryDataNodes(_, _, '//cm-handles[@id=\'PNFDemo\']', _) >> [pNFDemo]
- cpsDataPersistenceService.queryDataNodes(_, _, '//cm-handles[@id=\'PNFDemo2\']', _) >> [pNFDemo2]
- cpsDataPersistenceService.queryDataNodes(_, _, '//cm-handles[@id=\'PNFDemo3\']', _) >> [pNFDemo3]
- cpsDataPersistenceService.queryDataNodes(_, _, '//cm-handles[@id=\'PNFDemo4\']', _) >> [pNFDemo4]
+ cpsDataPersistenceService.getDataNode(_, _, '/dmi-registry/cm-handles[@id=\'PNFDemo1\']', _) >> pNFDemo1
+ cpsDataPersistenceService.getDataNode(_, _, '/dmi-registry/cm-handles[@id=\'PNFDemo2\']', _) >> pNFDemo2
+ cpsDataPersistenceService.getDataNode(_, _, '/dmi-registry/cm-handles[@id=\'PNFDemo3\']', _) >> pNFDemo3
+ cpsDataPersistenceService.getDataNode(_, _, '/dmi-registry/cm-handles[@id=\'PNFDemo4\']', _) >> pNFDemo4
- cpsAdminPersistenceService.queryAnchors(_, ['MODULE-NAME-001']) >> [new Anchor(name: 'PNFDemo2'), new Anchor(name: 'PNFDemo3'), new Anchor(name: 'PNFDemo')]
+ cpsAdminPersistenceService.queryAnchors(_, ['MODULE-NAME-001']) >> [new Anchor(name: 'PNFDemo1'), new Anchor(name: 'PNFDemo2'), new Anchor(name: 'PNFDemo3')]
cpsAdminPersistenceService.queryAnchors(_, ['MODULE-NAME-004']) >> []
cpsAdminPersistenceService.queryAnchors(_, ['MODULE-NAME-003', 'MODULE-NAME-002']) >> [new Anchor(name: 'PNFDemo4')]
cpsAdminPersistenceService.queryAnchors(_, ['MODULE-NAME-002', 'MODULE-NAME-003']) >> [new Anchor(name: 'PNFDemo4')]
cpsAdminPersistenceService.queryAnchors(_, ['MODULE-NAME-004', 'MODULE-NAME-002']) >> []
cpsAdminPersistenceService.queryAnchors(_, ['MODULE-NAME-002', 'MODULE-NAME-004']) >> []
cpsAdminPersistenceService.queryAnchors(_, ['MODULE-NAME-002']) >> [new Anchor(name: 'PNFDemo2'), new Anchor(name: 'PNFDemo4')]
+ cpsAdminPersistenceService.getAnchors(_) >> [new Anchor(name: 'PNFDemo1'), new Anchor(name: 'PNFDemo2'), new Anchor(name: 'PNFDemo3'), new Anchor(name: 'PNFDemo4')]
}
}
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 5d6d0a512d..c11d09d5a2 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
@@ -59,11 +59,9 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def mockCpsDataService = Mock(CpsDataService)
def mockCpsModuleService = Mock(CpsModuleService)
def spiedJsonObjectMapper = Spy(new JsonObjectMapper(new ObjectMapper()))
- def mockCpsAdminService = Mock(CpsAdminService)
def mockDmiDataOperations = Mock(DmiDataOperations)
def mockNetworkCmProxyDataServicePropertyHandler = Mock(NetworkCmProxyDataServicePropertyHandler)
def mockInventoryPersistence = Mock(InventoryPersistence)
- def mockModuleSyncService = Mock(ModuleSyncService)
def stubbedNetworkCmProxyCmHandlerQueryService = Stub(NetworkCmProxyCmHandlerQueryService)
def noTimestamp = null
def objectUnderTest = getObjectUnderTest()
@@ -352,7 +350,6 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def getObjectUnderTest() {
return Spy(new NetworkCmProxyDataServiceImpl(mockCpsDataService, spiedJsonObjectMapper, mockDmiDataOperations,
- mockCpsModuleService, mockCpsAdminService, mockNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence,
- mockModuleSyncService, stubbedNetworkCmProxyCmHandlerQueryService))
+ mockCpsModuleService, mockNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence, stubbedNetworkCmProxyCmHandlerQueryService))
}
}
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 92183f927a..48c28a8952 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
@@ -34,11 +34,11 @@ import org.onap.cps.ncmp.api.models.ConditionApiProperties
import org.onap.cps.ncmp.api.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
import org.onap.cps.spi.exceptions.DataValidationException
-import org.onap.cps.ncmp.api.inventory.sync.ModuleSyncService
import org.onap.cps.spi.model.CmHandleQueryServiceParameters
-import org.onap.cps.spi.model.ConditionProperties
import spock.lang.Shared
+import java.util.stream.Collectors
+
import static org.onap.cps.ncmp.api.impl.operations.DmiOperations.DataStoreEnum.PASSTHROUGH_OPERATIONAL
import static org.onap.cps.ncmp.api.impl.operations.DmiOperations.DataStoreEnum.PASSTHROUGH_RUNNING
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.CREATE
@@ -46,7 +46,6 @@ import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum
import org.onap.cps.utils.JsonObjectMapper
import com.fasterxml.jackson.databind.ObjectMapper
-import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.ncmp.api.impl.operations.DmiDataOperations
@@ -60,12 +59,10 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
def mockCpsDataService = Mock(CpsDataService)
def mockCpsModuleService = Mock(CpsModuleService)
- def mockCpsAdminService = Mock(CpsAdminService)
def spiedJsonObjectMapper = Spy(new JsonObjectMapper(new ObjectMapper()))
def mockDmiDataOperations = Mock(DmiDataOperations)
def nullNetworkCmProxyDataServicePropertyHandler = null
def mockInventoryPersistence = Mock(InventoryPersistence)
- def mockModuleSyncService = Mock(ModuleSyncService)
def mockDmiPluginRegistration = Mock(DmiPluginRegistration)
def mockCpsCmHandlerQueryService = Mock(NetworkCmProxyCmHandlerQueryService)
@@ -77,8 +74,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id')
def objectUnderTest = new NetworkCmProxyDataServiceImpl(mockCpsDataService, spiedJsonObjectMapper, mockDmiDataOperations,
- mockCpsModuleService, mockCpsAdminService, nullNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence,
- mockModuleSyncService, mockCpsCmHandlerQueryService)
+ mockCpsModuleService, nullNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence, mockCpsCmHandlerQueryService)
def cmHandleXPath = "/dmi-registry/cm-handles[@id='testCmHandle']"
@@ -291,14 +287,10 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
conditionApiProperties.conditionName = 'hasAllModules'
conditionApiProperties.conditionParameters = [[moduleName: 'module-name-1']]
cmHandleQueryApiParameters.cmHandleQueryParameters = [conditionApiProperties]
- and: 'valid CmHandleQueryParameters input'
- def cmHandleQueryParameters = new CmHandleQueryServiceParameters()
- def conditionProperties = new ConditionProperties()
- conditionProperties.conditionName = 'hasAllModules'
- conditionProperties.conditionParameters = [[moduleName: 'module-name-1']]
- cmHandleQueryParameters.cmHandleQueryParameters = [conditionProperties]
and: 'query cm handle method return with a data node list'
- mockCpsCmHandlerQueryService.queryCmHandles(cmHandleQueryParameters) >> [new DataNode(leaves: [id: 'cm-handle-id-1'])]
+ mockCpsCmHandlerQueryService.queryCmHandleIds(
+ spiedJsonObjectMapper.convertToValueType(cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class))
+ >> ['cm-handle-id-1']
when: 'execute cm handle search is called'
def result = objectUnderTest.executeCmHandleIdSearch(cmHandleQueryApiParameters)
then: 'result is the same collection as returned by the CPS Data Service'
@@ -307,8 +299,25 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
def dataStores() {
CompositeState.DataStores.builder()
- .operationalDataStore(CompositeState.Operational.builder()
- .syncState(SyncState.NONE_REQUESTED)
- .lastSyncTime('some-timestamp').build()).build()
+ .operationalDataStore(CompositeState.Operational.builder()
+ .syncState(SyncState.NONE_REQUESTED)
+ .lastSyncTime('some-timestamp').build()).build()
+ }
+
+ def 'Execute cm handle search'() {
+ given: 'valid CmHandleQueryApiParameters input'
+ def cmHandleQueryApiParameters = new CmHandleQueryApiParameters()
+ def conditionApiProperties = new ConditionApiProperties()
+ conditionApiProperties.conditionName = 'hasAllModules'
+ conditionApiProperties.conditionParameters = [[moduleName: 'module-name-1']]
+ cmHandleQueryApiParameters.cmHandleQueryParameters = [conditionApiProperties]
+ and: 'query cm handle method return with a data node list'
+ mockCpsCmHandlerQueryService.queryCmHandles(
+ spiedJsonObjectMapper.convertToValueType(cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class))
+ >> [new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1')]
+ when: 'execute cm handle search is called'
+ def result = objectUnderTest.executeCmHandleSearch(cmHandleQueryApiParameters)
+ then: 'result is the same collection as returned by the CPS Data Service'
+ assert result.stream().map(d -> d.cmHandleId).collect(Collectors.toSet()) == ['cm-handle-id-1'] as Set
}
}