From a03bfe0ac168a61a8c34329b2bfb73e360b812e1 Mon Sep 17 00:00:00 2001 From: ramverma Date: Thu, 13 Sep 2018 23:05:39 +0100 Subject: Adding statistics endpoint to distribution * Adding statistics endpoint in DistributionRestController * Adding DistributionStatisticsManager to hold all stats. * Adding StatisticsReport class to represent distribution stats report. * Updating stats at each step in SdcReceptionHandler. * Adding test cases for all code changes. Change-Id: I0b0f97aecc64b18314367fdff6d3ca7bee06efc7 Issue-ID: POLICY-1035 Signed-off-by: ramverma --- .../reception/handling/sdc/TestSdcReceptionHandler.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'plugins/reception-plugins/src/test/java') diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java index c4020a41..a8d15cb7 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java @@ -57,6 +57,7 @@ import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler; import org.onap.policy.distribution.reception.handling.PluginHandler; import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters; import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters; +import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; import org.onap.sdc.api.results.IDistributionClientDownloadResult; @@ -99,6 +100,7 @@ public class TestSdcReceptionHandler { */ @Before public final void init() throws IOException { + DistributionStatisticsManager.resetAllStatistics(); final Gson gson = new GsonBuilder().create(); pssdConfigParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"), SdcReceptionHandlerConfigurationParameterGroup.class); @@ -237,6 +239,12 @@ public class TestSdcReceptionHandler { assertTrue(policyDecoder.getDecodedPolicy().getPolicyName().contains(DUMMY_SERVICE_CSAR)); assertEquals(1, policyForwarder.getNumberOfPoliciesReceived()); assertTrue(policyForwarder.receivedPolicyWithGivenType(DummyDecoder.DUMMY_POLICY)); + assertEquals(1, DistributionStatisticsManager.getTotalDistributionCount()); + assertEquals(1, DistributionStatisticsManager.getDistributionSuccessCount()); + assertEquals(0, DistributionStatisticsManager.getDistributionFailureCount()); + assertEquals(1, DistributionStatisticsManager.getTotalDownloadCount()); + assertEquals(1, DistributionStatisticsManager.getDownloadSuccessCount()); + assertEquals(0, DistributionStatisticsManager.getDownloadFailureCount()); } @Test @@ -260,6 +268,12 @@ public class TestSdcReceptionHandler { assertEquals(null, policyDecoder.getDecodedPolicy()); assertEquals(0, policyForwarder.getNumberOfPoliciesReceived()); + assertEquals(1, DistributionStatisticsManager.getTotalDistributionCount()); + assertEquals(0, DistributionStatisticsManager.getDistributionSuccessCount()); + assertEquals(1, DistributionStatisticsManager.getDistributionFailureCount()); + assertEquals(1, DistributionStatisticsManager.getTotalDownloadCount()); + assertEquals(0, DistributionStatisticsManager.getDownloadSuccessCount()); + assertEquals(1, DistributionStatisticsManager.getDownloadFailureCount()); } @Test -- cgit 1.2.3-korg