summaryrefslogtreecommitdiffstats
path: root/models-provider
diff options
context:
space:
mode:
Diffstat (limited to 'models-provider')
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java16
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java18
2 files changed, 32 insertions, 2 deletions
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java
index 468d4d74b..e8c344189 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java
@@ -41,6 +41,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.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -145,10 +146,21 @@ public class PolicyPersistenceTest {
for (Map<String, ToscaPolicy> policyMap : serviceTemplate.getToscaTopologyTemplate().getPolicies()) {
for (ToscaPolicy policy : policyMap.values()) {
- ToscaServiceTemplate goToscaServiceTemplate =
+ ToscaServiceTemplate gotToscaServiceTemplate =
databaseProvider.getPolicies(policy.getName(), policy.getVersion());
- assertEquals(goToscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0)
+ assertEquals(gotToscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0)
+ .get(policy.getName()).getType(), policy.getType());
+
+ gotToscaServiceTemplate = databaseProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build());
+
+ assertEquals(gotToscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0)
+ .get(policy.getName()).getType(), policy.getType());
+
+ gotToscaServiceTemplate = databaseProvider.getFilteredPolicies(
+ ToscaPolicyFilter.builder().name(policy.getName()).version(policy.getVersion()).build());
+
+ assertEquals(gotToscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0)
.get(policy.getName()).getType(), policy.getType());
}
}
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
index 7f90a0b58..96360ec93 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
@@ -41,6 +41,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.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -146,7 +147,24 @@ public class PolicyTypePersistenceTest {
List<ToscaPolicyType> policyTypeList =
databaseProvider.getPolicyTypeList(inPolicyType.getName(), inPolicyType.getVersion());
+ policyTypeList = databaseProvider.getFilteredPolicyTypeList(ToscaPolicyTypeFilter.builder()
+ .name(inPolicyType.getName()).version(inPolicyType.getVersion()).build());
+
+ assertEquals(1, policyTypeList.size());
+ assertEquals(inPolicyType.getName(), policyTypeList.get(0).getName());
+
+ policyTypeList = databaseProvider
+ .getFilteredPolicyTypeList(ToscaPolicyTypeFilter.builder().name(inPolicyType.getName()).build());
+
assertEquals(1, policyTypeList.size());
assertEquals(inPolicyType.getName(), policyTypeList.get(0).getName());
+
+ policyTypeList = databaseProvider.getFilteredPolicyTypeList(ToscaPolicyTypeFilter.builder().build());
+ assertEquals(2, policyTypeList.size());
+ assertEquals(inPolicyType.getName(), policyTypeList.get(0).getName());
+
+ for (ToscaPolicyType policyType: databaseProvider.getPolicyTypeList(null, null)) {
+ databaseProvider.deletePolicyType(policyType.getName(), policyType.getVersion());
+ }
}
}