aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorAdam Krysiak <adam.krysiak@nokia.com>2019-03-13 08:10:33 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-13 08:10:33 +0000
commitd7df3862dd3af9b1b0062bd68bb183dd5a3416ed (patch)
tree42bef4799f9fcfbcf323992424fdc196b0fda7f6 /src/test
parentf451ca668c1de480211b380b58e1010c47f28008 (diff)
parent89695a32a794bd1a12464878a7ce834b2e2e07d3 (diff)
Merge "Add updateGlobalPropertiesJson controller"
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
index b7781bf2..d247344a 100644
--- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
@@ -92,7 +92,7 @@ public class LoopServiceTestItCase {
//when
Loop actualLoop = loopService
- .updateOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(operationalPolicy));
+ .updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(operationalPolicy));
//then
assertThat(actualLoop).isNotNull();
@@ -118,7 +118,7 @@ public class LoopServiceTestItCase {
//when
Loop actualLoop = loopService
- .updateMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(microServicePolicy));
+ .updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(microServicePolicy));
//then
assertThat(actualLoop).isNotNull();
@@ -143,14 +143,14 @@ public class LoopServiceTestItCase {
String secondPolicyTosca = "secondPolicyTosca";
MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy(firstPolicyName, "policyTosca",
false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
- loopService.updateMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
+ loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy(secondPolicyName, secondPolicyTosca, true,
newJsonRepresentation, null);
//when
firstMicroServicePolicy.setJsonRepresentation(newJsonRepresentation);
- Loop actualLoop = loopService.updateMicroservicePolicies(EXAMPLE_LOOP_NAME,
+ Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME,
Lists.newArrayList(firstMicroServicePolicy, secondMicroServicePolicy));
//then
@@ -180,14 +180,14 @@ public class LoopServiceTestItCase {
String secondPolicyTosca = "secondPolicyTosca";
MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy(firstPolicyName, "policyTosca",
false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
- loopService.updateMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
+ loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy(secondPolicyName, secondPolicyTosca, true,
jsonRepresentation, null);
//when
Loop actualLoop = loopService
- .updateMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(secondMicroServicePolicy));
+ .updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(secondMicroServicePolicy));
//then
assertThat(actualLoop).isNotNull();
@@ -210,13 +210,13 @@ public class LoopServiceTestItCase {
String secondPolicyName = "secondPolicyName";
OperationalPolicy firstOperationalPolicy = new OperationalPolicy(firstPolicyName, null,
JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
- loopService.updateOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
+ loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
OperationalPolicy secondOperationalPolicy = new OperationalPolicy(secondPolicyName, null, newJsonConfiguration);
//when
firstOperationalPolicy.setConfigurationsJson(newJsonConfiguration);
- Loop actualLoop = loopService.updateOperationalPolicies(EXAMPLE_LOOP_NAME,
+ Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
Lists.newArrayList(firstOperationalPolicy, secondOperationalPolicy));
//then
@@ -244,13 +244,13 @@ public class LoopServiceTestItCase {
String secondPolicyName = "policyName";
OperationalPolicy firstOperationalPolicy = new OperationalPolicy(firstPolicyName, null,
JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
- loopService.updateOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
+ loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
OperationalPolicy secondOperationalPolicy = new OperationalPolicy(secondPolicyName, null, jsonRepresentation);
//when
Loop actualLoop = loopService
- .updateOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(secondOperationalPolicy));
+ .updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(secondOperationalPolicy));
//then
assertThat(actualLoop).isNotNull();
@@ -264,6 +264,26 @@ public class LoopServiceTestItCase {
}
+ @Test
+ public void shouldCreateModelPropertiesAndUpdateJsonRepresentationOfOldOne() {
+ //given
+ saveTestLoopToDb();
+ String expectedJson = "{\"test\":\"test\"}";
+ JsonObject baseGlobalProperites = JsonUtils.GSON.fromJson("{}", JsonObject.class);
+ JsonObject updatedGlobalProperites = JsonUtils.GSON.fromJson(expectedJson, JsonObject.class);
+ loopService.updateAndSaveGlobalPropertiesJson(EXAMPLE_LOOP_NAME, baseGlobalProperites);
+
+ //when
+ Loop actualLoop = loopService
+ .updateAndSaveGlobalPropertiesJson(EXAMPLE_LOOP_NAME, updatedGlobalProperites);
+
+ //then
+ assertThat(actualLoop).isNotNull();
+ assertThat(actualLoop.getName()).isEqualTo(EXAMPLE_LOOP_NAME);
+ JsonObject returnedGlobalProperties = actualLoop.getGlobalPropertiesJson();
+ assertThat(returnedGlobalProperties.getAsJsonObject()).isEqualTo(updatedGlobalProperites);
+ }
+
private Loop createTestLoop(String loopName, String loopBlueprint, String loopSvg) {
return new Loop(loopName, loopBlueprint, loopSvg);
}