/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
-
import org.junit.Test;
import org.onap.policy.models.base.testconcepts.DummyAuthorativeConcept;
import org.onap.policy.models.base.testconcepts.DummyBadPfConceptContainer;
assertThatThrownBy(() -> new DummyPfConceptContainer((DummyPfConceptContainer) null))
.isInstanceOf(NullPointerException.class);
- assertFalse(container.compareTo(null) == 0);
+ assertNotEquals(0, container.compareTo(null));
assertEquals(0, container.compareTo(container));
- assertFalse(container.compareTo(conceptKey) == 0);
+ assertNotEquals(0, container.compareTo(conceptKey));
DummyPfConceptContainer testContainer = new DummyPfConceptContainer(container);
testContainer.getKey().setVersion("0.0.2");
- assertFalse(container.compareTo(testContainer) == 0);
+ assertNotEquals(0, container.compareTo(testContainer));
testContainer.getKey().setVersion(container.getKey().getVersion());
assertEquals(0, container.compareTo(testContainer));
PfConceptKey testConceptKey = new PfConceptKey("TestKey", VERSION0_0_1);
testContainer.getConceptMap().put(testConceptKey, new DummyPfConcept(testConceptKey));
- assertFalse(container.compareTo(testContainer) == 0);
+ assertNotEquals(0, container.compareTo(testContainer));
final DummyPfConceptContainer container3 = container;
assertThatThrownBy(() -> container3.validate(null))
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(conceptKey.getName(), "0.0.0");
+ 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
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");