diff options
author | ToineSiebelink <toine.siebelink@est.tech> | 2022-04-08 10:12:05 +0100 |
---|---|---|
committer | ToineSiebelink <toine.siebelink@est.tech> | 2022-04-08 10:12:16 +0100 |
commit | 0c42afde8120ddce873c99cec1a6a5ad8529dfe6 (patch) | |
tree | b03575c9cb5c1dece2e6e2ed55ea546d5bce469f /src/main | |
parent | 54d10a74fdd8cfcb89fd1c0ab91abefdf0602367 (diff) |
Fix SonarQube violations
- Use EnumMap
- Remove use of var
Issue-ID: CPS-475
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Change-Id: Iebc3d8a8a87d0477c38967126988a6825b7e80a9
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/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<ModuleSet> 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<OperationEnum, HttpMethod> operationToHttpMethodMap = new HashMap<>(5); + private static EnumMap<OperationEnum, HttpMethod> operationToHttpMethodMap = new EnumMap<>(OperationEnum.class); static { operationToHttpMethodMap.put(OperationEnum.READ, HttpMethod.GET); @@ -127,8 +126,8 @@ public class SdncOperations { * @return response entity */ public ResponseEntity<String> 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); |