aboutsummaryrefslogtreecommitdiffstats
path: root/models-sim
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-10 09:53:23 -0400
committerJim Hahn <jrh3@att.com>2021-05-10 11:07:36 -0400
commit6372b62fcd8813d7d49fb279b933ffe2e4637048 (patch)
tree5d221f640ece91ce331f56d7bb6537a4393def3a /models-sim
parentda708d64dc27f36ed5da733fca14ebfb4cc2832b (diff)
Fix sonars in policy-models impls & simulators
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>
Diffstat (limited to 'models-sim')
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java2
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/ConsumerGroupData.java4
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/TopicData.java4
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java11
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestServer.java4
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java5
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/DmaapSimActivator.java6
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/Main.java6
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java12
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java4
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java3
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java12
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java11
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java20
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java2
-rw-r--r--models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java12
-rw-r--r--models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java2
17 files changed, 61 insertions, 59 deletions
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java
index 4485defaa..7c9f79b77 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java
@@ -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()
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/ConsumerGroupData.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/ConsumerGroupData.java
index 737151339..3acaf0888 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/ConsumerGroupData.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/ConsumerGroupData.java
@@ -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;
}
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/TopicData.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/TopicData.java
index 5da2adca0..8e5cf24cc 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/TopicData.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/TopicData.java
@@ -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);
}
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java
index b468e34c3..64ea29dca 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java
@@ -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);
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestServer.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestServer.java
index b05a0fe1a..acac1439b 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestServer.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestServer.java
@@ -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 =
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java
index 3c903c82b..c72b7482a 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java
@@ -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) {
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/DmaapSimActivator.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/DmaapSimActivator.java
index b9e0efaaf..3d4e1c66c 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/DmaapSimActivator.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/DmaapSimActivator.java
@@ -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);
}
}
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/Main.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/Main.java
index 2c6c54063..e136509c9 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/Main.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/Main.java
@@ -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);
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java
index 430b89637..1bc2ff72d 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java
@@ -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());
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java
index 0d92aee8d..57fc8a146 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java
@@ -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);
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java
index b64967fa9..e490fe76a 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java
@@ -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);
}
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java
index 6e628cc62..ae028dd32 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java
@@ -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);
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java
index 9df1aa103..4f9804f7e 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java
@@ -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);
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java
index 5b77f4704..2262ee938 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java
@@ -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,
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java
index bf514f2e9..d86e0b424 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java
@@ -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()
diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java
index f82423c11..4c299914b 100644
--- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java
+++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java
@@ -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();
diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java
index 491585e9c..28c4f42d2 100644
--- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java
+++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java
@@ -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(),