diff options
author | Liam Fallon <liam.fallon@est.tech> | 2019-12-23 20:18:31 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-12-23 20:18:31 +0000 |
commit | 4fab7a327737ebdfaf7b55c39c49f0239ff627c8 (patch) | |
tree | 9e43171537ecc447cd03551c501d0b8bc5ad646a /models-provider | |
parent | a70dbf38827f6c3b50f35c947faa81985711e242 (diff) | |
parent | 1c9d2d26b1f34567dc6d3e9c51a4fb78c9fc13d4 (diff) |
Merge "pdp statistics database provider implementation"
Diffstat (limited to 'models-provider')
6 files changed, 193 insertions, 119 deletions
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 bd28c3238..2e1c71426 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 @@ -20,11 +20,10 @@ package org.onap.policy.models.provider; +import java.util.Date; import java.util.List; import java.util.Map; - import lombok.NonNull; - import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpGroup; @@ -354,17 +353,50 @@ public interface PolicyModelsProvider extends AutoCloseable { * @return the statistics found * @throws PfModelException on errors getting statistics */ - public List<PdpStatistics> getPdpStatistics(final String name) throws PfModelException; + public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException; + + + /** + * Get filtered PdpStatistics. + * + * @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 + * @return the PDP statistics found + * @throws PfModelException on errors getting policies + */ + public List<PdpStatistics> getFilteredPdpStatistics(String name, @NonNull String pdpGroupName, String pdpSubGroup, + Date startTimeStamp, Date endTimeStamp) throws PfModelException; + + /** + * Creates PDP statistics. + * + * @param pdpStatisticsList a specification of the PDP statistics to create + * @return the PDP statistics created + * @throws PfModelException on errors creating PDP statistics + */ + public List<PdpStatistics> createPdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList) + throws PfModelException; + + /** + * Updates PDP statistics. + * + * @param pdpStatisticsList a specification of the PDP statistics to update + * @return the PDP statistics updated + * @throws PfModelException on errors updating PDP statistics + */ + public List<PdpStatistics> updatePdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList) + throws PfModelException; /** - * Update PDP statistics for a PDP. + * Delete a PDP statistics. * - * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for - * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for - * @param pdpInstanceId the instance ID of the PDP to update statistics for - * @param pdpStatistics the PDP statistics - * @throws PfModelException on errors updating statistics + * @param name the name of the policy to get, null to get all PDP statistics + * @param timestamp the timestamp of statistics to delete, null to delete all statistics record of given pdp + * @return the PDP statistics deleted + * @throws PfModelException on errors deleting PDP statistics */ - public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpType, - @NonNull final String pdpInstanceId, @NonNull final PdpStatistics pdpStatistics) throws PfModelException; + public List<PdpStatistics> deletePdpStatistics(@NonNull String name, Date timestamp) throws PfModelException; } 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 9971454bd..1ac24585f 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 @@ -22,14 +22,12 @@ package org.onap.policy.models.provider.impl; import java.util.Base64; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Properties; - import javax.ws.rs.core.Response; - import lombok.NonNull; - import org.eclipse.persistence.config.PersistenceUnitProperties; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; @@ -43,6 +41,7 @@ import org.onap.policy.models.pdp.concepts.PdpGroupFilter; import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.pdp.persistence.provider.PdpProvider; +import org.onap.policy.models.pdp.persistence.provider.PdpStatisticsProvider; import org.onap.policy.models.provider.PolicyModelsProvider; import org.onap.policy.models.provider.PolicyModelsProviderParameters; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; @@ -140,71 +139,71 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { @Override public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().getPolicyTypes(pfDao, name, version); } @Override public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().getPolicyTypeList(pfDao, name, version); } @Override public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull ToscaPolicyTypeFilter filter) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, filter); } @Override public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull ToscaPolicyTypeFilter filter) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao, filter); } @Override public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().createPolicyTypes(pfDao, serviceTemplate); } @Override public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().updatePolicyTypes(pfDao, serviceTemplate); } @Override public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().deletePolicyType(pfDao, name, version); } @Override public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().getPolicies(pfDao, name, version); } @Override public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().getPolicyList(pfDao, name, version); } @Override public ToscaServiceTemplate getFilteredPolicies(@NonNull ToscaPolicyFilter filter) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().getFilteredPolicies(pfDao, filter); } @Override public List<ToscaPolicy> getFilteredPolicyList(@NonNull ToscaPolicyFilter filter) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().getFilteredPolicyList(pfDao, filter); } @@ -212,108 +211,109 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { @Override public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().createPolicies(pfDao, serviceTemplate); } @Override public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().updatePolicies(pfDao, serviceTemplate); } @Override public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version) throws PfModelException { - assertInitilized(); + assertInitialized(); return new AuthorativeToscaProvider().deletePolicy(pfDao, name, version); } @Override public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId, final String policyVersion) throws PfModelException { - assertInitilized(); + assertInitialized(); return new LegacyProvider().getOperationalPolicy(pfDao, policyId, policyVersion); } @Override public LegacyOperationalPolicy createOperationalPolicy( @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException { - assertInitilized(); + assertInitialized(); return new LegacyProvider().createOperationalPolicy(pfDao, legacyOperationalPolicy); } @Override public LegacyOperationalPolicy updateOperationalPolicy( @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException { - assertInitilized(); + assertInitialized(); return new LegacyProvider().updateOperationalPolicy(pfDao, legacyOperationalPolicy); } @Override public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId, @NonNull final String policyVersion) throws PfModelException { - assertInitilized(); + assertInitialized(); return new LegacyProvider().deleteOperationalPolicy(pfDao, policyId, policyVersion); } @Override public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId, final String policyVersion) throws PfModelException { - assertInitilized(); + assertInitialized(); return new LegacyProvider().getGuardPolicy(pfDao, policyId, policyVersion); } @Override public Map<String, LegacyGuardPolicyOutput> createGuardPolicy( @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException { - assertInitilized(); + assertInitialized(); return new LegacyProvider().createGuardPolicy(pfDao, legacyGuardPolicy); } @Override public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy( @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException { - assertInitilized(); + assertInitialized(); return new LegacyProvider().updateGuardPolicy(pfDao, legacyGuardPolicy); } @Override public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId, @NonNull final String policyVersion) throws PfModelException { - assertInitilized(); + assertInitialized(); return new LegacyProvider().deleteGuardPolicy(pfDao, policyId, policyVersion); } @Override public List<PdpGroup> getPdpGroups(final String name) throws PfModelException { - assertInitilized(); + assertInitialized(); return new PdpProvider().getPdpGroups(pfDao, name); } + @Override public List<PdpGroup> getFilteredPdpGroups(@NonNull PdpGroupFilter filter) throws PfModelException { - assertInitilized(); + assertInitialized(); return new PdpProvider().getFilteredPdpGroups(pfDao, filter); } @Override public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException { - assertInitilized(); + assertInitialized(); return new PdpProvider().createPdpGroups(pfDao, pdpGroups); } @Override public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException { - assertInitilized(); + assertInitialized(); return new PdpProvider().updatePdpGroups(pfDao, pdpGroups); } @Override public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException { - assertInitilized(); + assertInitialized(); new PdpProvider().updatePdpSubGroup(pfDao, pdpGroupName, pdpSubGroup); } @@ -325,27 +325,50 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { @Override public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException { - assertInitilized(); + assertInitialized(); return new PdpProvider().deletePdpGroup(pfDao, name); } @Override - public List<PdpStatistics> getPdpStatistics(final String name) throws PfModelException { - assertInitilized(); - return new PdpProvider().getPdpStatistics(pfDao, name); + public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException { + assertInitialized(); + return new PdpStatisticsProvider().getPdpStatistics(pfDao, name, timestamp); } @Override - public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpType, - @NonNull final String pdpInstanceId, @NonNull final PdpStatistics pdpStatistics) throws PfModelException { - assertInitilized(); - new PdpProvider().updatePdpStatistics(pfDao, pdpGroupName, pdpType, pdpInstanceId, pdpStatistics); + public List<PdpStatistics> getFilteredPdpStatistics(final String name, @NonNull final String pdpGroupName, + final String pdpSubGroup, final Date startTimeStamp, final Date endTimeStamp) throws PfModelException { + assertInitialized(); + return new PdpStatisticsProvider().getFilteredPdpStatistics(pfDao, name, pdpGroupName, pdpSubGroup, + startTimeStamp, endTimeStamp); + } + + @Override + public List<PdpStatistics> createPdpStatistics(@NonNull final List<PdpStatistics> pdpStatisticsList) + throws PfModelException { + assertInitialized(); + return new PdpStatisticsProvider().createPdpStatistics(pfDao, pdpStatisticsList); + } + + @Override + public List<PdpStatistics> updatePdpStatistics(@NonNull final List<PdpStatistics> pdpStatisticsList) + throws PfModelException { + assertInitialized(); + return new PdpStatisticsProvider().updatePdpStatistics(pfDao, pdpStatisticsList); + } + + + @Override + public List<PdpStatistics> deletePdpStatistics(@NonNull final String name, final Date timestamp) + throws PfModelException { + assertInitialized(); + return new PdpStatisticsProvider().deletePdpStatistics(pfDao, name, timestamp); } /** * Check if the model provider is initialized. */ - private void assertInitilized() { + private void assertInitialized() { if (pfDao == null) { String errorMessage = "policy models provider is not initilaized"; LOGGER.warn(errorMessage); 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 acc000c61..2c88bcacd 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 @@ -22,12 +22,11 @@ package org.onap.policy.models.provider.impl; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.ws.rs.core.Response; - import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.base.PfModelException; @@ -229,14 +228,35 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public List<PdpStatistics> getPdpStatistics(final String name) throws PfModelException { + public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException { + return new ArrayList<>(); + } + + @Override + public List<PdpStatistics> getFilteredPdpStatistics(String name, String pdpGroupName, String pdpSubGroup, + Date startTimeStamp, Date endTimeStamp) { + // Not implemented + return new ArrayList<>(); + } + + @Override + public List<PdpStatistics> createPdpStatistics(final List<PdpStatistics> pdpStatisticsList) + throws PfModelException { + // Not implemented + return new ArrayList<>(); + } + + @Override + public List<PdpStatistics> updatePdpStatistics(final List<PdpStatistics> pdpStatisticsList) + throws PfModelException { + // Not implemented return new ArrayList<>(); } @Override - public void updatePdpStatistics(final String pdpGroupName, final String pdpType, final String pdpInstanceId, - final PdpStatistics pdppStatistics) throws PfModelException { + public List<PdpStatistics> deletePdpStatistics(final String name, final Date timestamp) { // Not implemented + return null; } /** 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 d5c03a2cd..f8a3490cc 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 @@ -29,6 +29,7 @@ import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.Base64; +import java.util.Date; import java.util.List; import org.junit.Before; @@ -82,6 +83,8 @@ public class DatabasePolicyModelsProviderTest { private static final String VERSION_100 = "1.0.0"; + private static final Date TIMESTAMP = new Date(); + private static final Logger LOGGER = LoggerFactory.getLogger(DatabasePolicyModelsProviderTest.class); PolicyModelsProviderParameters parameters; @@ -327,66 +330,21 @@ public class DatabasePolicyModelsProviderTest { }).hasMessage(NAME_IS_NULL); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, null, null); - }).hasMessage(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, null, new PdpStatistics()); - }).hasMessage(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, INSTANCE, null); - }).hasMessage(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, INSTANCE, new PdpStatistics()); - }).hasMessage(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "type", null, null); - }).hasMessage(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "type", null, new PdpStatistics()); - }).hasMessage(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "type", INSTANCE, null); + databaseProvider.getFilteredPdpStatistics(NAME, null, "sub", TIMESTAMP, TIMESTAMP); }).hasMessage(GROUP_IS_NULL); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "type", INSTANCE, new PdpStatistics()); - }).hasMessage(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(NAME, null, null, null); - }).hasMessage(PDP_TYPE_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(NAME, null, null, new PdpStatistics()); - }).hasMessage(PDP_TYPE_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(NAME, null, INSTANCE, null); - }).hasMessage(PDP_TYPE_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(NAME, null, INSTANCE, new PdpStatistics()); - }).hasMessage(PDP_TYPE_IS_NULL); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(NAME, "type", null, null); - }).hasMessage("pdpInstanceId is marked @NonNull but is null"); + databaseProvider.createPdpStatistics(null); + }).hasMessage("pdpStatisticsList is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(NAME, "type", null, new PdpStatistics()); - }).hasMessage("pdpInstanceId is marked @NonNull but is null"); + databaseProvider.updatePdpStatistics(null); + }).hasMessage("pdpStatisticsList is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(NAME, "type", INSTANCE, null); - }).hasMessage("pdpStatistics is marked @NonNull but is null"); + databaseProvider.deletePdpStatistics(null, TIMESTAMP); + }).hasMessage(NAME_IS_NULL); - databaseProvider.updatePdpStatistics(NAME, "type", INSTANCE, new PdpStatistics()); } } @@ -512,6 +470,13 @@ public class DatabasePolicyModelsProviderTest { pdpSubGroup.setPdpInstances(new ArrayList<>()); pdpSubGroup.getPdpInstances().add(pdp); + PdpStatistics pdpStatistics = new PdpStatistics(); + pdpStatistics.setPdpInstanceId("Pdp1"); + pdpStatistics.setTimeStamp(new Date()); + pdpStatistics.setPdpGroupName("DefaultGroup"); + ArrayList<PdpStatistics> statisticsArrayList = new ArrayList<>(); + statisticsArrayList.add(pdpStatistics); + assertEquals(123, databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0) .getDesiredInstanceCount()); assertEquals(1, databaseProvider.getPdpGroups(GROUP).size()); @@ -534,9 +499,23 @@ public class DatabasePolicyModelsProviderTest { assertEquals(pdpGroup.getName(), databaseProvider.deletePdpGroup(GROUP).getName()); - assertEquals(0, databaseProvider.getPdpStatistics(null).size()); + assertEquals(0, databaseProvider.getPdpStatistics(null,null).size()); + + databaseProvider.getFilteredPdpStatistics(null, GROUP,null, null, null); + databaseProvider.getFilteredPdpStatistics(null, GROUP,null, new Date(), null); + databaseProvider.getFilteredPdpStatistics(null, GROUP,null, null, new Date()); + databaseProvider.getFilteredPdpStatistics(null, GROUP,null, new Date(), new Date()); + + databaseProvider.getFilteredPdpStatistics(NAME, GROUP,null, null, null); + databaseProvider.getFilteredPdpStatistics(NAME, GROUP,null, new Date(), new Date()); + + databaseProvider.getFilteredPdpStatistics(NAME, GROUP,"type", null, null); + databaseProvider.getFilteredPdpStatistics(NAME, GROUP,"type", new Date(), new Date()); + + databaseProvider.createPdpStatistics(statisticsArrayList); + databaseProvider.updatePdpStatistics(statisticsArrayList); - databaseProvider.updatePdpStatistics(GROUP, "type", "type-0", new PdpStatistics()); + databaseProvider.deletePdpStatistics("pdp1",null); } catch (Exception exc) { LOGGER.warn("test should not throw an exception", exc); fail("test should not throw an exception"); 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 21d13fd83..d809f66ba 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 @@ -21,14 +21,13 @@ package org.onap.policy.models.provider.impl; +import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.Map; - import javax.ws.rs.core.Response; - import lombok.NonNull; - import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.pdp.concepts.Pdp; @@ -225,13 +224,34 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { } @Override - public List<PdpStatistics> getPdpStatistics(String name) throws PfModelException { - return Collections.emptyList(); + public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException { + return new ArrayList<>(); } @Override - public void updatePdpStatistics(@NonNull String pdpGroupName, @NonNull String pdpType, - @NonNull String pdpInstanceId, @NonNull PdpStatistics pdppStatistics) { - // do nothing + public List<PdpStatistics> getFilteredPdpStatistics(String name, String pdpGroupName, String pdpSubGroup, + Date startTimeStamp, Date endTimeStamp) { + // Not implemented + return new ArrayList<>(); + } + + @Override + public List<PdpStatistics> createPdpStatistics(final List<PdpStatistics> pdpStatisticsList) + throws PfModelException { + // Not implemented + return new ArrayList<>(); + } + + @Override + public List<PdpStatistics> updatePdpStatistics(final List<PdpStatistics> pdpStatisticsList) + throws PfModelException { + // Not implemented + return new ArrayList<>(); + } + + @Override + public List<PdpStatistics> deletePdpStatistics(final String name, final Date timestamp) { + // Not implemented + return null; } } 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 e30cea940..737e0fc28 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 @@ -116,8 +116,8 @@ public class DummyPolicyModelsProviderTest { dummyProvider.updatePdpSubGroup("name", new PdpSubGroup()); dummyProvider.updatePdp("name", "type", new Pdp()); - dummyProvider.updatePdpStatistics("name", "type", "type-0", new PdpStatistics()); - assertTrue(dummyProvider.getPdpStatistics("name").isEmpty()); + dummyProvider.updatePdpStatistics(new ArrayList<>()); + assertTrue(dummyProvider.getPdpStatistics("name", null).isEmpty()); } } |