Add unit test for Version fetch change
[policy/models.git] / models-base / src / test / java / org / onap / policy / models / base / PfConceptContainerTest.java
index 8234741..600605a 100644 (file)
@@ -171,7 +171,23 @@ public class PfConceptContainerTest {
         returnSet = container.getAll(conceptKey.getName(), conceptKey.getVersion());
         assertEquals(conceptKey, returnSet.iterator().next().getKey());
 
+        returnSet = container.getAllNamesAndVersions(conceptKey.getName(), conceptKey.getVersion());
+        assertEquals(conceptKey, returnSet.iterator().next().getKey());
+        returnSet = container.getAllNamesAndVersions(null, conceptKey.getVersion());
+        assertEquals(conceptKey, returnSet.iterator().next().getKey());
+        returnSet = container.getAllNamesAndVersions(null, null);
+        assertEquals(conceptKey, returnSet.iterator().next().getKey());
+        returnSet = container.getAllNamesAndVersions(conceptKey.getName(), null);
+        assertEquals(conceptKey, returnSet.iterator().next().getKey());
+        returnSet = container.getAllNamesAndVersions("IDontExist", "1.0.0");
+        assertTrue(returnSet.isEmpty());
+
         container.getConceptMap().put(conceptKey, new DummyPfConceptSub(conceptKey));
+
+        PfConceptKey anotherKey = new PfConceptKey(conceptKey);
+        assertEquals(conceptKey, container.get(anotherKey).getKey());
+        anotherKey.setVersion(PfKey.NULL_KEY_VERSION);
+        assertEquals(conceptKey, container.get(anotherKey).getKey());
     }
 
     @Test
@@ -216,6 +232,15 @@ public class PfConceptContainerTest {
         assertEquals(dacMap.get(NAME2), outMapList.get(2).get(NAME2));
         assertEquals(dacMap.get(NAME3), outMapList.get(2).get(NAME3));
 
+        List<DummyAuthorativeConcept> outConceptList = container.toAuthorativeList();
+        assertEquals("Hello", outConceptList.get(0).getDescription());
+        assertEquals("Hi", outConceptList.get(1).getDescription());
+        assertEquals("Howdy", outConceptList.get(2).getDescription());
+        assertEquals("Ciao", outConceptList.get(3).getDescription());
+        assertEquals("name4", outConceptList.get(4).getName());
+        assertEquals("1.2.3", outConceptList.get(4).getVersion());
+        assertEquals("0.0.0", outConceptList.get(5).getVersion());
+
         DummyBadPfConceptContainer badContainer = new DummyBadPfConceptContainer();
         assertThatThrownBy(() -> badContainer.fromAuthorative(authorativeList))
             .hasMessage("failed to instantiate instance of container concept class");