From 6c7791e04e43b056ab944c3f7935f182fcbb13fb Mon Sep 17 00:00:00 2001 From: niamhcore Date: Mon, 8 Nov 2021 16:40:28 +0000 Subject: Update operation passthrough running - Service Layer Issue-ID: CPS-636 Signed-off-by: niamhcore Change-Id: I13334df383a23e59b3368b8664c10e086b1eb4a8 --- .../impl/NetworkCmProxyDataServiceImplSpec.groovy | 23 ++++++++++++++++++++++ .../api/impl/operation/DmiOperationsSpec.groovy | 15 ++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'cps-ncmp-service/src/test/groovy/org/onap') 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 -- cgit 1.2.3-korg