aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java6
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java2
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java9
3 files changed, 10 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 1c1e4613e..b4d51d173 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
@@ -300,7 +300,11 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
@Override
public C get(final PfConceptKey conceptKey) {
- return new PfConceptGetterImpl<>((NavigableMap<PfConceptKey, C>) conceptMap).get(conceptKey);
+ if (conceptKey.isNullVersion()) {
+ return get(conceptKey.getName());
+ } else {
+ return new PfConceptGetterImpl<>((NavigableMap<PfConceptKey, C>) conceptMap).get(conceptKey);
+ }
}
@Override
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
index c641a8035..033a7ddb2 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
@@ -55,7 +55,7 @@ public class PfConceptGetterImpl<C> implements PfConceptGetter<C> {
Assertions.argumentNotNull(conceptKeyName, "conceptKeyName may not be null");
// The very fist key that could have this name
- final PfConceptKey lowestArtifactKey = new PfConceptKey(conceptKeyName, "0.0.1");
+ final PfConceptKey lowestArtifactKey = new PfConceptKey(conceptKeyName, PfKey.NULL_KEY_VERSION);
// Check if we found a key for our name
PfConceptKey foundKey = conceptMap.ceilingKey(lowestArtifactKey);
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
index 35ec95b45..2f36f9a3c 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
@@ -20,7 +20,7 @@
package org.onap.policy.models.provider.revisionhierarchy;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.assertThatCode;
import java.util.Base64;
@@ -28,7 +28,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.TextFileUtils;
-import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
@@ -49,7 +48,7 @@ public class HierarchyFetchTest {
}
@Test
- public void testInitAndClose() throws Exception {
+ public void testMultipleVersions() throws Exception {
PolicyModelsProvider databaseProvider =
new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
@@ -58,9 +57,9 @@ public class HierarchyFetchTest {
.getTextFileAsString("src/test/resources/servicetemplates/MultipleRevisionServiceTemplate.yaml"),
ToscaServiceTemplate.class);
- assertThatThrownBy(() -> {
+ assertThatCode(() -> {
databaseProvider.createPolicies(serviceTemplate);
- }).isInstanceOf(PfModelRuntimeException.class);
+ }).doesNotThrowAnyException();
databaseProvider.close();
}