Add "source" to PAP-PDP messages 09/122109/4
authorJim Hahn <jrh3@att.com>
Tue, 22 Jun 2021 16:01:37 +0000 (12:01 -0400)
committerJim Hahn <jrh3@att.com>
Wed, 23 Jun 2021 15:18:31 +0000 (11:18 -0400)
Added a "source" field to the PdpStateChange and PdpUpdate messages so
that PAP can record a unique name in the message, for logging purposes.

In a separate review, planning to add a method in policy-common for
creating the unique name.  Once that has been created, it will be used
by PAP, to populate the "source" field, and all PDPs, to populate the
"name" field in the PdpStatus messages.

Issue-ID: POLICY-3409
Change-Id: I86c97702abe62a5672720330df50b7b106187661
Signed-off-by: Jim Hahn <jrh3@att.com>
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java

index fe953cb..6a7b7d5 100644 (file)
@@ -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.
@@ -38,6 +38,11 @@ import org.onap.policy.models.pdp.enums.PdpState;
 @ToString(callSuper = true)
 public class PdpStateChange extends PdpMessage {
 
+    /**
+     * System from which the message originated.
+     */
+    private String source;
+
     private PdpState state;
 
     /**
@@ -56,6 +61,7 @@ public class PdpStateChange extends PdpMessage {
     public PdpStateChange(PdpStateChange source) {
         super(source);
 
+        this.source = source.source;
         this.state = source.state;
     }
 }
index 19f79ee..aa2b85d 100644 (file)
@@ -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.
  *  Modifications Copyright (C) 2021 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,6 +44,11 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
 @ToString(callSuper = true)
 public class PdpUpdate extends PdpMessage {
 
+    /**
+     * System from which the message originated.
+     */
+    private String source;
+
     /**
      * Description of the PDP group.
      */
@@ -77,6 +82,7 @@ public class PdpUpdate extends PdpMessage {
     public PdpUpdate(PdpUpdate source) {
         super(source);
 
+        this.source = source.source;
         this.description = source.description;
         this.pdpHeartbeatIntervalMs = source.pdpHeartbeatIntervalMs;
         this.policiesToBeDeployed = (source.policiesToBeDeployed == null ? null
index f50d2a7..aa715b7 100644 (file)
@@ -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");
@@ -43,6 +43,7 @@ public class PdpStateChangeTest {
         assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpStateChange(orig).toString()));
 
         // verify with all values
+        orig.setSource("my-source");
         orig.setName("my-name");
         orig.setPdpGroup("my-group");
         orig.setPdpSubgroup("my-subgroup");
index a24b410..13ee54b 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Models
  * ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019-2021 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,6 +49,7 @@ public class PdpUpdateTest {
         assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpUpdate(orig).toString()));
 
         // verify with all values
+        orig.setSource("my-source");
         orig.setDescription("my-description");
         orig.setName("my-name");
         orig.setPdpGroup("my-group");