From: Niamh Core Date: Wed, 25 Aug 2021 15:19:17 +0000 (+0000) Subject: Merge "Remove CmHandle in DMI-Registry" X-Git-Tag: 2.0.0~19 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=0b0a89eec95e2cb2671bdd393e94fdaa89b9cc66;p=cps.git Merge "Remove CmHandle in DMI-Registry" --- 0b0a89eec95e2cb2671bdd393e94fdaa89b9cc66 diff --cc cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index a8c92d11f5,ca5fa8e086..235030a84c --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@@ -175,12 -177,23 +179,23 @@@ public class NetworkCmProxyDataServiceI } } + private void parseAndRemoveCmHandlesInDmiRegistration(final DmiPluginRegistration dmiPluginRegistration) { + for (final String cmHandle: dmiPluginRegistration.getRemovedCmHandles()) { + try { + cpsDataService.deleteListNodeData(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, + "/dmi-registry/cm-handles[@id='" + cmHandle + "']"); + } catch (final DataNodeNotFoundException e) { + log.warn("Datanode {} not deleted message {}", cmHandle, e.getMessage()); + } + } + } + @Override public Object getResourceDataOperationalForCmHandle(final @NotNull String cmHandle, - final @NotNull String resourceIdentifier, - final String acceptParam, - final String fieldsQueryParam, - final Integer depthQueryParam) { + final @NotNull String resourceIdentifier, + final String acceptParam, + final String fieldsQueryParam, + final Integer depthQueryParam) { final var dataNode = fetchDataNodeFromDmiRegistryForCmHandle(cmHandle); final var dmiServiceName = String.valueOf(dataNode.getLeaves().get("dmi-service-name")); diff --cc cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy index 34c9541759,c6c955fba7..0760167181 --- 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 @@@ -122,30 -124,18 +124,33 @@@ class NetworkCmProxyDataServiceImplSpe objectUnderTest.updateDmiPluginRegistration(dmiPluginRegistration) then: 'the CPS save list node data is invoked with the expected parameters' expectedCallsToSaveNode * mockCpsDataService.saveListNodeData('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', expectedJsonData) - and: 'update Node and Child Data Nodes is invoked with correct parameter' - expectedCallsToUpdateNode * mockCpsDataService.updateNodeLeavesAndExistingDescendantLeaves('NCMP-Admin', dmiRegistryAnchor, '/dmi-registry', expectedJsonData) + and: 'update Node and Child Data Nodes is invoked with correct parameters' + expectedCallsToUpdateNode * mockCpsDataService.updateNodeLeavesAndExistingDescendantLeaves('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', expectedJsonData) + and : 'delete list data node is invoked with the correct parameters' + expectedCallsToDeleteListDataNode * mockCpsDataService.deleteListNodeData('NCMP-Admin', 'ncmp-dmi-registry', "/dmi-registry/cm-handles[@id='cmHandle001']") where: - scenario | createdCmHandles | updatedCmHandles || expectedCallsToSaveNode | expectedCallsToUpdateNode - 'create' | [persistenceCmHandle ] | [] || 1 | 0 - 'update' | [] | [persistenceCmHandle ] || 0 | 1 - 'create and update' | [persistenceCmHandle ] | [persistenceCmHandle ] || 1 | 1 + scenario | createdCmHandles | updatedCmHandles | removedCmHandles || expectedCallsToSaveNode | expectedCallsToUpdateNode | expectedCallsToDeleteListDataNode + 'create' | [persistenceCmHandle ] | [] | [] || 1 | 0 | 0 + 'update' | [] | [persistenceCmHandle ] | [] || 0 | 1 | 0 + 'delete' | [] | [] | cmHandlesArray || 0 | 0 | 1 + 'create, update and delete' | [persistenceCmHandle ] | [persistenceCmHandle ] | cmHandlesArray || 1 | 1 | 1 } + + def 'Register a DMI Plugin for the given cmHandle without additional properties.'() { + given: 'a registration without cmHandle properties ' + def dmiPluginRegistration = new DmiPluginRegistration() + dmiPluginRegistration.dmiPlugin = 'my-server' + persistenceCmHandle.cmHandleID = '123' + persistenceCmHandle.cmHandleProperties = null + dmiPluginRegistration.createdCmHandles = [persistenceCmHandle ] + def expectedJsonData = '{"cm-handles":[{"id":"123","dmi-service-name":"my-server","additional-properties":[]}]}' + when: 'registration is updated' + objectUnderTest.updateDmiPluginRegistration(dmiPluginRegistration) + then: 'the CPS save list node data is invoked with the expected parameters' + 1 * mockCpsDataService.saveListNodeData('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', expectedJsonData) + } + def 'Get resource data for pass-through operational from dmi.'() { given: 'xpath' def xpath = "/dmi-registry/cm-handles[@id='testCmHandle']"