Fix sonars in policy-models impls & simulators 33/121233/1
authorJim Hahn <jrh3@att.com>
Mon, 10 May 2021 13:53:23 +0000 (09:53 -0400)
committerJim Hahn <jrh3@att.com>
Mon, 10 May 2021 15:07:36 +0000 (11:07 -0400)
Fixed:
- use "var"

Issue-ID: POLICY-3094
Change-Id: I65da54cae5a58966f21f981c6cea1259bfdf4239
Signed-off-by: Jim Hahn <jrh3@att.com>
simulators

Change-Id: I1144568485e62e0c72194caaf21ebf1ba88a6fef
Signed-off-by: Jim Hahn <jrh3@att.com>
36 files changed:
models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java
models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmResponseCode.java
models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorGrpcClient.java
models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorHandler.java
models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseCode.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/Serialization.java
models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoResponseWrapper.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLcmTopicServer.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLegacyTopicServer.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SdnrTopicServer.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/ConsumerGroupData.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/TopicData.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestServer.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/DmaapSimActivator.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/Main.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java
models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java
models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java

index 2648959..d638c9d 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  *
  * ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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,13 +95,13 @@ public class AaiCqResponse implements Serializable {
     public AaiCqResponse(String jsonString) {
 
         // Read JSON String and add all AaiObjects
-        JSONObject responseObj = new JSONObject(jsonString);
-        JSONArray resultsArray = new JSONArray();
+        var responseObj = new JSONObject(jsonString);
+        var resultsArray = new JSONArray();
         if (responseObj.has("results")) {
             resultsArray = (JSONArray) responseObj.get("results");
         }
-        for (int i = 0; i < resultsArray.length(); i++) {
-            final JSONObject resultObject = resultsArray.getJSONObject(i);
+        for (var i = 0; i < resultsArray.length(); i++) {
+            final var resultObject = resultsArray.getJSONObject(i);
 
             extractVserver(resultObject);
             extractGenericVnf(resultObject);
@@ -118,11 +118,11 @@ public class AaiCqResponse implements Serializable {
 
             // Create the StreamSource by creating StringReader using the
             // JSON input
-            StreamSource json = new StreamSource(
+            var json = new StreamSource(
                     new StringReader(resultObject.getJSONObject("vserver").toString()));
 
             // Getting the vserver pojo again from the json
-            Vserver vserver = this.getAaiObject(json, Vserver.class);
+            var vserver = this.getAaiObject(json, Vserver.class);
             this.inventoryResponseItems.add(vserver);
         }
     }
@@ -131,11 +131,11 @@ public class AaiCqResponse implements Serializable {
         if (resultObject.has(GENERIC_VNF)) {
             // Create the StreamSource by creating StringReader using the
             // JSON input
-            StreamSource json = new StreamSource(
+            var json = new StreamSource(
                     new StringReader(resultObject.getJSONObject(GENERIC_VNF).toString()));
 
             // Getting the generic vnf pojo again from the json
-            GenericVnf genericVnf = this.getAaiObject(json, GenericVnf.class);
+            var genericVnf = this.getAaiObject(json, GenericVnf.class);
 
             this.inventoryResponseItems.add(genericVnf);
         }
@@ -146,11 +146,11 @@ public class AaiCqResponse implements Serializable {
 
             // Create the StreamSource by creating StringReader using the
             // JSON input
-            StreamSource json = new StreamSource(
+            var json = new StreamSource(
                     new StringReader(resultObject.getJSONObject("service-instance").toString()));
 
             // Getting the employee pojo again from the json
-            ServiceInstance serviceInstance = this.getAaiObject(json, ServiceInstance.class);
+            var serviceInstance = this.getAaiObject(json, ServiceInstance.class);
 
             this.inventoryResponseItems.add(serviceInstance);
         }
@@ -160,11 +160,11 @@ public class AaiCqResponse implements Serializable {
         if (resultObject.has(VF_MODULE)) {
             // Create the StreamSource by creating StringReader using the
             // JSON input
-            StreamSource json = new StreamSource(
+            var json = new StreamSource(
                     new StringReader(resultObject.getJSONObject(VF_MODULE).toString()));
 
             // Getting the vf module pojo again from the json
-            VfModule vfModule = this.getAaiObject(json, VfModule.class);
+            var vfModule = this.getAaiObject(json, VfModule.class);
 
             this.inventoryResponseItems.add(vfModule);
         }
@@ -174,11 +174,11 @@ public class AaiCqResponse implements Serializable {
         if (resultObject.has("cloud-region")) {
             // Create the StreamSource by creating StringReader using the
             // JSON input
-            StreamSource json = new StreamSource(
+            var json = new StreamSource(
                     new StringReader(resultObject.getJSONObject("cloud-region").toString()));
 
             // Getting the cloud region pojo again from the json
-            CloudRegion cloudRegion = this.getAaiObject(json, CloudRegion.class);
+            var cloudRegion = this.getAaiObject(json, CloudRegion.class);
 
             this.inventoryResponseItems.add(cloudRegion);
         }
@@ -188,11 +188,11 @@ public class AaiCqResponse implements Serializable {
         if (resultObject.has("tenant")) {
             // Create the StreamSource by creating StringReader using the
             // JSON input
-            StreamSource json = new StreamSource(
+            var json = new StreamSource(
                     new StringReader(resultObject.getJSONObject("tenant").toString()));
 
             // Getting the tenant pojo again from the json
-            Tenant tenant = this.getAaiObject(json, Tenant.class);
+            var tenant = this.getAaiObject(json, Tenant.class);
 
             this.inventoryResponseItems.add(tenant);
         }
@@ -202,11 +202,11 @@ public class AaiCqResponse implements Serializable {
         if (resultObject.has("model-ver")) {
             // Create the StreamSource by creating StringReader using the
             // JSON input
-            StreamSource json = new StreamSource(
+            var json = new StreamSource(
                     new StringReader(resultObject.getJSONObject("model-ver").toString()));
 
             // Getting the ModelVer pojo again from the json
-            ModelVer modelVer = this.getAaiObject(json, ModelVer.class);
+            var modelVer = this.getAaiObject(json, ModelVer.class);
 
             this.inventoryResponseItems.add(modelVer);
         }
@@ -409,13 +409,13 @@ public class AaiCqResponse implements Serializable {
         GenericVnf genericVnf = null;
 
         // Get the vserver associated with the query
-        Vserver vserver = this.getVserver();
+        var vserver = this.getVserver();
 
         // Get the relationships of the vserver
         List<Relationship> relations = vserver.getRelationshipList().getRelationship();
 
         // Find the relationship of the genericVNF
-        String genericVnfId = "";
+        var genericVnfId = "";
         List<RelationshipData> relationshipData = null;
 
         // Iterate through the list of relationships and get generic vnf
@@ -457,13 +457,13 @@ public class AaiCqResponse implements Serializable {
         VfModule vfModule = null;
 
         // Get the vserver associated with the query
-        Vserver vserver = this.getVserver();
+        var vserver = this.getVserver();
 
         // Get the relationships of the vserver
         List<Relationship> relations = vserver.getRelationshipList().getRelationship();
 
         // Find the relationship of VfModule
-        String vfModuleId = "";
+        var vfModuleId = "";
         List<RelationshipData> relationshipData = null;
 
         // Iterate through the list of relationships and get vf module
@@ -554,7 +554,7 @@ public class AaiCqResponse implements Serializable {
      */
     public Vserver getVserver() {
         Vserver vserver = null;
-        int index = 0;
+        var index = 0;
         while (this.inventoryResponseItems.get(index).getClass() != Vserver.class) {
             index = index + 1;
         }
@@ -605,7 +605,7 @@ public class AaiCqResponse implements Serializable {
      */
     public int getVfModuleCount(String custId, String invId, String verId) {
         List<VfModule> vfModuleList = this.getAllVfModules();
-        int count = 0;
+        var count = 0;
         for (VfModule vfModule : vfModuleList) {
             if (vfModule.getModelCustomizationId() == null || vfModule.getModelInvariantId() == null
                     || vfModule.getModelVersionId() == null) {
index 16ee887..b2a4107 100644 (file)
@@ -86,17 +86,17 @@ public final class AaiManager {
         if (getResponse == null) {
             return null;
         } else {
-            JSONObject responseObj = new JSONObject(getResponse);
+            var responseObj = new JSONObject(getResponse);
             JSONArray resultsArray;
             if (responseObj.has("result-data")) {
                 resultsArray = (JSONArray) responseObj.get("result-data");
             } else {
                 return null;
             }
-            String resourceLink = resultsArray.getJSONObject(0).getString("resource-link");
-            String start = resourceLink.replace(PREFIX, "");
-            String query = "query/closed-loop";
-            JSONObject payload = new JSONObject();
+            var resourceLink = resultsArray.getJSONObject(0).getString("resource-link");
+            var start = resourceLink.replace(PREFIX, "");
+            var query = "query/closed-loop";
+            var payload = new JSONObject();
             payload.put("start", start);
             payload.put("query", query);
             return payload.toString();
@@ -119,7 +119,7 @@ public final class AaiManager {
 
         String urlGet = url + TENANT_URL;
 
-        String getResponse = getStringQuery(urlGet, username, password, requestId, vserver);
+        var getResponse = getStringQuery(urlGet, username, password, requestId, vserver);
         return createCustomQueryPayload(getResponse);
     }
 
@@ -186,7 +186,7 @@ public final class AaiManager {
 
         String urlGet = url + key;
 
-        int attemptsLeft = 3;
+        var attemptsLeft = 3;
 
         while (attemptsLeft-- > 0) {
             NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", CommInfrastructure.REST, urlGet);
@@ -255,7 +255,7 @@ public final class AaiManager {
             logger.error("Failed to encode the pnfName: {} using UTF-8", pnfName, e);
             return null;
         }
-        String responseGet = getStringQuery(urlGet, username, password, requestId, pnfName);
+        var responseGet = getStringQuery(urlGet, username, password, requestId, pnfName);
         if (responseGet == null) {
             logger.error("Null response from AAI for the url: {}.", urlGet);
             return null;
index 8a2c2cd..6a0e19a 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * appc
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,8 +47,8 @@ public class ResponseStatus implements Serializable {
 
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
+        final var prime = 31;
+        var result = 1;
         result = prime * result + code;
         result = prime * result + ((description == null) ? 0 : description.hashCode());
         result = prime * result + ((value == null) ? 0 : value.hashCode());
index 9d36ff8..43697e9 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * appclcm
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
@@ -59,7 +59,7 @@ public class AppcLcmResponseCode implements Serializable {
      * @return the string value equivalent of the APPC response code
      */
     public static String toResponseValue(int code) {
-        StatusCodeEnum statusCodeEnum = StatusCodeEnum.fromStatusCode(code);
+        var statusCodeEnum = StatusCodeEnum.fromStatusCode(code);
         return (statusCodeEnum != null) ? statusCodeEnum.toString() : null;
     }
 }
index 29fa687..ce0918d 100644 (file)
@@ -54,13 +54,7 @@ public class CdsProcessorGrpcClient implements AutoCloseable {
         Preconditions.checkState(validationResult.getStatus().isValid(), "Error validating CDS server "
             + "properties: " + validationResult.getResult());
 
-        StringBuilder bldr = new StringBuilder("gRPC://");
-        bldr.append(props.getHost());
-        bldr.append(":");
-        bldr.append(props.getPort());
-        bldr.append('/');
-
-        String url = bldr.toString();
+        String url = "gRPC://" + props.getHost() + ":" + props.getPort() + "/";
 
         this.channel = NettyChannelBuilder.forAddress(props.getHost(), props.getPort())
             .intercept(new BasicAuthClientHeaderInterceptor(props)).usePlaintext().build();
index 660908b..bb7a038 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2019-2021 Bell Canada.
- * 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.
@@ -22,7 +22,6 @@ package org.onap.policy.cds.client;
 import io.grpc.ManagedChannel;
 import io.grpc.stub.StreamObserver;
 import java.util.concurrent.CountDownLatch;
-import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
 import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc;
 import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub;
 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
@@ -47,13 +46,13 @@ public class CdsProcessorHandler {
     }
 
     CountDownLatch process(ExecutionServiceInput request, ManagedChannel channel) {
-        final ActionIdentifiers header = request.getActionIdentifiers();
+        final var header = request.getActionIdentifiers();
         LOGGER.info("Processing blueprint({}:{}) for action({})", header.getBlueprintVersion(),
             header.getBlueprintName(), header.getBlueprintVersion());
 
-        final CountDownLatch finishLatch = new CountDownLatch(1);
+        final var finishLatch = new CountDownLatch(1);
         final BluePrintProcessingServiceStub asyncStub = BluePrintProcessingServiceGrpc.newStub(channel);
-        final StreamObserver<ExecutionServiceOutput> responseObserver = new StreamObserver<ExecutionServiceOutput>() {
+        final StreamObserver<ExecutionServiceOutput> responseObserver = new StreamObserver<>() {
             @Override
             public void onNext(ExecutionServiceOutput output) {
                 NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, output.toString());
index 4f37e95..a91548f 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * rest
  * ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019-2020 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -61,11 +61,11 @@ public class RestManager {
      */
     public Pair<Integer, String> put(String url, String username, String password, Map<String, String> headers,
             String contentType, String body) {
-        HttpPut put = new HttpPut(url);
+        var put = new HttpPut(url);
         addHeaders(put, username, password, headers);
         put.addHeader(CONTENT_TYPE, contentType);
         try {
-            StringEntity input = new StringEntity(body);
+            var input = new StringEntity(body);
             input.setContentType(contentType);
             put.setEntity(input);
         } catch (Exception e) {
@@ -88,11 +88,11 @@ public class RestManager {
      */
     public Pair<Integer, String> post(String url, String username, String password, Map<String, String> headers,
             String contentType, String body) {
-        HttpPost post = new HttpPost(url);
+        var post = new HttpPost(url);
         addHeaders(post, username, password, headers);
         post.addHeader(CONTENT_TYPE, contentType);
         try {
-            StringEntity input = new StringEntity(body);
+            var input = new StringEntity(body);
             input.setContentType(contentType);
             post.setEntity(input);
         } catch (Exception e) {
@@ -112,7 +112,7 @@ public class RestManager {
      * @return a Pair for the response status and the body
      */
     public Pair<Integer, String> get(String url, String username, String password, Map<String, String> headers) {
-        HttpGet get = new HttpGet(url);
+        var get = new HttpGet(url);
         addHeaders(get, username, password, headers);
         return sendRequest(get);
     }
@@ -131,12 +131,12 @@ public class RestManager {
      */
     public Pair<Integer, String> delete(String url, String username, String password, Map<String, String> headers,
             String contentType, String body) {
-        HttpDeleteWithBody delete = new HttpDeleteWithBody(url);
+        var delete = new HttpDeleteWithBody(url);
         addHeaders(delete, username, password, headers);
         if (body != null && !body.isEmpty()) {
             delete.addHeader(CONTENT_TYPE, contentType);
             try {
-                StringEntity input = new StringEntity(body);
+                var input = new StringEntity(body);
                 input.setContentType(contentType);
                 delete.setEntity(input);
             } catch (Exception e) {
@@ -157,7 +157,7 @@ public class RestManager {
      * @return the response status code and the body
      */
     public Pair<Integer, String> delete(String url, String username, String password, Map<String, String> headers) {
-        HttpDelete delete = new HttpDelete(url);
+        var delete = new HttpDelete(url);
         addHeaders(delete, username, password, headers);
         return sendRequest(delete);
     }
@@ -174,12 +174,12 @@ public class RestManager {
      */
     public Pair<Integer, String> patch(String url, String username, String password, Map<String, String> headers,
             String body) {
-        String contentType = "application/merge-patch+json";
-        HttpPatch patch = new HttpPatch(url);
+        var contentType = "application/merge-patch+json";
+        var patch = new HttpPatch(url);
         addHeaders(patch, username, password, headers);
         patch.addHeader(CONTENT_TYPE, contentType);
         try {
-            StringEntity input = new StringEntity(body);
+            var input = new StringEntity(body);
             input.setContentType(contentType);
             patch.setEntity(input);
         } catch (Exception e) {
@@ -204,7 +204,7 @@ public class RestManager {
                 HttpClientBuilder.create().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()) {
             HttpResponse response = client.execute(request);
             if (response != null) {
-                String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
+                var returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
                 logger.debug("HTTP Response Status Code: {}", response.getStatusLine().getStatusCode());
                 logger.debug("HTTP Response Body:");
                 logger.debug(returnBody);
index 35a85d7..90864d4 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * Modifications Copyright (C) 2019 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.
@@ -59,7 +60,7 @@ public class PciResponseCode implements Serializable {
      * @return the string value equivalent of the SDNR response code
      */
     public static String toResponseValue(int code) {
-        StatusCodeEnum statusCodeEnum = StatusCodeEnum.fromStatusCode(code);
+        var statusCodeEnum = StatusCodeEnum.fromStatusCode(code);
         return (statusCodeEnum != null) ? statusCodeEnum.toString() : null;
     }
 }
index a5e4336..90aea71 100644 (file)
@@ -57,7 +57,7 @@ public final class Serialization {
         @Override
         public JsonElement serialize(PciRequest src, Type typeOfSrc, JsonSerializationContext context) {
             JsonElement requestJson = gsonPretty.toJsonTree(src, PciRequest.class);
-            JsonObject input = new JsonObject();
+            var input = new JsonObject();
             input.add("input", requestJson);
 
             return input;
@@ -74,7 +74,7 @@ public final class Serialization {
         @Override
         public JsonElement serialize(PciResponse src, Type typeOfSrc, JsonSerializationContext context) {
             JsonElement responseJson = gsonPretty.toJsonTree(src, PciResponse.class);
-            JsonObject output = new JsonObject();
+            var output = new JsonObject();
             output.add("output", responseJson);
             return output;
         }
index beb8528..b6eef29 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * so
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -70,7 +70,7 @@ public class SoResponseWrapper implements Serializable {
 
     @Override
     public int hashCode() {
-        final int prime = 31;
+        final var prime = 31;
         int result = super.hashCode();
         result = prime * result + ((soResponse == null) ? 0 : soResponse.hashCode());
         result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
index 3b0d8cd..a8ec6e5 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.
@@ -46,7 +46,7 @@ public class AppcLcmTopicServer extends TopicServer<AppcLcmDmaapWrapper> {
             return null;
         }
 
-        String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appclcm/appc.lcm.success.json");
+        var response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appclcm/appc.lcm.success.json");
         return response.replace("${replaceMe}", request.getBody().getInput().getCommonHeader().getSubRequestId());
     }
 }
index c3f0435..9447e01 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.
@@ -46,7 +46,7 @@ public class AppcLegacyTopicServer extends TopicServer<Request> {
             return null;
         }
 
-        String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appc/appc.legacy.success.json");
+        var response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appc/appc.legacy.success.json");
         return response.replace("${replaceMe}", request.getCommonHeader().getSubRequestId());
     }
 }
index 222bd7f..1677a35 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020 Nordix Foundation.
- *  Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import lombok.Getter;
 import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
 import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
 import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
 import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase;
@@ -93,7 +92,7 @@ public class CdsSimulator implements Runnable {
                     public void onNext(final ExecutionServiceInput executionServiceInput) {
                         LOGGER.info("Received request input to CDS: {}", executionServiceInput);
                         try {
-                            Builder builder = getResponse(executionServiceInput, countOfSuccesfulEvents);
+                            var builder = getResponse(executionServiceInput, countOfSuccesfulEvents);
                             TimeUnit.MILLISECONDS.sleep(requestedResponseDelayMs);
                             responseObserver.onNext(builder.build());
                         } catch (InvalidProtocolBufferException e) {
@@ -151,9 +150,9 @@ public class CdsSimulator implements Runnable {
      */
     public Builder getResponse(ExecutionServiceInput executionServiceInput, int countOfSuccesfulEvents)
         throws InvalidProtocolBufferException {
-        String resourceName = "DefaultResponseEvent";
+        var resourceName = "DefaultResponseEvent";
         if (!StringUtils.isBlank(executionServiceInput.getActionIdentifiers().getActionName())) {
-            ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
+            var actionIdentifiers = executionServiceInput.getActionIdentifiers();
             resourceName = actionIdentifiers.getBlueprintName() + "-" + actionIdentifiers.getActionName();
         }
         if (countOfSuccesfulEvents > 0 && countOfEvents.getAndIncrement() % countOfSuccesfulEvents == 0) {
@@ -163,11 +162,11 @@ public class CdsSimulator implements Runnable {
             resourceName = resourceName + ".json";
         }
         LOGGER.info("Fetching response from {}", resourceName);
-        String responseString = ResourceUtils.getResourceAsString(resourceLocation + resourceName);
-        Builder builder = ExecutionServiceOutput.newBuilder();
+        var responseString = ResourceUtils.getResourceAsString(resourceLocation + resourceName);
+        var builder = ExecutionServiceOutput.newBuilder();
         if (null == responseString) {
             LOGGER.info("Expected response file {} not found in {}", resourceName, resourceLocation);
-            ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
+            var actionIdentifiers = executionServiceInput.getActionIdentifiers();
             builder.setCommonHeader(executionServiceInput.getCommonHeader());
             builder.setActionIdentifiers(actionIdentifiers);
             builder.setPayload(executionServiceInput.getPayload());
index f915f86..7a33a19 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * simulators
  * ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,7 +49,7 @@ public class GuardSimulatorJaxRs {
         @SuppressWarnings("unchecked")
         Map<String, String> guard = (Map<String, String>) req.getResource().get("guard");
         String clName = guard.get("clname");
-        DecisionResponse response = new DecisionResponse();
+        var response = new DecisionResponse();
         if (DENY_CLNAME.equals(clName)) {
             response.setStatus("Deny");
             response.setAdvice(Collections.emptyMap());
index b6e8b04..7a28791 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Huawei. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-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.
@@ -65,9 +65,9 @@ public class SdncSimulatorJaxRs {
 
 
     private String makeSuccessResponse() {
-        final SdncResponse response = new SdncResponse();
+        final var response = new SdncResponse();
         response.setRequestId(UUID.randomUUID().toString());
-        SdncResponseOutput responseOutput = new SdncResponseOutput();
+        var responseOutput = new SdncResponseOutput();
         responseOutput.setResponseCode("200");
         responseOutput.setAckFinalIndicator("Y");
         responseOutput.setSvcRequestId(UUID.randomUUID().toString());
index 9aad4d4..cf297e5 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.
@@ -46,7 +46,7 @@ public class SdnrTopicServer extends TopicServer<PciMessage> {
             return null;
         }
 
-        String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/sdnr/vpci.sdnr.success.json");
+        var response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/sdnr/vpci.sdnr.success.json");
         return response.replace("${replaceMe}", request.getBody().getInput().getCommonHeader().getSubRequestId());
     }
 }
index 12a523a..3d21878 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * simulators
  * ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * Modifications Copyright (C) 2020 Wipro Limited.
  * ================================================================================
@@ -135,9 +135,9 @@ public class SoSimulatorJaxRs {
     }
 
     private String makeStarted() {
-        String requestId = UUID.randomUUID().toString();
+        var requestId = UUID.randomUUID().toString();
 
-        String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.started.json");
+        var response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.started.json");
 
         incomplete.add(requestId);
 
@@ -145,17 +145,17 @@ public class SoSimulatorJaxRs {
     }
 
     private String makeImmediateComplete() {
-        String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.immediate.success.json");
+        var response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.immediate.success.json");
         return response.replace(REPLACE_ME, UUID.randomUUID().toString());
     }
 
     private String makeComplete(String requestId) {
-        String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.complete.success.json");
+        var response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.complete.success.json");
         return response.replace(REPLACE_ME, requestId);
     }
 
     private String makeStillRunning(String requestId) {
-        String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.still.running.json");
+        var response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.still.running.json");
         return response.replace(REPLACE_ME, requestId);
     }
 }
index d9fb52b..51f2f9d 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * simulators
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,6 @@
 package org.onap.policy.simulators;
 
 import java.io.IOException;
-import java.util.Properties;
 import org.onap.policy.common.endpoints.http.server.HttpServletServer;
 import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -81,7 +80,7 @@ public class Util {
      * @throws IOException if an I/O error occurs
      */
     public static CdsSimulator buildCdsSim() throws InterruptedException, IOException {
-        final CdsSimulator testServer = new CdsSimulator(LOCALHOST, CDSSIM_SERVER_PORT);
+        final var testServer = new CdsSimulator(LOCALHOST, CDSSIM_SERVER_PORT);
         testServer.start();
         waitForServerToListen(testServer.getPort());
         return testServer;
@@ -155,7 +154,7 @@ public class Util {
      * @throws InterruptedException if a thread is interrupted
      */
     public static HttpServletServer buildDmaapSim() throws InterruptedException {
-        String json = ResourceUtils.getResourceAsString("org/onap/policy/simulators/dmaap/DmaapParameters.json");
+        var json = ResourceUtils.getResourceAsString("org/onap/policy/simulators/dmaap/DmaapParameters.json");
         DmaapSimParameterGroup params = null;
         try {
             params = new StandardCoder().decode(json, DmaapSimParameterGroup.class);
@@ -166,7 +165,7 @@ public class Util {
 
         DmaapSimProvider.setInstance(new DmaapSimProvider(params));
 
-        Properties props = DmaapSimRestServer.getServerProperties(params.getRestServerParameters());
+        var props = DmaapSimRestServer.getServerProperties(params.getRestServerParameters());
 
         final String svcpfx = PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
                 + params.getRestServerParameters().getName();
index cf21c7b..3702fdd 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * simulators
  * ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,7 +30,6 @@ import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
-import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Path("/api/nslcm/v1")
@@ -53,7 +52,7 @@ public class VfcSimulatorJaxRs {
         try {
             response.flushBuffer();
         } catch (Exception e) {
-            final Logger logger = LoggerFactory.getLogger(VfcSimulatorJaxRs.class);
+            final var logger = LoggerFactory.getLogger(VfcSimulatorJaxRs.class);
             logger.error("flushBuffer threw: ", e);
             return "";
         }
index 4485def..7c9f79b 100644 (file)
@@ -53,7 +53,7 @@ public class DmaapSimParameterHandler {
         // Read the parameters
         try {
             // Read the parameters from JSON
-            File file = new File(arguments.getFullConfigurationFilePath());
+            var file = new File(arguments.getFullConfigurationFilePath());
             dmaapSimParameterGroup = coder.decode(file, DmaapSimParameterGroup.class);
         } catch (final CoderException e) {
             final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
index 7371513..3acaf08 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Models
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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.
@@ -146,7 +146,7 @@ public class ConsumerGroupData {
             lst.add(obj);
 
             // perform NON-blocking read of subsequent messages
-            for (int x = 1; x < maxRead2; ++x) {
+            for (var x = 1; x < maxRead2; ++x) {
                 if ((obj = messageQueue.poll()) == null) {
                     break;
                 }
index 5da2adc..8e5cf24 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Models
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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.
@@ -153,7 +153,7 @@ public class TopicData {
         List<String> list = new ArrayList<>(messages.size());
 
         for (Object msg : messages) {
-            String str = convertMessageToString(msg, coder);
+            var str = convertMessageToString(msg, coder);
             if (str != null) {
                 list.add(str);
             }
index b468e34..64ea29d 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Models
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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.
@@ -65,8 +65,7 @@ public class CambriaMessageBodyHandler implements MessageBodyReader<Object> {
     public List<Object> readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
                     MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
 
-        try (BufferedReader bufferedReader =
-                        new BufferedReader(new InputStreamReader(entityStream, StandardCharsets.UTF_8))) {
+        try (var bufferedReader = new BufferedReader(new InputStreamReader(entityStream, StandardCharsets.UTF_8))) {
             List<Object> messages = new LinkedList<>();
             String msg;
             while ((msg = readMessage(bufferedReader)) != null) {
@@ -137,10 +136,10 @@ public class CambriaMessageBodyHandler implements MessageBodyReader<Object> {
      * @throws IOException if an error occurs
      */
     private int readLength(Reader reader) throws IOException {
-        StringBuilder bldr = new StringBuilder(MAX_DIGITS);
+        var bldr = new StringBuilder(MAX_DIGITS);
 
         int chr;
-        for (int x = 0; x < MAX_DIGITS; ++x) {
+        for (var x = 0; x < MAX_DIGITS; ++x) {
             if ((chr = reader.read()) < 0) {
                 throw new EOFException("missing '.' in 'length' field");
             }
@@ -169,7 +168,7 @@ public class CambriaMessageBodyHandler implements MessageBodyReader<Object> {
      * @throws IOException if an error occurs
      */
     private String readString(Reader reader, int len) throws IOException {
-        char[] buf = new char[len];
+        var buf = new char[len];
         IOUtils.readFully(reader, buf);
 
         return new String(buf);
index b05a0fe..acac143 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019, 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.
@@ -59,7 +59,7 @@ public class DmaapSimRestServer extends ServiceManagerContainer {
      * @return a set of properties representing the given parameters
      */
     public static Properties getServerProperties(RestServerParameters restServerParameters) {
-        final Properties props = new Properties();
+        final var props = new Properties();
         props.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES, restServerParameters.getName());
 
         final String svcpfx =
index 3c903c8..c72b748 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Models
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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.
@@ -52,8 +52,7 @@ public class TextMessageBodyHandler implements MessageBodyReader<Object> {
     public List<Object> readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
                     MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
 
-        try (BufferedReader bufferedReader =
-                        new BufferedReader(new InputStreamReader(entityStream, StandardCharsets.UTF_8))) {
+        try (var bufferedReader = new BufferedReader(new InputStreamReader(entityStream, StandardCharsets.UTF_8))) {
             List<Object> messages = new LinkedList<>();
             String msg;
             while ((msg = bufferedReader.readLine()) != null) {
index b9e0efa..3d4e1c6 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019, 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.
@@ -39,11 +39,11 @@ public class DmaapSimActivator extends ServiceManagerContainer {
     public DmaapSimActivator(final DmaapSimParameterGroup dmaapSimParameterGroup) {
         super("DMaaP Simulator");
 
-        DmaapSimProvider provider = new DmaapSimProvider(dmaapSimParameterGroup);
+        var provider = new DmaapSimProvider(dmaapSimParameterGroup);
         DmaapSimProvider.setInstance(provider);
         addAction("Sim Provider", provider::start, provider::stop);
 
-        DmaapSimRestServer restServer = new DmaapSimRestServer(dmaapSimParameterGroup.getRestServerParameters());
+        var restServer = new DmaapSimRestServer(dmaapSimParameterGroup.getRestServerParameters());
         addAction("REST server", restServer::start, restServer::stop);
     }
 }
index 2c6c540..e136509 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2021 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019, 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.
@@ -46,11 +46,11 @@ public class Main {
      * @param args the command line arguments
      */
     public Main(final String[] args) {
-        final String argumentString = Arrays.toString(args);
+        final var argumentString = Arrays.toString(args);
         LOGGER.info("Starting DMaaP simulator service with arguments - {}", argumentString);
 
         // Check the arguments
-        final DmaapSimCommandLineArguments arguments = new DmaapSimCommandLineArguments();
+        final var arguments = new DmaapSimCommandLineArguments();
         try {
             // The arguments return a string if there is a message to print and we should exit
             final String argumentMessage = arguments.parse(args);
index 430b896..1bc2ff7 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
- *  Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019-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.
@@ -89,7 +89,7 @@ public class PdpSimulatorActivator {
         topicSources = TopicEndpointManager.getManager()
                         .addTopicSources(pdpSimulatorParameterGroup.getTopicParameterGroup().getTopicSources());
 
-        final int random = RANDOM.nextInt();
+        final var random = RANDOM.nextInt();
         final String instanceId = "pdp_" + random;
         LOGGER.debug("PdpSimulatorActivator initializing with instance id: {}", instanceId);
         try {
@@ -99,8 +99,8 @@ public class PdpSimulatorActivator {
             throw new PdpSimulatorRunTimeException(e);
         }
 
-        final PdpUpdateListener pdpUpdateListener = new PdpUpdateListener();
-        final PdpStateChangeListener pdpStateChangeListener = new PdpStateChangeListener();
+        final var pdpUpdateListener = new PdpUpdateListener();
+        final var pdpStateChangeListener = new PdpStateChangeListener();
         // @formatter:off
         this.manager = new ServiceManager()
             .addAction("topics",
@@ -139,7 +139,7 @@ public class PdpSimulatorActivator {
      * Method to stop and unregister the pdp status publisher.
      */
     private void stopAndRemovePdpStatusPublisher() {
-        final PdpStatusPublisher pdpStatusPublisher =
+        final var pdpStatusPublisher =
                 Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
         pdpStatusPublisher.terminate();
         Registry.unregister(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER);
@@ -175,7 +175,7 @@ public class PdpSimulatorActivator {
             throw new IllegalStateException("activator is not running");
         }
         try {
-            final PdpStatusPublisher pdpStatusPublisher =
+            final var pdpStatusPublisher =
                     Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
             // send a final heartbeat with terminated status
             pdpStatusPublisher.send(new PdpMessageHandler().getTerminatedPdpStatus());
index 0d92aee..57fc8a1 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2021 Nordix Foundation.
- *  Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019-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.
@@ -56,7 +56,7 @@ public class PdpSimulatorMain {
         }
 
         // Check the arguments
-        final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments();
+        final var arguments = new PdpSimulatorCommandLineArguments();
         try {
             // The arguments return a string if there is a message to print and we should exit
             final String argumentMessage = arguments.parse(args);
index b64967f..e490fe7 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 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,7 +59,7 @@ public class PdpStatusPublisher extends TimerTask {
 
     @Override
     public void run() {
-        final PdpStatus pdpStatus = new PdpMessageHandler().createPdpStatusFromContext();
+        final var pdpStatus = new PdpMessageHandler().createPdpStatusFromContext();
         topicSinkClient.send(pdpStatus);
         LOGGER.debug("Sent heartbeat to PAP - {}", pdpStatus);
     }
index 6e628cc..ae028dd 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2021 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019, 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.
@@ -51,7 +51,7 @@ public class PdpMessageHandler {
      */
     public PdpStatus createPdpStatusFromParameters(final String instanceId,
             final PdpStatusParameters pdpStatusParameters) {
-        final PdpStatus pdpStatus = new PdpStatus();
+        final var pdpStatus = new PdpStatus();
         pdpStatus.setPdpGroup(pdpStatusParameters.getPdpGroup());
         pdpStatus.setPdpType(pdpStatusParameters.getPdpType());
         pdpStatus.setState(PdpState.PASSIVE);
@@ -67,8 +67,8 @@ public class PdpMessageHandler {
      * @return PdpStatus the pdp status message
      */
     public PdpStatus createPdpStatusFromContext() {
-        final PdpStatus pdpStatusContext = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
-        final PdpStatus pdpStatus = new PdpStatus();
+        final var pdpStatusContext = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+        final var pdpStatus = new PdpStatus();
         pdpStatus.setName(pdpStatusContext.getName());
         pdpStatus.setPdpType(pdpStatusContext.getPdpType());
         pdpStatus.setState(pdpStatusContext.getState());
@@ -86,7 +86,7 @@ public class PdpMessageHandler {
      * @return PdpStatus the pdp status message
      */
     public PdpStatus getTerminatedPdpStatus() {
-        final PdpStatus pdpStatusInContext = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+        final var pdpStatusInContext = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
         pdpStatusInContext.setState(PdpState.TERMINATED);
         pdpStatusInContext.setDescription("Pdp Simulator shutting down.");
         return createPdpStatusFromContext();
@@ -103,7 +103,7 @@ public class PdpMessageHandler {
      */
     public PdpResponseDetails createPdpResonseDetails(final String requestId, final PdpResponseStatus status,
             final String responseMessage) {
-        final PdpResponseDetails pdpResponseDetails = new PdpResponseDetails();
+        final var pdpResponseDetails = new PdpResponseDetails();
         pdpResponseDetails.setResponseTo(requestId);
         pdpResponseDetails.setResponseStatus(status);
         pdpResponseDetails.setResponseMessage(responseMessage);
index 9df1aa1..4f9804f 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019, 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,9 +45,10 @@ public class PdpStateChangeMessageHandler {
      * @param pdpStateChangeMsg pdp state change message
      */
     public void handlePdpStateChangeEvent(final PdpStateChange pdpStateChangeMsg) {
-        final PdpStatus pdpStatusContext = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
-        final PdpStatusPublisher pdpStatusPublisher = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER);
-        final PdpMessageHandler pdpMessageHandler = new PdpMessageHandler();
+        final var pdpStatusContext = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+        final var pdpStatusPublisher =
+                        Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
+        final var pdpMessageHandler = new PdpMessageHandler();
         PdpResponseDetails pdpResponseDetails = null;
         if (pdpStateChangeMsg.appliesTo(pdpStatusContext.getName(), pdpStatusContext.getPdpGroup(),
                 pdpStatusContext.getPdpSubgroup())) {
@@ -61,7 +62,7 @@ public class PdpStateChangeMessageHandler {
                 default:
                     break;
             }
-            final PdpStatus pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
+            final var pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
             pdpStatus.setResponse(pdpResponseDetails);
             pdpStatus.setDescription("Pdp status response message for PdpStateChange");
             pdpStatusPublisher.send(pdpStatus);
index 5b77f47..2262ee9 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019, 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,12 +45,13 @@ public class PdpUpdateMessageHandler {
      * @param pdpUpdateMsg pdp update message
      */
     public void handlePdpUpdateEvent(final PdpUpdate pdpUpdateMsg) {
-        final PdpMessageHandler pdpMessageHandler = new PdpMessageHandler();
-        final PdpStatus pdpStatusContext = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+        final var pdpMessageHandler = new PdpMessageHandler();
+        final var pdpStatusContext = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
         PdpResponseDetails pdpResponseDetails = null;
         if (pdpUpdateMsg.appliesTo(pdpStatusContext.getName(), pdpStatusContext.getPdpGroup(),
-                pdpStatusContext.getPdpSubgroup())) {
-            final PdpStatusPublisher pdpStatusPublisher = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER);
+                        pdpStatusContext.getPdpSubgroup())) {
+            final var pdpStatusPublisher =
+                            Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
             if (checkIfAlreadyHandled(pdpUpdateMsg, pdpStatusContext)) {
                 pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(),
                         PdpResponseStatus.SUCCESS, "Pdp already updated");
@@ -73,9 +74,9 @@ public class PdpUpdateMessageHandler {
                             PdpResponseStatus.SUCCESS, "Pdp update successful.");
                 }
             }
-            final PdpStatusPublisher pdpStatusPublisherTemp =
-                    Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER);
-            final PdpStatus pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
+            final var pdpStatusPublisherTemp =
+                    Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
+            final var pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
             pdpStatus.setResponse(pdpResponseDetails);
             pdpStatus.setDescription("Pdp status response message for PdpUpdate");
             pdpStatusPublisherTemp.send(pdpStatus);
@@ -111,7 +112,8 @@ public class PdpUpdateMessageHandler {
      * @param interval time interval received in the pdp update message from pap
      */
     public void updateInterval(final long interval) {
-        final PdpStatusPublisher pdpStatusPublisher = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER);
+        final var pdpStatusPublisher =
+                        Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
         pdpStatusPublisher.terminate();
         final List<TopicSink> topicSinks = Registry.get(PdpSimulatorConstants.REG_PDP_TOPIC_SINKS);
         Registry.registerOrReplace(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER,
index bf514f2..d86e0b4 100644 (file)
@@ -55,7 +55,7 @@ public class PdpSimulatorParameterHandler {
         // Read the parameters
         try {
             // Read the parameters from JSON
-            final File file = new File(arguments.getFullConfigurationFilePath());
+            final var file = new File(arguments.getFullConfigurationFilePath());
             pdpSimulatorParameterGroup = CODER.decode(file, PdpSimulatorParameterGroup.class);
         } catch (final CoderException e) {
             final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
index f82423c..4c29991 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -165,7 +165,7 @@ public class Main extends ServiceManagerContainer {
 
     private SimulatorParameters readParameters(String paramFile) {
         try {
-            String paramsJson = getResourceAsString(paramFile);
+            var paramsJson = getResourceAsString(paramFile);
             if (paramsJson == null) {
                 throw new IllegalArgumentException(new FileNotFoundException(paramFile));
             }
@@ -183,14 +183,14 @@ public class Main extends ServiceManagerContainer {
     }
 
     private DmaapSimProvider buildDmaapProvider(DmaapSimParameterGroup params) {
-        DmaapSimProvider prov = new DmaapSimProvider(params);
+        var prov = new DmaapSimProvider(params);
         DmaapSimProvider.setInstance(prov);
         prov.start();
         return prov;
     }
 
     private CdsSimulator buildCdsSimulator(CdsServerParameters params) throws IOException {
-        CdsSimulator cdsSimulator = new CdsSimulator(params.getHost(), params.getPort(), params.getResourceLocation(),
+        var cdsSimulator = new CdsSimulator(params.getHost(), params.getPort(), params.getResourceLocation(),
             params.getSuccessRepeatCount(), params.getRequestedResponseDelayMs());
         cdsSimulator.start();
         return cdsSimulator;
@@ -211,7 +211,7 @@ public class Main extends ServiceManagerContainer {
 
     private HttpServletServer buildRestServer(String dmaapName, ClassRestServerParameters params) {
         try {
-            Properties props = getServerProperties(dmaapName, params);
+            var props = getServerProperties(dmaapName, params);
             HttpServletServer testServer = makeServer(props);
             testServer.waitedStart(5000);
 
@@ -263,7 +263,7 @@ public class Main extends ServiceManagerContainer {
      * @return a set of properties representing the given parameters
      */
     private static Properties getServerProperties(String dmaapName, ClassRestServerParameters params) {
-        final Properties props = new Properties();
+        final var props = new Properties();
         props.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES, params.getName());
 
         final String svcpfx = PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + params.getName();
index 491585e..28c4f42 100644 (file)
@@ -80,7 +80,7 @@ public class SimulatorParameters {
         if (dmaapProvider != null) {
             // do not want full validation of the provider, so validate the relevant
             // fields ourselves
-            BeanValidationResult subResult = new BeanValidationResult("dmaapProvider", dmaapProvider);
+            var subResult = new BeanValidationResult("dmaapProvider", dmaapProvider);
             subResult.validateNotNull("name", dmaapProvider.getName());
             if (dmaapProvider.getTopicSweepSec() < 1) {
                 subResult.addResult("topicSweepSec", dmaapProvider.getTopicSweepSec(),