From d57b30c68b030f7960d1aa7fe4f3632e55cef4cc Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 28 Jul 2021 09:48:00 -0400 Subject: Add junit test for empty statistics filter Also removed the version field from the filter, as it is not applicable to the PDP instance name. Issue-ID: POLICY-3511 Change-Id: I17e8d2d6646a27736a827b9e9e17881d6b0a3795 Signed-off-by: Jim Hahn --- .../models/pdp/persistence/provider/PdpFilterParameters.java | 9 ++++++++- .../pdp/persistence/provider/PdpStatisticsProviderTest.java | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpFilterParameters.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpFilterParameters.java index 775c15452..991e8231b 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpFilterParameters.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpFilterParameters.java @@ -30,8 +30,9 @@ import org.onap.policy.models.dao.PfFilterParametersIntfc; @Getter @Builder public class PdpFilterParameters implements PfFilterParametersIntfc { + // PDP instance ID private String name; - private String version; + private Instant startTime; private Instant endTime; @@ -63,4 +64,10 @@ public class PdpFilterParameters implements PfFilterParametersIntfc { return filterMap; } } + + @Override + public String getVersion() { + // version is not used + return null; + } } 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 57f364336..90b85b5ae 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 @@ -195,6 +195,11 @@ public class PdpStatisticsProviderTest { List getPdpStatisticsList; + // empty filter - should return everything + getPdpStatisticsList = new PdpStatisticsProvider().getFilteredPdpStatistics(pfDao, PdpFilterParameters + .builder().build()); + verifyEquals(getPdpStatisticsList, List.of(pdpStatistics11, pdpStatistics12, pdpStatistics22, pdpStatistics31)); + // match on name - returns multiple records getPdpStatisticsList = new PdpStatisticsProvider().getFilteredPdpStatistics(pfDao, PdpFilterParameters .builder().name(NAME).group(GROUP).startTime(TIMESTAMP1).endTime(TIMESTAMP2).build()); -- cgit 1.2.3-korg