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)
public void shouldCreateEmptyLoop() {
// given
String loopBlueprint = "blueprint";
- String loopSvg = "representation";
- Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, loopBlueprint, loopSvg);
+ Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, loopBlueprint);
testLoop.setGlobalPropertiesJson(JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
testLoop.setLastComputedState(LoopState.DESIGN);
assertThat(actualLoop).isNotNull();
assertThat(actualLoop).isEqualTo(loopsRepository.findById(actualLoop.getName()).get());
assertThat(actualLoop.getName()).isEqualTo(EXAMPLE_LOOP_NAME);
- assertThat(actualLoop.getSvgRepresentation()).isEqualTo(loopSvg);
assertThat(actualLoop.getGlobalPropertiesJson().getAsJsonPrimitive("testName").getAsString())
.isEqualTo("testValue");
}
// given
saveTestLoopToDb();
OperationalPolicy operationalPolicy = new OperationalPolicy("policyName", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null, null);
// when
Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
"tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "policyModel1");
policyModelsService.saveOrUpdatePolicyModel(policyModel);
MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", policyModel,
- false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
// when
Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME,
"tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "secondPolicyName");
policyModelsService.saveOrUpdatePolicyModel(policyModel2);
MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", policyModel1, false,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("secondPolicyName", policyModel2, false,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
// when
firstMicroServicePolicy
}
private void saveTestLoopToDb() {
- Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, "blueprint", "representation");
+ Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, "blueprint");
testLoop.setGlobalPropertiesJson(JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
LoopTemplate template = new LoopTemplate();
template.setName("testTemplate");
"tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "secondPolicyName");
policyModelsService.saveOrUpdatePolicyModel(policyModel2);
MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", policyModel1,
- false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("secondPolicyName", policyModel2,
- false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
// when
Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME,
JsonObject newJsonConfiguration = JsonUtils.GSON.fromJson("{}", JsonObject.class);
OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null, null);
loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
OperationalPolicy secondOperationalPolicy = new OperationalPolicy("secondPolicyName", null,
- newJsonConfiguration, null);
+ newJsonConfiguration, null, null, null, null);
// when
firstOperationalPolicy.setConfigurationsJson(newJsonConfiguration);
saveTestLoopToDb();
OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null, null);
loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
OperationalPolicy secondOperationalPolicy = new OperationalPolicy("policyName", null,
- JsonUtils.GSON.fromJson("{}", JsonObject.class), null);
+ JsonUtils.GSON.fromJson("{}", JsonObject.class), null, null, "pdpGroup1", "pdpSubgroup1");
// when
Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
loop = loopService.saveOrUpdateLoop(loop);
// Add op policy
OperationalPolicy operationalPolicy = new OperationalPolicy("opPolicy", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null, null);
loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(operationalPolicy));
PolicyModel policyModel = new PolicyModel("org.policies.microPolicy",
policyModelsService.saveOrUpdatePolicyModel(policyModel);
// Add Micro service policy
MicroServicePolicy microServicePolicy = new MicroServicePolicy("microPolicy", policyModel,
- false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(microServicePolicy));
// Verify it's there
"tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "policyName");
policyModelsService.saveOrUpdatePolicyModel(policyModel);
MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", policyModel,
- false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, 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, loopSvg);
+ private Loop createTestLoop(String loopName, String loopBlueprint) {
+ return new Loop(loopName);
}
}
\ No newline at end of file