From 0c42afde8120ddce873c99cec1a6a5ad8529dfe6 Mon Sep 17 00:00:00 2001 From: ToineSiebelink Date: Fri, 8 Apr 2022 10:12:05 +0100 Subject: Fix SonarQube violations - Use EnumMap - Remove use of var Issue-ID: CPS-475 Signed-off-by: ToineSiebelink Change-Id: Iebc3d8a8a87d0477c38967126988a6825b7e80a9 --- .../cps/ncmp/dmi/rest/controller/DmiRestController.java | 2 +- .../cps/ncmp/dmi/service/operation/SdncOperations.java | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java index 653ebf7f..cb2ac870 100644 --- a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java +++ b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java @@ -71,7 +71,7 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { public ResponseEntity getModuleReferences(final String cmHandle, final @Valid ModuleReferencesRequest body) { // For onap-dmi-plugin we don't need cmHandleProperties, so DataAccessReadRequest is not used. - final var moduleSet = dmiService.getModulesForCmHandle(cmHandle); + final ModuleSet moduleSet = dmiService.getModulesForCmHandle(cmHandle); return ResponseEntity.ok(moduleSet); } diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java b/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java index 46a332cb..c2a4a7ed 100644 --- a/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java +++ b/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java @@ -32,7 +32,7 @@ import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; +import java.util.EnumMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -54,8 +54,7 @@ import org.springframework.web.util.UriComponentsBuilder; @Component public class SdncOperations { - private static final String TOPOLOGY_URL_TEMPLATE_DATA = - "/rests/data/network-topology:network-topology/"; + private static final String TOPOLOGY_URL_TEMPLATE_DATA = "/rests/data/network-topology:network-topology/"; private static final String TOPOLOGY_URL_TEMPLATE_OPERATIONAL = "/rests/operations/network-topology:network-topology/"; private static final String GET_SCHEMA_URL = "ietf-netconf-monitoring:netconf-state/schemas"; @@ -65,7 +64,7 @@ public class SdncOperations { private static final int QUERY_PARAM_VALUE_INDEX = 1; private static final int QUERY_PARAM_NAME_INDEX = 0; - private static Map operationToHttpMethodMap = new HashMap<>(5); + private static EnumMap operationToHttpMethodMap = new EnumMap<>(OperationEnum.class); static { operationToHttpMethodMap.put(OperationEnum.READ, HttpMethod.GET); @@ -127,8 +126,8 @@ public class SdncOperations { * @return response entity */ public ResponseEntity getModuleResource(final String nodeId, final String moduleProperties) { - final var getYangResourceUrl = prepareGetOperationSchemaUrl(nodeId); - final var httpHeaders = new HttpHeaders(); + final String getYangResourceUrl = prepareGetOperationSchemaUrl(nodeId); + final HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); return sdncRestconfClient.httpOperationWithJsonData( HttpMethod.POST, getYangResourceUrl, moduleProperties, httpHeaders); @@ -166,8 +165,8 @@ public class SdncOperations { final String resourceId, final String contentType, final String requestData) { - final var getResourceDataUrl = prepareWriteUrl(nodeId, resourceId); - final var httpHeaders = new HttpHeaders(); + final String getResourceDataUrl = prepareWriteUrl(nodeId, resourceId); + final HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.parseMediaType(contentType)); final HttpMethod httpMethod = operationToHttpMethodMap.get(operation); return sdncRestconfClient.httpOperationWithJsonData(httpMethod, getResourceDataUrl, requestData, httpHeaders); -- cgit 1.2.3-korg