aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp
diff options
context:
space:
mode:
Diffstat (limited to 'models-pdp')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java8
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpTopicCheck.java52
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java7
-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
5 files changed, 119 insertions, 6 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java
index 5d0359c74..219193266 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.models.pdp.concepts;
import java.util.UUID;
import lombok.AccessLevel;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
@@ -38,6 +39,7 @@ import org.onap.policy.models.pdp.enums.PdpMessageType;
@Getter
@Setter
@ToString
+@EqualsAndHashCode
public class PdpMessage {
@Setter(AccessLevel.NONE)
@@ -58,13 +60,13 @@ public class PdpMessage {
/**
* Group associated with the PDP. For state-change messages, this may be {@code null},
- * if the {@link #name} is provided.
+ * if the {@link #name} is provided. Also {@code null} for topic-check messages.
*/
private String pdpGroup;
/**
* Group associated with the PDP. For state-change messages, this may be {@code null},
- * if the {@link #name} is provided.
+ * if the {@link #name} is provided. Also {@code null} for topic-check messages.
*/
private String pdpSubgroup;
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpTopicCheck.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpTopicCheck.java
new file mode 100644
index 000000000..2cd3a9d8b
--- /dev/null
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpTopicCheck.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 AT&T Intellectual Property.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.pdp.concepts;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.models.pdp.enums.PdpMessageType;
+
+/**
+ * Class to represent the PDP_TOPIC_CHECK message that a PDP will send to itself.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class PdpTopicCheck extends PdpMessage {
+
+ /**
+ * Constructs the object.
+ *
+ */
+ public PdpTopicCheck() {
+ super(PdpMessageType.PDP_TOPIC_CHECK);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public PdpTopicCheck(PdpTopicCheck source) {
+ super(source);
+ }
+}
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java
index 7ba4ad73e..a8aad9667 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,4 +50,9 @@ public enum PdpMessageType {
* PDP_HEALTH_CHECK operation.
*/
PDP_HEALTH_CHECK,
+
+ /**
+ * Used by PDPs to check their ability to send and receive messages on the PDP-PAP topic.
+ */
+ PDP_TOPIC_CHECK,
}
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()));
+ }
+}