summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2023-02-01 14:48:52 +0000
committerdanielhanrahan <daniel.hanrahan@est.tech>2023-02-02 13:30:57 +0000
commita0aa860665b94ce35ecd6253e69959b7cf08ddb7 (patch)
tree4832401ba689c78b9c3d94d23eef84903e0fd00c /cps-ncmp-service/src/test
parent605bec25914adb79403bb43947aa3eb1bfb36fc4 (diff)
CmHandle batch deletion
- Use plural deleteDataNodes to remove CmHandles in batches, falling back to individual delete on error - Use single deleteDataNode instead of deleteListOrListElement for individual delete Issue-ID: CPS-1464 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: If09f22478df8703290c8fc24aa6fe2a11c90788a
Diffstat (limited to 'cps-ncmp-service/src/test')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy13
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy8
2 files changed, 16 insertions, 5 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
index 1ebd69eb60..5824a47292 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation
+ * Copyright (C) 2021-2023 Nordix Foundation
* Modifications Copyright (C) 2022 Bell Canada
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -256,7 +256,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
and: 'method to delete relevant schema set is called once'
1 * mockInventoryPersistence.deleteSchemaSetWithCascade(_)
and: 'method to delete relevant list/list element is called once'
- 1 * mockInventoryPersistence.deleteListOrListElement(_)
+ 1 * mockInventoryPersistence.deleteDataNodes(_)
and: 'successful response is received'
assert response.getRemovedCmHandles().size() == 1
with(response.getRemovedCmHandles().get(0)) {
@@ -275,8 +275,10 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
given: 'a registration with three cm-handles to be deleted'
def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server',
removedCmHandles: ['cmhandle1', 'cmhandle2', 'cmhandle3'])
+ and: 'cm-handle deletion fails on batch'
+ mockInventoryPersistence.deleteDataNodes(_) >> { throw new RuntimeException("Failed") }
and: 'cm-handle deletion is successful for 1st and 3rd; failed for 2nd'
- mockInventoryPersistence.deleteListOrListElement(_) >> {} >> { throw new RuntimeException("Failed") } >> {}
+ mockInventoryPersistence.deleteDataNode(_) >> {} >> { throw new RuntimeException("Failed") } >> {}
when: 'registration is updated to delete cmhandles'
def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
then: 'a response is received for all cm-handles'
@@ -315,7 +317,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
then: 'no exception is thrown'
noExceptionThrown()
and: 'cm-handle is not deleted'
- 0 * mockInventoryPersistence.deleteListOrListElement(_)
+ 0 * mockInventoryPersistence.deleteDataNodes(_)
and: 'the cmHandle state is not updated to "DELETED"'
0 * mockLcmEventsCmHandleStateHandler.updateCmHandleState(_, CmHandleState.DELETED)
and: 'a failure response is received'
@@ -333,7 +335,8 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server',
removedCmHandles: ['cmhandle'])
and: 'cm-handle deletion throws exception'
- mockInventoryPersistence.deleteListOrListElement(_) >> { throw deleteListElementException }
+ mockInventoryPersistence.deleteDataNodes(_) >> { throw deleteListElementException }
+ mockInventoryPersistence.deleteDataNode(_) >> { throw deleteListElementException }
when: 'registration is updated to delete cmhandle'
def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
then: 'a failure response is received'
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy
index 355487f64a..2ca0e9964a 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy
@@ -270,4 +270,12 @@ class InventoryPersistenceImplSpec extends Specification {
'sample dataNode xpath', NO_TIMESTAMP);
}
+ def 'Delete multiple data nodes via xPath'() {
+ when: 'Delete data nodes method is called with multiple xpaths as parameters'
+ objectUnderTest.deleteDataNodes(['xpath1', 'xpath2'])
+ then: 'the cps data service method to delete data nodes is invoked once with the same xPaths'
+ 1 * mockCpsDataService.deleteDataNodes('NCMP-Admin', 'ncmp-dmi-registry',
+ ['xpath1', 'xpath2'], NO_TIMESTAMP);
+ }
+
}