aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca/src/test/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-08-26 12:20:27 -0400
committerJim Hahn <jrh3@att.com>2019-08-27 11:49:30 -0400
commitfd809717ca774dfabeddd3984fbbbbdfd029601e (patch)
treea4070c2529b0be1899ece44e3687b72ed32505a4 /models-tosca/src/test/java/org
parenta930b0105c2e45a657427cfcb41fc0330d0c2e99 (diff)
Replace copyTo methods with copy constructors
Deleted the copyTo() method from PfConcepts and replaced uses with deep-copy constructors. Also added mapMap() and makeCopy() methods to PfUtils to facilitate. Change-Id: Id6391bb806ef0dfab6c1089278bf2b514c7e303e Issue-ID: POLICY-1600 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-tosca/src/test/java/org')
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java12
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilterTest.java7
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModelTest.java6
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTest.java12
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypeTest.java9
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java9
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java7
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java9
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplateTest.java8
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTriggerTest.java7
10 files changed, 28 insertions, 58 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java
index 591c65518..281ddfcee 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java
@@ -62,9 +62,8 @@ public class JpaToscaDataTypeTest {
new JpaToscaDataType((PfConceptKey) null);
}).hasMessage("key is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- new JpaToscaDataType((JpaToscaDataType) null);
- }).hasMessage("copyConcept is marked @NonNull but is null");
+ assertThatThrownBy(() -> new JpaToscaDataType((JpaToscaDataType) null))
+ .isInstanceOf(NullPointerException.class);
PfConceptKey dtKey = new PfConceptKey("tdt", VERSION_001);
JpaToscaDataType tdt = new JpaToscaDataType(dtKey);
@@ -86,8 +85,7 @@ public class JpaToscaDataTypeTest {
assertEquals(tdt, tdtClone0);
assertEquals(0, tdt.compareTo(tdtClone0));
- JpaToscaDataType tdtClone1 = new JpaToscaDataType();
- tdt.copyTo(tdtClone1);
+ JpaToscaDataType tdtClone1 = new JpaToscaDataType(tdt);
assertEquals(tdt, tdtClone1);
assertEquals(0, tdt.compareTo(tdtClone1));
@@ -106,10 +104,6 @@ public class JpaToscaDataTypeTest {
otherDt.setProperties(properties);
assertEquals(0, tdt.compareTo(otherDt));
- assertThatThrownBy(() -> {
- tdt.copyTo(null);
- }).hasMessage("target is marked @NonNull but is null");
-
assertEquals(3, tdt.getKeys().size());
assertEquals(1, new JpaToscaDataType().getKeys().size());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilterTest.java
index 602985dda..7d34a73eb 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilterTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilterTest.java
@@ -61,7 +61,7 @@ public class JpaToscaEventFilterTest {
.hasMessage("node is marked @NonNull but is null");
assertThatThrownBy(() -> new JpaToscaEventFilter((JpaToscaEventFilter) null))
- .hasMessage("copyConcept is marked @NonNull but is null");
+ .isInstanceOf(NullPointerException.class);
PfConceptKey efParentKey = new PfConceptKey("tParentKey", VERSION_001);
PfReferenceKey efKey = new PfReferenceKey(efParentKey, "trigger0");
@@ -78,8 +78,7 @@ public class JpaToscaEventFilterTest {
assertEquals(tef, tdtClone0);
assertEquals(0, tef.compareTo(tdtClone0));
- JpaToscaEventFilter tdtClone1 = new JpaToscaEventFilter();
- tef.copyTo(tdtClone1);
+ JpaToscaEventFilter tdtClone1 = new JpaToscaEventFilter(tef);
assertEquals(tef, tdtClone1);
assertEquals(0, tef.compareTo(tdtClone1));
@@ -100,8 +99,6 @@ public class JpaToscaEventFilterTest {
otherDt.setCapability(A_CAPABILITY);
assertEquals(0, tef.compareTo(otherDt));
- assertThatThrownBy(() -> tef.copyTo(null)).hasMessage("target is marked @NonNull but is null");
-
assertEquals(2, tef.getKeys().size());
assertEquals(2, new JpaToscaEventFilter().getKeys().size());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModelTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModelTest.java
index 40fbc0515..74a4e7c7f 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModelTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModelTest.java
@@ -73,8 +73,7 @@ public class JpaToscaModelTest {
assertEquals(tm, tttClone0);
assertEquals(0, tm.compareTo(tttClone0));
- JpaToscaModel tttClone1 = new JpaToscaModel();
- tm.copyTo(tttClone1);
+ JpaToscaModel tttClone1 = new JpaToscaModel(tm);
assertEquals(tm, tttClone1);
assertEquals(0, tm.compareTo(tttClone1));
@@ -91,7 +90,8 @@ public class JpaToscaModelTest {
otherDt.setServiceTemplates(tsts);
assertEquals(0, tm.compareTo(otherDt));
- assertThatThrownBy(() -> tm.copyTo(null)).hasMessage("targetObject is marked @NonNull but is null");
+ assertThatThrownBy(() -> new JpaToscaModel((JpaToscaModel) null))
+ .isInstanceOf(NullPointerException.class);
assertEquals(2, tm.getKeys().size());
assertEquals(2, new JpaToscaModel().getKeys().size());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTest.java
index bb961783c..73e5066c1 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTest.java
@@ -76,9 +76,8 @@ public class JpaToscaPolicyTest {
new JpaToscaPolicy(null, new PfConceptKey());
}).hasMessage(KEY_IS_NULL);
- assertThatThrownBy(() -> {
- new JpaToscaPolicy((JpaToscaPolicy) null);
- }).hasMessage("copyConcept is marked @NonNull but is null");
+ assertThatThrownBy(() -> new JpaToscaPolicy((JpaToscaPolicy) null))
+ .isInstanceOf(NullPointerException.class);
PfConceptKey tpKey = new PfConceptKey("tdt", VERSION_001);
PfConceptKey ptKey = new PfConceptKey("policyType", VERSION_001);
@@ -99,8 +98,7 @@ public class JpaToscaPolicyTest {
assertEquals(tp, tdtClone0);
assertEquals(0, tp.compareTo(tdtClone0));
- JpaToscaPolicy tdtClone1 = new JpaToscaPolicy();
- tp.copyTo(tdtClone1);
+ JpaToscaPolicy tdtClone1 = new JpaToscaPolicy(tp);
assertEquals(tp, tdtClone1);
assertEquals(0, tp.compareTo(tdtClone1));
@@ -121,10 +119,6 @@ public class JpaToscaPolicyTest {
otherDt.setTargets(targets);
assertEquals(0, tp.compareTo(otherDt));
- assertThatThrownBy(() -> {
- tp.copyTo(null);
- }).hasMessage("target is marked @NonNull but is null");
-
assertEquals(3, tp.getKeys().size());
assertEquals(2, new JpaToscaPolicy().getKeys().size());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypeTest.java
index eb94a5ecc..1f2a4e111 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypeTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypeTest.java
@@ -58,7 +58,7 @@ public class JpaToscaPolicyTypeTest {
.hasMessage("key is marked @NonNull but is null");
assertThatThrownBy(() -> new JpaToscaPolicyType((JpaToscaPolicyType) null))
- .hasMessage("copyConcept is marked @NonNull but is null");
+ .isInstanceOf(NullPointerException.class);
PfConceptKey ptKey = new PfConceptKey("tdt", VERSION_001);
JpaToscaPolicyType tpt = new JpaToscaPolicyType(ptKey);
@@ -96,8 +96,7 @@ public class JpaToscaPolicyTypeTest {
assertEquals(tpt, tdtClone0);
assertEquals(0, tpt.compareTo(tdtClone0));
- JpaToscaPolicyType tdtClone1 = new JpaToscaPolicyType();
- tpt.copyTo(tdtClone1);
+ JpaToscaPolicyType tdtClone1 = new JpaToscaPolicyType(tpt);
assertEquals(tpt, tdtClone1);
assertEquals(0, tpt.compareTo(tdtClone1));
@@ -124,8 +123,6 @@ public class JpaToscaPolicyTypeTest {
otherDt.setTriggers(triggers);
assertEquals(0, tpt.compareTo(otherDt));
- assertThatThrownBy(() -> tpt.copyTo(null)).hasMessage("target is marked @NonNull but is null");
-
assertEquals(6, tpt.getKeys().size());
assertEquals(1, new JpaToscaPolicyType().getKeys().size());
@@ -177,7 +174,7 @@ public class JpaToscaPolicyTypeTest {
.hasMessage("key is marked @NonNull but is null");
assertThatThrownBy(() -> new JpaToscaEntityType<ToscaPolicy>((JpaToscaEntityType<ToscaPolicy>) null))
- .hasMessage("copyConcept is marked @NonNull but is null");
+ .isInstanceOf(NullPointerException.class);
JpaToscaEntityType<ToscaPolicy> tet = new JpaToscaEntityType<>(tpt.getKey());
assertEquals(-1, tet.compareTo(null));
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java
index 70018b62a..2da2090de 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java
@@ -63,9 +63,6 @@ public class JpaToscaPropertyTest {
assertThatThrownBy(() -> new JpaToscaProperty(new PfReferenceKey(), null))
.hasMessage("type is marked @NonNull but is null");
- assertThatThrownBy(() -> new JpaToscaProperty((JpaToscaProperty) null))
- .hasMessage("copyConcept is marked @NonNull but is null");
-
PfConceptKey pparentKey = new PfConceptKey("tParentKey", VERSION_001);
PfReferenceKey pkey = new PfReferenceKey(pparentKey, "trigger0");
PfConceptKey ptypeKey = new PfConceptKey("TTypeKey", VERSION_001);
@@ -95,8 +92,7 @@ public class JpaToscaPropertyTest {
assertEquals(tp, tdtClone0);
assertEquals(0, tp.compareTo(tdtClone0));
- JpaToscaProperty tdtClone1 = new JpaToscaProperty();
- tp.copyTo(tdtClone1);
+ JpaToscaProperty tdtClone1 = new JpaToscaProperty(tp);
assertEquals(tp, tdtClone1);
assertEquals(0, tp.compareTo(tdtClone1));
@@ -136,7 +132,8 @@ public class JpaToscaPropertyTest {
otherDt.setStatus(ToscaProperty.Status.SUPPORTED);
assertEquals(0, tp.compareTo(otherDt));
- assertThatThrownBy(() -> tp.copyTo(null)).hasMessage("target is marked @NonNull but is null");
+ assertThatThrownBy(() -> new JpaToscaProperty((JpaToscaProperty) null))
+ .isInstanceOf(NullPointerException.class);
assertEquals(3, tp.getKeys().size());
assertEquals(2, new JpaToscaProperty().getKeys().size());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java
index df72ce57b..911f4a1bf 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java
@@ -61,7 +61,7 @@ public class JpaToscaServiceTemplateTest {
.hasMessage("toscaDefinitionsVersion is marked @NonNull but is null");
assertThatThrownBy(() -> new JpaToscaServiceTemplate((JpaToscaServiceTemplate) null))
- .hasMessage("copyConcept is marked @NonNull but is null");
+ .isInstanceOf(NullPointerException.class);
PfConceptKey tstKey = new PfConceptKey("tst", VERSION_001);
JpaToscaServiceTemplate tst = new JpaToscaServiceTemplate(tstKey, "Tosca Version");
@@ -93,8 +93,7 @@ public class JpaToscaServiceTemplateTest {
assertEquals(tst, tttClone0);
assertEquals(0, tst.compareTo(tttClone0));
- JpaToscaServiceTemplate tttClone1 = new JpaToscaServiceTemplate();
- tst.copyTo(tttClone1);
+ JpaToscaServiceTemplate tttClone1 = new JpaToscaServiceTemplate(tst);
assertEquals(tst, tttClone1);
assertEquals(0, tst.compareTo(tttClone1));
@@ -117,8 +116,6 @@ public class JpaToscaServiceTemplateTest {
otherDt.setTopologyTemplate(ttt);
assertEquals(0, tst.compareTo(otherDt));
- assertThatThrownBy(() -> tst.copyTo(null)).hasMessage("target is marked @NonNull but is null");
-
assertEquals(6, tst.getKeys().size());
assertEquals(1, new JpaToscaServiceTemplate().getKeys().size());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java
index e77f12062..49cf18e28 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java
@@ -68,8 +68,8 @@ public class JpaToscaTimeIntervalTest {
assertThatThrownBy(() -> new JpaToscaTimeInterval(new PfReferenceKey(), new Date(), null))
.hasMessage("endTime is marked @NonNull but is null");
- assertThatThrownBy(() -> new JpaToscaTimeInterval((JpaToscaTimeInterval) null))
- .hasMessage("copyConcept is marked @NonNull but is null");
+ assertThatThrownBy(() -> new JpaToscaServiceTemplate((JpaToscaServiceTemplate) null))
+ .isInstanceOf(NullPointerException.class);
PfConceptKey ttiParentKey = new PfConceptKey("tParentKey", "0.0.1");
PfReferenceKey ttiKey = new PfReferenceKey(ttiParentKey, "trigger0");
@@ -81,8 +81,7 @@ public class JpaToscaTimeIntervalTest {
assertEquals(tti, tdtClone0);
assertEquals(0, tti.compareTo(tdtClone0));
- JpaToscaTimeInterval tdtClone1 = new JpaToscaTimeInterval();
- tti.copyTo(tdtClone1);
+ JpaToscaTimeInterval tdtClone1 = new JpaToscaTimeInterval(tti);
assertEquals(tti, tdtClone1);
assertEquals(0, tti.compareTo(tdtClone1));
@@ -101,8 +100,6 @@ public class JpaToscaTimeIntervalTest {
otherDt.setEndTime(endTime);
assertEquals(0, tti.compareTo(otherDt));
- assertThatThrownBy(() -> tti.copyTo(null)).hasMessage("target is marked @NonNull but is null");
-
assertEquals(1, tti.getKeys().size());
assertEquals(1, new JpaToscaTimeInterval().getKeys().size());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplateTest.java
index 7712a64c0..94525f0a9 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplateTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplateTest.java
@@ -56,7 +56,7 @@ public class JpaToscaTopologyTemplateTest {
.hasMessage("key is marked @NonNull but is null");
assertThatThrownBy(() -> new JpaToscaTopologyTemplate((JpaToscaTopologyTemplate) null))
- .hasMessage("copyConcept is marked @NonNull but is null");
+ .isInstanceOf(NullPointerException.class);
PfReferenceKey tttKey = new PfReferenceKey("tst", VERSION_001, "ttt");
JpaToscaTopologyTemplate ttt = new JpaToscaTopologyTemplate(tttKey);
@@ -78,8 +78,7 @@ public class JpaToscaTopologyTemplateTest {
assertEquals(ttt, tttClone0);
assertEquals(0, ttt.compareTo(tttClone0));
- JpaToscaTopologyTemplate tttClone1 = new JpaToscaTopologyTemplate();
- ttt.copyTo(tttClone1);
+ JpaToscaTopologyTemplate tttClone1 = new JpaToscaTopologyTemplate(ttt);
assertEquals(ttt, tttClone1);
assertEquals(0, ttt.compareTo(tttClone1));
@@ -98,7 +97,8 @@ public class JpaToscaTopologyTemplateTest {
otherDt.setPolicies(policies);
assertEquals(0, ttt.compareTo(otherDt));
- assertThatThrownBy(() -> ttt.copyTo(null)).hasMessage("target is marked @NonNull but is null");
+ assertThatThrownBy(() -> new JpaToscaTopologyTemplate((JpaToscaTopologyTemplate) null))
+ .isInstanceOf(NullPointerException.class);
assertEquals(4, ttt.getKeys().size());
assertEquals(1, new JpaToscaTopologyTemplate().getKeys().size());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTriggerTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTriggerTest.java
index 97c1b6fb7..0baf1e5e2 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTriggerTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTriggerTest.java
@@ -75,7 +75,7 @@ public class JpaToscaTriggerTest {
.hasMessage("eventType is marked @NonNull but is null");
assertThatThrownBy(() -> new JpaToscaTrigger((JpaToscaTrigger) null))
- .hasMessage("copyConcept is marked @NonNull but is null");
+ .isInstanceOf(NullPointerException.class);
PfConceptKey tparentKey = new PfConceptKey("tParentKey", VERSION_001);
PfReferenceKey tkey = new PfReferenceKey(tparentKey, "trigger0");
@@ -108,8 +108,7 @@ public class JpaToscaTriggerTest {
assertEquals(tdt, tdtClone0);
assertEquals(0, tdt.compareTo(tdtClone0));
- JpaToscaTrigger tdtClone1 = new JpaToscaTrigger();
- tdt.copyTo(tdtClone1);
+ JpaToscaTrigger tdtClone1 = new JpaToscaTrigger(tdt);
assertEquals(tdt, tdtClone1);
assertEquals(0, tdt.compareTo(tdtClone1));
@@ -147,8 +146,6 @@ public class JpaToscaTriggerTest {
otherDt.setEvaluations(0);
assertEquals(0, tdt.compareTo(otherDt));
- assertThatThrownBy(() -> tdt.copyTo(null)).hasMessage("target is marked @NonNull but is null");
-
assertEquals(4, tdt.getKeys().size());
assertEquals(1, new JpaToscaTrigger().getKeys().size());