diff options
author | xuegao <xg353y@intl.att.com> | 2020-03-11 11:22:15 +0100 |
---|---|---|
committer | xuegao <xg353y@intl.att.com> | 2020-03-13 16:16:54 +0100 |
commit | fb4b25f6827accf6f975f9ca9a7aaee08d335c2f (patch) | |
tree | d3cea2040049a9b73fcdd94f79758dd52c75b758 /src/test | |
parent | 5c3a825851bb1a345620c5c4951726c5b94a0341 (diff) |
Add remove op policy option
Update the UI and backend code to be able to remove op policy for loop
instances.
Issue-ID: CLAMP-648
Change-Id: Ib3eab4977fe4f1b85e11f2373263197009bbc3e1
Signed-off-by: xuegao <xg353y@intl.att.com>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java index f017dd899..24a9037ad 100644 --- a/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java @@ -36,14 +36,17 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; import org.onap.clamp.clds.util.JsonUtils; +import org.onap.clamp.loop.service.Service; import org.onap.clamp.loop.template.LoopTemplate; import org.onap.clamp.loop.template.PolicyModel; import org.onap.clamp.loop.template.PolicyModelsService; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.microservice.MicroServicePolicyService; import org.onap.clamp.policy.operational.OperationalPolicy; +import org.onap.clamp.policy.operational.OperationalPolicyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.Commit; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @@ -63,6 +66,9 @@ public class LoopControllerTestItCase { MicroServicePolicyService microServicePolicyService; @Autowired + OperationalPolicyService operationalPolicyService; + + @Autowired PolicyModelsService policyModelsService; @Autowired @@ -74,6 +80,8 @@ public class LoopControllerTestItCase { LoopTemplate template = new LoopTemplate(); template.setName("testTemplate"); testLoop.setLoopTemplate(template); + Service modelService = new Service("{\"name\":\"serviceName\",\"UUID\":\"uuid\"}","{}"); + testLoop.setModelService(modelService); loopService.saveOrUpdateLoop(testLoop); } @@ -131,7 +139,7 @@ public class LoopControllerTestItCase { @Transactional public void testUpdateMicroservicePolicy() { saveTestLoopToDb(); - PolicyModel policyModel = new PolicyModel("", + PolicyModel policyModel = new PolicyModel("testPolicyModel", "tosca_definitions_version: tosca_simple_yaml_1_0_0","1.0.0"); policyModelsService.saveOrUpdatePolicyModel(policyModel); MicroServicePolicy policy = new MicroServicePolicy("policyName", policyModel, false, @@ -147,4 +155,28 @@ public class LoopControllerTestItCase { String svgRepresentation = loopController.getSvgRepresentation(EXAMPLE_LOOP_NAME); assertThat(svgRepresentation).isEqualTo("representation"); } + + @Test + @Transactional + public void testAddAndRemoveOperationalPolicies() { + saveTestLoopToDb(); + PolicyModel policyModel = new PolicyModel("testPolicyModel", + "tosca_definitions_version: tosca_simple_yaml_1_0_0","1.0.0"); + policyModelsService.saveOrUpdatePolicyModel(policyModel); + + loopController.addOperationalPolicy(EXAMPLE_LOOP_NAME, "testPolicyModel", "1.0.0"); + + Loop newLoop = loopController.getLoop(EXAMPLE_LOOP_NAME); + Set<OperationalPolicy> opPolicyList = newLoop.getOperationalPolicies(); + assertThat(opPolicyList.size()).isEqualTo(1); + for(OperationalPolicy policy : opPolicyList) { + assertThat(policy.getName().contains("OPERATIONAL_serviceName")).isTrue(); + assertThat(policy.getPolicyModel().getPolicyModelType()).isEqualTo("testPolicyModel"); + assertThat(policy.getPolicyModel().getVersion()).isEqualTo("1.0.0"); + } + + loopController.removeOperationalPolicy(EXAMPLE_LOOP_NAME, "testPolicyModel", "1.0.0"); + Loop newLoop2 = loopController.getLoop(EXAMPLE_LOOP_NAME); + assertThat(newLoop2.getOperationalPolicies().size()).isEqualTo(0); + } }
\ No newline at end of file |