summaryrefslogtreecommitdiffstats
path: root/models-pdp/src/test/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-17 15:25:39 -0400
committerJim Hahn <jrh3@att.com>2021-08-18 15:51:02 -0400
commitf9506fa28790781dbba0cb7ac16e1f19350ea4ef (patch)
tree1c2fecf159fc15bcdcde851b8818fb3aece9d259 /models-pdp/src/test/java/org
parent35dff8f8bd31fd71e7f5e6c9aa39fe096e35d98a (diff)
Add PDP-TOPIC-CHECK message
Added a new PdpMessage subclass that a PDP can use to verify its ability to send/receive to/from the PDP-PAP topic before it sends its first registration message. Issue-ID: POLICY-3531 Change-Id: Ied61caa805e93e25732385bf91272b4fc248fd69 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pdp/src/test/java/org')
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java10
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpTopicCheckTest.java48
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()));
+ }
+}