diff options
author | k.kazak <k.kazak@samsung.com> | 2019-02-15 17:27:08 +0100 |
---|---|---|
committer | k.kazak <k.kazak@samsung.com> | 2019-02-15 17:27:08 +0100 |
commit | c9a28a8316cf3a19fcaa2f78cf92798a99139781 (patch) | |
tree | 8bcc15b809538cae7244a551e0cfa55c64906af6 /adapters/mso-adapter-utils/src/main/java | |
parent | b7f55f47a964351e7dc46d05af7f53f7da1c9eba (diff) |
fix sonar critical bug
MsoHeatUtils: remove unnecessary heatClient check for null
1. sonar assumes that heatClient is nullable and NullPointer may be thrown in line 309
2. heatClient is never null: method creates a new object or throws Exception
MsoHeatUtilsTest: added tests for getHeatClient and createStack methods
BaseTest: made CloudIdentity and CloudSite getters protected for other tests to use them
StubOpenStack: added stubs for getStack and unsuccessful authorization
removed unused imports
Change-Id: Ie62c89f55d1894df48d9cc4d14760d36e96c4cb2
Issue-ID: SO-1516
Signed-off-by: k.kazak <k.kazak@samsung.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/main/java')
-rw-r--r-- | adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index 20498cb694..ddc725188f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -21,7 +23,6 @@ package org.onap.so.openstack.utils; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -29,7 +30,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Optional; import java.util.Set; import org.onap.so.adapters.vdu.CloudInfo; @@ -55,7 +55,6 @@ import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; -import org.onap.so.openstack.beans.HeatCacheEntry; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoAdapterException; @@ -72,7 +71,6 @@ import org.springframework.context.annotation.Primary; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.woorea.openstack.base.client.OpenStackConnectException; @@ -298,9 +296,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ // Get a Heat client. They are cached between calls (keyed by tenantId:cloudId) // This could throw MsoTenantNotFound or MsoOpenstackException (both propagated) Heat heatClient = getHeatClient (cloudSite, tenantId); - if (heatClient != null) { - LOGGER.debug("Found: " + heatClient.toString()); - } + LOGGER.debug("Found: " + heatClient.toString()); LOGGER.debug ("Ready to Create Stack (" + heatTemplate + ") with input params: " + stackInputs); |