summaryrefslogtreecommitdiffstats
path: root/models-base
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-02-03 14:37:33 +0000
committerliamfallon <liam.fallon@est.tech>2020-02-04 12:47:09 +0000
commit70dbf7a387b0e5d00f50a954751c4d4b4e54d7e2 (patch)
tree129e5118d695802d378cd5924b7aa1e5ee043891 /models-base
parent172a67f92943d64d5a1eda2b1dabf6c1c1c77f7e (diff)
Add merge utility for service templates
This utility function allows a TOSCA service template fragment to be merged with an exsiting service template and will be tbe backbone of "create" methods on the API from now on. Issue-ID: POLICY-1402 Change-Id: I3381cb2a1bd30621a639dedc213c546eeb2bf9aa Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-base')
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java5
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java19
2 files changed, 11 insertions, 13 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 2ecf8c1c6..949cb96dc 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
@@ -234,10 +234,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
result = key.validate(result);
- if (conceptMap.isEmpty()) {
- result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "conceptMap may not be empty"));
- } else {
+ if (!conceptMap.isEmpty()) {
result = validateConceptMap(result);
}
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 5e84dff9a..b760e17c0 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,6 +33,7 @@ import java.util.List;
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;
@@ -54,7 +55,7 @@ public class PfConceptContainerTest {
private static final String DUMMY_VALUE = "Dummy";
private static final String VERSION0 = "0.0.1";
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void testConceptContainer() {
DummyPfConceptContainer container = new DummyPfConceptContainer();
@@ -74,10 +75,10 @@ public class PfConceptContainerTest {
assertThatThrownBy(() -> new DummyPfConceptContainer((PfConceptKey) null, null)).hasMessage(KEY_IS_NULL);
assertThatThrownBy(() -> new DummyPfConceptContainer(new PfConceptKey(), null))
- .hasMessage("conceptMap is marked @NonNull but is null");
+ .hasMessage("conceptMap is marked @NonNull but is null");
assertThatThrownBy(() -> new DummyPfConceptContainer(null, new TreeMap<PfConceptKey, DummyPfConcept>()))
- .hasMessage(KEY_IS_NULL);
+ .hasMessage(KEY_IS_NULL);
container.getKey().setName(DUMMY_VALUE);
DummyPfConceptContainer clonedContainer = new DummyPfConceptContainer(container);
@@ -85,7 +86,7 @@ public class PfConceptContainerTest {
assertEquals(DUMMY_VALUE, clonedContainer.getKey().getName());
assertThatThrownBy(() -> new DummyPfConceptContainer((DummyPfConceptContainer) null))
- .hasMessage("copyConcept is marked @NonNull but is null");
+ .hasMessage("copyConcept is marked @NonNull but is null");
List<PfKey> keyList = container.getKeys();
assertEquals(1, keyList.size());
@@ -114,7 +115,7 @@ public class PfConceptContainerTest {
assertEquals(0, container.compareTo(clonedContainer));
assertThatThrownBy(() -> new DummyPfConceptContainer((DummyPfConceptContainer) null))
- .isInstanceOf(NullPointerException.class);
+ .isInstanceOf(NullPointerException.class);
assertFalse(container.compareTo(null) == 0);
assertEquals(0, container.compareTo(container));
@@ -136,7 +137,7 @@ public class PfConceptContainerTest {
DummyPfConceptContainer validateContainer = new DummyPfConceptContainer();
assertFalse(validateContainer.validate(new PfValidationResult()).isOk());
validateContainer.setKey(new PfConceptKey("VCKey", VERSION0));
- assertFalse(validateContainer.validate(new PfValidationResult()).isOk());
+ assertTrue(validateContainer.validate(new PfValidationResult()).isOk());
validateContainer.getConceptMap().put(testConceptKey, new DummyPfConcept(testConceptKey));
assertTrue(validateContainer.validate(new PfValidationResult()).isOk());
@@ -194,11 +195,11 @@ public class PfConceptContainerTest {
DummyBadPfConceptContainer badContainer = new DummyBadPfConceptContainer();
assertThatThrownBy(() -> badContainer.fromAuthorative(authorativeList))
- .hasMessage("failed to instantiate instance of container concept class");
+ .hasMessage("failed to instantiate instance of container concept class");
authorativeList.clear();
assertThatThrownBy(() -> container.fromAuthorative(authorativeList))
- .hasMessage("An incoming list of concepts must have at least one entry");
+ .hasMessage("An incoming list of concepts must have at least one entry");
}
@Test(expected = NullPointerException.class)