From a318b9dff3ac360550c203667576a78ab5f0abc3 Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Tue, 15 Oct 2019 15:16:22 +0530 Subject: Improve unit test coverage of LoopService Improve unit test coverage of LoopService Change-Id: I929d6c9fca8cbb1fa19b50bfee2c8523d94c41ce Issue-ID: CLAMP-510 Signed-off-by: Vidyashree Rama --- .../org/onap/clamp/loop/LoopServiceTestItCase.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/test/java/org') diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java index 8add1a7be..1fedc9abe 100644 --- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java @@ -319,6 +319,40 @@ public class LoopServiceTestItCase { assertThat(loopLogService.isExisting(((LoopLog) loop.getLoopLogs().toArray()[0]).getId())).isFalse(); } + @Test + @Transactional + public void testUpdateLoopState() { + saveTestLoopToDb(); + Loop loop = loopService.getLoop(EXAMPLE_LOOP_NAME); + loopService.updateLoopState(loop, "SUBMITTED"); + Loop updatedLoop = loopService.getLoop(EXAMPLE_LOOP_NAME); + assertThat(updatedLoop.getLastComputedState()).isEqualTo(LoopState.SUBMITTED); + } + + @Test + @Transactional + public void testUpdateDcaeDeploymentFields() { + saveTestLoopToDb(); + Loop loop = loopService.getLoop(EXAMPLE_LOOP_NAME); + loopService.updateDcaeDeploymentFields(loop,"CLAMP_c5ce429a-f570-48c5-a7ea-53bed8f86f85", + "https4://deployment-handler.onap:8443"); + loop = loopService.getLoop(EXAMPLE_LOOP_NAME); + assertThat(loop.getDcaeDeploymentId()).isEqualTo("CLAMP_c5ce429a-f570-48c5-a7ea-53bed8f86f85"); + assertThat(loop.getDcaeDeploymentStatusUrl()).isEqualTo("https4://deployment-handler.onap:8443"); + } + + @Test + @Transactional + public void testUpdateMicroservicePolicy() { + saveTestLoopToDb(); + assertThat(microServicePolicyService.isExisting("policyName")).isFalse(); + MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", "", + "tosca_definitions_version: tosca_simple_yaml_1_0_0", false, + JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); + loopService.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, microServicePolicy); + assertThat(microServicePolicyService.isExisting("policyName")).isTrue(); + } + private Loop createTestLoop(String loopName, String loopBlueprint, String loopSvg) { return new Loop(loopName, loopBlueprint, loopSvg); } -- cgit 1.2.3-korg