Add null test to DistributionMonitoringBusinessLogic 62/106362/2
authorChris André <chris.andre@yoppworks.com>
Tue, 21 Apr 2020 15:21:32 +0000 (11:21 -0400)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Wed, 22 Apr 2020 11:00:55 +0000 (11:00 +0000)
- Added test in `handleAuditingDaoResponse` for null value related to `resAuditingGenericEvent`

Issue-ID: SDC-2909
Signed-off-by: Chris Andre <chris.andre@yoppworks.com>
Change-Id: I422629cdbd4f05e10609cd78b7328c4e9f45538b

catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogic.java

index 0876852..66cab35 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,7 @@
 package org.openecomp.sdc.be.components.impl;
 
 import fj.data.Either;
+import java.util.Optional;
 import org.apache.http.HttpStatus;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
@@ -152,9 +153,17 @@ public class DistributionMonitoringBusinessLogic extends BaseBusinessLogic {
                 }
 
                 resAuditingGenericEvent = auditingGenericEvent;
+            }
+
+            if (resAuditingGenericEvent != null) {
+                Map<String, Object> fields = resAuditingGenericEvent.getFields();
 
+                if (fields != null) {
+                    Optional.ofNullable(
+                        fields.get(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName()))
+                        .ifPresent(timestamp -> distributionStatusOfServiceInfo.setTimestamp((String) timestamp));
+                }
             }
-            distributionStatusOfServiceInfo.setTimestamp((String) resAuditingGenericEvent.getFields().get(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName()));
 
             if (!isResult) {
                 if (dReguestStatus.equals(String.valueOf(HttpStatus.SC_OK))) {