aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2021-07-05 17:42:21 -0400
committerRam Krishna Verma <ram_krishna.verma@bell.ca>2021-07-05 17:45:53 -0400
commit49d86a99c3ed1920e3d999d85b7ae95a61b8d23a (patch)
treebc81bf42c1bc406989e4eacb858d489058b3ef41 /main/src
parente58c1431cdea1627b2c2043b5d932ad90730481d (diff)
Use lombok in policy/distribution
Issue-ID: POLICY-3393 Change-Id: I4221d8c6ecff3b529e7cd65f467bcf9bd3ac758d Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java159
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java33
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java21
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java13
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java5
5 files changed, 31 insertions, 200 deletions
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java b/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java
index 8b275501..107d7803 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -21,11 +22,18 @@
package org.onap.policy.distribution.main.rest;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
/**
* Class to represent statistics report of distribution service.
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
+@ToString
+@Getter
+@Setter
public class StatisticsReport {
private int code;
@@ -35,155 +43,4 @@ public class StatisticsReport {
private long totalDownloadCount;
private long downloadSuccessCount;
private long downloadFailureCount;
-
- /**
- * Returns the code of this {@link StatisticsReport} instance.
- *
- * @return the code
- */
- public int getCode() {
- return code;
- }
-
- /**
- * Set code in this {@link StatisticsReport} instance.
- *
- * @param code the code to set
- */
- public void setCode(final int code) {
- this.code = code;
- }
-
- /**
- * Returns the totalDistributionCount of this {@link StatisticsReport} instance.
- *
- * @return the totalDistributionCount
- */
- public long getTotalDistributionCount() {
- return totalDistributionCount;
- }
-
- /**
- * Set totalDistributionCount in this {@link StatisticsReport} instance.
- *
- * @param totalDistributionCount the totalDistributionCount to set
- */
- public void setTotalDistributionCount(final long totalDistributionCount) {
- this.totalDistributionCount = totalDistributionCount;
- }
-
- /**
- * Returns the distributionSuccessCount of this {@link StatisticsReport} instance.
- *
- * @return the distributionSuccessCount
- */
- public long getDistributionSuccessCount() {
- return distributionSuccessCount;
- }
-
- /**
- * Set distributionSuccessCount in this {@link StatisticsReport} instance.
- *
- * @param distributionSuccessCount the distributionSuccessCount to set
- */
- public void setDistributionSuccessCount(final long distributionSuccessCount) {
- this.distributionSuccessCount = distributionSuccessCount;
- }
-
- /**
- * Returns the distributionFailureCount of this {@link StatisticsReport} instance.
- *
- * @return the distributionFailureCount
- */
- public long getDistributionFailureCount() {
- return distributionFailureCount;
- }
-
- /**
- * Set distributionFailureCount in this {@link StatisticsReport} instance.
- *
- * @param distributionFailureCount the distributionFailureCount to set
- */
- public void setDistributionFailureCount(final long distributionFailureCount) {
- this.distributionFailureCount = distributionFailureCount;
- }
-
- /**
- * Returns the totalDownloadCount of this {@link StatisticsReport} instance.
- *
- * @return the totalDownloadCount
- */
- public long getTotalDownloadCount() {
- return totalDownloadCount;
- }
-
- /**
- * Set totalDownloadCount in this {@link StatisticsReport} instance.
- *
- * @param totalDownloadCount the totalDownloadCount to set
- */
- public void setTotalDownloadCount(final long totalDownloadCount) {
- this.totalDownloadCount = totalDownloadCount;
- }
-
- /**
- * Returns the downloadSuccessCount of this {@link StatisticsReport} instance.
- *
- * @return the downloadSuccessCount
- */
- public long getDownloadSuccessCount() {
- return downloadSuccessCount;
- }
-
- /**
- * Set downloadSuccessCount in this {@link StatisticsReport} instance.
- *
- * @param downloadSuccessCount the downloadSuccessCount to set
- */
- public void setDownloadSuccessCount(final long downloadSuccessCount) {
- this.downloadSuccessCount = downloadSuccessCount;
- }
-
- /**
- * Returns the downloadFailureCount of this {@link StatisticsReport} instance.
- *
- * @return the downloadFailureCount
- */
- public long getDownloadFailureCount() {
- return downloadFailureCount;
- }
-
- /**
- * Set downloadFailureCount in this {@link StatisticsReport} instance.
- *
- * @param downloadFailureCount the downloadFailureCount to set
- */
- public void setDownloadFailureCount(final long downloadFailureCount) {
- this.downloadFailureCount = downloadFailureCount;
- }
-
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append("StatisticsReport [code=");
- builder.append(getCode());
- builder.append(", totalDistributionCount=");
- builder.append(getTotalDistributionCount());
- builder.append(", distributionSuccessCount=");
- builder.append(getDistributionSuccessCount());
- builder.append(", distributionFailureCount=");
- builder.append(getDistributionFailureCount());
- builder.append(", totalDownloadCount=");
- builder.append(getTotalDownloadCount());
- builder.append(", downloadSuccessCount=");
- builder.append(getDownloadSuccessCount());
- builder.append(", downloadFailureCount=");
- builder.append(getDownloadFailureCount());
- builder.append("]");
- return builder.toString();
- }
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
index 3f19baf1..61210343 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -26,6 +27,8 @@ import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.common.endpoints.http.server.RestServer;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.main.PolicyDistributionException;
@@ -50,11 +53,14 @@ public class DistributionActivator {
private static final Logger LOGGER = LoggerFactory.getLogger(DistributionActivator.class);
// The parameters of this policy distribution activator
+ @Getter
private final DistributionParameterGroup distributionParameterGroup;
// The map of reception handlers initialized by this distribution activator
private final Map<String, AbstractReceptionHandler> receptionHandlersMap = new HashMap<>();
+ @Getter
+ @Setter
private static boolean alive = false;
private RestServer restServer;
@@ -134,15 +140,6 @@ public class DistributionActivator {
}
/**
- * Get the parameters used by the activator.
- *
- * @return the parameters of the activator
- */
- public DistributionParameterGroup getParameterGroup() {
- return distributionParameterGroup;
- }
-
- /**
* Method to register the parameters to Common Parameter Service.
*
* @param distributionParameterGroup the distribution parameter group
@@ -205,22 +202,4 @@ public class DistributionActivator {
}
//@formatter:on
}
-
- /**
- * Returns the alive status of distribution service.
- *
- * @return the alive
- */
- public static boolean isAlive() {
- return alive;
- }
-
- /**
- * Change the alive status of distribution service.
- *
- * @param status the status
- */
- public static void setAlive(final boolean status) {
- alive = status;
- }
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
index 64215e82..c15b1e3a 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
@@ -3,7 +3,7 @@
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,6 +25,7 @@
package org.onap.policy.distribution.main.startstop;
import java.util.Arrays;
+import lombok.Getter;
import org.onap.policy.common.utils.cmd.CommandLineException;
import org.onap.policy.common.utils.resources.MessageConstants;
import org.onap.policy.distribution.main.PolicyDistributionException;
@@ -46,7 +47,8 @@ public class Main {
private DistributionActivator activator;
// The parameters read in from JSON
- private DistributionParameterGroup parameterGroup;
+ @Getter
+ private DistributionParameterGroup distributionParameterGroup;
/**
* Instantiates the policy distribution service.
@@ -71,10 +73,10 @@ public class Main {
arguments.validate();
// Read the parameters
- parameterGroup = new DistributionParameterHandler().getParameters(arguments);
+ distributionParameterGroup = new DistributionParameterHandler().getParameters(arguments);
// Now, create the activator for the policy distribution service
- activator = new DistributionActivator(parameterGroup);
+ activator = new DistributionActivator(distributionParameterGroup);
// Start the activator
activator.initialize();
@@ -90,22 +92,13 @@ public class Main {
}
/**
- * Get the parameters specified in JSON.
- *
- * @return the parameters
- */
- public DistributionParameterGroup getParameters() {
- return parameterGroup;
- }
-
- /**
* Shut down Execution.
*
* @throws PolicyDistributionException on shutdown errors
*/
public void shutdown() throws PolicyDistributionException {
// clear the parameterGroup variable
- parameterGroup = null;
+ distributionParameterGroup = null;
// clear the distribution activator
if (activator != null) {
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java
index 6505dfbe..dd498bfa 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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,22 +60,22 @@ public class TestDistributionActivator {
final DistributionActivator activator = new DistributionActivator(parGroup);
activator.initialize();
- assertTrue(activator.getParameterGroup().isValid());
+ assertTrue(activator.getDistributionParameterGroup().isValid());
assertTrue(DistributionActivator.isAlive());
- assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, activator.getParameterGroup().getName());
+ assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, activator.getDistributionParameterGroup().getName());
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE,
- activator.getParameterGroup().getReceptionHandlerParameters()
+ activator.getDistributionParameterGroup().getReceptionHandlerParameters()
.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getReceptionHandlerType());
assertEquals(CommonTestData.DECODER_TYPE,
- activator.getParameterGroup().getReceptionHandlerParameters()
+ activator.getDistributionParameterGroup().getReceptionHandlerParameters()
.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getPluginHandlerParameters()
.getPolicyDecoders().get(CommonTestData.DUMMY_DECODER_KEY).getDecoderType());
assertEquals(CommonTestData.FORWARDER_TYPE,
- activator.getParameterGroup().getReceptionHandlerParameters()
+ activator.getDistributionParameterGroup().getReceptionHandlerParameters()
.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getPluginHandlerParameters()
.getPolicyForwarders().get(CommonTestData.DUMMY_ENGINE_FORWARDER_KEY).getForwarderType());
assertEquals(DummyPolicyForwarderParameterGroup.class,
- activator.getParameterGroup().getPolicyForwarderConfigurationParameters()
+ activator.getDistributionParameterGroup().getPolicyForwarderConfigurationParameters()
.get(CommonTestData.FORWARDER_CONFIGURATION_PARAMETERS).getClass());
activator.terminate();
assertFalse(DistributionActivator.isAlive());
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
index e00c1810..bdb2ba7d 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 AT&T Inc.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -53,8 +54,8 @@ public class TestMain {
CommonTestData.makeConfigFile("parameters/DistributionConfigParameters.json");
final String[] distributionConfigParameters = { "-c", CommonTestData.CONFIG_FILE };
final Main main = new Main(distributionConfigParameters);
- assertTrue(main.getParameters().isValid());
- assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, main.getParameters().getName());
+ assertTrue(main.getDistributionParameterGroup().isValid());
+ assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, main.getDistributionParameterGroup().getName());
main.shutdown();
}