diff options
Diffstat (limited to 'src/test')
5 files changed, 66 insertions, 30 deletions
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 caed3ba9..8972e511 100644 --- a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java +++ b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java @@ -33,6 +33,7 @@ import java.util.Map; import org.junit.Test; import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.policy.operational.LegacyOperationalPolicy; import org.onap.clamp.policy.operational.OperationalPolicy; import org.skyscreamer.jsonassert.JSONAssert; @@ -43,15 +44,23 @@ public class OperationalPolicyPayloadTest { JsonObject jsonConfig = new GsonBuilder().create().fromJson( ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class); 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")); } @Test + public void testLegacyOperationalPolicyPayloadConstruction() throws IOException { + JsonObject jsonConfig = new GsonBuilder().create().fromJson( + ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class); + assertThat(LegacyOperationalPolicy.createPolicyPayloadYamlLegacy(jsonConfig.get("operational_policy"))) + .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload-legacy.yaml")); + } + + @Test public void testGuardPolicyEmptyPayloadConstruction() throws IOException { JsonObject jsonConfig = new GsonBuilder().create().fromJson( ResourceFileUtil.getResourceAsString("tosca/operational-policy-no-guard-properties.json"), diff --git a/src/test/resources/tosca/operational-policy-payload-legacy.yaml b/src/test/resources/tosca/operational-policy-payload-legacy.yaml index ddaaf71f..41184c9c 100644 --- a/src/test/resources/tosca/operational-policy-payload-legacy.yaml +++ b/src/test/resources/tosca/operational-policy-payload-legacy.yaml @@ -1,23 +1,39 @@ -controlLoop: {controlLoopName: control loop, version: 2.0.0, trigger_policy: new1, - timeout: '30', abatement: 'true'} +controlLoop: + abatement: true + controlLoopName: control loop + timeout: 30 + trigger_policy: new1 + version: 2.0.0 policies: -- id: new1 - recipe: Rebuild - retry: '10' - timeout: '20' - actor: SO - payload: test - success: new2 +- actor: SO failure: new2 - failure_timeout: new2 - failure_retries: new2 failure_exception: new2 failure_guard: new2 - target: {type: VFC, resourceTargetId: test} -- id: new2 + failure_retries: new2 + failure_timeout: new2 + id: new1 + payload: + configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[10].value","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[15].value","enabled":"$.vf-module-topology.vf-module-parameters.param[22].value"}]' + requestParameters: '{"usePreload":true,"userParams":[]}' + recipe: Rebuild + retry: 10 + success: new2 + target: + resourceTargetId: test + type: VFC + timeout: 20 +- actor: SDNC + failure: final_failure + failure_exception: final_failure_exception + failure_guard: final_failure_guard + failure_retries: final_failure_retries + failure_timeout: final_failure_timeout + id: new2 + payload: '' recipe: Migrate - retry: '30' - timeout: '40' - actor: SDNC - payload: test - target: {type: VFC, resourceTargetId: test} + retry: 30 + success: final_success + target: + resourceTargetId: test + type: VFC + timeout: 40 diff --git a/src/test/resources/tosca/operational-policy-payload.json b/src/test/resources/tosca/operational-policy-payload.json index f2271cd3..5097654d 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": "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" + "content": "controlLoop%3A%0A++abatement%3A+true%0A++controlLoopName%3A+control+loop%0A++timeout%3A+30%0A++trigger_policy%3A+new1%0A++version%3A+2.0.0%0Apolicies%3A%0A-+actor%3A+SO%0A++failure%3A+new2%0A++failure_exception%3A+new2%0A++failure_guard%3A+new2%0A++failure_retries%3A+new2%0A++failure_timeout%3A+new2%0A++id%3A+new1%0A++payload%3A%0A++++configurationParameters%3A+%27%5B%7B%22ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B10%5D.value%22%2C%22oam-ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B15%5D.value%22%2C%22enabled%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B22%5D.value%22%7D%5D%27%0A++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue%2C%22userParams%22%3A%5B%5D%7D%27%0A++recipe%3A+Rebuild%0A++retry%3A+10%0A++success%3A+new2%0A++target%3A%0A++++resourceTargetId%3A+test%0A++++type%3A+VFC%0A++timeout%3A+20%0A-+actor%3A+SDNC%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+new2%0A++payload%3A+%27%27%0A++recipe%3A+Migrate%0A++retry%3A+30%0A++success%3A+final_success%0A++target%3A%0A++++resourceTargetId%3A+test%0A++++type%3A+VFC%0A++timeout%3A+40%0A" }
\ No newline at end of file diff --git a/src/test/resources/tosca/operational-policy-payload.yaml b/src/test/resources/tosca/operational-policy-payload.yaml index 68116b00..c3a6b5c2 100644 --- a/src/test/resources/tosca/operational-policy-payload.yaml +++ b/src/test/resources/tosca/operational-policy-payload.yaml @@ -4,28 +4,39 @@ topology_template: - testPolicy: type: onap.policies.controlloop.Operational version: 1.0.0 - metadata: {policy-id: testPolicy} + metadata: + policy-id: testPolicy properties: - controlLoop: {controlLoopName: control loop, version: 2.0.0, trigger_policy: new1, - timeout: '30', abatement: 'true'} + 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 + payload: + requestParameters: '{"usePreload":true,"userParams":[]}' + configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[10].value","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[15].value","enabled":"$.vf-module-topology.vf-module-parameters.param[22].value"}]' success: new2 failure: new2 failure_timeout: new2 failure_retries: new2 failure_exception: new2 failure_guard: new2 - target: {type: VFC, resourceTargetId: test} + target: + type: VFC + resourceTargetId: test - id: new2 recipe: Migrate retry: '30' timeout: '40' actor: SDNC - payload: test - target: {type: VFC, resourceTargetId: test} + payload: '' + target: + type: VFC + resourceTargetId: test diff --git a/src/test/resources/tosca/operational-policy-properties.json b/src/test/resources/tosca/operational-policy-properties.json index 52eabb8a..bfce6b33 100644 --- a/src/test/resources/tosca/operational-policy-properties.json +++ b/src/test/resources/tosca/operational-policy-properties.json @@ -42,7 +42,7 @@ "retry": "10", "timeout": "20", "actor": "SO", - "payload": "test", + "payload": "requestParameters: '{\"usePreload\":true,\"userParams\":[]}'\r\nconfigurationParameters: '[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[10].value\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[15].value\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[22].value\"}]'", "success": "new2", "failure": "new2", "failure_timeout": "new2", @@ -60,7 +60,7 @@ "retry": "30", "timeout": "40", "actor": "SDNC", - "payload": "test", + "payload": "", "target": { "type": "VFC", "resourceTargetId": "test" |