Use singleton for api statistics

Reimplemented the statistics manager to use a singleton instead of
static fields.
Also changed some fields to "private".

Issue-ID: POLICY-3392
Change-Id: Ic708f7fa29cba795c47d387764267016163f679f
Signed-off-by: Jim Hahn <jrh3@att.com>
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
index 5e84508..eb60c5e 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
@@ -1093,7 +1093,8 @@
 

     private void updateApiStatisticsCounter(Target target, Result result, HttpMethod http) {

 

-        ApiStatisticsManager.updateTotalApiCallCount();

+        var mgr = ApiStatisticsManager.getInstance();

+        mgr.updateTotalApiCallCount();

 

         switch (target) {

             case POLICY:

@@ -1103,98 +1104,102 @@
                 updatePolicyTypeStats(result, http);

                 break;

             default:

-                ApiStatisticsManager.updateApiCallSuccessCount();

+                mgr.updateApiCallSuccessCount();

                 break;

         }

     }

 

     private void updatePolicyStats(Result result, HttpMethod http) {

+        var mgr = ApiStatisticsManager.getInstance();

+

         if (result == Result.SUCCESS) {

             switch (http) {

                 case GET:

-                    ApiStatisticsManager.updateApiCallSuccessCount();

-                    ApiStatisticsManager.updateTotalPolicyGetCount();

-                    ApiStatisticsManager.updatePolicyGetSuccessCount();

+                    mgr.updateApiCallSuccessCount();

+                    mgr.updateTotalPolicyGetCount();

+                    mgr.updatePolicyGetSuccessCount();

                     break;

                 case POST:

-                    ApiStatisticsManager.updateApiCallSuccessCount();

-                    ApiStatisticsManager.updateTotalPolicyPostCount();

-                    ApiStatisticsManager.updatePolicyPostSuccessCount();

+                    mgr.updateApiCallSuccessCount();

+                    mgr.updateTotalPolicyPostCount();

+                    mgr.updatePolicyPostSuccessCount();

                     break;

                 case DELETE:

-                    ApiStatisticsManager.updateApiCallSuccessCount();

-                    ApiStatisticsManager.updateTotalPolicyDeleteCount();

-                    ApiStatisticsManager.updatePolicyDeleteSuccessCount();

+                    mgr.updateApiCallSuccessCount();

+                    mgr.updateTotalPolicyDeleteCount();

+                    mgr.updatePolicyDeleteSuccessCount();

                     break;

                 default:

-                    ApiStatisticsManager.updateApiCallSuccessCount();

+                    mgr.updateApiCallSuccessCount();

                     break;

             }

         } else {

             switch (http) {

                 case GET:

-                    ApiStatisticsManager.updateApiCallFailureCount();

-                    ApiStatisticsManager.updateTotalPolicyGetCount();

-                    ApiStatisticsManager.updatePolicyGetFailureCount();

+                    mgr.updateApiCallFailureCount();

+                    mgr.updateTotalPolicyGetCount();

+                    mgr.updatePolicyGetFailureCount();

                     break;

                 case POST:

-                    ApiStatisticsManager.updateApiCallFailureCount();

-                    ApiStatisticsManager.updateTotalPolicyPostCount();

-                    ApiStatisticsManager.updatePolicyPostFailureCount();

+                    mgr.updateApiCallFailureCount();

+                    mgr.updateTotalPolicyPostCount();

+                    mgr.updatePolicyPostFailureCount();

                     break;

                 case DELETE:

-                    ApiStatisticsManager.updateApiCallFailureCount();

-                    ApiStatisticsManager.updateTotalPolicyDeleteCount();

-                    ApiStatisticsManager.updatePolicyDeleteFailureCount();

+                    mgr.updateApiCallFailureCount();

+                    mgr.updateTotalPolicyDeleteCount();

+                    mgr.updatePolicyDeleteFailureCount();

                     break;

                 default:

-                    ApiStatisticsManager.updateApiCallFailureCount();

+                    mgr.updateApiCallFailureCount();

                     break;

             }

         }

     }

 

     private void updatePolicyTypeStats(Result result, HttpMethod http) {

+        var mgr = ApiStatisticsManager.getInstance();

+

         if (result == Result.SUCCESS) {

             switch (http) {

                 case GET:

-                    ApiStatisticsManager.updateApiCallSuccessCount();

-                    ApiStatisticsManager.updateTotalPolicyTypeGetCount();

-                    ApiStatisticsManager.updatePolicyTypeGetSuccessCount();

+                    mgr.updateApiCallSuccessCount();

+                    mgr.updateTotalPolicyTypeGetCount();

+                    mgr.updatePolicyTypeGetSuccessCount();

                     break;

                 case POST:

-                    ApiStatisticsManager.updateApiCallSuccessCount();

-                    ApiStatisticsManager.updateTotalPolicyTypePostCount();

-                    ApiStatisticsManager.updatePolicyTypePostSuccessCount();

+                    mgr.updateApiCallSuccessCount();

+                    mgr.updateTotalPolicyTypePostCount();

+                    mgr.updatePolicyTypePostSuccessCount();

                     break;

                 case DELETE:

-                    ApiStatisticsManager.updateApiCallSuccessCount();

-                    ApiStatisticsManager.updateTotalPolicyTypeDeleteCount();

-                    ApiStatisticsManager.updatePolicyTypeDeleteSuccessCount();

+                    mgr.updateApiCallSuccessCount();

+                    mgr.updateTotalPolicyTypeDeleteCount();

+                    mgr.updatePolicyTypeDeleteSuccessCount();

                     break;

                 default:

-                    ApiStatisticsManager.updateApiCallSuccessCount();

+                    mgr.updateApiCallSuccessCount();

                     break;

             }

         } else {

             switch (http) {

                 case GET:

-                    ApiStatisticsManager.updateApiCallFailureCount();

-                    ApiStatisticsManager.updateTotalPolicyTypeGetCount();

-                    ApiStatisticsManager.updatePolicyTypeGetFailureCount();

+                    mgr.updateApiCallFailureCount();

+                    mgr.updateTotalPolicyTypeGetCount();

+                    mgr.updatePolicyTypeGetFailureCount();

                     break;

                 case POST:

-                    ApiStatisticsManager.updateApiCallFailureCount();

-                    ApiStatisticsManager.updateTotalPolicyTypePostCount();

-                    ApiStatisticsManager.updatePolicyTypePostFailureCount();

+                    mgr.updateApiCallFailureCount();

+                    mgr.updateTotalPolicyTypePostCount();

+                    mgr.updatePolicyTypePostFailureCount();

                     break;

                 case DELETE:

-                    ApiStatisticsManager.updateApiCallFailureCount();

-                    ApiStatisticsManager.updateTotalPolicyTypeDeleteCount();

-                    ApiStatisticsManager.updatePolicyTypeDeleteFailureCount();

+                    mgr.updateApiCallFailureCount();

+                    mgr.updateTotalPolicyTypeDeleteCount();

+                    mgr.updatePolicyTypeDeleteFailureCount();

                     break;

                 default:

-                    ApiStatisticsManager.updateApiCallFailureCount();

+                    mgr.updateApiCallFailureCount();

                     break;

             }

         }

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 5be9cf1..2a4a46a 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
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy API
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2020-2021 Bell Canada.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,6 @@
 
 package org.onap.policy.api.main.rest;
 
-import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 
@@ -32,79 +31,27 @@
  *
  * @author Chenfei Gao (cgao@research.att.com)
  */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ApiStatisticsManager {
-
+@Getter
+@NoArgsConstructor
+public class ApiStatisticsManager {
     @Getter
-    private static long totalApiCallCount;
+    private static ApiStatisticsManager instance = new ApiStatisticsManager();
 
-    @Getter
-    private static long apiCallSuccessCount;
-
-    @Getter
-    private static long apiCallFailureCount;
-
-    @Getter
-    private static long totalPolicyGetCount;
-
-    @Getter
-    private static long totalPolicyPostCount;
-
-    @Getter
-    private static long totalPolicyDeleteCount;
-
-    @Getter
-    private static long totalPolicyTypeGetCount;
-
-    @Getter
-    private static long totalPolicyTypePostCount;
-
-    @Getter
-    private static long totalPolicyTypeDeleteCount;
-
-    @Getter
-    private static long policyGetSuccessCount;
-
-    @Getter
-    private static long policyGetFailureCount;
-
-    @Getter
-    private static long policyPostSuccessCount;
-
-    @Getter
-    private static long policyPostFailureCount;
-
-    @Getter
-    private static long policyDeleteSuccessCount;
-
-    @Getter
-    private static long policyDeleteFailureCount;
-
-    @Getter
-    private static long policyTypeGetSuccessCount;
-
-    @Getter
-    private static long policyTypeGetFailureCount;
-
-    @Getter
-    private static long policyTypePostSuccessCount;
-
-    @Getter
-    private static long policyTypePostFailureCount;
-
-    @Getter
-    private static long policyTypeDeleteSuccessCount;
-
-    @Getter
-    private static long policyTypeDeleteFailureCount;
+    private StatisticsReport report = new StatisticsReport();
+    private long totalPolicyDeleteCount;
+    private long totalPolicyTypeDeleteCount;
+    private long policyDeleteSuccessCount;
+    private long policyDeleteFailureCount;
+    private long policyTypeDeleteSuccessCount;
+    private long policyTypeDeleteFailureCount;
 
     /**
      * Method to update the total api call count.
      *
      * @return the updated value of totalApiCallCount
      */
-    public static long updateTotalApiCallCount() {
-        return ++totalApiCallCount;
+    public long updateTotalApiCallCount() {
+        return ++report.totalApiCallCount;
     }
 
     /**
@@ -112,8 +59,8 @@
      *
      * @return the updated value of apiCallSuccessCount
      */
-    public static long updateApiCallSuccessCount() {
-        return ++apiCallSuccessCount;
+    public long updateApiCallSuccessCount() {
+        return ++report.apiCallSuccessCount;
     }
 
     /**
@@ -121,8 +68,8 @@
      *
      * @return the updated value of apiCallFailureCount
      */
-    public static long updateApiCallFailureCount() {
-        return ++apiCallFailureCount;
+    public long updateApiCallFailureCount() {
+        return ++report.apiCallFailureCount;
     }
 
     /**
@@ -130,8 +77,8 @@
      *
      * @return the updated value of totalPolicyGetCount
      */
-    public static long updateTotalPolicyGetCount() {
-        return ++totalPolicyGetCount;
+    public long updateTotalPolicyGetCount() {
+        return ++report.totalPolicyGetCount;
     }
 
     /**
@@ -139,8 +86,8 @@
      *
      * @return the updated value of totalPolicyPostCount
      */
-    public static long updateTotalPolicyPostCount() {
-        return ++totalPolicyPostCount;
+    public long updateTotalPolicyPostCount() {
+        return ++report.totalPolicyPostCount;
     }
 
     /**
@@ -148,7 +95,7 @@
      *
      * @return the updated value of  totalPolicyDeleteCount
      */
-    public static long updateTotalPolicyDeleteCount() {
+    public long updateTotalPolicyDeleteCount() {
         return ++totalPolicyDeleteCount;
     }
 
@@ -157,8 +104,8 @@
      *
      * @return the updated value of totalPolicyTypeGetCount
      */
-    public static long updateTotalPolicyTypeGetCount() {
-        return ++totalPolicyTypeGetCount;
+    public long updateTotalPolicyTypeGetCount() {
+        return ++report.totalPolicyTypeGetCount;
     }
 
     /**
@@ -166,8 +113,8 @@
      *
      * @return the updated value of totalPolicyTypePostCount
      */
-    public static long updateTotalPolicyTypePostCount() {
-        return ++totalPolicyTypePostCount;
+    public long updateTotalPolicyTypePostCount() {
+        return ++report.totalPolicyTypePostCount;
     }
 
     /**
@@ -175,7 +122,7 @@
      *
      * @return the updated value of totalPolicyTypeDeleteCount
      */
-    public static long updateTotalPolicyTypeDeleteCount() {
+    public long updateTotalPolicyTypeDeleteCount() {
         return ++totalPolicyTypeDeleteCount;
     }
 
@@ -184,8 +131,8 @@
      *
      * @return the updated value of policyGetSuccessCount
      */
-    public static long updatePolicyGetSuccessCount() {
-        return ++policyGetSuccessCount;
+    public long updatePolicyGetSuccessCount() {
+        return ++report.policyGetSuccessCount;
     }
 
     /**
@@ -193,8 +140,8 @@
      *
      * @return the updated value of policyGetFailureCount
      */
-    public static long updatePolicyGetFailureCount() {
-        return ++policyGetFailureCount;
+    public long updatePolicyGetFailureCount() {
+        return ++report.policyGetFailureCount;
     }
 
     /**
@@ -202,8 +149,8 @@
      *
      * @return the updated value of policyPostSuccessCount
      */
-    public static long updatePolicyPostSuccessCount() {
-        return ++policyPostSuccessCount;
+    public long updatePolicyPostSuccessCount() {
+        return ++report.policyPostSuccessCount;
     }
 
     /**
@@ -211,8 +158,8 @@
      *
      * @return the updated value of policyPostFailureCount
      */
-    public static long updatePolicyPostFailureCount() {
-        return ++policyPostFailureCount;
+    public long updatePolicyPostFailureCount() {
+        return ++report.policyPostFailureCount;
     }
 
     /**
@@ -220,7 +167,7 @@
      *
      * @return the updated value of policyDeleteSuccessCount
      */
-    public static long updatePolicyDeleteSuccessCount() {
+    public long updatePolicyDeleteSuccessCount() {
         return ++policyDeleteSuccessCount;
     }
 
@@ -229,7 +176,7 @@
      *
      * @return the updated value of policyDeleteFailureCount
      */
-    public static long updatePolicyDeleteFailureCount() {
+    public long updatePolicyDeleteFailureCount() {
         return ++policyDeleteFailureCount;
     }
 
@@ -238,8 +185,8 @@
      *
      * @return the updated value of policyTypeGetSuccessCount
      */
-    public static long updatePolicyTypeGetSuccessCount() {
-        return ++policyTypeGetSuccessCount;
+    public long updatePolicyTypeGetSuccessCount() {
+        return ++report.policyTypeGetSuccessCount;
     }
 
     /**
@@ -247,8 +194,8 @@
      *
      * @return the updated value of policyTypeGetFailureCount
      */
-    public static long updatePolicyTypeGetFailureCount() {
-        return ++policyTypeGetFailureCount;
+    public long updatePolicyTypeGetFailureCount() {
+        return ++report.policyTypeGetFailureCount;
     }
 
     /**
@@ -256,8 +203,8 @@
      *
      * @return the updated value of policyTypePostSuccessCount
      */
-    public static long updatePolicyTypePostSuccessCount() {
-        return ++policyTypePostSuccessCount;
+    public long updatePolicyTypePostSuccessCount() {
+        return ++report.policyTypePostSuccessCount;
     }
 
     /**
@@ -265,8 +212,8 @@
      *
      * @return the updated value of policyTypePostFailureCount
      */
-    public static long updatePolicyTypePostFailureCount() {
-        return ++policyTypePostFailureCount;
+    public long updatePolicyTypePostFailureCount() {
+        return ++report.policyTypePostFailureCount;
     }
 
     /**
@@ -274,7 +221,7 @@
      *
      * @return the updated value of policyTypeDeleteSuccessCount
      */
-    public static long updatePolicyTypeDeleteSuccessCount() {
+    public long updatePolicyTypeDeleteSuccessCount() {
         return ++policyTypeDeleteSuccessCount;
     }
 
@@ -283,36 +230,14 @@
      *
      * @return the updated value of policyTypePostFailureCount
      */
-    public static long updatePolicyTypeDeleteFailureCount() {
+    public long updatePolicyTypeDeleteFailureCount() {
         return ++policyTypeDeleteFailureCount;
     }
 
     /**
-     * Reset all the statistics counts to 0.
+     * Resets the statistics.
      */
-    public static void resetAllStatistics() {
-        totalApiCallCount = 0L;
-        apiCallSuccessCount = 0L;
-        apiCallFailureCount = 0L;
-        totalPolicyGetCount = 0L;
-        totalPolicyPostCount = 0L;
-        totalPolicyDeleteCount = 0L;
-        totalPolicyTypeGetCount = 0L;
-        totalPolicyTypePostCount = 0L;
-        totalPolicyTypeDeleteCount = 0L;
-        policyGetSuccessCount = 0L;
-        policyGetFailureCount = 0L;
-        policyPostSuccessCount = 0L;
-        policyPostFailureCount = 0L;
-        policyDeleteSuccessCount = 0L;
-        policyDeleteFailureCount = 0L;
-        policyTypeGetSuccessCount = 0L;
-        policyTypeGetFailureCount = 0L;
-        policyTypePostSuccessCount = 0L;
-        policyTypePostFailureCount = 0L;
-        policyTypeDeleteSuccessCount = 0L;
-        policyTypeDeleteFailureCount = 0L;
-
+    protected static void resetAllStatistics() {
+        instance = new ApiStatisticsManager();
     }
-
 }
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 e434f04..bf12c7f 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
@@ -37,19 +37,19 @@
 @Setter
 public class StatisticsReport {
     private int code;
-    private long totalApiCallCount;
-    private long apiCallSuccessCount;
-    private long apiCallFailureCount;
-    private long totalPolicyGetCount;
-    private long totalPolicyPostCount;
-    private long totalPolicyTypeGetCount;
-    private long totalPolicyTypePostCount;
-    private long policyGetSuccessCount;
-    private long policyGetFailureCount;
-    private long policyPostSuccessCount;
-    private long policyPostFailureCount;
-    private long policyTypeGetSuccessCount;
-    private long policyTypeGetFailureCount;
-    private long policyTypePostSuccessCount;
-    private long policyTypePostFailureCount;
+    protected long totalApiCallCount;
+    protected long apiCallSuccessCount;
+    protected long apiCallFailureCount;
+    protected long totalPolicyGetCount;
+    protected long totalPolicyPostCount;
+    protected long totalPolicyTypeGetCount;
+    protected long totalPolicyTypePostCount;
+    protected long policyGetSuccessCount;
+    protected long policyGetFailureCount;
+    protected long policyPostSuccessCount;
+    protected long policyPostFailureCount;
+    protected long policyTypeGetSuccessCount;
+    protected long policyTypeGetFailureCount;
+    protected long policyTypePostSuccessCount;
+    protected long policyTypePostFailureCount;
 }
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/StatisticsProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/StatisticsProvider.java
index dadc630..9df0047 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/provider/StatisticsProvider.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/provider/StatisticsProvider.java
@@ -40,23 +40,8 @@
      * @return Report containing API statistics
      */
     public StatisticsReport fetchCurrentStatistics() {
-        final var report = new StatisticsReport();
+        final var report = ApiStatisticsManager.getInstance().getReport();
         report.setCode(ApiActivator.isAlive() ? 200 : 500);
-        report.setTotalApiCallCount(ApiStatisticsManager.getTotalApiCallCount());
-        report.setApiCallSuccessCount(ApiStatisticsManager.getApiCallSuccessCount());
-        report.setApiCallFailureCount(ApiStatisticsManager.getApiCallFailureCount());
-        report.setTotalPolicyGetCount(ApiStatisticsManager.getTotalPolicyGetCount());
-        report.setTotalPolicyPostCount(ApiStatisticsManager.getTotalPolicyPostCount());
-        report.setTotalPolicyTypeGetCount(ApiStatisticsManager.getTotalPolicyTypeGetCount());
-        report.setTotalPolicyTypePostCount(ApiStatisticsManager.getTotalPolicyTypePostCount());
-        report.setPolicyGetSuccessCount(ApiStatisticsManager.getPolicyGetSuccessCount());
-        report.setPolicyGetFailureCount(ApiStatisticsManager.getPolicyGetFailureCount());
-        report.setPolicyPostSuccessCount(ApiStatisticsManager.getPolicyPostSuccessCount());
-        report.setPolicyPostFailureCount(ApiStatisticsManager.getPolicyPostFailureCount());
-        report.setPolicyTypeGetSuccessCount(ApiStatisticsManager.getPolicyTypeGetSuccessCount());
-        report.setPolicyTypeGetFailureCount(ApiStatisticsManager.getPolicyTypeGetFailureCount());
-        report.setPolicyTypePostSuccessCount(ApiStatisticsManager.getPolicyTypePostSuccessCount());
-        report.setPolicyTypePostFailureCount(ApiStatisticsManager.getPolicyTypePostFailureCount());
         return report;
     }
 }
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 a630ea9..156837d 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
@@ -3,7 +3,7 @@
  * ONAP Policy API
  * ================================================================================
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 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");
@@ -25,6 +25,7 @@
 package org.onap.policy.api.main.startstop;
 
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 import lombok.Setter;
 import org.onap.policy.api.main.exception.PolicyApiException;
 import org.onap.policy.api.main.parameters.ApiParameterGroup;
@@ -39,27 +40,19 @@
  * This class wraps a distributor so that it can be activated as a complete service together with all its api and
  * forwarding handlers.
  */
+@RequiredArgsConstructor
 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;
+    @Getter
+    private final ApiParameterGroup parameterGroup;
 
-    /**
-     * Instantiate the activator for policy api as a complete service.
-     *
-     * @param apiParameterGroup the parameters for the api service
-     */
-    public ApiActivator(final ApiParameterGroup apiParameterGroup) {
-        this.apiParameterGroup = apiParameterGroup;
-    }
+    private RestServer restServer;
 
     /**
      * Initialize api as a complete service.
@@ -69,7 +62,7 @@
     public void initialize() throws PolicyApiException {
         LOGGER.debug("Policy api starting as a service . . .");
         startApiRestServer();
-        registerToParameterService(apiParameterGroup);
+        registerToParameterService(parameterGroup);
         ApiActivator.setAlive(true);
         LOGGER.debug("Policy api started as a service");
     }
@@ -80,8 +73,8 @@
      * @throws PolicyApiException if server start fails
      */
     private void startApiRestServer() throws PolicyApiException {
-        apiParameterGroup.getRestServerParameters().setName(apiParameterGroup.getName());
-        restServer = new RestServer(apiParameterGroup.getRestServerParameters(), AafApiFilter.class,
+        parameterGroup.getRestServerParameters().setName(parameterGroup.getName());
+        restServer = new RestServer(parameterGroup.getRestServerParameters(), AafApiFilter.class,
                         ApiRestController.class);
         if (!restServer.start()) {
             throw new PolicyApiException("Failed to start api rest server. Check log for more details...");
@@ -95,7 +88,7 @@
      */
     public void terminate() throws PolicyApiException {
         try {
-            deregisterToParameterService(apiParameterGroup);
+            deregisterToParameterService(parameterGroup);
 
             if (ApiActivator.isAlive()) {
                 ApiActivator.setAlive(false);
@@ -129,4 +122,4 @@
             ParameterService.deregister(apiParameterGroup.getName());
         }
     }
-}
\ No newline at end of file
+}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
index aac37f1..ba3ad89 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
@@ -28,12 +28,9 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
 import java.security.SecureRandom;
 import java.util.Collections;
 import java.util.List;
@@ -226,20 +223,6 @@
     }
 
     @Test
-    public void testApiStatisticsConstructorIsPrivate() {
-
-        try {
-            final Constructor<ApiStatisticsManager> constructor = ApiStatisticsManager.class.getDeclaredConstructor();
-            assertTrue(Modifier.isPrivate(constructor.getModifiers()));
-            constructor.setAccessible(true);
-            constructor.newInstance();
-
-        } catch (final Exception exp) {
-            assertTrue(exp.getCause().toString().contains("Instantiation of the class is not allowed"));
-        }
-    }
-
-    @Test
     public void testCreatePolicyTypes() throws Exception {
         for (String resrcName : TOSCA_POLICYTYPE_RESOURCE_NAMES) {
             Response rawResponse = createResource(POLICYTYPES, resrcName);
@@ -815,22 +798,23 @@
     }
 
     private void updateApiStatistics() {
+        var mgr = ApiStatisticsManager.getInstance();
 
-        ApiStatisticsManager.updateTotalApiCallCount();
-        ApiStatisticsManager.updateApiCallSuccessCount();
-        ApiStatisticsManager.updateApiCallFailureCount();
-        ApiStatisticsManager.updateTotalPolicyGetCount();
-        ApiStatisticsManager.updateTotalPolicyPostCount();
-        ApiStatisticsManager.updateTotalPolicyTypeGetCount();
-        ApiStatisticsManager.updateTotalPolicyTypePostCount();
-        ApiStatisticsManager.updatePolicyGetSuccessCount();
-        ApiStatisticsManager.updatePolicyGetFailureCount();
-        ApiStatisticsManager.updatePolicyPostSuccessCount();
-        ApiStatisticsManager.updatePolicyPostFailureCount();
-        ApiStatisticsManager.updatePolicyTypeGetSuccessCount();
-        ApiStatisticsManager.updatePolicyTypeGetFailureCount();
-        ApiStatisticsManager.updatePolicyTypePostSuccessCount();
-        ApiStatisticsManager.updatePolicyTypePostFailureCount();
+        mgr.updateTotalApiCallCount();
+        mgr.updateApiCallSuccessCount();
+        mgr.updateApiCallFailureCount();
+        mgr.updateTotalPolicyGetCount();
+        mgr.updateTotalPolicyPostCount();
+        mgr.updateTotalPolicyTypeGetCount();
+        mgr.updateTotalPolicyTypePostCount();
+        mgr.updatePolicyGetSuccessCount();
+        mgr.updatePolicyGetFailureCount();
+        mgr.updatePolicyPostSuccessCount();
+        mgr.updatePolicyPostFailureCount();
+        mgr.updatePolicyTypeGetSuccessCount();
+        mgr.updatePolicyTypeGetFailureCount();
+        mgr.updatePolicyTypePostSuccessCount();
+        mgr.updatePolicyTypePostFailureCount();
     }
 
     private void validateStatisticsReport(final StatisticsReport report, final int code) {
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java
index 148ec1b..5f5c586 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java
@@ -4,6 +4,7 @@
  * ================================================================================
  * Copyright (C) 2019 IBM.
  * Modifications Copyright (C) 2020 Bell Canada.
+ * 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.
@@ -25,38 +26,34 @@
 
 import static org.junit.Assert.assertEquals;
 
-import org.junit.Before;
 import org.junit.Test;
 
 public class TestApiStatisticsManager {
 
-    @Before
-    public void setUp() {
-        ApiStatisticsManager.resetAllStatistics();
-    }
-
     @Test
     public void testUpdateMethods() {
-        assertEquals(1, ApiStatisticsManager.updateTotalApiCallCount());
-        assertEquals(1, ApiStatisticsManager.updateApiCallSuccessCount());
-        assertEquals(1, ApiStatisticsManager.updateApiCallFailureCount());
-        assertEquals(1, ApiStatisticsManager.updateTotalPolicyGetCount());
-        assertEquals(1, ApiStatisticsManager.updateTotalPolicyPostCount());
-        assertEquals(1, ApiStatisticsManager.updateTotalPolicyDeleteCount());
-        assertEquals(1, ApiStatisticsManager.updateTotalPolicyTypeGetCount());
-        assertEquals(1, ApiStatisticsManager.updateTotalPolicyTypePostCount());
-        assertEquals(1, ApiStatisticsManager.updateTotalPolicyTypeDeleteCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyGetSuccessCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyGetFailureCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyPostSuccessCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyPostFailureCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyDeleteSuccessCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyDeleteFailureCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyTypeGetSuccessCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyTypeGetFailureCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyTypePostSuccessCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyTypePostFailureCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyTypeDeleteSuccessCount());
-        assertEquals(1, ApiStatisticsManager.updatePolicyTypeDeleteFailureCount());
+        var mgr = new ApiStatisticsManager();
+
+        assertEquals(1, mgr.updateTotalApiCallCount());
+        assertEquals(1, mgr.updateApiCallSuccessCount());
+        assertEquals(1, mgr.updateApiCallFailureCount());
+        assertEquals(1, mgr.updateTotalPolicyGetCount());
+        assertEquals(1, mgr.updateTotalPolicyPostCount());
+        assertEquals(1, mgr.updateTotalPolicyDeleteCount());
+        assertEquals(1, mgr.updateTotalPolicyTypeGetCount());
+        assertEquals(1, mgr.updateTotalPolicyTypePostCount());
+        assertEquals(1, mgr.updateTotalPolicyTypeDeleteCount());
+        assertEquals(1, mgr.updatePolicyGetSuccessCount());
+        assertEquals(1, mgr.updatePolicyGetFailureCount());
+        assertEquals(1, mgr.updatePolicyPostSuccessCount());
+        assertEquals(1, mgr.updatePolicyPostFailureCount());
+        assertEquals(1, mgr.updatePolicyDeleteSuccessCount());
+        assertEquals(1, mgr.updatePolicyDeleteFailureCount());
+        assertEquals(1, mgr.updatePolicyTypeGetSuccessCount());
+        assertEquals(1, mgr.updatePolicyTypeGetFailureCount());
+        assertEquals(1, mgr.updatePolicyTypePostSuccessCount());
+        assertEquals(1, mgr.updatePolicyTypePostFailureCount());
+        assertEquals(1, mgr.updatePolicyTypeDeleteSuccessCount());
+        assertEquals(1, mgr.updatePolicyTypeDeleteFailureCount());
     }
 }
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
index 7541c50..e47a4ce 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy API
  * ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019-2021 Nordix Foundation.
  * Modifications Copyright (C) 2020 Bell Canada.
  * ================================================================================
@@ -81,12 +81,12 @@
             "policies/vCPE.policy.different.policy.fields.json";
     private static final String MULTIPLE_POLICIES_RESOURCE = "policies/vCPE.policies.optimization.input.tosca.json";
 
-    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON =
+    private static final String POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON =
             "policytypes/onap.policies.controlloop.operational.Common.yaml";
-    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS =
+    private static final String POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS =
             "policytypes/onap.policies.controlloop.operational.common.Drools.yaml";
     private static final String POLICY_RESOURCE_OPERATIONAL = "policies/vCPE.policy.operational.input.tosca.json";
-    public static final String POLICY_TYPE_OPERATIONAL_DROOLS = "onap.policies.controlloop.operational.common.Drools";
+    private static final String POLICY_TYPE_OPERATIONAL_DROOLS = "onap.policies.controlloop.operational.common.Drools";
 
     /**
      * Initializes parameters.
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
index 95f9386..355f3d4 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy API
  * ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019-2021 Nordix Foundation.
  * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
  * ================================================================================
@@ -64,15 +64,15 @@
             "policytypes/onap.policies.optimization.Resource.no.version.yaml";
     private static final String POLICY_TYPE_NAME_MONITORING = "onap.policies.monitoring.tcagen2";
 
-    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON =
+    private static final String POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON =
             "policytypes/onap.policies.controlloop.operational.Common.yaml";
-    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS =
+    private static final String POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS =
             "policytypes/onap.policies.controlloop.operational.common.Drools.yaml";
-    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_APEX =
+    private static final String POLICY_TYPE_RESOURCE_OPERATIONAL_APEX =
             "policytypes/onap.policies.controlloop.operational.common.Apex.yaml";
-    public static final String POLICY_TYPE_OPERATIONAL_COMMON = "onap.policies.controlloop.operational.Common";
-    public static final String POLICY_TYPE_OPERATIONAL_APEX = "onap.policies.controlloop.operational.common.Apex";
-    public static final String POLICY_TYPE_OPERATIONAL_DROOLS = "onap.policies.controlloop.operational.common.Drools";
+    private static final String POLICY_TYPE_OPERATIONAL_COMMON = "onap.policies.controlloop.operational.Common";
+    private static final String POLICY_TYPE_OPERATIONAL_APEX = "onap.policies.controlloop.operational.common.Apex";
+    private static final String POLICY_TYPE_OPERATIONAL_DROOLS = "onap.policies.controlloop.operational.common.Drools";
 
     /**
      * Initializes parameters.
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 b899e01..ccd0f14 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
@@ -1,7 +1,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) 2019, 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");
@@ -47,8 +47,8 @@
         final ApiParameterGroup parGroup = new ApiParameterHandler().getParameters(arguments);
         final ApiActivator activator = new ApiActivator(parGroup);
         activator.initialize();
-        assertTrue(activator.getApiParameterGroup().isValid());
-        assertEquals(CommonTestData.API_GROUP_NAME, activator.getApiParameterGroup().getName());
+        assertTrue(activator.getParameterGroup().isValid());
+        assertEquals(CommonTestData.API_GROUP_NAME, activator.getParameterGroup().getName());
         activator.terminate();
     }
 }