X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fimpl%2FNetworkCmProxyDataServiceImplSpec.groovy;h=b0c447ee18320bcdb934df9d527d034debf87af8;hb=bc742a1dbe39a3269abab9e62a9d489f460144b0;hp=1bad8ce0bac33921d59901d759271c3166d8974a;hpb=b33fcb39c094069cb3284ff037d486a4394647bc;p=cps.git 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 1bad8ce0b..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 @@ -119,7 +119,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { when: 'addListNodeElements is invoked' objectUnderTest.addListNodeElements(cmHandle, xpath, jsonData) then: 'the CPS service method is invoked once with the expected parameters' - 1 * mockCpsDataService.saveListNodeData(expectedDataspaceName, cmHandle, xpath, jsonData, noTimestamp) + 1 * mockCpsDataService.saveListElements(expectedDataspaceName, cmHandle, xpath, jsonData, noTimestamp) } def 'Update data node leaves.'() { @@ -155,18 +155,18 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { def expectedJsonData = '{"cm-handles":[{"id":"123","dmi-service-name":"my-server","additional-properties":[{"name":"name1","value":"value1"},{"name":"name2","value":"value2"}]}]}' when: 'registration is updated' objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration) - then: 'the CPS save list node data is invoked with the expected parameters' - expectedCallsToSaveNode * mockCpsDataService.saveListNodeData('NCMP-Admin', 'ncmp-dmi-registry', + then: 'cps save list elements is invoked with the expected parameters' + expectedCallsToSaveNode * mockCpsDataService.saveListElements('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', expectedJsonData, noTimestamp) - and: 'update Node and Child Data Nodes is invoked with correct parameters' + and: 'update node and child data nodes is invoked with correct parameters' expectedCallsToUpdateNode * mockCpsDataService.updateNodeLeavesAndExistingDescendantLeaves('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', expectedJsonData, noTimestamp) - and : 'delete list data node is invoked with the correct parameters' - expectedCallsToDeleteListDataNode * mockCpsDataService.deleteListNodeData('NCMP-Admin', + and : 'delete list or list element is invoked with the correct parameters' + expectedCallsToDeleteListElement * mockCpsDataService.deleteListOrListElement('NCMP-Admin', 'ncmp-dmi-registry', "/dmi-registry/cm-handles[@id='cmHandle001']", noTimestamp) where: - scenario | createdCmHandles | updatedCmHandles | removedCmHandles || expectedCallsToSaveNode | expectedCallsToUpdateNode | expectedCallsToDeleteListDataNode + scenario | createdCmHandles | updatedCmHandles | removedCmHandles || expectedCallsToSaveNode | expectedCallsToUpdateNode | expectedCallsToDeleteListElement 'create' | [persistenceCmHandle] | [] | [] || 1 | 0 | 0 'update' | [] | [persistenceCmHandle] | [] || 0 | 1 | 0 'delete' | [] | [] | cmHandlesArray || 0 | 0 | 1 @@ -185,8 +185,8 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { def expectedJsonData = '{"cm-handles":[{"id":"123","dmi-service-name":"my-server","additional-properties":[]}]}' when: 'registration is updated' objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration) - then: 'the CPS save list node data is invoked with the expected parameters' - 1 * mockCpsDataService.saveListNodeData('NCMP-Admin', 'ncmp-dmi-registry', + then: 'the cps save list element is invoked with the expected parameters' + 1 * mockCpsDataService.saveListElements('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', expectedJsonData, noTimestamp) } @@ -214,7 +214,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { def dmiPluginRegistration = new DmiPluginRegistration() dmiPluginRegistration.removedCmHandles = ['some cm handle'] and: 'an JSON processing exception occurs' - mockCpsDataService.deleteListNodeData(*_) >> { throw (new DataNodeNotFoundException('','')) } + mockCpsDataService.deleteListOrListElement(*_) >> { throw (new DataNodeNotFoundException('','')) } when: 'registration is updated' objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration) then: 'no exception is thrown' @@ -450,6 +450,36 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { result == expectedRequestBody } + def 'Get cm handle identifiers for the given module names.'() { + when: 'execute a cm handle search for the given module names' + objectUnderTest.executeCmHandleHasAllModulesSearch(['some-module-name']) + then: 'get anchor identifiers is invoked with the expected parameters' + 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))