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/DatabasePolicyModelsProviderTest.java4
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java18
2 files changed, 18 insertions, 4 deletions
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 5d1a8d0e1..d5c03a2cd 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
@@ -410,7 +410,7 @@ public class DatabasePolicyModelsProviderTest {
assertTrue(databaseProvider.getPolicyTypes(NAME, VERSION_100).getPolicyTypes().isEmpty());
assertTrue(databaseProvider.getPolicyTypeList(NAME, VERSION_100).isEmpty());
assertEquals(0, databaseProvider.getFilteredPolicyTypes(ToscaPolicyTypeFilter.builder().build())
- .getPolicyTypes().get(0).size());
+ .getPolicyTypes().size());
assertEquals(0, databaseProvider.getFilteredPolicyTypeList(ToscaPolicyTypeFilter.builder().build()).size());
assertThatThrownBy(() -> {
@@ -429,7 +429,7 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.getPolicies(NAME, VERSION_100).getToscaTopologyTemplate().getPolicies().isEmpty());
assertTrue(databaseProvider.getPolicyList(NAME, VERSION_100).isEmpty());
assertEquals(0, databaseProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build())
- .getToscaTopologyTemplate().getPolicies().get(0).size());
+ .getToscaTopologyTemplate().getPolicies().size());
assertEquals(0, databaseProvider.getFilteredPolicyList(ToscaPolicyFilter.builder().build()).size());
assertThatThrownBy(() -> {
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 a8a4aab54..1f577ae21 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
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
import com.google.gson.GsonBuilder;
import java.util.Base64;
+import java.util.List;
import java.util.Map;
import lombok.NonNull;
@@ -162,8 +163,9 @@ public class PolicyPersistenceTest {
gotToscaServiceTemplate = databaseProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build());
- assertEquals(gotToscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0)
- .get(policy.getName()).getType(), policy.getType());
+ assertEquals(getToscaPolicyFromMapList(
+ gotToscaServiceTemplate.getToscaTopologyTemplate().getPolicies(), policy.getName()).getType(),
+ policy.getType());
gotToscaServiceTemplate = databaseProvider.getFilteredPolicies(
ToscaPolicyFilter.builder().name(policy.getName()).version(policy.getVersion()).build());
@@ -174,6 +176,18 @@ public class PolicyPersistenceTest {
}
}
+ private ToscaPolicy getToscaPolicyFromMapList(List<Map<String, ToscaPolicy>> toscaPolicyMapList,
+ String policyName) {
+ ToscaPolicy toscaPolicy = new ToscaPolicy();
+ for (Map<String, ToscaPolicy> policyMap: toscaPolicyMapList) {
+ if (policyMap.get(policyName) != null) {
+ toscaPolicy = policyMap.get(policyName);
+ break;
+ }
+ }
+ return toscaPolicy;
+ }
+
private void createPolicyTypes() throws CoderException, PfModelException {
Object yamlObject = new Yaml().load(
ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml"));