diff options
author | kris.jinka <kris.jinka@samsung.com> | 2018-11-13 09:10:52 +0900 |
---|---|---|
committer | kris.jinka <kris.jinka@samsung.com> | 2018-11-13 09:11:41 +0900 |
commit | 2b82696ea09c21cf5b47cedf08fe294622a6c4e6 (patch) | |
tree | 44fa6e6f299e9eb91254c84a7a37e49f11663fd4 /controlloop/common/policy-yaml/src/test/java | |
parent | 918d8aa79654111a7254571adf0f84c89dddb36c (diff) |
Use parameter obj for policy results
Policy result method uses more params than allowed
Use parameter object for setting params instead
Issue-ID: POLICY-1251
Change-Id: I6bf1f20896dc5176811bc363a390c682faa06ca4
Signed-off-by: kris.jinka <kris.jinka@samsung.com>
Diffstat (limited to 'controlloop/common/policy-yaml/src/test/java')
-rw-r--r-- | controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java | 102 |
1 files changed, 83 insertions, 19 deletions
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java index ac36603a1..be5e488d0 100644 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java +++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java @@ -339,9 +339,20 @@ public class ControlLoopPolicyBuilderTest { .retries(2) .timeout(300).build()); @SuppressWarnings("unused") - Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult("Rebuild VM", - "If the restart fails, rebuild it", "APPC", new Target(TargetType.VM), "Rebuild", null, 1, 600, - trigger.getId(), PolicyResult.FAILURE, PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT); + Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult( + PolicyParam.builder() + .name("Rebuild VM") + .description("If the restart fails, rebuild it") + .actor("APPC") + .target(new Target(TargetType.VM)) + .recipe("Rebuild") + .payload(null) + .retries(1) + .timeout(600) + .id(trigger.getId()).build(), + PolicyResult.FAILURE, + PolicyResult.FAILURE_RETRIES, + PolicyResult.FAILURE_TIMEOUT); assertTrue(builder.calculateTimeout().equals(new Integer(300 + 600))); // } catch (BuilderException e) { @@ -466,10 +477,22 @@ public class ControlLoopPolicyBuilderTest { // // Test create a policy and chain it to the results of trigger policy // - Policy onRestartFailurePolicy1 = builder.setPolicyForPolicyResult("Rebuild VM", - "If the restart fails, rebuild it.", "APPC", new Target(TargetType.VM), "Rebuild", null, 1, 600, - triggerPolicy.getId(), PolicyResult.FAILURE, PolicyResult.FAILURE_EXCEPTION, - PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT, PolicyResult.FAILURE_GUARD); + Policy onRestartFailurePolicy1 = builder.setPolicyForPolicyResult( + PolicyParam.builder() + .name("Rebuild VM") + .description("If the restart fails, rebuild it.") + .actor("APPC") + .target(new Target(TargetType.VM)) + .recipe("Rebuild") + .payload(null) + .retries(1) + .timeout(600) + .id(triggerPolicy.getId()).build(), + PolicyResult.FAILURE, + PolicyResult.FAILURE_EXCEPTION, + PolicyResult.FAILURE_RETRIES, + PolicyResult.FAILURE_TIMEOUT, + PolicyResult.FAILURE_GUARD); // assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy1.getId())); assertTrue(builder.getTriggerPolicy().getFailure_exception().equals(onRestartFailurePolicy1.getId())); @@ -480,9 +503,18 @@ public class ControlLoopPolicyBuilderTest { // // Test create a policy and chain it to the results of trigger policy success // - Policy onSuccessPolicy1 = builder.setPolicyForPolicyResult("Do something", - "If the restart succeeds, do something else.", "APPC", new Target(TargetType.VM), "SomethingElse", - null, 1, 600, triggerPolicy.getId(), PolicyResult.SUCCESS); + Policy onSuccessPolicy1 = builder.setPolicyForPolicyResult( + PolicyParam.builder() + .name("Do something") + .description("If the restart succeeds, do something else.") + .actor("APPC") + .target(new Target(TargetType.VM)) + .recipe("SomethingElse") + .payload(null) + .retries(1) + .timeout(600) + .id(triggerPolicy.getId()).build(), + PolicyResult.SUCCESS); // assertTrue(builder.getTriggerPolicy().getSuccess().equals(onSuccessPolicy1.getId())); @@ -502,9 +534,20 @@ public class ControlLoopPolicyBuilderTest { // Create another policy and chain it to the results of trigger policy // final Policy onRestartFailurePolicy2 = - builder.setPolicyForPolicyResult("Rebuild VM", "If the restart fails, rebuild it.", "APPC", - new Target(TargetType.VM), "Rebuild", null, 2, 600, triggerPolicy.getId(), - PolicyResult.FAILURE, PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT); + builder.setPolicyForPolicyResult( + PolicyParam.builder() + .name("Rebuild VM") + .description("If the restart fails, rebuild it.") + .actor("APPC") + .target(new Target(TargetType.VM)) + .recipe("Rebuild") + .payload(null) + .retries(2) + .timeout(600) + .id(triggerPolicy.getId()).build(), + PolicyResult.FAILURE, + PolicyResult.FAILURE_RETRIES, + PolicyResult.FAILURE_TIMEOUT); // // Test reset policy results // @@ -556,9 +599,21 @@ public class ControlLoopPolicyBuilderTest { expectedException.expect(BuilderException.class); expectedException.expectMessage("Unknown policy " + policyId); - builder.setPolicyForPolicyResult("Rebuild VM", "If the restart fails, rebuild it.", "APPC", - new Target(TargetType.VM), "Rebuild", null, 1, 600, policyId, PolicyResult.FAILURE, - PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT, PolicyResult.FAILURE_GUARD); + builder.setPolicyForPolicyResult( + PolicyParam.builder() + .name("Rebuild VM") + .description("If the restart fails, rebuild it.") + .actor("APPC") + .target(new Target(TargetType.VM)) + .recipe("Rebuild") + .payload(null) + .retries(1) + .timeout(600) + .id(policyId).build(), + PolicyResult.FAILURE, + PolicyResult.FAILURE_RETRIES, + PolicyResult.FAILURE_TIMEOUT, + PolicyResult.FAILURE_GUARD); } @Test @@ -579,9 +634,18 @@ public class ControlLoopPolicyBuilderTest { .timeout(300).build()); - Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult("Rebuild VM", - "If the restart fails, rebuild it.", "APPC", new Target(TargetType.VM), "Rebuild", null, 1, 600, - triggerPolicy.getId(), PolicyResult.FAILURE); + Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult( + PolicyParam.builder() + .name("Rebuild VM") + .description("If the restart fails, rebuild it.") + .actor("APPC") + .target(new Target(TargetType.VM)) + .recipe("Rebuild") + .payload(null) + .retries(1) + .timeout(600) + .id(triggerPolicy.getId()).build(), + PolicyResult.FAILURE); final String unknownPolicyId = "100"; expectedException.expect(BuilderException.class); |