From 9237b0792526693f5cf302f4bfe0f1150d5662bc Mon Sep 17 00:00:00 2001 From: "halil.cakal" Date: Mon, 2 Sep 2024 14:30:02 +0100 Subject: Remove event notifications when removing trust level entries Issue-ID: CPS-2315 Change-Id: I4f0cb7c2066e0ab9c62ac9cdb0fc39ce7de7791b Signed-off-by: halil.cakal --- .../impl/inventory/trustlevel/TrustLevelManager.java | 8 ++------ .../inventory/trustlevel/TrustLevelManagerSpec.groovy | 19 +++---------------- 2 files changed, 5 insertions(+), 22 deletions(-) (limited to 'cps-ncmp-service/src') 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 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(*_) } } -- cgit 1.2.3-korg