summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPriyank Maheshwari <priyank.maheshwari@est.tech>2024-09-04 09:33:48 +0000
committerGerrit Code Review <gerrit@onap.org>2024-09-04 09:33:48 +0000
commit99412d06de4648e511ce156b23b52d57709c1add (patch)
treee15f61d47c173eab55a80ef1c4535171df70db09
parent7045c11f9b7a49c9b711a2a61b299bf886dc0836 (diff)
parent9237b0792526693f5cf302f4bfe0f1150d5662bc (diff)
Merge "Remove event notifications when removing trust level entries"
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java8
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy19
-rw-r--r--csit/tests/cps-trust-level/cps-trust-level.robot4
3 files changed, 7 insertions, 24 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java
index 33310b955e..aff0e19981 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java
@@ -145,17 +145,13 @@ public class TrustLevelManager {
}
/**
- * Remove cm handle trust level from the cache and publish notification for trust level of cmHandles
- * if it is COMPLETE.
+ * Remove cm handle trust level from the cache.
*
* @param cmHandleIds cm handle ids to be removed from the cache
*/
public void removeCmHandles(final Collection<String> cmHandleIds) {
for (final String cmHandleId : cmHandleIds) {
- if (trustLevelPerCmHandle.containsKey(cmHandleId)) {
- final TrustLevel oldTrustLevel = trustLevelPerCmHandle.remove(cmHandleId);
- sendAvcNotificationIfRequired(cmHandleId, oldTrustLevel, TrustLevel.NONE);
- } else {
+ if (trustLevelPerCmHandle.remove(cmHandleId) == null) {
log.debug("Removed Cm handle: {} is not in trust level cache", cmHandleId);
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy
index 84d93e0b7f..7dc9602e46 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation
+ * Copyright (C) 2023-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -146,26 +146,13 @@ class TrustLevelManagerSpec extends Specification {
assert effectiveTrustLevel == TrustLevel.NONE
}
- def 'CmHandle trust level (COMPLETE) removed'() {
- given: 'a trusted cm handle'
+ def 'CmHandle trust level removed'() {
+ given: 'a cm handle'
trustLevelPerCmHandle.put('ch-1', TrustLevel.COMPLETE)
when: 'the remove is handled'
objectUnderTest.removeCmHandles(['ch-1'])
then: 'cm handle removed from the cache'
assert trustLevelPerCmHandle.get('ch-1') == null
- and: 'notification is sent'
- 1 * mockAttributeValueChangeEventPublisher.publishAvcEvent(_,'trustLevel','COMPLETE','NONE')
- }
-
- def 'CmHandle trust level (NONE) removed'() {
- given: 'a non-trusted cm handle'
- trustLevelPerCmHandle.put('ch-1', TrustLevel.NONE)
- when: 'the remove is handled'
- objectUnderTest.removeCmHandles(['ch-1'])
- then: 'cm handle removed from the cache'
- assert trustLevelPerCmHandle.get('ch-1') == null
- and: 'no notification is sent'
- 0 * mockAttributeValueChangeEventPublisher.publishAvcEvent(*_)
}
}
diff --git a/csit/tests/cps-trust-level/cps-trust-level.robot b/csit/tests/cps-trust-level/cps-trust-level.robot
index 4db0115871..810bcf4d12 100644
--- a/csit/tests/cps-trust-level/cps-trust-level.robot
+++ b/csit/tests/cps-trust-level/cps-trust-level.robot
@@ -36,7 +36,7 @@ ${ncmpBasePath} /ncmp/v1
${dmiUrl} http://${DMI_HOST}:${DMI_PORT}
${jsonCreateCmHandles} {"dmiPlugin":"${dmiUrl}","dmiDataPlugin":"","dmiModelPlugin":"","createdCmHandles":[{"trustLevel":"COMPLETE","cmHandle":"CH-1"},{"trustLevel":"COMPLETE","cmHandle":"CH-2"},{"cmHandle":"CH-3"},{"trustLevel":"NONE","cmHandle":"CH-4"}]}
${jsonTrustLevelPropertyQueryParameters} {"cmHandleQueryParameters": [{"conditionName": "cmHandleWithTrustLevel", "conditionParameters": [ {"trustLevel": "COMPLETE"} ] }]}
-${jsonTrustLevelEventPayload} {"data":{"attributeValueChange":[{"attributeName":"trustLevel","oldAttributeValue":"COMPLETE","newAttributeValue":"NONE"}]}}
+${jsonTrustLevelEventPayload} {"data":{"attributeValueChange":[{"attributeName":"trustLevel","newAttributeValue":"NONE"}]}}
*** Test Cases ***
Register data node
@@ -55,7 +55,7 @@ Verify notification
Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_specversion" "1.0"
Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_source" "NCMP"
Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_type" "org.onap.cps.ncmp.events.avc.ncmp_to_client.AvcEvent"
- Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_correlationid" "CmHandleForDelete"
+ Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_correlationid" "CH-4"
END
Should Be Equal As Strings ${payload} ${jsonTrustLevelEventPayload}
[Teardown] Basic Teardown ${group_id}