BugFix: 500 Server error when upgrade and service restart with data in DB

- return NONE for get effective trust level api if the trustlevel caches
  empty (restart case)

Issue-ID: CPS-2409

Change-Id: I72a755ca6ba5d4a78f5458a235c0d1f43aaa8d53
Signed-off-by: halil.cakal <halil.cakal@est.tech>
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 afe6ad5..9b0cc3a 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 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 fe762f8..e0f5f9c 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 @@
             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)