From c6430ad773f18da97ab25e2d9e92a120fd55c482 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 19 Jun 2019 14:24:31 -0400 Subject: Update totalPoliciesCount statistic Modified the code to set the policy count statistic at start-up and whenever the policy list is changed. Also fixed a couple of checkstyle issues in guard. Change-Id: I92017fe64cd5d19c36908347193cc21d183f051e Issue-ID: POLICY-1844 Signed-off-by: Jim Hahn --- .../org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java | 7 ++++++- .../org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'main/src/test/java') diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java index ba8f0044..7865851d 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java @@ -44,6 +44,8 @@ public class TestXacmlPdpRestServer extends CommonRest { private static final String HEALTHCHECK_ENDPOINT = "healthcheck"; private static final String STATISTICS_ENDPOINT = "statistics"; + private int nupdates = 0; + @Test public void testHealthCheckSuccess() throws Exception { LOGGER.info("***************************** Running testHealthCheckSuccess *****************************"); @@ -111,7 +113,9 @@ public class TestXacmlPdpRestServer extends CommonRest { private void updateXacmlPdpStatistics() { XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent(); - stats.updateTotalPoliciesCount(); + ++nupdates; + stats.setTotalPolicyCount(nupdates); + stats.setTotalPolicyTypesCount(nupdates); stats.updatePermitDecisionsCount(); stats.updateDenyDecisionsCount(); stats.updateIndeterminantDecisionsCount(); @@ -121,6 +125,7 @@ public class TestXacmlPdpRestServer extends CommonRest { private void validateStatisticsReport(final StatisticsReport report, final int count, final int code) { assertEquals(code, report.getCode()); assertEquals(count, report.getTotalPoliciesCount()); + assertEquals(count, report.getTotalPolicyTypesCount()); assertEquals(count, report.getPermitDecisionsCount()); assertEquals(count, report.getDenyDecisionsCount()); assertEquals(count, report.getIndeterminantDecisionsCount()); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java index 250f21e6..030b9075 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java @@ -37,6 +37,8 @@ public class TestXacmlPdpStatistics extends CommonRest { private static final Logger LOGGER = LoggerFactory.getLogger(TestXacmlPdpStatistics.class); + private int nupdates = 0; + @Test public void testXacmlPdpStatistics_200() throws Exception { LOGGER.info("*************************** Running testXacmlPdpStatistics_200 ***************************"); @@ -64,7 +66,9 @@ public class TestXacmlPdpStatistics extends CommonRest { private void updateXacmlPdpStatistics() { XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent(); - stats.updateTotalPoliciesCount(); + ++nupdates; + stats.setTotalPolicyCount(nupdates); + stats.setTotalPolicyTypesCount(nupdates); stats.updatePermitDecisionsCount(); stats.updateDenyDecisionsCount(); stats.updateIndeterminantDecisionsCount(); @@ -74,6 +78,7 @@ public class TestXacmlPdpStatistics extends CommonRest { private void validateReport(final StatisticsReport report, final int count, final int code) { assertEquals(code, report.getCode()); assertEquals(count, report.getTotalPoliciesCount()); + assertEquals(count, report.getTotalPolicyTypesCount()); assertEquals(count, report.getPermitDecisionsCount()); assertEquals(count, report.getDenyDecisionsCount()); assertEquals(count, report.getIndeterminantDecisionsCount()); -- cgit 1.2.3-korg