Use lombok annotations in policy-api 19/122719/1
authora.sreekumar <ajith.sreekumar@bell.ca>
Mon, 19 Jul 2021 16:09:02 +0000 (17:09 +0100)
committera.sreekumar <ajith.sreekumar@bell.ca>
Mon, 19 Jul 2021 16:09:55 +0000 (17:09 +0100)
Change-Id: I858b3bff44804f3bf0c04bd637fafa0c01af2e57
Issue-ID: POLICY-3392
Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java
main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java
main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
main/src/main/java/org/onap/policy/api/main/startstop/Main.java
main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java
main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java

index c40a38c..5be9cf1 100644 (file)
@@ -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.
 
 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.
      *
index 4919303..e434f04 100644 (file)
@@ -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;
 }
index e52bc9a..a630ea9 100644 (file)
@@ -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;
@@ -104,15 +110,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.
      *
@@ -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
index 76de017..21bd5c4 100644 (file)
@@ -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;
 
     /**
@@ -92,15 +94,6 @@ public class Main {
         LOGGER.info(successMsg);
     }
 
-    /**
-     * Get the parameters specified in JSON.
-     *
-     * @return the parameters
-     */
-    public ApiParameterGroup getParameters() {
-        return parameterGroup;
-    }
-
     /**
      * Shut down Execution.
      *
index 3e482a6..b899e01 100644 (file)
@@ -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();
     }
 }
index 0c4eb4e..6c8c514 100644 (file)
@@ -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();
     }