summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVidyashree Rama <vidyashree.rama@huawei.com>2019-10-15 15:16:22 +0530
committerVidyashree Rama <vidyashree.rama@huawei.com>2019-10-15 15:17:11 +0530
commita318b9dff3ac360550c203667576a78ab5f0abc3 (patch)
treed314e0cf805eb1478087c11ad8cc0c1c4220e2f7
parent6fcc35ae7a132b6e8c673b75b48f12409c92348c (diff)
Improve unit test coverage of LoopService
Improve unit test coverage of LoopService Change-Id: I929d6c9fca8cbb1fa19b50bfee2c8523d94c41ce Issue-ID: CLAMP-510 Signed-off-by: Vidyashree Rama <vidyashree.rama@huawei.com>
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java34
1 files changed, 34 insertions, 0 deletions
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);
}