From: Chris André Date: Tue, 21 Apr 2020 15:21:32 +0000 (-0400) Subject: Add null test to DistributionMonitoringBusinessLogic X-Git-Tag: 1.7.0~209 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F62%2F106362%2F2;p=sdc.git Add null test to DistributionMonitoringBusinessLogic - Added test in `handleAuditingDaoResponse` for null value related to `resAuditingGenericEvent` Issue-ID: SDC-2909 Signed-off-by: Chris Andre Change-Id: I422629cdbd4f05e10609cd78b7328c4e9f45538b --- diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogic.java index 087685292b..66cab35cd2 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogic.java @@ -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 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))) {