diff options
author | waynedunican <wayne.dunican@est.tech> | 2024-07-23 09:23:51 +0100 |
---|---|---|
committer | waynedunican <wayne.dunican@est.tech> | 2024-08-13 08:49:10 +0100 |
commit | b7804abcf865dc58a01bed3f2be4756e731d9288 (patch) | |
tree | 7f6fc3b50622578bb8612de9fe5e5c6adddfaf28 /models-interactions/model-impl/aai/src | |
parent | a029ccab07f2dd71286804da620c513da9fdfc0e (diff) |
Improve code coverage and sonar fixes
Increased code coverage to 90%
SONAR - Removed TODO comments
SONAR - Added NOSONAR where appropriate
SONAR - Replaced stream.Collect() with stream.toList() where applicable
SONAR - Made variables serializable or transient to comply with sonar rules
Issue-ID: POLICY-5069
Change-Id: Ife256eaf4e6f427fe40b138bacc6f112dc5bcea4
Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'models-interactions/model-impl/aai/src')
-rw-r--r-- | models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java | 5 | ||||
-rw-r--r-- | models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java | 11 |
2 files changed, 7 insertions, 9 deletions
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java index 7a6eb6859..ed77525be 100644 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java @@ -3,7 +3,7 @@ * * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,6 @@ import org.onap.aai.domain.yang.Vserver; public class AaiCqResponse implements Serializable { private static final long serialVersionUID = 1L; - public static final String CONTEXT_KEY = AaiConstants.CONTEXT_PREFIX + "AaiCqResponse"; public static final String OPERATION = "CustomQuery"; private static final String GENERIC_VNF = "generic-vnf"; private static final String VF_MODULE = "vf-module"; @@ -50,7 +49,7 @@ public class AaiCqResponse implements Serializable { @SerializedName("results") private List<Serializable> inventoryResponseItems = new LinkedList<>(); - private final Gson gson; + private final transient Gson gson; /** * Constructor creates a custom query response from a valid json string. diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java index a6a671815..26a39875f 100644 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java @@ -3,7 +3,7 @@ * aai * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation. * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,6 +25,7 @@ package org.onap.policy.aai; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -48,8 +49,6 @@ import org.slf4j.LoggerFactory; @AllArgsConstructor public final class AaiManager { - // TODO remove this class - /** The Constant logger. */ private static final Logger logger = LoggerFactory.getLogger(AaiManager.class); @@ -246,12 +245,12 @@ public final class AaiManager { pnfName = URLEncoder.encode(pnfName, StandardCharsets.UTF_8.toString()) + AAI_DEPTH_SUFFIX; } catch (UnsupportedEncodingException e) { logger.error("Failed to encode the pnfName: {} using UTF-8", pnfName, e); - return null; + return Collections.emptyMap(); } var responseGet = getStringQuery(urlGet, username, password, requestId, pnfName); if (responseGet == null) { logger.error("Null response from AAI for the url: {}.", urlGet); - return null; + return Collections.emptyMap(); } try { @SuppressWarnings("unchecked") @@ -261,7 +260,7 @@ public final class AaiManager { .collect(Collectors.toMap(e -> "pnf." + e.getKey(), Map.Entry::getValue)); } catch (CoderException e) { logger.error("Failed to fetch PNF from AAI", e); - return null; + return Collections.emptyMap(); } } } |