aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java10
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java2
4 files changed, 25 insertions, 9 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 565b3fe13..c188560e5 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
@@ -403,7 +403,7 @@ public class DatabasePolicyModelsProviderTest {
assertTrue(databaseProvider.getPolicyTypes("name", "1.0.0").getPolicyTypes().isEmpty());
assertEquals(0, databaseProvider.getPolicyTypeList("name", "1.0.0").size());
assertEquals(0, databaseProvider.getFilteredPolicyTypes(ToscaPolicyTypeFilter.builder().build())
- .getPolicyTypes().get(0).size());
+ .getPolicyTypes().size());
assertEquals(0, databaseProvider.getFilteredPolicyTypeList(ToscaPolicyTypeFilter.builder().build()).size());
assertThatThrownBy(() -> {
@@ -422,7 +422,7 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.getPolicies("name", "1.0.0").getToscaTopologyTemplate().getPolicies().isEmpty());
assertEquals(0, databaseProvider.getPolicyList("name", "1.0.0").size());
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 7fa21b021..a08ad6669 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"));
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
index 0fae304c3..cd73ae599 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
@@ -368,15 +368,17 @@ public class AuthorativeToscaProvider {
/**
* Return the contents of a list of concepts as a list of maps of concepts.
*
- * @param comceptList the concept list
- * @return the concept map
+ * @param conceptList the concept list
+ * @return the list of concept map
*/
private <T extends ToscaEntity> List<Map<String, T>> asConceptMap(List<T> conceptList) {
- Map<String, T> conceptMap = new LinkedHashMap<>();
+ List<Map<String, T>> toscaEntityMapList = new ArrayList<>();
for (T concept : conceptList) {
+ Map<String, T> conceptMap = new LinkedHashMap<>();
conceptMap.put(concept.getName(), concept);
+ toscaEntityMapList.add(conceptMap);
}
- return Collections.singletonList(conceptMap);
+ return toscaEntityMapList;
}
}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
index e360dcda8..c2b387952 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
@@ -211,7 +211,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
ToscaServiceTemplate gotServiceTemplate =
new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, ToscaPolicyTypeFilter.builder().build());
- ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));