Remove unused DAO statistics methods 82/122582/1
authorJim Hahn <jrh3@att.com>
Mon, 12 Jul 2021 14:04:40 +0000 (10:04 -0400)
committerJim Hahn <jrh3@att.com>
Mon, 12 Jul 2021 14:07:36 +0000 (10:07 -0400)
The PDP statistics provider had several filter methods, at least one
of which has now been subsumed by another and is no longer being used.

Issue-ID: POLICY-3405
Change-Id: If603eaf3df36fd4e6e3555376bf1b95144ec8eb1
Signed-off-by: Jim Hahn <jrh3@att.com>
models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java
models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java

index ea118f3..195f51f 100644 (file)
@@ -25,9 +25,7 @@ package org.onap.policy.models.pdp.persistence.provider;
 
 import java.time.Instant;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.stream.Collectors;
 import javax.ws.rs.core.Response;
 import lombok.NonNull;
@@ -89,44 +87,6 @@ public class PdpStatisticsProvider {
         return pdpStatistics;
     }
 
-    /**
-     * Get filtered PDP statistics.
-     *
-     * @param dao the DAO to use to access the database
-     * @param name the pdpInstance name for the PDP statistics to get
-     * @param pdpGroupName pdpGroupName to filter statistics
-     * @param pdpSubGroup pdpSubGroupType name to filter statistics
-     * @param startTimeStamp startTimeStamp to filter statistics
-     * @param endTimeStamp endTimeStamp to filter statistics
-     * @param sortOrder sortOrder to query database
-     * @param getRecordNum Total query count from database
-     * @return the PDP statistics found
-     * @throws PfModelException on errors getting policies
-     */
-    public List<PdpStatistics> getFilteredPdpStatistics(@NonNull final PfDao dao, final String name,
-            @NonNull final String pdpGroupName, final String pdpSubGroup, final Instant startTimeStamp,
-            final Instant endTimeStamp, final String sortOrder, final int getRecordNum) {
-        Map<String, Object> filterMap = new HashMap<>();
-        filterMap.put("pdpGroupName", pdpGroupName);
-        if (pdpSubGroup != null) {
-            filterMap.put("pdpSubGroupName", pdpSubGroup);
-        }
-
-        // @formatter:off
-        return asPdpStatisticsList(
-                    dao.getFiltered(JpaPdpStatistics.class,
-                        PdpFilterParameters.builder()
-                            .name(name)
-                            .startTime(startTimeStamp)
-                            .endTime(endTimeStamp)
-                            .group(pdpGroupName)
-                            .subGroup(pdpSubGroup)
-                            .sortOrder(sortOrder)
-                            .recordNum(getRecordNum)
-                            .build()));
-        // @formatter:on
-    }
-
     /**
      * Get filtered PDP statistics.
      *
index 91eb54e..6f6d435 100644 (file)
@@ -52,7 +52,6 @@ public class PdpStatisticsProviderTest {
     private static final Instant TIMESTAMP2 = Instant.ofEpochSecond(1078884350);
     private static final Long GENERATEDID1 = 1L;
     private static final Long GENERATEDID2 = 2L;
-    private static final String ORDER = "DESC";
 
     private PfDao pfDao;
 
@@ -180,36 +179,6 @@ public class PdpStatisticsProviderTest {
         assertEquals(testListStr.replaceAll("\\s+", ""), gotListStr.replaceAll("\\s+", ""));
     }
 
-    @Test
-    public void testGetFilteredPdpStatisticsOld() throws Exception {
-        assertThatThrownBy(() -> {
-            new PdpStatisticsProvider().getFilteredPdpStatistics(null, NAME, GROUP, SUBGROUP, TIMESTAMP1, TIMESTAMP2,
-                    ORDER, 1);
-        }).hasMessageMatching(DAO_IS_NULL);
-
-        assertThatThrownBy(() -> {
-            new PdpStatisticsProvider().getFilteredPdpStatistics(pfDao, NAME, null, null, TIMESTAMP1, TIMESTAMP2, ORDER,
-                    1);
-        }).hasMessageMatching("pdpGroupName is marked .*ull but is null");
-
-
-        List<PdpStatistics> createdPdpStatisticsList;
-        createdPdpStatisticsList = new PdpStatisticsProvider().createPdpStatistics(pfDao, pdpStatisticsTestList);
-        createdListStr = createdPdpStatisticsList.toString();
-        assertEquals(createdListStr.replaceAll("\\s+", ""), testListStr.replaceAll("\\s+", ""));
-
-        List<PdpStatistics> getPdpStatisticsList;
-        getPdpStatisticsList = new PdpStatisticsProvider().getFilteredPdpStatistics(pfDao, NAME, GROUP, null,
-                TIMESTAMP1, TIMESTAMP2, ORDER, 0);
-        assertThat(getPdpStatisticsList).hasSize(1);
-        getPdpStatisticsList = new PdpStatisticsProvider().getFilteredPdpStatistics(pfDao, "name2", GROUP, null,
-                TIMESTAMP1, TIMESTAMP2, ORDER, 0);
-        assertThat(getPdpStatisticsList).hasSize(1);
-        getPdpStatisticsList = new PdpStatisticsProvider().getFilteredPdpStatistics(pfDao, "name2", GROUP, SUBGROUP,
-                TIMESTAMP1, TIMESTAMP2, ORDER, 0);
-        assertThat(getPdpStatisticsList).hasSize(1);
-    }
-
     @Test
     public void testGetFilteredPdpStatistics() throws Exception {