Fix sonars in policy-models actors 07/121207/3
authorJim Hahn <jrh3@att.com>
Fri, 7 May 2021 22:07:09 +0000 (18:07 -0400)
committerJim Hahn <jrh3@att.com>
Fri, 7 May 2021 22:13:22 +0000 (18:13 -0400)
Fixed:
- use "var"
- don't throw generic Exception

Issue-ID: POLICY-3094
Change-Id: I020addb9511fd665b5fed48e7d40719e27039224
Signed-off-by: Jim Hahn <jrh3@att.com>
29 files changed:
models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java
models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java
models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java
models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java
models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java
models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/DecisionOperation.java
models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperation.java
models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperation.java
models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.java
models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java
models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/Restart.java
models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentString.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationFinalResult.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java

index 27dd56c..ca3a55c 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -76,7 +76,7 @@ public class AaiCustomQueryOperation extends HttpOperation<String> {
         final Map<String, String> request = makeRequest();
         Map<String, Object> headers = makeHeaders();
 
-        StringBuilder str = new StringBuilder(getClient().getBaseUrl());
+        var str = new StringBuilder(getClient().getBaseUrl());
 
         String path = getPath();
         WebTarget web = getClient().getWebTarget().path(path);
@@ -89,7 +89,7 @@ public class AaiCustomQueryOperation extends HttpOperation<String> {
             webldr.header(header.getKey(), header.getValue());
         }
 
-        String url = str.toString();
+        var url = str.toString();
 
         String strRequest = prettyPrint(request);
         logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
index 1f19918..839fe13 100644 (file)
@@ -70,7 +70,7 @@ public class AaiGetPnfOperation extends AaiGetOperation {
     protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
         Map<String, Object> headers = makeHeaders();
 
-        StringBuilder str = new StringBuilder(getClient().getBaseUrl());
+        var str = new StringBuilder(getClient().getBaseUrl());
 
         String target = getRequiredProperty(OperationProperties.AAI_TARGET_ENTITY, "target entity");
         String path = getPath() + URI_SEP + URLEncoder.encode(target, StandardCharsets.UTF_8);
@@ -82,7 +82,7 @@ public class AaiGetPnfOperation extends AaiGetOperation {
         Builder webldr = web.request();
         addHeaders(webldr, headers);
 
-        String url = str.toString();
+        var url = str.toString();
 
         logMessage(EventType.OUT, CommInfrastructure.REST, url, null);
 
index 412e463..4f09dcb 100644 (file)
@@ -67,7 +67,7 @@ public class AaiGetTenantOperation extends AaiGetOperation {
     protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
         final Map<String, Object> headers = makeHeaders();
 
-        StringBuilder str = new StringBuilder(getClient().getBaseUrl());
+        var str = new StringBuilder(getClient().getBaseUrl());
 
         String path = getPath();
         WebTarget web = getClient().getWebTarget().path(path);
@@ -81,7 +81,7 @@ public class AaiGetTenantOperation extends AaiGetOperation {
         Builder webldr = web.request();
         addHeaders(webldr, headers);
 
-        String url = str.toString();
+        var url = str.toString();
 
         logMessage(EventType.OUT, CommInfrastructure.REST, url, null);
 
index 31b4aec..b8ec634 100644 (file)
@@ -79,7 +79,7 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request,
      * @return a new request
      */
     protected Request makeRequest(int attempt, GenericVnf targetVnf) {
-        Request request = new Request();
+        var request = new Request();
         request.setCommonHeader(new CommonHeader());
         request.getCommonHeader().setRequestId(params.getRequestId());
         request.getCommonHeader().setSubRequestId(getSubRequestId());
@@ -139,7 +139,7 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request,
             return Status.STILL_WAITING;
         }
 
-        ResponseCode code = ResponseCode.toResponseCode(response.getStatus().getCode());
+        var code = ResponseCode.toResponseCode(response.getStatus().getCode());
         if (code == null) {
             throw new IllegalArgumentException(
                             "unknown APPC-C response status code: " + response.getStatus().getCode());
index 559709e..c3aae68 100644 (file)
@@ -69,15 +69,15 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr
     protected AppcLcmDmaapWrapper makeRequest(int attempt) {
         String subRequestId = getSubRequestId();
 
-        AppcLcmCommonHeader header = new AppcLcmCommonHeader();
+        var header = new AppcLcmCommonHeader();
         header.setOriginatorId(params.getRequestId().toString());
         header.setRequestId(params.getRequestId());
         header.setSubRequestId(subRequestId);
 
-        AppcLcmInput inputRequest = new AppcLcmInput();
+        var inputRequest = new AppcLcmInput();
         inputRequest.setCommonHeader(header);
 
-        AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter(getName());
+        var recipeFormatter = new AppcLcmRecipeFormatter(getName());
         inputRequest.setAction(recipeFormatter.getBodyRecipe());
 
         /*
@@ -99,10 +99,10 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr
             inputRequest.setPayload(null);
         }
 
-        AppcLcmBody body = new AppcLcmBody();
+        var body = new AppcLcmBody();
         body.setInput(inputRequest);
 
-        AppcLcmDmaapWrapper dmaapRequest = new AppcLcmDmaapWrapper();
+        var dmaapRequest = new AppcLcmDmaapWrapper();
         dmaapRequest.setBody(body);
         dmaapRequest.setVersion("2.0");
         dmaapRequest.setCorrelationId(params.getRequestId() + "-" + subRequestId);
@@ -123,7 +123,7 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr
      */
     private void convertPayload(Map<String, Object> source, AppcLcmInput request) {
         try {
-            String encodedPayloadString = getCoder().encode(source);
+            var encodedPayloadString = getCoder().encode(source);
             request.setPayload(encodedPayloadString);
         } catch (CoderException e) {
             throw new IllegalArgumentException("Cannot convert payload", e);
index 4da23f1..53ad568 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020 Bell Canada. 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.
@@ -19,7 +20,6 @@
 package org.onap.policy.controlloop.actor.cds;
 
 import java.util.concurrent.CompletableFuture;
-import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
 import org.onap.policy.cds.api.CdsProcessorListener;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
@@ -55,7 +55,7 @@ public class CdsActorServiceManager implements CdsProcessorListener {
     @Override
     public void onMessage(final ExecutionServiceOutput message) {
         LOGGER.info("Received notification from CDS: {}", message);
-        EventType eventType = message.getStatus().getEventType();
+        var eventType = message.getStatus().getEventType();
         switch (eventType) {
             case EVENT_COMPONENT_PROCESSING:
                 LOGGER.info("CDS is processing the message: {}", message);
index 44d5181..87eaa95 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-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.
@@ -23,7 +23,6 @@ import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.protobuf.InvalidProtocolBufferException;
 import com.google.protobuf.Struct;
-import com.google.protobuf.Struct.Builder;
 import com.google.protobuf.util.JsonFormat;
 import java.util.Collections;
 import java.util.HashMap;
@@ -168,13 +167,13 @@ public class GrpcOperation extends OperationPartial {
     }
 
     protected String getServiceInstanceId() {
-        ServiceInstance serviceInstance =
-                        getRequiredProperty(OperationProperties.AAI_SERVICE, "Target service instance");
+        var serviceInstance = (ServiceInstance) getRequiredProperty(OperationProperties.AAI_SERVICE,
+                        "Target service instance");
         return serviceInstance.getServiceInstanceId();
     }
 
     protected String getVnfId() {
-        GenericVnf genericVnf = getRequiredProperty(OperationProperties.AAI_RESOURCE_VNF, "Target generic vnf");
+        var genericVnf = (GenericVnf) getRequiredProperty(OperationProperties.AAI_RESOURCE_VNF, "Target generic vnf");
         return genericVnf.getVnfId();
     }
 
@@ -240,7 +239,7 @@ public class GrpcOperation extends OperationPartial {
         // Embed payload from policy to ConfigDeployRequest object, serialize and inject
         // into grpc request.
         String cbaActionName = params.getOperation();
-        CdsActionRequest request = new CdsActionRequest();
+        var request = new CdsActionRequest();
         request.setPolicyPayload(payload);
         request.setActionName(cbaActionName);
         request.setResolutionKey(UUID.randomUUID().toString());
@@ -260,7 +259,7 @@ public class GrpcOperation extends OperationPartial {
             request.setAdditionalEventParams(additionalParams);
         }
 
-        Builder struct = Struct.newBuilder();
+        var struct = Struct.newBuilder();
         try {
             String requestStr = request.generateCdsPayload();
             Preconditions.checkState(!Strings.isNullOrEmpty(requestStr),
@@ -272,11 +271,11 @@ public class GrpcOperation extends OperationPartial {
         }
 
         // Build CDS gRPC request common-header
-        CommonHeader commonHeader = CommonHeader.newBuilder().setOriginatorId(CdsActorConstants.ORIGINATOR_ID)
+        var commonHeader = CommonHeader.newBuilder().setOriginatorId(CdsActorConstants.ORIGINATOR_ID)
                         .setRequestId(params.getRequestId().toString()).setSubRequestId(getSubRequestId()).build();
 
         // Build CDS gRPC request action-identifier
-        ActionIdentifiers actionIdentifiers =
+        var actionIdentifiers =
                         ActionIdentifiers.newBuilder().setBlueprintName(cbaName).setBlueprintVersion(cbaVersion)
                                         .setActionName(cbaActionName).setMode(CdsActorConstants.CDS_MODE).build();
 
index f18a04f..6291c93 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -23,7 +23,6 @@ package org.onap.policy.controlloop.actor.guard;
 import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executor;
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -96,8 +95,8 @@ public class DecisionOperation extends HttpOperation<DecisionResponse> {
         // guard is disabled, thus it is always treated as a success
         logger.info("{}: guard disabled, always succeeds for {}", getFullName(), params.getRequestId());
 
-        final Executor executor = params.getExecutor();
-        final CallbackManager callbacks = new CallbackManager();
+        final var executor = params.getExecutor();
+        final var callbacks = new CallbackManager();
 
         return CompletableFuture.completedFuture(makeOutcome())
                         .whenCompleteAsync(callbackStarted(callbacks), executor)
index 61bf838..2f6654d 100644 (file)
@@ -71,45 +71,45 @@ public class BandwidthOnDemandOperation extends SdncOperation {
             throw new IllegalArgumentException("missing enrichment data, " + SERVICE_ID_KEY);
         }
 
-        SdncHealVfModuleParameter bandwidth = new SdncHealVfModuleParameter();
+        var bandwidth = new SdncHealVfModuleParameter();
         bandwidth.setName(BANDWIDTH);
         bandwidth.setValue(getRequiredProperty(OperationProperties.ENRICHMENT_BANDWIDTH,
                         "bandwidth from enrichment data"));
 
-        SdncHealVfModuleParameter timeStamp = new SdncHealVfModuleParameter();
+        var timeStamp = new SdncHealVfModuleParameter();
         timeStamp.setName(BANDWIDTH_CHANGE_TIME);
         timeStamp.setValue(getRequiredProperty(OperationProperties.ENRICHMENT_BANDWIDTH_CHANGE_TIME,
                         "bandwidth change time from enrichment data"));
 
-        SdncHealVfModuleParametersInfo vfParametersInfo = new SdncHealVfModuleParametersInfo();
+        var vfParametersInfo = new SdncHealVfModuleParametersInfo();
         vfParametersInfo.addParameters(bandwidth);
         vfParametersInfo.addParameters(timeStamp);
 
-        SdncHealVfModuleRequestInput vfRequestInfo = new SdncHealVfModuleRequestInput();
+        var vfRequestInfo = new SdncHealVfModuleRequestInput();
         vfRequestInfo.setVfModuleParametersInfo(vfParametersInfo);
 
-        SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo();
+        var serviceInfo = new SdncHealServiceInfo();
         serviceInfo.setServiceInstanceId(serviceInstance);
 
-        SdncHealRequestInfo requestInfo = new SdncHealRequestInfo();
+        var requestInfo = new SdncHealRequestInfo();
         requestInfo.setRequestAction("SdwanBandwidthChange");
 
-        SdncHealRequestHeaderInfo headerInfo = new SdncHealRequestHeaderInfo();
+        var headerInfo = new SdncHealRequestHeaderInfo();
         headerInfo.setSvcAction("update");
         headerInfo.setSvcRequestId(getSubRequestId());
 
-        SdncRequest request = new SdncRequest();
+        var request = new SdncRequest();
         request.setNsInstanceId(serviceInstance);
         request.setRequestId(params.getRequestId());
         request.setUrl("/" + getPath());
 
-        SdncHealVnfInfo vnfInfo = new SdncHealVnfInfo();
+        var vnfInfo = new SdncHealVnfInfo();
         vnfInfo.setVnfId(getRequiredProperty(OperationProperties.ENRICHMENT_VNF_ID, "VNF id from enrichment data"));
 
-        SdncHealVfModuleInfo vfModuleInfo = new SdncHealVfModuleInfo();
+        var vfModuleInfo = new SdncHealVfModuleInfo();
         vfModuleInfo.setVfModuleId("");
 
-        SdncHealRequest healRequest = new SdncHealRequest();
+        var healRequest = new SdncHealRequest();
         healRequest.setVnfInfo(vnfInfo);
         healRequest.setVfModuleInfo(vfModuleInfo);
         healRequest.setRequestHeaderInfo(headerInfo);
index 02209bb..562266d 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -61,29 +61,29 @@ public class RerouteOperation extends SdncOperation {
         if (StringUtils.isBlank(serviceInstance)) {
             throw new IllegalArgumentException("missing enrichment data, " + SERVICE_ID_KEY);
         }
-        SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo();
+        var serviceInfo = new SdncHealServiceInfo();
         serviceInfo.setServiceInstanceId(serviceInstance);
 
         String networkId = getProperty(OperationProperties.ENRICHMENT_NETWORK_ID);
         if (StringUtils.isBlank(networkId)) {
             throw new IllegalArgumentException("missing enrichment data, " + NETWORK_ID_KEY);
         }
-        SdncHealNetworkInfo networkInfo = new SdncHealNetworkInfo();
+        var networkInfo = new SdncHealNetworkInfo();
         networkInfo.setNetworkId(networkId);
 
-        SdncHealRequestInfo requestInfo = new SdncHealRequestInfo();
+        var requestInfo = new SdncHealRequestInfo();
         requestInfo.setRequestAction("ReoptimizeSOTNInstance");
 
-        SdncHealRequestHeaderInfo headerInfo = new SdncHealRequestHeaderInfo();
+        var headerInfo = new SdncHealRequestHeaderInfo();
         headerInfo.setSvcAction("reoptimize");
         headerInfo.setSvcRequestId(getSubRequestId());
 
-        SdncRequest request = new SdncRequest();
+        var request = new SdncRequest();
         request.setNsInstanceId(serviceInstance);
         request.setRequestId(params.getRequestId());
         request.setUrl("/" + getPath());
 
-        SdncHealRequest healRequest = new SdncHealRequest();
+        var healRequest = new SdncHealRequest();
         healRequest.setRequestHeaderInfo(headerInfo);
         healRequest.setNetworkInfo(networkInfo);
         healRequest.setRequestInfo(requestInfo);
index ebfbaba..5b30c67 100644 (file)
@@ -83,7 +83,7 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe
             return Status.FAILURE;
         }
 
-        StatusCodeEnum code = StatusCodeEnum.fromStatusCode(response.getStatus().getCode());
+        var code = StatusCodeEnum.fromStatusCode(response.getStatus().getCode());
 
         if (code == null) {
             logger.warn("unknown SDNR response status code: {}", response.getStatus().getCode());
@@ -119,7 +119,7 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe
             return setOutcome(outcome, result);
         }
 
-        PciResponse pciResponse = responseWrapper.getBody().getOutput();
+        var pciResponse = responseWrapper.getBody().getOutput();
         if (pciResponse.getStatus() == null || pciResponse.getStatus().getValue() == null) {
             return setOutcome(outcome, result);
         }
@@ -135,17 +135,17 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe
 
         /* Construct an SDNR request using pci Model */
 
-        PciMessage dmaapRequest = new PciMessage();
+        var dmaapRequest = new PciMessage();
         dmaapRequest.setVersion("1.0");
         dmaapRequest.setCorrelationId(params.getRequestId() + "-" + subRequestId);
         dmaapRequest.setType("request");
         dmaapRequest.setRpcName(params.getOperation().toLowerCase());
 
         /* This is the actual request that is placed in the dmaap wrapper. */
-        final PciRequest sdnrRequest = new PciRequest();
+        final var sdnrRequest = new PciRequest();
 
         /* The common header is a required field for all SDNR requests. */
-        PciCommonHeader requestCommonHeader = new PciCommonHeader();
+        var requestCommonHeader = new PciCommonHeader();
         requestCommonHeader.setRequestId(params.getRequestId());
         requestCommonHeader.setSubRequestId(subRequestId);
 
@@ -156,7 +156,7 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe
         /*
          * Once the pci request is constructed, add it into the body of the dmaap wrapper.
          */
-        PciBody body = new PciBody();
+        var body = new PciBody();
         body.setInput(sdnrRequest);
         dmaapRequest.setBody(body);
 
index 8d3fb59..824c434 100644 (file)
@@ -251,7 +251,7 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
     }
 
     protected SoModelInfo prepareSoModelInfo() {
-        SoModelInfo soModelInfo = new SoModelInfo();
+        var soModelInfo = new SoModelInfo();
         soModelInfo.setModelCustomizationId(modelCustomizationId);
         soModelInfo.setModelInvariantId(modelInvariantId);
         soModelInfo.setModelName(modelName);
@@ -267,7 +267,7 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
      * @return SO request information
      */
     protected SoRequestInfo constructRequestInfo() {
-        SoRequestInfo soRequestInfo = new SoRequestInfo();
+        var soRequestInfo = new SoRequestInfo();
         soRequestInfo.setSource("POLICY");
         soRequestInfo.setSuppressRollback(false);
         soRequestInfo.setRequestorId("policy");
@@ -323,7 +323,7 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
      * @return SO cloud configuration
      */
     protected SoCloudConfiguration constructCloudConfiguration(Tenant tenantItem, CloudRegion cloudRegionItem) {
-        SoCloudConfiguration cloudConfiguration = new SoCloudConfiguration();
+        var cloudConfiguration = new SoCloudConfiguration();
         cloudConfiguration.setTenantId(getRequiredText("tenant ID", tenantItem.getTenantId()));
         cloudConfiguration.setLcpCloudRegionId(getRequiredText("cloud region ID", cloudRegionItem.getCloudRegionId()));
         return cloudConfiguration;
index 3d753bb..10c6737 100644 (file)
@@ -28,11 +28,7 @@ import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import org.apache.commons.lang3.tuple.Pair;
-import org.onap.aai.domain.yang.CloudRegion;
-import org.onap.aai.domain.yang.GenericVnf;
 import org.onap.aai.domain.yang.ModelVer;
-import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.Tenant;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
@@ -110,7 +106,7 @@ public class VfModuleCreate extends SoOperation {
      */
     @Override
     protected Status detmStatus(Response rawResponse, SoResponse response) {
-        Status status = super.detmStatus(rawResponse, response);
+        var status = super.detmStatus(rawResponse, response);
 
         if (status == Status.SUCCESS) {
             setVfCount(getVfCount() + 1);
@@ -125,15 +121,15 @@ public class VfModuleCreate extends SoOperation {
      * @return a pair containing the request URL and the new request
      */
     protected Pair<String, SoRequest> makeRequest() {
-        final SoModelInfo soModelInfo = prepareSoModelInfo();
-        final GenericVnf vnfItem = getVnfItem();
-        final ServiceInstance vnfServiceItem = getServiceInstance();
-        final Tenant tenantItem = getDefaultTenant();
-        final CloudRegion cloudRegionItem = getDefaultCloudRegion();
+        final var soModelInfo = prepareSoModelInfo();
+        final var vnfItem = getVnfItem();
+        final var vnfServiceItem = getServiceInstance();
+        final var tenantItem = getDefaultTenant();
+        final var cloudRegionItem = getDefaultCloudRegion();
         final ModelVer vnfModel = getVnfModel();
         final ModelVer vnfServiceModel = getServiceModel();
 
-        SoRequest request = new SoRequest();
+        var request = new SoRequest();
         request.setOperationType(SoOperationType.SCALE_OUT);
 
         //
@@ -155,8 +151,8 @@ public class VfModuleCreate extends SoOperation {
         request.getRequestDetails().getRequestInfo().setInstanceName("vfModuleName");
 
         // relatedInstanceList
-        SoRelatedInstanceListElement relatedInstanceListElement1 = new SoRelatedInstanceListElement();
-        SoRelatedInstanceListElement relatedInstanceListElement2 = new SoRelatedInstanceListElement();
+        var relatedInstanceListElement1 = new SoRelatedInstanceListElement();
+        var relatedInstanceListElement2 = new SoRelatedInstanceListElement();
         relatedInstanceListElement1.setRelatedInstance(new SoRelatedInstance());
         relatedInstanceListElement2.setRelatedInstance(new SoRelatedInstance());
 
index 1881b5c..09584b4 100644 (file)
@@ -38,10 +38,6 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
-import org.onap.aai.domain.yang.CloudRegion;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.Tenant;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
@@ -50,7 +46,6 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
 import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture;
-import org.onap.policy.so.SoModelInfo;
 import org.onap.policy.so.SoOperationType;
 import org.onap.policy.so.SoRequest;
 import org.onap.policy.so.SoRequestDetails;
@@ -129,7 +124,7 @@ public class VfModuleDelete extends SoOperation {
 
         final String url = getClient().getBaseUrl() + uri;
 
-        Builder builder = HttpRequest.newBuilder(URI.create(url));
+        var builder = HttpRequest.newBuilder(URI.create(url));
         builder = builder.header("Content-type", contentType);
         builder = addAuthHeader(builder);
 
@@ -191,7 +186,7 @@ public class VfModuleDelete extends SoOperation {
      */
     @Override
     protected Status detmStatus(Response rawResponse, SoResponse response) {
-        Status status = super.detmStatus(rawResponse, response);
+        var status = super.detmStatus(rawResponse, response);
 
         if (status == Status.SUCCESS) {
             setVfCount(getVfCount() - 1);
@@ -206,20 +201,20 @@ public class VfModuleDelete extends SoOperation {
      * @return a pair containing the request URL and the new request
      */
     protected Pair<String, SoRequest> makeRequest() {
-        final SoModelInfo soModelInfo = prepareSoModelInfo();
-        final GenericVnf vnfItem = getVnfItem();
-        final ServiceInstance vnfServiceItem = getServiceInstance();
-        final Tenant tenantItem = getDefaultTenant();
-        final CloudRegion cloudRegionItem = getDefaultCloudRegion();
+        final var soModelInfo = prepareSoModelInfo();
+        final var vnfItem = getVnfItem();
+        final var vnfServiceItem = getServiceInstance();
+        final var tenantItem = getDefaultTenant();
+        final var cloudRegionItem = getDefaultCloudRegion();
 
-        SoRequest request = new SoRequest();
+        var request = new SoRequest();
         request.setOperationType(SoOperationType.DELETE_VF_MODULE);
 
         //
         //
         // Do NOT send SO the requestId, they do not support this field
         //
-        SoRequestDetails details = new SoRequestDetails();
+        var details = new SoRequestDetails();
         request.setRequestDetails(details);
         details.setRelatedInstanceList(null);
         details.setConfigurationParameters(null);
index 304d4cd..7aa5b94 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -30,7 +30,6 @@ import lombok.Getter;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
 import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
-import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
 import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
 import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
 import org.onap.policy.common.parameters.BeanValidationResult;
@@ -116,7 +115,7 @@ public class BasicActor {
      */
     private MyConfig readConfig(String yamlConfigFile) {
         try {
-            String yaml = ResourceUtils.getResourceAsString(yamlConfigFile);
+            var yaml = ResourceUtils.getResourceAsString(yamlConfigFile);
             if (yaml == null) {
                 throw new FileNotFoundException(yamlConfigFile);
             }
@@ -139,7 +138,7 @@ public class BasicActor {
         stopOtherServices();
 
         if (config.getHttpClients() != null) {
-            HttpClientFactory factory = HttpClientFactoryInstance.getClientFactory();
+            var factory = HttpClientFactoryInstance.getClientFactory();
             for (BusTopicParams params : config.getHttpClients()) {
                 factory.build(params);
             }
index f30802c..3e06f1c 100644 (file)
@@ -31,6 +31,7 @@ import org.mockito.Mock;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
+import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
 import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
 import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
 import org.onap.policy.common.endpoints.parameters.TopicParameters;
@@ -97,13 +98,17 @@ public abstract class BasicBidirectionalTopicOperation<Q> extends BasicOperation
 
     /**
      * Starts the topic.
+     *
+     * @throws InterruptedException if interrupted
+     * @throws BidirectionalTopicClientException if the client cannot be built
      */
-    protected static void initBeforeClass(String sinkTopic, String sourceTopic) throws Exception {
+    protected static void initBeforeClass(String sinkTopic, String sourceTopic)
+                    throws InterruptedException, BidirectionalTopicClientException {
 
         Util.buildDmaapSim();
 
         // note: the sink and source names are swapped for the simulator
-        TopicParameters ptopic = new TopicParameters();
+        var ptopic = new TopicParameters();
         ptopic.setTopic(sourceTopic);
         ptopic.setManaged(true);
         ptopic.setServers(List.of("localhost"));
index 766e0fb..39adbf5 100644 (file)
@@ -53,7 +53,7 @@ public class BasicOperation {
     protected static final String EVENT_VERSION = "my-event-version";
 
     protected static final Executor blockingExecutor = command -> {
-        Thread thread = new Thread(command);
+        var thread = new Thread(command);
         thread.setDaemon(true);
         thread.start();
     };
@@ -137,7 +137,7 @@ public class BasicOperation {
      */
     protected <R> void verifyRequest(String expectedJsonFile, R request, String... ignore) throws CoderException {
         String json = coder.encode(request, true);
-        String expected = ResourceUtils.getResourceAsString(expectedJsonFile);
+        var expected = ResourceUtils.getResourceAsString(expectedJsonFile);
 
         // strip various items, because they change for each request
         for (String stripper : ignore) {
index bc96428..7840548 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -61,7 +61,7 @@ public class Restart extends VfcOperation {
      */
     protected Pair<String, VfcRequest> makeRequest() {
 
-        VfcRequest request = super.constructVfcRequest();
+        var request = super.constructVfcRequest();
         String requestUrl = "/" + request.getNsInstanceId() + "/heal";
         return Pair.of(requestUrl, request);
     }
index 2d6dc58..3e64506 100644 (file)
@@ -172,20 +172,20 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
                             "Missing enrichment data for service instance, server id, or server name.");
         }
 
-        VfcHealActionVmInfo vmActionInfo = new VfcHealActionVmInfo();
+        var vmActionInfo = new VfcHealActionVmInfo();
         vmActionInfo.setVmid(vmId);
         vmActionInfo.setVmname(vmName);
 
-        VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams();
+        var additionalParams = new VfcHealAdditionalParams();
         additionalParams.setAction(getName());
         additionalParams.setActionInfo(vmActionInfo);
 
-        VfcHealRequest healRequest = new VfcHealRequest();
+        var healRequest = new VfcHealRequest();
         healRequest.setVnfInstanceId(vnfId);
         healRequest.setCause(getName());
         healRequest.setAdditionalParams(additionalParams);
 
-        VfcRequest request = new VfcRequest();
+        var request = new VfcRequest();
         request.setHealRequest(healRequest);
         request.setNsInstanceId(serviceInstance);
         request.setRequestId(params.getRequestId());
index 4347c1d..5cd4c84 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ActorService
  * ================================================================================
- * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -89,7 +89,7 @@ public class ActorService extends StartConfigPartial<Map<String, Object>> {
         }
 
         actors.sort((actor1, actor2) -> {
-            int cmp = Integer.compare(actor1.getSequenceNumber(), actor2.getSequenceNumber());
+            var cmp = Integer.compare(actor1.getSequenceNumber(), actor2.getSequenceNumber());
             if (cmp != 0) {
                 return cmp;
             }
@@ -108,7 +108,7 @@ public class ActorService extends StartConfigPartial<Map<String, Object>> {
      * @throws IllegalArgumentException if no actor by the given name exists
      */
     public Actor getActor(String name) {
-        Actor actor = name2actor.get(name);
+        var actor = name2actor.get(name);
         if (actor == null) {
             throw new IllegalArgumentException("unknown actor " + name);
         }
index b7a9a53..dc105d9 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -45,7 +45,7 @@ public class DelayedIdentString {
             return NULL_STRING;
         }
 
-        String ident = objectToString();
+        var ident = objectToString();
         if (ident == null) {
             return NULL_STRING;
         }
index 67d25f2..f9f3a10 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * models
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -96,7 +96,7 @@ public enum OperationFinalResult {
      * @return true if a result
      */
     public static boolean isResult(String result, OperationFinalResult finalResult) {
-        OperationFinalResult toResult = OperationFinalResult.toResult(result);
+        var toResult = OperationFinalResult.toResult(result);
         if (toResult == null) {
             return false;
         }
index f5947e7..758f492 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -69,7 +69,7 @@ public class OperationOutcome {
      * @return ControlLoopOperation
      */
     public ControlLoopOperation toControlLoopOperation() {
-        ControlLoopOperation clo = new ControlLoopOperation();
+        var clo = new ControlLoopOperation();
 
         clo.setActor(actor);
         clo.setOperation(operation);
index 336860e..36e5268 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -95,7 +95,7 @@ public class ActorImpl extends StartConfigPartial<Map<String, Object>> implement
 
     @Override
     public Operator getOperator(String name) {
-        Operator operator = name2operator.get(name);
+        var operator = name2operator.get(name);
         if (operator == null) {
             throw new IllegalArgumentException("unknown operator " + getName() + "." + name);
         }
index b0ad38e..c4d5cca 100644 (file)
@@ -22,7 +22,6 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
 
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executor;
 import java.util.function.BiConsumer;
 import lombok.Getter;
 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
@@ -106,11 +105,11 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
     @Override
     protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
 
-        final Q request = makeRequest(attempt);
+        final var request = makeRequest(attempt);
         final List<String> expectedKeyValues = getExpectedKeyValues(attempt, request);
 
         final PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>();
-        final Executor executor = params.getExecutor();
+        final var executor = params.getExecutor();
 
         // register a listener BEFORE publishing
 
index a4b48d4..4812e77 100644 (file)
@@ -24,7 +24,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executor;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
@@ -182,7 +181,7 @@ public abstract class HttpOperation<T> extends OperationPartial {
 
         final PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>();
         final CompletableFuture<Response> future = new CompletableFuture<>();
-        final Executor executor = params.getExecutor();
+        final var executor = params.getExecutor();
 
         // arrange for the callback to complete "future"
         InvocationCallback<Response> callback = new InvocationCallback<>() {
index 7ad0cd8..5fbf7d2 100644 (file)
@@ -225,9 +225,9 @@ public abstract class OperationPartial implements Operation {
 
         logger.info("{}: start operation attempt {} for {}", getFullName(), attempt, params.getRequestId());
 
-        final Executor executor = params.getExecutor();
-        final OperationOutcome outcome = makeOutcome();
-        final CallbackManager callbacks = new CallbackManager();
+        final var executor = params.getExecutor();
+        final var outcome = makeOutcome();
+        final var callbacks = new CallbackManager();
 
         // this operation attempt gets its own controller
         final PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>();
@@ -594,14 +594,13 @@ public abstract class OperationPartial implements Operation {
      * @return an array of futures, possibly zero-length. If the array is of size one,
      *         then that one item should be returned instead of the controller
      */
+    @SuppressWarnings("unchecked")
     private CompletableFuture<OperationOutcome>[] attachFutures(PipelineControllerFuture<OperationOutcome> controller,
                     List<Supplier<CompletableFuture<OperationOutcome>>> futureMakers,
                     UnaryOperator<CompletableFuture<OperationOutcome>> adorn) {
 
         if (futureMakers.isEmpty()) {
-            @SuppressWarnings("unchecked")
-            CompletableFuture<OperationOutcome>[] result = new CompletableFuture[0];
-            return result;
+            return new CompletableFuture[0];
         }
 
         // the last, unadorned future that is created
@@ -631,8 +630,7 @@ public abstract class OperationPartial implements Operation {
             }
         }
 
-        @SuppressWarnings("unchecked")
-        CompletableFuture<OperationOutcome>[] result = new CompletableFuture[futures.size()];
+        var result = new CompletableFuture[futures.size()];
 
         if (result.length == 1) {
             // special case - return the unadorned future
@@ -747,7 +745,7 @@ public abstract class OperationPartial implements Operation {
          * executing
          */
         final PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>();
-        final Executor executor = params.getExecutor();
+        final var executor = params.getExecutor();
 
         // @formatter:off
         controller.wrap(nextTask)
@@ -830,7 +828,7 @@ public abstract class OperationPartial implements Operation {
                 outcome.setEnd(null);
 
                 // pass a copy to the callback
-                OperationOutcome outcome2 = new OperationOutcome(outcome);
+                var outcome2 = new OperationOutcome(outcome);
                 outcome2.setFinalOutcome(false);
                 params.callbackStarted(outcome2);
             }
index e75e99e..eacb107 100644 (file)
@@ -38,7 +38,7 @@ public abstract class OperatorPartial extends StartConfigPartial<Map<String, Obj
      */
     @Getter
     private final Executor blockingExecutor = command -> {
-        Thread thread = new Thread(command);
+        var thread = new Thread(command);
         thread.setDaemon(true);
         thread.start();
     };
index f287770..22dfc28 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -188,7 +188,7 @@ public class ControlLoopOperationParams {
      * @return a new operation outcome
      */
     public OperationOutcome makeOutcome() {
-        OperationOutcome outcome = new OperationOutcome();
+        var outcome = new OperationOutcome();
         outcome.setActor(getActor());
         outcome.setOperation(getOperation());