Merge "Fix default timestamp in upgrade script"
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 4f1a4f3..ea5e49f 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -595,7 +595,10 @@
         return status;
     }
 
-    private PdpStatistics statisticsPayload() {
+    /**
+     * It provides a snapshot of the current statistics.
+     */
+    public PdpStatistics statisticsPayload() {
         PdpStatistics updateStats = new PdpStatistics(stats);
         updateStats.setTimeStamp(Instant.now());
 
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
index e996909..9af78ae 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
@@ -45,6 +45,7 @@
 import org.onap.policy.drools.lifecycle.LifecycleFeature;
 import org.onap.policy.drools.lifecycle.PolicyTypeController;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
 import org.onap.policy.models.pdp.concepts.PdpUpdate;
 import org.onap.policy.models.pdp.enums.PdpState;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -408,6 +409,17 @@
         return Response.status(Response.Status.OK).entity(Collections.emptyList()).build();
     }
 
+    /**
+     * Get current counts.
+     */
+
+    @GET
+    @Path("statistics")
+    @ApiOperation(value = "Gets Policy Statistics", response = PdpStatistics.class)
+    public Response stats() {
+        return Response.status(Response.Status.OK).entity(LifecycleFeature.getFsm().statisticsPayload()).build();
+    }
+
     private Response deployUndeployOperation(String policy, boolean deploy) {
         ToscaPolicy toscaPolicy = getToscaPolicy(policy);
         if (toscaPolicy == null) {
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
index 43d3fe3..de67c02 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 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.
@@ -91,8 +91,8 @@
     private static final String VCPE_OPERATIONAL_DROOLS_POLICY_JSON =
             "policies/vCPE.policy.operational.input.tosca.json";
 
-    private static StandardCoder coder = new StandardCoder();
-    private static ControllerSupport controllerSupport = new ControllerSupport("lifecycle");
+    private static final StandardCoder coder = new StandardCoder();
+    private static final ControllerSupport controllerSupport = new ControllerSupport("lifecycle");
 
     private LifecycleFsm fsm;
     private HttpClient client;
@@ -235,6 +235,7 @@
         resourceLists("policies", 2);
         get("policies/example.controller/1.0.0", Status.OK.getStatusCode());
         get("policies/example.artifact/1.0.0", Status.OK.getStatusCode());
+        get("statistics", Status.OK.getStatusCode());
 
         /* add tosca compliant operational policy */