diff options
Diffstat (limited to 'models-pdp/src/test')
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java | 10 | ||||
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpTopicCheckTest.java | 48 |
2 files changed, 56 insertions, 2 deletions
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java index dc6726846..763b29a4b 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Models * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,6 +24,7 @@ package org.onap.policy.models.pdp.concepts; 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.assertTrue; import org.junit.Test; @@ -39,7 +40,7 @@ public class PdpMessageTest { private PdpMessage message; @Test - public void testCopyConstructor() { + public void testCopyConstructorAndEquals() { assertThatThrownBy(() -> new PdpMessage((PdpMessage) null)).isInstanceOf(NullPointerException.class); // verify with null values @@ -48,6 +49,7 @@ public class PdpMessageTest { newmsg.setRequestId(message.getRequestId()); newmsg.setTimestampMs(message.getTimestampMs()); assertEquals(message.toString(), newmsg.toString()); + assertEquals(message, newmsg); // verify with all values message = makeMessage(PDP_NAME, PDP_GROUP, PDP_SUBGROUP); @@ -55,6 +57,10 @@ public class PdpMessageTest { newmsg.setRequestId(message.getRequestId()); newmsg.setTimestampMs(message.getTimestampMs()); assertEquals(message.toString(), newmsg.toString()); + assertEquals(message, newmsg); + + newmsg.setTimestampMs(1); + assertNotEquals(message, newmsg); } @Test diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpTopicCheckTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpTopicCheckTest.java new file mode 100644 index 000000000..270278ab1 --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpTopicCheckTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2021 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; + +import org.junit.Test; + +/** + * Test the copy constructor, as {@link ModelsTest} tests the other methods. + */ +public class PdpTopicCheckTest { + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new PdpTopicCheck(null)).isInstanceOf(NullPointerException.class); + + PdpTopicCheck orig = new PdpTopicCheck(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpTopicCheck(orig).toString())); + + // verify with all values + orig.setName("my-name"); + + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpTopicCheck(orig).toString())); + } +} |