Fix op policy payload

The payload should contain a different content value, not the entire
yaml

Issue-ID: CLAMP-395
Change-Id: I7311caffed554f3c97ef7e07c729266a4fe30940
Signed-off-by: Determe, Sebastien (sd378r) <sebastien.determe@intl.att.com>
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
index 906c3cf..2ce5aff 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
@@ -183,13 +183,20 @@
         return (new Yaml()).dump(jsonMap);
     }
 
+    public String createPolicyPayloadYamlLegacy() {
+        Gson gson = new GsonBuilder().create();
+        Map<?, ?> jsonMap = gson.fromJson(gson.toJson(this.configurationsJson.get("operational_policy")), Map.class);
+        return (new Yaml()).dump(jsonMap);
+    }
+
     @Override
     public String createPolicyPayload() throws UnsupportedEncodingException {
 
         // Now the Yaml payload must be injected in a json ...
         JsonObject payload = new JsonObject();
         payload.addProperty("policy-id", this.getName());
-        payload.addProperty("content", URLEncoder.encode(createPolicyPayloadYaml(), StandardCharsets.UTF_8.toString()));
+        payload.addProperty("content",
+            URLEncoder.encode(createPolicyPayloadYamlLegacy(), StandardCharsets.UTF_8.toString()));
         return new GsonBuilder().setPrettyPrinting().create().toJson(payload);
     }
 
diff --git a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
index b12ca89..caed3ba 100644
--- a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
+++ b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
@@ -45,6 +45,8 @@
         OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig);
         assertThat(policy.createPolicyPayloadYaml())
             .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.yaml"));
+        assertThat(policy.createPolicyPayloadYamlLegacy())
+            .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload-legacy.yaml"));
         assertThat(policy.createPolicyPayload())
             .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.json"));
     }
diff --git a/src/test/resources/tosca/operational-policy-payload-legacy.yaml b/src/test/resources/tosca/operational-policy-payload-legacy.yaml
new file mode 100644
index 0000000..ddaaf71
--- /dev/null
+++ b/src/test/resources/tosca/operational-policy-payload-legacy.yaml
@@ -0,0 +1,23 @@
+controlLoop: {controlLoopName: control loop, version: 2.0.0, trigger_policy: new1,
+  timeout: '30', abatement: 'true'}
+policies:
+- id: new1
+  recipe: Rebuild
+  retry: '10'
+  timeout: '20'
+  actor: SO
+  payload: test
+  success: new2
+  failure: new2
+  failure_timeout: new2
+  failure_retries: new2
+  failure_exception: new2
+  failure_guard: new2
+  target: {type: VFC, resourceTargetId: test}
+- id: new2
+  recipe: Migrate
+  retry: '30'
+  timeout: '40'
+  actor: SDNC
+  payload: test
+  target: {type: VFC, resourceTargetId: test}
diff --git a/src/test/resources/tosca/operational-policy-payload.json b/src/test/resources/tosca/operational-policy-payload.json
index 1017d0a..f2271cd 100644
--- a/src/test/resources/tosca/operational-policy-payload.json
+++ b/src/test/resources/tosca/operational-policy-payload.json
@@ -1,4 +1,4 @@
 {
   "policy-id": "testPolicy",
-  "content": "tosca_definitions_version%3A+tosca_simple_yaml_1_0_0%0Atopology_template%3A%0A++policies%3A%0A++-+testPolicy%3A%0A++++++type%3A+onap.policies.controlloop.Operational%0A++++++version%3A+1.0.0%0A++++++metadata%3A+%7Bpolicy-id%3A+testPolicy%7D%0A++++++properties%3A%0A++++++++controlLoop%3A+%7BcontrolLoopName%3A+control+loop%2C+version%3A+2.0.0%2C+trigger_policy%3A+new1%2C%0A++++++++++timeout%3A+%2730%27%2C+abatement%3A+%27true%27%7D%0A++++++++policies%3A%0A++++++++-+id%3A+new1%0A++++++++++recipe%3A+Rebuild%0A++++++++++retry%3A+%2710%27%0A++++++++++timeout%3A+%2720%27%0A++++++++++actor%3A+SO%0A++++++++++payload%3A+test%0A++++++++++success%3A+new2%0A++++++++++failure%3A+new2%0A++++++++++failure_timeout%3A+new2%0A++++++++++failure_retries%3A+new2%0A++++++++++failure_exception%3A+new2%0A++++++++++failure_guard%3A+new2%0A++++++++++target%3A+%7Btype%3A+VFC%2C+resourceTargetId%3A+test%7D%0A++++++++-+id%3A+new2%0A++++++++++recipe%3A+Migrate%0A++++++++++retry%3A+%2730%27%0A++++++++++timeout%3A+%2740%27%0A++++++++++actor%3A+SDNC%0A++++++++++payload%3A+test%0A++++++++++target%3A+%7Btype%3A+VFC%2C+resourceTargetId%3A+test%7D%0A"
+  "content": "controlLoop%3A+%7BcontrolLoopName%3A+control+loop%2C+version%3A+2.0.0%2C+trigger_policy%3A+new1%2C%0A++timeout%3A+%2730%27%2C+abatement%3A+%27true%27%7D%0Apolicies%3A%0A-+id%3A+new1%0A++recipe%3A+Rebuild%0A++retry%3A+%2710%27%0A++timeout%3A+%2720%27%0A++actor%3A+SO%0A++payload%3A+test%0A++success%3A+new2%0A++failure%3A+new2%0A++failure_timeout%3A+new2%0A++failure_retries%3A+new2%0A++failure_exception%3A+new2%0A++failure_guard%3A+new2%0A++target%3A+%7Btype%3A+VFC%2C+resourceTargetId%3A+test%7D%0A-+id%3A+new2%0A++recipe%3A+Migrate%0A++retry%3A+%2730%27%0A++timeout%3A+%2740%27%0A++actor%3A+SDNC%0A++payload%3A+test%0A++target%3A+%7Btype%3A+VFC%2C+resourceTargetId%3A+test%7D%0A"
 }
\ No newline at end of file