summaryrefslogtreecommitdiffstats
path: root/models-base
diff options
context:
space:
mode:
Diffstat (limited to 'models-base')
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java14
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java6
2 files changed, 13 insertions, 7 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
index 2576aab0a..99b5f9710 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
@@ -126,16 +126,22 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
@Override
public List<Map<String, A>> toAuthorative() {
- Map<String, A> toscaPolicyMap = new LinkedHashMap<>();
+ // The returned list is a list of map singletons with one map for each map
+ // entry in the concept container
+ List<Map<String, A>> toscaPolicyMapList = new ArrayList<>();
for (Entry<PfConceptKey, C> conceptEntry : getConceptMap().entrySet()) {
+ // Create a map to hold this entry
+ Map<String, A> toscaPolicyMap = new LinkedHashMap<>(1);
+
+ // Add the concept container entry to the singleton map
@SuppressWarnings("unchecked")
PfAuthorative<A> authoritiveImpl = (PfAuthorative<A>) conceptEntry.getValue();
toscaPolicyMap.put(conceptEntry.getKey().getName(), authoritiveImpl.toAuthorative());
- }
- List<Map<String, A>> toscaPolicyMapList = new ArrayList<>();
- toscaPolicyMapList.add(toscaPolicyMap);
+ // Add the map to the returned list
+ toscaPolicyMapList.add(toscaPolicyMap);
+ }
return toscaPolicyMapList;
}
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
index 44ec51019..4ad7c0f9e 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
@@ -213,9 +213,9 @@ public class PfConceptContainerTest {
List<Map<String, DummyAuthorativeConcept>> outMapList = container.toAuthorative();
- assertEquals(dacMap.get("name0"), outMapList.get(0).get("name0"));
- assertEquals(dacMap.get("name1").getDescription(), outMapList.get(0).get("NULL").getDescription());
- assertEquals(dacMap.get("name2"), outMapList.get(0).get("name2"));
+ assertEquals(dacMap.get("name1"), outMapList.get(0).get("NULL"));
+ assertEquals(dacMap.get("name0").getDescription(), outMapList.get(1).get("name0").getDescription());
+ assertEquals(dacMap.get("name2"), outMapList.get(2).get("name2"));
DummyBadPfConceptContainer badContainer = new DummyBadPfConceptContainer();
assertThatThrownBy(() -> {