summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSourabh Sourabh <sourabh.sourabh@est.tech>2024-09-30 11:10:19 +0000
committerGerrit Code Review <gerrit@onap.org>2024-09-30 11:10:19 +0000
commit78674d78554dda5f6eb8331410b261720dd126ab (patch)
tree8c1ebac0a557a1e03ead5113190fb107c9d5137c
parent4baa75b06dcfb9365a8ea5cde03d77d7f21fa01c (diff)
parentfe846d2dd21d57889356943762f2006b2122427c (diff)
Merge "BugFix: 500 Server error when upgrade and service restart with data in DB"
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy5
2 files changed, 6 insertions, 1 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 afe6ad5c1c..9b0cc3a0c0 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
@@ -140,7 +140,7 @@ public class TrustLevelManager {
*/
public TrustLevel getEffectiveTrustLevel(final String cmHandleId) {
final TrustLevel dmiTrustLevel = TrustLevel.COMPLETE; // TODO: CPS-2375
- final TrustLevel cmHandleTrustLevel = trustLevelPerCmHandle.get(cmHandleId);
+ final TrustLevel cmHandleTrustLevel = trustLevelPerCmHandle.getOrDefault(cmHandleId, TrustLevel.NONE);
return dmiTrustLevel.getEffectiveTrustLevel(cmHandleTrustLevel);
}
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 fe762f891a..e0f5f9c4f8 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
@@ -149,6 +149,11 @@ class TrustLevelManagerSpec extends Specification {
assert effectiveTrustLevel == TrustLevel.NONE
}
+ def 'Select effective trust level when the trust level caches are empty (restart case)'() {
+ expect: 'effective trust level is NONE when cm-1 does not exist in the cache'
+ assert objectUnderTest.getEffectiveTrustLevel('ch-1') == TrustLevel.NONE
+ }
+
def 'CmHandle trust level removed'() {
given: 'a cm handle'
trustLevelPerCmHandle.put('ch-1', TrustLevel.COMPLETE)