summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy
diff options
context:
space:
mode:
authorraviteja.karumuri <raviteja.karumuri@est.tech>2023-06-20 19:10:21 +0100
committerraviteja.karumuri <raviteja.karumuri@est.tech>2023-06-22 11:23:30 +0100
commit977f7c395cee52cdecd0b01cb0412ebfeb9db048 (patch)
tree8547c2bf9426d25f3d5fd13ff4e328838ce0e1f4 /cps-ncmp-service/src/test/groovy
parentcac2186419db6c3d956dd8cd759622da022ea9b2 (diff)
NCMP : Replacing the word 'Batch' as 'DataOperation'.
Issue-ID: CPS-1754 Signed-off-by: raviteja.karumuri <raviteja.karumuri@est.tech> Change-Id: Ie9f56effb160582ba7177331fb6260b2bde2342b
Diffstat (limited to 'cps-ncmp-service/src/test/groovy')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy41
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy16
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/ResourceDataBatchRequestUtilsSpec.groovy)30
3 files changed, 44 insertions, 43 deletions
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 79f7e50e76..af2b80f755 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
@@ -33,13 +33,13 @@ import org.onap.cps.ncmp.api.inventory.CompositeState
import org.onap.cps.ncmp.api.inventory.InventoryPersistence
import org.onap.cps.ncmp.api.inventory.LockReasonCategory
import org.onap.cps.ncmp.api.inventory.DataStoreSyncState
-import org.onap.cps.ncmp.api.models.BatchOperationDefinition
+import org.onap.cps.ncmp.api.models.DataOperationDefinition
import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters
import org.onap.cps.ncmp.api.models.CmHandleQueryServiceParameters
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.ncmp.api.models.ResourceDataBatchRequest
+import org.onap.cps.ncmp.api.models.DataOperationRequest
import org.onap.cps.spi.exceptions.CpsException
import org.onap.cps.spi.model.ConditionProperties
import spock.lang.Shared
@@ -135,13 +135,13 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
response == '{dmi-response}'
}
- def 'Get batch resource data for #datastoreName from DMI.'() {
+ def 'Execute (async) data operation for #datastoreName from DMI.'() {
given: 'cpsDataService returns valid data node'
- def resourceDataBatchRequest = getResourceDataBatchRequest(datastoreName)
- when: 'get batch resource data is called'
- objectUnderTest.requestResourceDataForCmHandleBatch('some topic', resourceDataBatchRequest, 'requestId')
- then: 'get batch resource data returns expected response'
- 1 * mockDmiDataOperations.requestResourceDataFromDmi('some topic', resourceDataBatchRequest, 'requestId')
+ def dataOperationRequest = getDataOperationRequest(datastoreName)
+ when: 'request resource data for data operation is called'
+ objectUnderTest.executeDataOperationForCmHandles('some topic', dataOperationRequest, 'requestId')
+ then: 'request resource data for data operation returns expected response'
+ 1 * mockDmiDataOperations.requestResourceDataFromDmi('some topic', dataOperationRequest, 'requestId')
where: 'the following data stores are used'
datastoreName << [PASSTHROUGH_RUNNING.datastoreName, PASSTHROUGH_OPERATIONAL.datastoreName]
}
@@ -368,21 +368,22 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
cmHandleXPath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> dataNode
}
- def getResourceDataBatchRequest(datastore) {
- def resourceDataBatchRequest = new ResourceDataBatchRequest()
- def batchOperationDefinitions = new ArrayList()
- batchOperationDefinitions.add(getBatchOperationDefinition(datastore))
- resourceDataBatchRequest.setBatchOperationDefinitions(batchOperationDefinitions)
+ def getDataOperationRequest(datastore) {
+ def dataOperationRequest = new DataOperationRequest()
+ def dataOperationDefinitions = new ArrayList()
+ dataOperationDefinitions.add(getDataOperationDefinition(datastore))
+ dataOperationRequest.setDataOperationDefinitions(dataOperationDefinitions)
+ return dataOperationRequest
}
- def getBatchOperationDefinition(datastore) {
- def batchOperationDefinition = new BatchOperationDefinition()
- batchOperationDefinition.setOperation("read")
- batchOperationDefinition.setOperationId("operational-12")
- batchOperationDefinition.setDatastore(datastore)
+ def getDataOperationDefinition(datastore) {
+ def dataOperationDefinition = new DataOperationDefinition()
+ dataOperationDefinition.setOperation("read")
+ dataOperationDefinition.setOperationId("operational-12")
+ dataOperationDefinition.setDatastore(datastore)
def targetIds = new ArrayList()
targetIds.add("some-cm-handle")
- batchOperationDefinition.setCmHandleIds(targetIds)
- return batchOperationDefinition
+ dataOperationDefinition.setCmHandleIds(targetIds)
+ return dataOperationDefinition
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
index 9343666260..be178e1276 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
@@ -24,7 +24,7 @@ package org.onap.cps.ncmp.api.impl.operations
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration
import org.onap.cps.ncmp.api.impl.utils.DmiServiceUrlBuilder
-import org.onap.cps.ncmp.api.models.ResourceDataBatchRequest
+import org.onap.cps.ncmp.api.models.DataOperationRequest
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
@@ -82,12 +82,12 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
'datastore running with properties' | [yangModelCmHandleProperty] | PASSTHROUGH_RUNNING | OPTIONS_PARAM || '{"operation":"read","cmHandleProperties":{"prop1":"val1"}}' | 'passthrough-running' | '&options=(a=1,b=2)'
}
- def 'call get batch resource data from DMI service #scenario.'() {
- given: 'collection of yang model cm Handles and resource data batch request'
+ def 'Execute (async) data operation from DMI service.'() {
+ given: 'collection of yang model cm Handles and data operation request'
mockYangModelCmHandleCollectionRetrieval([yangModelCmHandleProperty])
- def resourceDataBatchRequestJsonData = TestUtils.getResourceFileContent('resourceDataBatchRequest.json')
- def resourceDataBatchRequest = spiedJsonObjectMapper.convertJsonString(resourceDataBatchRequestJsonData, ResourceDataBatchRequest.class)
- resourceDataBatchRequest.batchOperationDefinitions[0].cmHandleIds = [cmHandleId]
+ def dataOperationBatchRequestJsonData = TestUtils.getResourceFileContent('dataOperationRequest.json')
+ def dataOperationRequest = spiedJsonObjectMapper.convertJsonString(dataOperationBatchRequestJsonData, DataOperationRequest.class)
+ dataOperationRequest.dataOperationDefinitions[0].cmHandleIds = [cmHandleId]
def requestBodyAsJsonStringArg = null
and: 'a positive response from DMI service when it is called with valid request parameters'
def responseFromDmi = new ResponseEntity<Object>(HttpStatus.ACCEPTED)
@@ -95,8 +95,8 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
def expectedBatchRequestAsJson = '[{"operation":"read","operationId":"operational-14","datastore":"ncmp-datastore:passthrough-operational","options":"some option","resourceIdentifier":"some resource identifier","cmHandles":[{"id":"some-cm-handle","cmHandleProperties":{"prop1":"val1"}}]}]'
mockDmiRestClient.postOperationWithJsonData(expectedDmiBatchResourceDataUrl, _, READ.operationName) >> responseFromDmi
dmiServiceUrlBuilder.getBatchRequestUrl(_, _) >> expectedDmiBatchResourceDataUrl
- when: 'get resource data for batch of cm handles are invoked'
- objectUnderTest.requestResourceDataFromDmi('my-topic-name', resourceDataBatchRequest, 'requestId')
+ when: 'get resource data for group of cm handles are invoked'
+ objectUnderTest.requestResourceDataFromDmi('my-topic-name', dataOperationRequest, 'requestId')
then: 'wait a little to allow execution of service method by task executor (on separate thread)'
Thread.sleep(100)
then: 'validate ncmp generated dmi request body json args'
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/ResourceDataBatchRequestUtilsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy
index e65874930b..af3841a40b 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/ResourceDataBatchRequestUtilsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy
@@ -24,36 +24,36 @@ import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
import org.onap.cps.ncmp.api.inventory.CmHandleState
import org.onap.cps.ncmp.api.inventory.CompositeStateBuilder
-import org.onap.cps.ncmp.api.models.ResourceDataBatchRequest
+import org.onap.cps.ncmp.api.models.DataOperationRequest
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
import spock.lang.Specification
-class ResourceDataBatchRequestUtilsSpec extends Specification {
+class DataOperationRequestUtilsSpec extends Specification {
@SpringBean
JsonObjectMapper jsonObjectMapper = new JsonObjectMapper(new ObjectMapper())
- def 'Process per operation in batch request with #serviceName.'() {
- given: 'batch request with 3 operations'
- def resourceDataBatchRequestJsonData = TestUtils.getResourceFileContent('resourceDataBatchRequest.json')
- def resourceDataBatchRequest = jsonObjectMapper.convertJsonString(resourceDataBatchRequestJsonData, ResourceDataBatchRequest.class)
+ def 'Process per data operation request with #serviceName.'() {
+ given: 'data operation request with 3 operations'
+ def dataOperationRequestJsonData = TestUtils.getResourceFileContent('dataOperationRequest.json')
+ def dataOperationRequest = jsonObjectMapper.convertJsonString(dataOperationRequestJsonData, DataOperationRequest.class)
and: '4 known cm handles: ch1-dmi1, ch2-dmi1, ch3-dmi2, ch4-dmi2'
def yangModelCmHandles = getYangModelCmHandles()
- when: 'Operation in batch request is processed'
- def operationsOutPerDmiServiceName = ResourceDataBatchRequestUtils.processPerOperationInBatchRequest(resourceDataBatchRequest, yangModelCmHandles)
+ when: 'data operation request is processed'
+ def operationsOutPerDmiServiceName = ResourceDataBatchRequestUtils.processPerOperationInBatchRequest(dataOperationRequest, yangModelCmHandles)
and: 'converted to a json node'
- def dmiBatchRequestBody = jsonObjectMapper.asJsonString(operationsOutPerDmiServiceName.get(serviceName))
- def dmiBatchRequestBodyAsJsonNode = jsonObjectMapper.convertToJsonNode(dmiBatchRequestBody).get(operationIndex)
+ def dmiDataOperationRequestBody = jsonObjectMapper.asJsonString(operationsOutPerDmiServiceName.get(serviceName))
+ def dmiDataOperationRequestBodyAsJsonNode = jsonObjectMapper.convertToJsonNode(dmiDataOperationRequestBody).get(operationIndex)
then: 'it contains the correct operation details'
- assert dmiBatchRequestBodyAsJsonNode.get('operation').asText() == 'read'
- assert dmiBatchRequestBodyAsJsonNode.get('operationId').asText() == expectedOperationId
- assert dmiBatchRequestBodyAsJsonNode.get('datastore').asText() == expectedDatastore
+ assert dmiDataOperationRequestBodyAsJsonNode.get('operation').asText() == 'read'
+ assert dmiDataOperationRequestBodyAsJsonNode.get('operationId').asText() == expectedOperationId
+ assert dmiDataOperationRequestBodyAsJsonNode.get('datastore').asText() == expectedDatastore
and: 'the correct cm handles (just for #serviceName)'
- assert dmiBatchRequestBodyAsJsonNode.get('cmHandles').size() == expectedCmHandleIds.size()
+ assert dmiDataOperationRequestBodyAsJsonNode.get('cmHandles').size() == expectedCmHandleIds.size()
expectedCmHandleIds.each {
- dmiBatchRequestBodyAsJsonNode.get('cmHandles').toString().contains(it)
+ dmiDataOperationRequestBodyAsJsonNode.get('cmHandles').toString().contains(it)
}
where: 'the following dmi service and operations are checked'
serviceName | operationIndex || expectedOperationId | expectedDatastore | expectedCmHandleIds