From 07be24fc1c3b87f6aae0d52a26283ec18d33e772 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 23 Jul 2021 15:14:12 -0400 Subject: Remove unused statistics methods The getPdpStatistics method should be removed as they're functionality has been subsumed by getFilteredPdpStatistics. Issue-ID: POLICY-3511 Change-Id: I98da98ac483705bea46ebaa0619257195be6b518 Signed-off-by: Jim Hahn --- .../provider/PdpStatisticsProvider.java | 28 ---------------- .../provider/PdpStatisticsProviderTest.java | 39 ---------------------- .../models/provider/PolicyModelsProvider.java | 9 ----- .../impl/DatabasePolicyModelsProviderImpl.java | 6 ---- .../impl/DummyPolicyModelsProviderImpl.java | 5 --- .../impl/DatabasePolicyModelsProviderTest.java | 7 ++-- .../models/provider/impl/DummyBadProviderImpl.java | 5 --- .../impl/DummyPolicyModelsProviderTest.java | 3 +- 8 files changed, 6 insertions(+), 96 deletions(-) diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java index 8e3f0128e..0b3f32cf5 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java @@ -49,34 +49,6 @@ public class PdpStatisticsProvider { private static final int DEFAULT_RECORD_COUNT = 10; private static final int MAX_RECORD_COUNT = 100; - /** - * Get PDP statistics. - * - * @param dao the DAO to use to access the database - * @param name the name of the PDP statistics to get, null to get all PDPs - * @return the PDP statistics found - * @throws PfModelException on errors getting PDP statistics - */ - public List getPdpStatistics(@NonNull final PfDao dao, final String name, final Instant timeStamp) - throws PfModelException { - return asPdpStatisticsList(dao.getFiltered(JpaPdpStatistics.class, PdpFilterParameters.builder().name(name) - .startTime(timeStamp).endTime(timeStamp).recordNum(MAX_RECORD_COUNT).build())); - } - - /** - * Get PDP statistics. - * - * @param dao the DAO to use to access the database - * @param name the name of the PDP statistics to get, null to get all PDPs - * @return the PDP statistics found - * @throws PfModelException on errors getting PDP statistics - */ - public List getPdpStatistics(@NonNull final PfDao dao, final String name) - throws PfModelException { - return asPdpStatisticsList(dao.getFiltered(JpaPdpStatistics.class, - PdpFilterParameters.builder().name(name).recordNum(MAX_RECORD_COUNT).build())); - } - /** * Get filtered PDP statistics. * diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java index b308dbdcd..57f364336 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java @@ -186,45 +186,6 @@ public class PdpStatisticsProviderTest { .hasMessageContaining(Validated.IS_A_NULL_KEY); } - @Test - public void testGetPdpStatisticsName() throws Exception { - assertThatThrownBy(() -> { - new PdpStatisticsProvider().createPdpStatistics(null, null); - }).hasMessageMatching(DAO_IS_NULL); - assertThatThrownBy(() -> { - new PdpStatisticsProvider().getPdpStatistics(null, null); - }).hasMessageMatching(DAO_IS_NULL); - - List getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, NAME); - verifyEquals(getPdpStatisticsList, List.of(pdpStatistics12, pdpStatistics11)); - - // name is null - getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, null); - verifyEquals(getPdpStatisticsList, List.of(pdpStatistics12, pdpStatistics22, pdpStatistics11, pdpStatistics31)); - } - - @Test - public void testGetPdpStatisticsNameTimestamp() throws Exception { - assertThatThrownBy(() -> { - new PdpStatisticsProvider().createPdpStatistics(null, null); - }).hasMessageMatching(DAO_IS_NULL); - assertThatThrownBy(() -> { - new PdpStatisticsProvider().getPdpStatistics(null, null, null); - }).hasMessageMatching(DAO_IS_NULL); - - List getPdpStatisticsList; - getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, NAME, TIMESTAMP1); - verifyEquals(getPdpStatisticsList, List.of(pdpStatistics11)); - - // name is null - getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, null, TIMESTAMP1); - verifyEquals(getPdpStatisticsList, List.of(pdpStatistics11, pdpStatistics31)); - - // timestamp is null - getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, NAME, null); - verifyEquals(getPdpStatisticsList, List.of(pdpStatistics11, pdpStatistics12)); - } - @Test public void testGetFilteredPdpStatistics() throws Exception { diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java index 8782a6928..85aab6ec4 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java @@ -320,15 +320,6 @@ public interface PolicyModelsProvider extends AutoCloseable { */ public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException; - /** - * Get PDP statistics. - * - * @param name the name of the PDP group to get statistics for, null to get all PDP groups - * @return the statistics found - * @throws PfModelException on errors getting statistics - */ - public List getPdpStatistics(final String name, final Instant timestamp) throws PfModelException; - /** * Get filtered PdpStatistics. diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java index 95300e62d..05722d71b 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java @@ -250,12 +250,6 @@ public class DatabasePolicyModelsProviderImpl extends AbstractModelsProvider imp return new PdpProvider().deletePdpGroup(getPfDao(), name); } - @Override - public List getPdpStatistics(final String name, final Instant timestamp) throws PfModelException { - assertInitialized(); - return new PdpStatisticsProvider().getPdpStatistics(getPfDao(), name, timestamp); - } - @Override public List getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException { assertInitialized(); diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java index e705ae3ed..b9b34a24d 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java @@ -213,11 +213,6 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { return null; } - @Override - public List getPdpStatistics(final String name, final Instant timestamp) throws PfModelException { - return new ArrayList<>(); - } - @Override public List getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException { // Not implemented diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java index de7b28a60..57c261cb5 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java @@ -412,7 +412,7 @@ public class DatabasePolicyModelsProviderTest { List statisticsArrayList = makePdpStatisticsList(); - assertThat(databaseProvider.getPdpStatistics(null, null)).isEmpty(); + assertThat(databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().build())).isEmpty(); assertThat(databaseProvider.createPdpStatistics(statisticsArrayList)).hasSize(1); assertThat(databaseProvider.updatePdpStatistics(statisticsArrayList)).hasSize(1); } @@ -422,7 +422,8 @@ public class DatabasePolicyModelsProviderTest { databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters); databaseProvider.createPdpStatistics(makePdpStatisticsList()); - assertEquals(NAME, databaseProvider.getPdpStatistics(null, null).get(0).getPdpInstanceId()); + assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().build()).get(0) + .getPdpInstanceId()); assertEquals(NAME, databaseProvider.getFilteredPdpStatistics( PdpFilterParameters.builder().group(GROUP).build()).get(0).getPdpInstanceId()); assertEquals(0, databaseProvider.getFilteredPdpStatistics( @@ -460,7 +461,7 @@ public class DatabasePolicyModelsProviderTest { .sortOrder(ORDER).recordNum(5).build()).size()); assertEquals(NAME, databaseProvider.deletePdpStatistics(NAME, null).get(0).getPdpInstanceId()); - assertEquals(0, databaseProvider.getPdpStatistics(null, null).size()); + assertThat(databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().build())).isEmpty(); assertThat(databaseProvider.getAllPolicyStatus()).isEmpty(); assertThat(databaseProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy", null))) diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java index 224ef0e85..6cb95ee54 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java @@ -205,11 +205,6 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { // do nothing } - @Override - public List getPdpStatistics(final String name, final Instant timestamp) throws PfModelException { - return new ArrayList<>(); - } - @Override public List getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException { // Not implemented diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java index d7c69bbb2..ca4c2e573 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java @@ -113,7 +113,8 @@ public class DummyPolicyModelsProviderTest { dummyProvider.updatePdpSubGroup("name", new PdpSubGroup()); dummyProvider.updatePdp("name", "type", new Pdp()); dummyProvider.updatePdpStatistics(new ArrayList<>()); - assertTrue(dummyProvider.getPdpStatistics("name", null).isEmpty()); + assertThat(dummyProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().name("name").build())) + .isEmpty(); assertTrue( dummyProvider.getFilteredPdpStatistics( -- cgit 1.2.3-korg