From 9a67d321484b935eaf63e55373088fa64b0ffd76 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 12 Jan 2021 11:52:29 -0500 Subject: Add more methods to query deployment status Issue-ID: POLICY-2648 Change-Id: I398fa1332eb5a862dabd97ed409ef6413bb0c202 Signed-off-by: Jim Hahn --- .../policy/models/provider/PolicyModelsProvider.java | 19 +++++++++++++++++++ .../impl/DatabasePolicyModelsProviderImpl.java | 14 ++++++++++++++ .../provider/impl/DummyPolicyModelsProviderImpl.java | 14 ++++++++++++++ .../impl/DatabasePolicyModelsProviderTest.java | 4 ++++ .../models/provider/impl/DummyBadProviderImpl.java | 16 +++++++++++++++- .../provider/impl/DummyPolicyModelsProviderTest.java | 3 +++ 6 files changed, 69 insertions(+), 1 deletion(-) (limited to 'models-provider/src') 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 65876629c..e0cb44cb6 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 @@ -33,6 +33,7 @@ import org.onap.policy.models.pdp.concepts.PdpGroupFilter; import org.onap.policy.models.pdp.concepts.PdpPolicyStatus; import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpSubGroup; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; @@ -371,6 +372,24 @@ public interface PolicyModelsProvider extends AutoCloseable { */ public List deletePdpStatistics(@NonNull String name, Date timestamp) throws PfModelException; + /** + * Gets all policy deployments. + * + * @return the deployments found + * @throws PfModelException on errors getting PDP groups + */ + public List getAllPolicyStatus() + throws PfModelException; + + /** + * Gets all deployments for a policy. + * + * @return the deployments found + * @throws PfModelException on errors getting PDP groups + */ + public List getAllPolicyStatus(@NonNull ToscaConceptIdentifierOptVersion policy) + throws PfModelException; + /** * Gets the policy deployments for a PDP group. * 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 f7c58cf19..6b54a1c24 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 @@ -46,6 +46,7 @@ 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.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; @@ -347,6 +348,19 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { return new PdpStatisticsProvider().deletePdpStatistics(pfDao, name, timestamp); } + @Override + public List getAllPolicyStatus() throws PfModelException { + assertInitialized(); + return new PdpProvider().getAllPolicyStatus(pfDao); + } + + @Override + public List getAllPolicyStatus(@NonNull ToscaConceptIdentifierOptVersion policy) + throws PfModelException { + assertInitialized(); + return new PdpProvider().getAllPolicyStatus(pfDao, policy); + } + @Override public List getGroupPolicyStatus(@NonNull String groupName) throws PfModelException { 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 f0b968c10..0a9ea723f 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 @@ -40,6 +40,7 @@ import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.provider.PolicyModelsProvider; import org.onap.policy.models.provider.PolicyModelsProviderParameters; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; @@ -240,6 +241,19 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { return new ArrayList<>(); } + @Override + public List getAllPolicyStatus() throws PfModelException { + // Not implemented + return new ArrayList<>(); + } + + @Override + public List getAllPolicyStatus(@NonNull ToscaConceptIdentifierOptVersion policy) + throws PfModelException { + // Not implemented + return new ArrayList<>(); + } + @Override public List getGroupPolicyStatus(String groupName) 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 cace06224..fb5af1e1b 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 @@ -46,6 +46,7 @@ import org.onap.policy.models.provider.PolicyModelsProvider; import org.onap.policy.models.provider.PolicyModelsProviderFactory; import org.onap.policy.models.provider.PolicyModelsProviderParameters; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; @@ -425,6 +426,9 @@ public class DatabasePolicyModelsProviderTest { assertEquals(NAME, databaseProvider.deletePdpStatistics(NAME, null).get(0).getPdpInstanceId()); assertEquals(0, databaseProvider.getPdpStatistics(null, null).size()); + assertThat(databaseProvider.getAllPolicyStatus()).isEmpty(); + assertThat(databaseProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy", null))) + .isEmpty(); assertThat(databaseProvider.getGroupPolicyStatus(GROUP)).isEmpty(); assertThatCode(() -> databaseProvider.cudPolicyStatus(null, null, null)).doesNotThrowAnyException(); 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 0a3acb019..008a1ccf9 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 @@ -38,6 +38,7 @@ import org.onap.policy.models.pdp.concepts.PdpPolicyStatus; import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.provider.PolicyModelsProvider; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; @@ -231,6 +232,19 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { return null; } + @Override + public List getAllPolicyStatus() throws PfModelException { + // Not implemented + return null; + } + + @Override + public List getAllPolicyStatus(@NonNull ToscaConceptIdentifierOptVersion policy) + throws PfModelException { + // Not implemented + return null; + } + @Override public List getGroupPolicyStatus(@NonNull String groupName) throws PfModelException { // Not implemented @@ -245,7 +259,7 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { @Override public List getServiceTemplateList(String name, String version) throws PfModelException { - // TODO Auto-generated method stub + // 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 06c95ef64..223aa5b36 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 @@ -39,6 +39,7 @@ import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.provider.PolicyModelsProvider; import org.onap.policy.models.provider.PolicyModelsProviderFactory; import org.onap.policy.models.provider.PolicyModelsProviderParameters; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; @@ -114,6 +115,8 @@ public class DummyPolicyModelsProviderTest { assertTrue(dummyProvider.updatePdpStatistics(null).isEmpty()); assertTrue(dummyProvider.deletePdpStatistics(null, new Date()).isEmpty()); + assertThat(dummyProvider.getAllPolicyStatus()).isEmpty(); + assertThat(dummyProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy", null))).isEmpty(); assertThat(dummyProvider.getGroupPolicyStatus("name")).isEmpty(); assertThatCode(() -> dummyProvider.cudPolicyStatus(null, null, null)).doesNotThrowAnyException(); } -- cgit 1.2.3-korg