summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-11-08 16:40:28 +0000
committerniamhcore <niamh.core@est.tech>2021-11-10 13:09:41 +0000
commit6c7791e04e43b056ab944c3f7935f182fcbb13fb (patch)
treefff0b4a26d02d139078ccc18db90908f92902137 /cps-ncmp-service/src/test
parentb6fe4eb602206e5495423ff8614eb5238829d115 (diff)
Update operation passthrough running - Service Layer
Issue-ID: CPS-636 Signed-off-by: niamhcore <niamh.core@est.tech> Change-Id: I13334df383a23e59b3368b8664c10e086b1eb4a8
Diffstat (limited to 'cps-ncmp-service/src/test')
-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 88277d3e97..b0c447ee18 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 9405b66325..44d4f0ce27 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