aboutsummaryrefslogtreecommitdiffstats
path: root/models-provider
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-08 18:31:06 +0000
committerGerrit Code Review <gerrit@onap.org>2021-02-08 18:31:06 +0000
commit5f0183ff4608e1c87436967dbc8760fe9a1febaf (patch)
tree2ebe1db7f44331709030561a617206291093aaca /models-provider
parent296a26edcc3102602b494d1be9c23e0265b09f66 (diff)
parented54f1f94a43e9fc5e353eb2c7111dcc552be18e (diff)
Merge "Make filters on TOSCA entities generic"
Diffstat (limited to 'models-provider')
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java36
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java29
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java25
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java24
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java26
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java16
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java69
7 files changed, 119 insertions, 106 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 e0cb44cb6..3bf81adf7 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -34,12 +34,11 @@ 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.ToscaEntityFilter;
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;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
/**
* This interface describes the operations that are provided to users and components for reading objects from and
@@ -76,8 +75,8 @@ public interface PolicyModelsProvider extends AutoCloseable {
* @return the service templates found
* @throws PfModelException on errors getting service templates
*/
- public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull final ToscaServiceTemplateFilter filter)
- throws PfModelException;
+ public List<ToscaServiceTemplate> getFilteredServiceTemplateList(
+ @NonNull final ToscaEntityFilter<ToscaServiceTemplate> filter) throws PfModelException;
/**
* Create service template.
@@ -137,7 +136,7 @@ public interface PolicyModelsProvider extends AutoCloseable {
* @return the policy types found
* @throws PfModelException on errors getting policy types
*/
- public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaPolicyTypeFilter filter)
+ public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaEntityFilter<ToscaPolicyType> filter)
throws PfModelException;
/**
@@ -147,7 +146,7 @@ public interface PolicyModelsProvider extends AutoCloseable {
* @return the policy types found
* @throws PfModelException on errors getting policy types
*/
- public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaPolicyTypeFilter filter)
+ public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaEntityFilter<ToscaPolicyType> filter)
throws PfModelException;
/**
@@ -208,7 +207,8 @@ public interface PolicyModelsProvider extends AutoCloseable {
* @return the policies found
* @throws PfModelException on errors getting policies
*/
- public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
+ public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaTypedEntityFilter<ToscaPolicy> filter)
+ throws PfModelException;
/**
* Get filtered policies.
@@ -217,7 +217,8 @@ public interface PolicyModelsProvider extends AutoCloseable {
* @return the policies found
* @throws PfModelException on errors getting policies
*/
- public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
+ public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaTypedEntityFilter<ToscaPolicy> filter)
+ throws PfModelException;
/**
* Create policies.
@@ -378,8 +379,7 @@ public interface PolicyModelsProvider extends AutoCloseable {
* @return the deployments found
* @throws PfModelException on errors getting PDP groups
*/
- public List<PdpPolicyStatus> getAllPolicyStatus()
- throws PfModelException;
+ public List<PdpPolicyStatus> getAllPolicyStatus() throws PfModelException;
/**
* Gets all deployments for a policy.
@@ -388,18 +388,16 @@ public interface PolicyModelsProvider extends AutoCloseable {
* @throws PfModelException on errors getting PDP groups
*/
public List<PdpPolicyStatus> getAllPolicyStatus(@NonNull ToscaConceptIdentifierOptVersion policy)
- throws PfModelException;
+ throws PfModelException;
/**
* Gets the policy deployments for a PDP group.
*
- * @param groupName the name of the PDP group of interest, null to get results for all
- * PDP groups
+ * @param groupName the name of the PDP group of interest, null to get results for all PDP groups
* @return the deployments found
* @throws PfModelException on errors getting PDP groups
*/
- public List<PdpPolicyStatus> getGroupPolicyStatus(@NonNull final String groupName)
- throws PfModelException;
+ public List<PdpPolicyStatus> getGroupPolicyStatus(@NonNull final String groupName) throws PfModelException;
/**
* Creates, updates, and deletes collections of policy status.
@@ -408,6 +406,6 @@ public interface PolicyModelsProvider extends AutoCloseable {
* @param updateObjs the objects to update
* @param deleteObjs the objects to delete
*/
- public void cudPolicyStatus(Collection<PdpPolicyStatus> createObjs,
- Collection<PdpPolicyStatus> updateObjs, Collection<PdpPolicyStatus> deleteObjs);
+ public void cudPolicyStatus(Collection<PdpPolicyStatus> createObjs, Collection<PdpPolicyStatus> updateObjs,
+ Collection<PdpPolicyStatus> deleteObjs);
}
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 3094efc27..8c7c5122b 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
@@ -41,12 +41,11 @@ 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.ToscaEntityFilter;
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;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
import org.onap.policy.models.tosca.authorative.provider.AuthorativeToscaProvider;
/**
@@ -74,8 +73,8 @@ public class DatabasePolicyModelsProviderImpl extends AbstractModelsProvider imp
@Override
- public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull ToscaServiceTemplateFilter filter)
- throws PfModelException {
+ public List<ToscaServiceTemplate> getFilteredServiceTemplateList(
+ @NonNull ToscaEntityFilter<ToscaServiceTemplate> filter) throws PfModelException {
assertInitialized();
return new AuthorativeToscaProvider().getFilteredServiceTemplateList(getPfDao(), filter);
}
@@ -115,13 +114,14 @@ public class DatabasePolicyModelsProviderImpl extends AbstractModelsProvider imp
}
@Override
- public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull ToscaPolicyTypeFilter filter) throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull ToscaEntityFilter<ToscaPolicyType> filter)
+ throws PfModelException {
assertInitialized();
return new AuthorativeToscaProvider().getFilteredPolicyTypes(getPfDao(), filter);
}
@Override
- public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull ToscaPolicyTypeFilter filter)
+ public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull ToscaEntityFilter<ToscaPolicyType> filter)
throws PfModelException {
assertInitialized();
return new AuthorativeToscaProvider().getFilteredPolicyTypeList(getPfDao(), filter);
@@ -165,13 +165,15 @@ public class DatabasePolicyModelsProviderImpl extends AbstractModelsProvider imp
}
@Override
- public ToscaServiceTemplate getFilteredPolicies(@NonNull ToscaPolicyFilter filter) throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicies(@NonNull ToscaTypedEntityFilter<ToscaPolicy> filter)
+ throws PfModelException {
assertInitialized();
return new AuthorativeToscaProvider().getFilteredPolicies(getPfDao(), filter);
}
@Override
- public List<ToscaPolicy> getFilteredPolicyList(@NonNull ToscaPolicyFilter filter) throws PfModelException {
+ public List<ToscaPolicy> getFilteredPolicyList(@NonNull ToscaTypedEntityFilter<ToscaPolicy> filter)
+ throws PfModelException {
assertInitialized();
return new AuthorativeToscaProvider().getFilteredPolicyList(getPfDao(), filter);
}
@@ -288,21 +290,20 @@ public class DatabasePolicyModelsProviderImpl extends AbstractModelsProvider imp
@Override
public List<PdpPolicyStatus> getAllPolicyStatus(@NonNull ToscaConceptIdentifierOptVersion policy)
- throws PfModelException {
+ throws PfModelException {
assertInitialized();
return new PdpProvider().getAllPolicyStatus(getPfDao(), policy);
}
@Override
- public List<PdpPolicyStatus> getGroupPolicyStatus(@NonNull String groupName)
- throws PfModelException {
+ public List<PdpPolicyStatus> getGroupPolicyStatus(@NonNull String groupName) throws PfModelException {
assertInitialized();
return new PdpProvider().getGroupPolicyStatus(getPfDao(), groupName);
}
@Override
- public void cudPolicyStatus(Collection<PdpPolicyStatus> createObjs,
- Collection<PdpPolicyStatus> updateObjs, Collection<PdpPolicyStatus> deleteObjs) {
+ public void cudPolicyStatus(Collection<PdpPolicyStatus> createObjs, Collection<PdpPolicyStatus> updateObjs,
+ Collection<PdpPolicyStatus> deleteObjs) {
assertInitialized();
new PdpProvider().cudPolicyStatus(getPfDao(), createObjs, updateObjs, deleteObjs);
}
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 0a9ea723f..1b91f07c6 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
@@ -41,12 +41,11 @@ 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.ToscaEntityFilter;
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;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
/**
* This class provides a dummy implementation of the Policy Models Provider for the ONAP Policy Framework.
@@ -81,8 +80,8 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull ToscaServiceTemplateFilter filter)
- throws PfModelException {
+ public List<ToscaServiceTemplate> getFilteredServiceTemplateList(
+ @NonNull ToscaEntityFilter<ToscaServiceTemplate> filter) throws PfModelException {
return new ArrayList<>();
}
@@ -115,12 +114,13 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getFilteredPolicyTypes(ToscaPolicyTypeFilter filter) throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicyTypes(ToscaEntityFilter<ToscaPolicyType> filter)
+ throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyTypeGetResponse.json");
}
@Override
- public List<ToscaPolicyType> getFilteredPolicyTypeList(ToscaPolicyTypeFilter filter) {
+ public List<ToscaPolicyType> getFilteredPolicyTypeList(ToscaEntityFilter<ToscaPolicyType> filter) {
return new ArrayList<>();
}
@@ -150,12 +150,13 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getFilteredPolicies(ToscaPolicyFilter filter) throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicies(ToscaTypedEntityFilter<ToscaPolicy> filter)
+ throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyGetResponse.json");
}
@Override
- public List<ToscaPolicy> getFilteredPolicyList(ToscaPolicyFilter filter) throws PfModelException {
+ public List<ToscaPolicy> getFilteredPolicyList(ToscaTypedEntityFilter<ToscaPolicy> filter) throws PfModelException {
return new ArrayList<>();
}
@@ -249,7 +250,7 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
@Override
public List<PdpPolicyStatus> getAllPolicyStatus(@NonNull ToscaConceptIdentifierOptVersion policy)
- throws PfModelException {
+ throws PfModelException {
// Not implemented
return new ArrayList<>();
}
@@ -262,7 +263,7 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
@Override
public void cudPolicyStatus(Collection<PdpPolicyStatus> createObjs, Collection<PdpPolicyStatus> updateObjs,
- Collection<PdpPolicyStatus> deleteObjs) {
+ Collection<PdpPolicyStatus> deleteObjs) {
// 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 fb5af1e1b..596f9fa0d 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
@@ -47,9 +47,11 @@ 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.ToscaEntityFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
/**
* Test the database models provider implementation.
@@ -296,10 +298,12 @@ public class DatabasePolicyModelsProviderTest {
assertTrue(databaseProvider.getPolicyTypeList(NAME, VERSION_100).isEmpty());
- assertThatThrownBy(() -> databaseProvider.getFilteredPolicyTypes(ToscaPolicyTypeFilter.builder().build()))
- .hasMessage("service template not found in database");
+ assertThatThrownBy(
+ () -> databaseProvider.getFilteredPolicyTypes(ToscaEntityFilter.<ToscaPolicyType>builder().build()))
+ .hasMessage("service template not found in database");
- assertTrue(databaseProvider.getFilteredPolicyTypeList(ToscaPolicyTypeFilter.builder().build()).isEmpty());
+ assertTrue(databaseProvider.getFilteredPolicyTypeList(ToscaEntityFilter.<ToscaPolicyType>builder().build())
+ .isEmpty());
assertThatThrownBy(() -> {
databaseProvider.createPolicyTypes(new ToscaServiceTemplate());
@@ -317,10 +321,12 @@ public class DatabasePolicyModelsProviderTest {
assertTrue(databaseProvider.getPolicyList(NAME, VERSION_100).isEmpty());
- assertThatThrownBy(() -> databaseProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build()))
- .hasMessage("service template not found in database");
+ assertThatThrownBy(
+ () -> databaseProvider.getFilteredPolicies(ToscaTypedEntityFilter.<ToscaPolicy>builder().build()))
+ .hasMessage("service template not found in database");
- assertTrue(databaseProvider.getFilteredPolicyList(ToscaPolicyFilter.builder().build()).isEmpty());
+ assertTrue(databaseProvider.getFilteredPolicyList(ToscaTypedEntityFilter.<ToscaPolicy>builder().build())
+ .isEmpty());
assertThatThrownBy(() -> {
databaseProvider.createPolicies(new ToscaServiceTemplate());
@@ -428,7 +434,7 @@ public class DatabasePolicyModelsProviderTest {
assertThat(databaseProvider.getAllPolicyStatus()).isEmpty();
assertThat(databaseProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy", null)))
- .isEmpty();
+ .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 008a1ccf9..f2e8e8489 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
@@ -39,12 +39,11 @@ 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.ToscaEntityFilter;
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;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
/**
* Dummy implementation of {@link PolicyModelsProvider} with bad constructor.
@@ -67,8 +66,8 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull ToscaServiceTemplateFilter filter)
- throws PfModelException {
+ public List<ToscaServiceTemplate> getFilteredServiceTemplateList(
+ @NonNull ToscaEntityFilter<ToscaServiceTemplate> filter) throws PfModelException {
return null;
}
@@ -164,12 +163,13 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull ToscaPolicyTypeFilter filter) throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull ToscaEntityFilter<ToscaPolicyType> filter)
+ throws PfModelException {
return null;
}
@Override
- public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull ToscaPolicyTypeFilter filter)
+ public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull ToscaEntityFilter<ToscaPolicyType> filter)
throws PfModelException {
return Collections.emptyList();
}
@@ -180,12 +180,14 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getFilteredPolicies(@NonNull ToscaPolicyFilter filter) throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicies(@NonNull ToscaTypedEntityFilter<ToscaPolicy> filter)
+ throws PfModelException {
return null;
}
@Override
- public List<ToscaPolicy> getFilteredPolicyList(@NonNull ToscaPolicyFilter filter) throws PfModelException {
+ public List<ToscaPolicy> getFilteredPolicyList(@NonNull ToscaTypedEntityFilter<ToscaPolicy> filter)
+ throws PfModelException {
return Collections.emptyList();
}
@@ -240,7 +242,7 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
@Override
public List<PdpPolicyStatus> getAllPolicyStatus(@NonNull ToscaConceptIdentifierOptVersion policy)
- throws PfModelException {
+ throws PfModelException {
// Not implemented
return null;
}
@@ -253,7 +255,7 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
@Override
public void cudPolicyStatus(Collection<PdpPolicyStatus> createObjs, Collection<PdpPolicyStatus> updateObjs,
- Collection<PdpPolicyStatus> deleteObjs) {
+ Collection<PdpPolicyStatus> deleteObjs) {
// 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 223aa5b36..a57cc956d 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
@@ -40,9 +40,11 @@ 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.ToscaEntityFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
/**
* Test the dummy models provider implementation.
@@ -83,17 +85,17 @@ public class DummyPolicyModelsProviderTest {
dummyProvider.init();
assertNotNull(dummyProvider.getPolicyTypes("name", VERSION));
- assertNotNull(dummyProvider.getFilteredPolicyTypes(ToscaPolicyTypeFilter.builder().build()));
+ assertNotNull(dummyProvider.getFilteredPolicyTypes(ToscaEntityFilter.<ToscaPolicyType>builder().build()));
assertNotNull(dummyProvider.getPolicyTypeList("name", VERSION));
- assertNotNull(dummyProvider.getFilteredPolicyTypeList(ToscaPolicyTypeFilter.builder().build()));
+ assertNotNull(dummyProvider.getFilteredPolicyTypeList(ToscaEntityFilter.<ToscaPolicyType>builder().build()));
assertNotNull(dummyProvider.createPolicyTypes(new ToscaServiceTemplate()));
assertNotNull(dummyProvider.updatePolicyTypes(new ToscaServiceTemplate()));
assertNotNull(dummyProvider.deletePolicyType("name", VERSION));
assertNotNull(dummyProvider.getPolicies("name", VERSION));
- assertNotNull(dummyProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build()));
+ assertNotNull(dummyProvider.getFilteredPolicies(ToscaTypedEntityFilter.<ToscaPolicy>builder().build()));
assertNotNull(dummyProvider.getPolicyList("name", VERSION));
- assertNotNull(dummyProvider.getFilteredPolicyList(ToscaPolicyFilter.builder().build()));
+ assertNotNull(dummyProvider.getFilteredPolicyList(ToscaTypedEntityFilter.<ToscaPolicy>builder().build()));
assertNotNull(dummyProvider.createPolicies(new ToscaServiceTemplate()));
assertNotNull(dummyProvider.updatePolicies(new ToscaServiceTemplate()));
assertNotNull(dummyProvider.deletePolicy("name", VERSION));
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
index a42aae4b6..ac62569b3 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,10 +44,11 @@ import org.onap.policy.models.base.PfModelException;
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.ToscaEntityFilter;
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.ToscaPolicyTypeFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -114,15 +115,15 @@ public class PolicyToscaPersistenceTest {
public void testHpaPolicyTypeGet() throws PfModelException {
long getStartTime = System.currentTimeMillis();
ToscaServiceTemplate hpaServiceTemplate =
- databaseProvider.getPolicyTypes("onap.policies.optimization.resource.HpaPolicy", "1.0.0");
+ databaseProvider.getPolicyTypes("onap.policies.optimization.resource.HpaPolicy", "1.0.0");
LOGGER.trace("HPA policy normal get time (ms): {}", System.currentTimeMillis() - getStartTime);
assertEquals(3, hpaServiceTemplate.getPolicyTypesAsMap().size());
assertEquals(5, hpaServiceTemplate.getDataTypesAsMap().size());
getStartTime = System.currentTimeMillis();
- ToscaPolicyTypeFilter hpaFilter = ToscaPolicyTypeFilter.builder()
- .name("onap.policies.optimization.resource.HpaPolicy").version("1.0.0").build();
+ ToscaEntityFilter<ToscaPolicyType> hpaFilter = ToscaEntityFilter.<ToscaPolicyType>builder()
+ .name("onap.policies.optimization.resource.HpaPolicy").version("1.0.0").build();
hpaServiceTemplate = databaseProvider.getFilteredPolicyTypes(hpaFilter);
LOGGER.trace("HPA policy filter name version get time (ms): {}", System.currentTimeMillis() - getStartTime);
@@ -130,7 +131,8 @@ public class PolicyToscaPersistenceTest {
assertEquals(5, hpaServiceTemplate.getDataTypesAsMap().size());
getStartTime = System.currentTimeMillis();
- hpaFilter = ToscaPolicyTypeFilter.builder().name("onap.policies.optimization.resource.HpaPolicy").build();
+ hpaFilter = ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.optimization.resource.HpaPolicy")
+ .build();
hpaServiceTemplate = databaseProvider.getFilteredPolicyTypes(hpaFilter);
LOGGER.trace("HPA policy filter name only get time (ms): {}", System.currentTimeMillis() - getStartTime);
@@ -142,7 +144,7 @@ public class PolicyToscaPersistenceTest {
public void testNamingPolicyGet() throws PfModelException {
String policyYamlString = ResourceUtils.getResourceAsString("policies/sdnc.policy.naming.input.tosca.yaml");
ToscaServiceTemplate serviceTemplate =
- yamlJsonTranslator.fromYaml(policyYamlString, ToscaServiceTemplate.class);
+ yamlJsonTranslator.fromYaml(policyYamlString, ToscaServiceTemplate.class);
long createStartTime = System.currentTimeMillis();
databaseProvider.createPolicies(serviceTemplate);
@@ -150,7 +152,7 @@ public class PolicyToscaPersistenceTest {
long getStartTime = System.currentTimeMillis();
ToscaServiceTemplate namingServiceTemplate =
- databaseProvider.getPolicies("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", "1.0.0");
+ databaseProvider.getPolicies("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", "1.0.0");
LOGGER.trace("Naming policy normal get time (ms): {}", System.currentTimeMillis() - getStartTime);
assertEquals(1, namingServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
@@ -158,8 +160,8 @@ public class PolicyToscaPersistenceTest {
assertEquals(3, namingServiceTemplate.getDataTypesAsMap().size());
getStartTime = System.currentTimeMillis();
- ToscaPolicyFilter filter =
- ToscaPolicyFilter.builder().name("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP").version("1.0.0").build();
+ ToscaTypedEntityFilter<ToscaPolicy> filter = ToscaTypedEntityFilter.<ToscaPolicy>builder()
+ .name("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP").version("1.0.0").build();
namingServiceTemplate = databaseProvider.getFilteredPolicies(filter);
LOGGER.trace("Naming policy filtered get time (ms): {}", System.currentTimeMillis() - getStartTime);
@@ -168,7 +170,7 @@ public class PolicyToscaPersistenceTest {
assertEquals(3, namingServiceTemplate.getDataTypesAsMap().size());
getStartTime = System.currentTimeMillis();
- filter = ToscaPolicyFilter.builder().name("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP").build();
+ filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().name("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP").build();
namingServiceTemplate = databaseProvider.getFilteredPolicies(filter);
LOGGER.trace("Naming policy filtered name only get time (ms): {}", System.currentTimeMillis() - getStartTime);
@@ -178,7 +180,7 @@ public class PolicyToscaPersistenceTest {
long deleteStartTime = System.currentTimeMillis();
ToscaServiceTemplate deletedServiceTemplate =
- databaseProvider.deletePolicy("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", "1.0.0");
+ databaseProvider.deletePolicy("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", "1.0.0");
LOGGER.trace("Naming policy delete time (ms): {}", System.currentTimeMillis() - deleteStartTime);
assertEquals(1, deletedServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
@@ -188,7 +190,7 @@ public class PolicyToscaPersistenceTest {
public void testNamingPolicyVersions() throws PfModelException {
String policyYamlString = ResourceUtils.getResourceAsString("policies/sdnc.policy.naming.input.tosca.yaml");
ToscaServiceTemplate serviceTemplate =
- yamlJsonTranslator.fromYaml(policyYamlString, ToscaServiceTemplate.class);
+ yamlJsonTranslator.fromYaml(policyYamlString, ToscaServiceTemplate.class);
// Create policy types and data types
List<Map<String, ToscaPolicy>> policyMapList = serviceTemplate.getToscaTopologyTemplate().getPolicies();
@@ -211,26 +213,26 @@ public class PolicyToscaPersistenceTest {
for (int i = 1; i < 22; i++) {
ToscaServiceTemplate namingServiceTemplate =
- databaseProvider.getPolicies("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", i + ".0.0");
+ databaseProvider.getPolicies("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", i + ".0.0");
assertEquals(i + ".0.0", namingServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0).values()
- .iterator().next().getVersion());
+ .iterator().next().getVersion());
- ToscaPolicyFilter policyFilter =
- ToscaPolicyFilter.builder().name("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP").version(i + ".0.0").build();
+ ToscaTypedEntityFilter<ToscaPolicy> policyFilter = ToscaTypedEntityFilter.<ToscaPolicy>builder()
+ .name("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP").version(i + ".0.0").build();
namingServiceTemplate = databaseProvider.getFilteredPolicies(policyFilter);
assertEquals(i + ".0.0", namingServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0).values()
- .iterator().next().getVersion());
+ .iterator().next().getVersion());
}
- ToscaPolicyFilter policyFilter = ToscaPolicyFilter.builder().name("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP")
- .version(ToscaPolicyFilter.LATEST_VERSION).build();
+ ToscaTypedEntityFilter<ToscaPolicy> policyFilter = ToscaTypedEntityFilter.<ToscaPolicy>builder()
+ .name("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP").version(ToscaTypedEntityFilter.LATEST_VERSION).build();
ToscaServiceTemplate namingServiceTemplate = databaseProvider.getFilteredPolicies(policyFilter);
assertEquals("21.0.0", namingServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0).values().iterator()
- .next().getVersion());
+ .next().getVersion());
for (int i = 1; i < 22; i++) {
ToscaServiceTemplate deletedServiceTemplate =
- databaseProvider.deletePolicy("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", i + ".0.0");
+ databaseProvider.deletePolicy("SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", i + ".0.0");
assertEquals(1, deletedServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
}
}
@@ -262,28 +264,29 @@ public class PolicyToscaPersistenceTest {
for (Map<String, ToscaPolicy> policyMap : serviceTemplate.getToscaTopologyTemplate().getPolicies()) {
for (ToscaPolicy policy : policyMap.values()) {
ToscaServiceTemplate gotToscaServiceTemplate =
- databaseProvider.getPolicies(policy.getName(), policy.getVersion());
+ databaseProvider.getPolicies(policy.getName(), policy.getVersion());
assertEquals(policy.getType(), gotToscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0)
- .get(policy.getName()).getType());
+ .get(policy.getName()).getType());
- gotToscaServiceTemplate = databaseProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build());
+ gotToscaServiceTemplate =
+ databaseProvider.getFilteredPolicies(ToscaTypedEntityFilter.<ToscaPolicy>builder().build());
assertEquals(policy.getType(),
- getToscaPolicyFromMapList(gotToscaServiceTemplate.getToscaTopologyTemplate().getPolicies(),
- policy.getName()).getType());
+ getToscaPolicyFromMapList(gotToscaServiceTemplate.getToscaTopologyTemplate().getPolicies(),
+ policy.getName()).getType());
- gotToscaServiceTemplate = databaseProvider.getFilteredPolicies(
- ToscaPolicyFilter.builder().name(policy.getName()).version(policy.getVersion()).build());
+ gotToscaServiceTemplate = databaseProvider.getFilteredPolicies(ToscaTypedEntityFilter
+ .<ToscaPolicy>builder().name(policy.getName()).version(policy.getVersion()).build());
assertEquals(policy.getType(), gotToscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0)
- .get(policy.getName()).getType());
+ .get(policy.getName()).getType());
}
}
}
private ToscaPolicy getToscaPolicyFromMapList(List<Map<String, ToscaPolicy>> toscaPolicyMapList,
- String policyName) {
+ String policyName) {
ToscaPolicy toscaPolicy = new ToscaPolicy();
for (Map<String, ToscaPolicy> policyMap : toscaPolicyMapList) {
toscaPolicy = policyMap.get(policyName);
@@ -300,7 +303,7 @@ public class PolicyToscaPersistenceTest {
for (String policyTypeResource : policyTypeResources) {
String policyTypeYamlString = ResourceUtils.getResourceAsString(policyTypeResource);
ToscaServiceTemplate toscaServiceTemplatePolicyType =
- yamlJsonTranslator.fromYaml(policyTypeYamlString, ToscaServiceTemplate.class);
+ yamlJsonTranslator.fromYaml(policyTypeYamlString, ToscaServiceTemplate.class);
assertNotNull(toscaServiceTemplatePolicyType);
databaseProvider.createPolicyTypes(toscaServiceTemplatePolicyType);