summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-04-10 14:07:35 +0200
committersebdet <sebastien.determe@intl.att.com>2019-04-10 14:07:35 +0200
commitcd64cc4b390a15602e084d0d94007ec83aa530a4 (patch)
treec928f5bc4f9e7b12b2955ec880e69d850cea3073 /src/test/java
parent9342b6c9ea3dd02feb9e1d8acc81e5b50c66f1e2 (diff)
Add delete support
Move delete code to Camel way so that it's more flexible + introduce removal of the loop + test Issue-ID: CLAMP-315 Change-Id: I7df87e1441d4511ad6b42d0d269c3b2c8c7d8eef Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java43
1 files changed, 43 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 23723386b..c4254ec8c 100644
--- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
@@ -38,8 +38,13 @@ 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.log.LogType;
+import org.onap.clamp.loop.log.LoopLog;
+import org.onap.clamp.loop.log.LoopLogService;
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.context.junit4.SpringRunner;
@@ -57,6 +62,15 @@ public class LoopServiceTestItCase {
@Autowired
LoopsRepository loopsRepository;
+ @Autowired
+ MicroservicePolicyService microServicePolicyService;
+
+ @Autowired
+ OperationalPolicyService operationalPolicyService;
+
+ @Autowired
+ LoopLogService loopLogService;
+
@After
public void tearDown() {
loopsRepository.deleteAll();
@@ -276,6 +290,35 @@ public class LoopServiceTestItCase {
assertThat(returnedGlobalProperties.getAsJsonObject()).isEqualTo(updatedGlobalProperites);
}
+ @Test
+ @Transactional
+ public void deleteAttempt() {
+ saveTestLoopToDb();
+ // Add log
+ Loop loop = loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null);
+ loop.addLog(new LoopLog("test", LogType.INFO, loop));
+ loop = loopService.saveOrUpdateLoop(loop);
+ // Add op policy
+ OperationalPolicy operationalPolicy = new OperationalPolicy("opPolicy", null,
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
+ loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(operationalPolicy));
+
+ // Add Micro service policy
+ MicroServicePolicy microServicePolicy = new MicroServicePolicy("microPolicy", "",
+ "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(microServicePolicy));
+
+ // Verify it's there
+ assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null)).isNotNull();
+ loopService.deleteLoop(EXAMPLE_LOOP_NAME);
+ // Verify it's well deleted and has been cascaded
+ assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null)).isNull();
+ assertThat(microServicePolicyService.isExisting("microPolicy")).isFalse();
+ assertThat(operationalPolicyService.isExisting("opPolicy")).isFalse();
+ assertThat(loopLogService.isExisting(((LoopLog) loop.getLoopLogs().toArray()[0]).getId())).isFalse();
+ }
+
private Loop createTestLoop(String loopName, String loopBlueprint, String loopSvg) {
return new Loop(loopName, loopBlueprint, loopSvg);
}