From 60c01004daf199820825f9bf345a3ed8a96f8933 Mon Sep 17 00:00:00 2001 From: Chris André Date: Tue, 21 Apr 2020 11:21:32 -0400 Subject: 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 --- .../impl/DistributionMonitoringBusinessLogic.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'catalog-be/src/main') 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))) { -- cgit 1.2.3-korg