Merge "Change field names in policy notifications to match wiki"
authorJorge Hernandez <jorge.hernandez-herrero@att.com>
Fri, 1 Nov 2019 13:22:20 +0000 (13:22 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 1 Nov 2019 13:22:20 +0000 (13:22 +0000)
models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyNotification.java
models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyStatus.java
models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyStatusTest.java

index 1cdf254..0583edd 100644 (file)
@@ -31,13 +31,13 @@ public class PolicyNotification {
     /**
      * Status of policies that are being added to PDPs.
      */
-    @SerializedName("added-policies")
+    @SerializedName("deployed-policies")
     private List<PolicyStatus> added = new ArrayList<>();
 
     /**
      * Status of policies that are being deleted from PDPs.
      */
-    @SerializedName("deleted-policies")
+    @SerializedName("undeployed-policies")
     private List<PolicyStatus> deleted = new ArrayList<>();
 
 
index 2da4c3c..427f168 100644 (file)
@@ -29,10 +29,16 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
 public class PolicyStatus {
 
     @SerializedName("policy-type")
-    private ToscaPolicyTypeIdentifier policyType;
+    private String policyTypeId;
+
+    @SerializedName("policy-type-version")
+    private String policyTypeVersion;
 
     @SerializedName("policy-id")
-    private ToscaPolicyIdentifier policy;
+    private String policyId;
+
+    @SerializedName("policy-version")
+    private String policyVersion;
 
     /**
      * Number of PDPs that have successfully added/deleted the policy.
@@ -53,8 +59,25 @@ public class PolicyStatus {
     private int incompleteCount = 0;
 
 
+    /**
+     * Constructs the object.
+     *
+     * @param policyType policy type, from which the name and version are to be extracted
+     * @param policy policy identifier, from which the name and version are to be
+     *        extracted
+     */
     public PolicyStatus(ToscaPolicyTypeIdentifier policyType, ToscaPolicyIdentifier policy) {
-        this.policyType = policyType;
-        this.policy = policy;
+        this.policyTypeId = policyType.getName();
+        this.policyTypeVersion = policyType.getVersion();
+        this.policyId = policy.getName();
+        this.policyVersion = policy.getVersion();
+    }
+
+    public ToscaPolicyTypeIdentifier getPolicyType() {
+        return new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion);
+    }
+
+    public ToscaPolicyIdentifier getPolicy() {
+        return new ToscaPolicyIdentifier(policyId, policyVersion);
     }
 }
index 0a00e7b..869bd1d 100644 (file)
@@ -19,7 +19,6 @@
 package org.onap.policy.models.pap.concepts;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
 
 import org.junit.Test;
 import org.onap.policy.common.utils.coder.CoderException;
@@ -39,8 +38,13 @@ public class PolicyStatusTest {
 
         // test constructor with arguments
         PolicyStatus status = new PolicyStatus(type, policy);
-        assertSame(type, status.getPolicyType());
-        assertSame(policy, status.getPolicy());
+        assertEquals("my-type", status.getPolicyTypeId());
+        assertEquals("3.2.1", status.getPolicyTypeVersion());
+        assertEquals("my-name", status.getPolicyId());
+        assertEquals("1.2.3", status.getPolicyVersion());
+
+        assertEquals(type, status.getPolicyType());
+        assertEquals(policy, status.getPolicy());
 
         assertEquals(0, status.getSuccessCount());
         assertEquals(0, status.getFailureCount());