aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2021-07-19 17:09:02 +0100
committera.sreekumar <ajith.sreekumar@bell.ca>2021-07-19 17:09:55 +0100
commitd3f2a5b966e49f4018d9913a2d91ed3a1f7cebbf (patch)
tree17b471a0450995cc4b7c5a54dec5f7c652c04bdd /main/src
parentc0b019187866fe832ba614ceaca1f764952c9ff2 (diff)
Use lombok annotations in policy-api
Change-Id: I858b3bff44804f3bf0c04bd637fafa0c01af2e57 Issue-ID: POLICY-3392 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java11
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java51
-rw-r--r--main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java33
-rw-r--r--main/src/main/java/org/onap/policy/api/main/startstop/Main.java13
-rw-r--r--main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java5
-rw-r--r--main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java6
6 files changed, 23 insertions, 96 deletions
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java
index c40a38c4..5be9cf1a 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java
@@ -3,7 +3,7 @@
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Bell Canada.
+ * Modifications Copyright (C) 2020-2021 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,14 +23,17 @@
package org.onap.policy.api.main.rest;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
/**
* Class to hold statistical data for API access.
*
* @author Chenfei Gao (cgao@research.att.com)
*/
-public class ApiStatisticsManager {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ApiStatisticsManager {
@Getter
private static long totalApiCallCount;
@@ -95,10 +98,6 @@ public class ApiStatisticsManager {
@Getter
private static long policyTypeDeleteFailureCount;
- private ApiStatisticsManager() {
- throw new IllegalStateException("Instantiation of the class is not allowed");
- }
-
/**
* Method to update the total api call count.
*
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java b/main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java
index 4919303f..e434f04a 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java
@@ -3,6 +3,7 @@
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019 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.
@@ -32,69 +33,23 @@ import lombok.ToString;
* @author Chenfei Gao (cgao@research.att.com)
*/
@ToString
+@Getter
+@Setter
public class StatisticsReport {
-
- @Getter
- @Setter
private int code;
-
- @Getter
- @Setter
private long totalApiCallCount;
-
- @Getter
- @Setter
private long apiCallSuccessCount;
-
- @Getter
- @Setter
private long apiCallFailureCount;
-
- @Getter
- @Setter
private long totalPolicyGetCount;
-
- @Getter
- @Setter
private long totalPolicyPostCount;
-
- @Getter
- @Setter
private long totalPolicyTypeGetCount;
-
- @Getter
- @Setter
private long totalPolicyTypePostCount;
-
- @Getter
- @Setter
private long policyGetSuccessCount;
-
- @Getter
- @Setter
private long policyGetFailureCount;
-
- @Getter
- @Setter
private long policyPostSuccessCount;
-
- @Getter
- @Setter
private long policyPostFailureCount;
-
- @Getter
- @Setter
private long policyTypeGetSuccessCount;
-
- @Getter
- @Setter
private long policyTypeGetFailureCount;
-
- @Getter
- @Setter
private long policyTypePostSuccessCount;
-
- @Getter
- @Setter
private long policyTypePostFailureCount;
}
diff --git a/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java b/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
index e52bc9a2..a630ea9b 100644
--- a/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
+++ b/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Copyright (C) 2019 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.
@@ -23,6 +24,8 @@
package org.onap.policy.api.main.startstop;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.api.main.rest.ApiRestController;
@@ -40,8 +43,11 @@ public class ApiActivator {
private static final Logger LOGGER = LoggerFactory.getLogger(ApiActivator.class);
+ @Getter
private final ApiParameterGroup apiParameterGroup;
+ @Getter
+ @Setter
private static boolean alive = false;
private RestServer restServer;
@@ -105,15 +111,6 @@ public class ApiActivator {
}
/**
- * Get the parameters used by the activator.
- *
- * @return the parameters of the activator
- */
- public ApiParameterGroup getParameterGroup() {
- return apiParameterGroup;
- }
-
- /**
* Method to register the parameters to Common Parameter Service.
*
* @param apiParameterGroup the api parameter group
@@ -132,22 +129,4 @@ public class ApiActivator {
ParameterService.deregister(apiParameterGroup.getName());
}
}
-
- /**
- * Returns the alive status of api service.
- *
- * @return the alive
- */
- public static boolean isAlive() {
- return alive;
- }
-
- /**
- * Change the alive status of api service.
- *
- * @param status the status
- */
- public static void setAlive(final boolean status) {
- alive = status;
- }
} \ No newline at end of file
diff --git a/main/src/main/java/org/onap/policy/api/main/startstop/Main.java b/main/src/main/java/org/onap/policy/api/main/startstop/Main.java
index 76de0173..21bd5c48 100644
--- a/main/src/main/java/org/onap/policy/api/main/startstop/Main.java
+++ b/main/src/main/java/org/onap/policy/api/main/startstop/Main.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Modifications Copyright (C) 2019, 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");
@@ -26,6 +26,7 @@
package org.onap.policy.api.main.startstop;
import java.util.Arrays;
+import lombok.Getter;
import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.exception.PolicyApiRuntimeException;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
@@ -47,6 +48,7 @@ public class Main {
private ApiActivator activator;
// The parameters read in from JSON
+ @Getter
private ApiParameterGroup parameterGroup;
/**
@@ -93,15 +95,6 @@ public class Main {
}
/**
- * Get the parameters specified in JSON.
- *
- * @return the parameters
- */
- public ApiParameterGroup getParameters() {
- return parameterGroup;
- }
-
- /**
* Shut down Execution.
*
* @throws PolicyApiException on shutdown errors
diff --git a/main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java b/main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java
index 3e482a62..b899e014 100644
--- a/main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java
+++ b/main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Copyright (C) 2019 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.
@@ -46,8 +47,8 @@ public class TestApiActivator {
final ApiParameterGroup parGroup = new ApiParameterHandler().getParameters(arguments);
final ApiActivator activator = new ApiActivator(parGroup);
activator.initialize();
- assertTrue(activator.getParameterGroup().isValid());
- assertEquals(CommonTestData.API_GROUP_NAME, activator.getParameterGroup().getName());
+ assertTrue(activator.getApiParameterGroup().isValid());
+ assertEquals(CommonTestData.API_GROUP_NAME, activator.getApiParameterGroup().getName());
activator.terminate();
}
}
diff --git a/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java
index 0c4eb4ed..6c8c514d 100644
--- a/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java
+++ b/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Modifications Copyright (C) 2019-2020 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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,8 +46,8 @@ public class TestMain {
"src/test/resources/parameters/ApiConfigParametersXXX.json", NetworkUtil.allocPort());
final String[] apiConfigParameters = {"-c", "src/test/resources/parameters/ApiConfigParametersXXX.json"};
final Main main = new Main(apiConfigParameters);
- assertTrue(main.getParameters().isValid());
- assertEquals(CommonTestData.API_GROUP_NAME, main.getParameters().getName());
+ assertTrue(main.getParameterGroup().isValid());
+ assertEquals(CommonTestData.API_GROUP_NAME, main.getParameterGroup().getName());
main.shutdown();
}