aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2021-11-15 17:39:04 +0000
committerGerrit Code Review <gerrit@onap.org>2021-11-15 17:39:04 +0000
commitbc742a1dbe39a3269abab9e62a9d489f460144b0 (patch)
tree7bc2704612a06bd155bbed3b073f07ce35c9af7d /cps-ncmp-service/src/test/groovy
parent9e09fe868b39fd5f13092a923da3474deb0f75b9 (diff)
parent6c7791e04e43b056ab944c3f7935f182fcbb13fb (diff)
Merge "Update operation passthrough running - Service Layer"
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.groovy23
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy15
2 files changed, 38 insertions, 0 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 88277d3e9..b0c447ee1 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
@@ -457,6 +457,29 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
1 * mockCpsAdminService.queryAnchorNames('NFP-Operational', ['some-module-name'])
}
+ def 'Update resource data for pass-through running from dmi using POST #scenario cm handle properties.'() {
+ given: 'data node representing cmHandle #scenario cm handle properties'
+ def cmHandleDataNode = getCmHandleDataNodeForTest(includeCmHandleProperties)
+ and: 'cpsDataService returns valid cm-handle datanode'
+ mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry',
+ cmHandleXPath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> cmHandleDataNode
+ when: 'update resource data is called'
+ objectUnderTest.updateResourceDataPassThroughRunningForCmHandle('testCmHandle',
+ 'testResourceId',
+ '{some-json}', 'application/json')
+ then: 'dmi called with correct data'
+ 1 * mockDmiOperations.updateResourceDataPassThroughRunningFromDmi('testDmiService',
+ 'testCmHandle',
+ 'testResourceId',
+ '{"operation":"update","dataType":"application/json","data":"{some-json}","cmHandleProperties":'
+ + expectedJsonForCmhandleProperties + '}')
+ >> new ResponseEntity<>(HttpStatus.OK)
+ where:
+ scenario | includeCmHandleProperties || expectedJsonForCmhandleProperties
+ 'with' | true || '{"testName":"testValue"}'
+ 'without' | false || '{}'
+ }
+
def getObjectUnderTestWithModelSyncDisabled() {
def objectUnderTest = Spy(new NetworkCmProxyDataServiceImpl(mockDmiOperations, mockCpsModuleService,
mockCpsDataService, mockCpsQueryService, mockCpsAdminService, spyObjectMapper))
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy
index 9405b6632..44d4f0ce2 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy
@@ -118,4 +118,19 @@ class DmiOperationsSpec extends Specification {
then: 'the post operation is executed with the correct URL and json data'
1 * mockDmiRestClient.postOperationWithJsonData(expectedUrl, requestBody, expectedHttpHeaders)
}
+
+ def 'Update resource data for pass-through:running datastore from DMI.'() {
+ given: 'the expected url'
+ def cmHandle = 'some-cmhandle'
+ def resourceIdentifier = 'parent/child'
+ def expectedUrl = 'some-dmi-service-name/dmi/v1/ch/' + cmHandle + '/data/ds' +
+ '/ncmp-datastore:passthrough-running?resourceIdentifier=' + resourceIdentifier
+ when: 'replace resource data is called for DMI'
+ objectUnderTest.updateResourceDataPassThroughRunningFromDmi('some-dmi-service-name',
+ cmHandle,
+ resourceIdentifier,
+ 'some-json-body')
+ then: 'the post operation is executed with the correct URL'
+ 1 * mockDmiRestClient.postOperationWithJsonData(expectedUrl, 'some-json-body', _ as HttpHeaders)
+ }
} \ No newline at end of file