From f1a24cb3c4514092fde0a9f114ffa43d637ce175 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 1 Sep 2021 17:16:53 -0400 Subject: Fix sonars in clamp Fixed some sonars: - no assertion in test case - unused fields - unthrown exception - define a constant - use boolean instead of Boolean - remove unused parameter Fixed some eclipse warnings: - unused imports - unused methods - suppress warnings - add type parameter Renamed directory from "org.onap.policy..." to "org/onap/policy/...". Issue-ID: POLICY-3200 Change-Id: I76f7cd4a508ac421c37e457fdca6894e6100c802 Signed-off-by: Jim Hahn --- .../controlloop/runtime/commissioning/CommissioningProvider.java | 3 ++- .../runtime/instantiation/ControlLoopInstantiationProvider.java | 9 ++++++--- .../controlloop/runtime/main/rest/InstantiationController.java | 4 ++-- .../controlloop/runtime/supervision/SupervisionHandler.java | 6 ++---- 4 files changed, 12 insertions(+), 10 deletions(-) (limited to 'runtime-controlloop/src/main/java/org/onap') diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java index 74b5394f4..fbfc1de69 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -500,7 +501,7 @@ public class CommissioningProvider { * * @return true if exists instance properties */ - private Boolean verifyIfInstancePropertiesExists() { + private boolean verifyIfInstancePropertiesExists() { return clProvider.getNodeTemplates(null, null).stream() .anyMatch(nodeTemplate -> nodeTemplate.getKey().getName().contains("_Instance")); diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java index da85b0a83..a71772624 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,6 +59,8 @@ import org.springframework.stereotype.Component; @Component @AllArgsConstructor public class ControlLoopInstantiationProvider { + private static final String INSTANCE_TEXT = "_Instance"; + private final ControlLoopProvider controlLoopProvider; private final CommissioningProvider commissioningProvider; private final SupervisionHandler supervisionHandler; @@ -350,12 +353,12 @@ public class ControlLoopInstantiationProvider { int instanceNumber = nodeTemplates.stream().map(ToscaNodeTemplate::getName) - .filter(name -> name.contains("_Instance")).map(n -> { - String[] defNameArr = n.split("_Instance"); + .filter(name -> name.contains(INSTANCE_TEXT)).map(n -> { + String[] defNameArr = n.split(INSTANCE_TEXT); return Integer.parseInt(defNameArr[1]); }).reduce(0, Math::max); - return "_Instance" + (instanceNumber + 1); + return INSTANCE_TEXT + (instanceNumber + 1); } } diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java index d2a85c46d..5a8275f8a 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -186,8 +187,7 @@ public class InstantiationController extends AbstractRestController { @RequestHeader( name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body) - throws PfModelException { + @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body) { return ResponseEntity.ok().body(provider.saveInstanceProperties(body)); } diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java index c68b7fd49..789e4fa92 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java @@ -1,8 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -217,10 +216,9 @@ public class SupervisionHandler { * Supervise a control loop, performing whatever actions need to be performed on the control loop. * * @param controlLoop the control loop to supervises - * @throws PfModelException on accessing models in the database * @throws ControlLoopException on supervision errors */ - private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException { + private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException { switch (controlLoop.getOrderedState()) { case UNINITIALISED: superviseControlLoopUninitialization(controlLoop); -- cgit 1.2.3-korg