summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSébastien Determe <sebastien.determe@intl.att.com>2020-03-04 13:20:47 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-04 13:20:47 +0000
commitf0e00e7c9ea8dd15a4aacdd880aa648539caf087 (patch)
treefd88ae4cee57fca2b47485dbb22a092c039f82f2 /src
parentf0a648cc89cb870a4053d47a06fe2a4a54cc3f1c (diff)
parent635445a5f262464c88287e5b5ceace4abf9cc4bc (diff)
Merge "Update UI to define Pdp Group"
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java2
-rw-r--r--src/main/java/org/onap/clamp/loop/Loop.java2
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopController.java4
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java2
-rw-r--r--src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java7
-rw-r--r--src/main/java/org/onap/clamp/loop/template/PolicyModel.java1
-rw-r--r--src/main/java/org/onap/clamp/policy/Policy.java18
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java13
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java4
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java18
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java10
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java2
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/SvgLoopGeneratorTest.java2
-rw-r--r--src/test/java/org/onap/clamp/loop/DcaeComponentTest.java2
-rw-r--r--src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java2
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java2
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java4
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java26
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopToJsonTest.java4
-rw-r--r--src/test/java/org/onap/clamp/loop/PolicyComponentTest.java13
-rw-r--r--src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java6
21 files changed, 77 insertions, 67 deletions
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java
index 8e3b06a46..846b3ab2d 100755
--- a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java
@@ -91,7 +91,7 @@ public class ClampGraphBuilder {
loopElementModel.getPolicyModels().first(), false, loopElementModel));
} else if (LoopElementModel.OPERATIONAL_POLICY_TYPE.equals(loopElementModel.getLoopElementType())) {
policies.add(new OperationalPolicy(loopElementModel.getName(), null, null,
- loopElementModel.getPolicyModels().first(), loopElementModel));
+ loopElementModel.getPolicyModels().first(), loopElementModel, null, null));
}
return this;
}
diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java
index b3fe58f9c..122b4c77f 100644
--- a/src/main/java/org/onap/clamp/loop/Loop.java
+++ b/src/main/java/org/onap/clamp/loop/Loop.java
@@ -173,7 +173,7 @@ public class Loop extends AuditEntity implements Serializable {
} else if (LoopElementModel.OPERATIONAL_POLICY_TYPE
.equals(element.getLoopElementModel().getLoopElementType())) {
this.addOperationalPolicy(new OperationalPolicy(name, null, new JsonObject(),
- element.getLoopElementModel().getPolicyModels().first(), element.getLoopElementModel()));
+ element.getLoopElementModel().getPolicyModels().first(), element.getLoopElementModel(), null, null));
}
});
}
diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java
index 7ee088c44..59b97e1a2 100644
--- a/src/main/java/org/onap/clamp/loop/LoopController.java
+++ b/src/main/java/org/onap/clamp/loop/LoopController.java
@@ -69,7 +69,7 @@ public class LoopController {
* @return The updated loop
*/
public Loop updateOperationalPolicies(String loopName, JsonArray operationalPoliciesJson) {
- List<OperationalPolicy> operationalPolicies = JsonUtils.GSON.fromJson(operationalPoliciesJson,
+ List<OperationalPolicy> operationalPolicies = JsonUtils.GSON_JPA_MODEL.fromJson(operationalPoliciesJson,
OPERATIONAL_POLICY_TYPE);
return loopService.updateAndSaveOperationalPolicies(loopName, operationalPolicies);
}
@@ -83,7 +83,7 @@ public class LoopController {
* @return The updated loop
*/
public Loop updateMicroservicePolicies(String loopName, JsonArray microServicePoliciesJson) {
- List<MicroServicePolicy> microservicePolicies = JsonUtils.GSON.fromJson(microServicePoliciesJson,
+ List<MicroServicePolicy> microservicePolicies = JsonUtils.GSON_JPA_MODEL.fromJson(microServicePoliciesJson,
MICROSERVICE_POLICY_TYPE);
return loopService.updateAndSaveMicroservicePolicies(loopName, microservicePolicies);
}
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index 0be3132b0..98a2fbddc 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -119,7 +119,7 @@ public class LoopService {
loop.addOperationalPolicy(
new OperationalPolicy(Policy.generatePolicyName("OPERATIONAL", loop.getModelService().getName(),
loop.getModelService().getVersion(), RandomStringUtils.randomAlphanumeric(3),
- RandomStringUtils.randomAlphanumeric(4)), loop, null, policyModel, null));
+ RandomStringUtils.randomAlphanumeric(4)), loop, null, policyModel, null, null, null));
return loopsRepository.save(loop);
}
diff --git a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
index d47bc9644..4cabe7f1f 100644
--- a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
+++ b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
@@ -35,7 +35,6 @@ import java.util.List;
import javax.persistence.Transient;
import org.apache.camel.Exchange;
-import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.loop.Loop;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
@@ -85,18 +84,18 @@ public class PolicyComponent extends ExternalComponent {
jsonObject.add("groups", jsonArray);
for (OperationalPolicy opPolicy : loop.getOperationalPolicies()) {
- jsonArray.add(createPdpDeploymentPayload(opPolicy.getPdpGroup(), opPolicy.getPdpSubGroup(),
+ jsonArray.add(createPdpDeploymentPayload(opPolicy.getPdpGroup(), opPolicy.getPdpSubgroup(),
opPolicy.getPolicyModel().getPolicyModelType(), opPolicy.getPolicyModel().getVersion()));
}
for (MicroServicePolicy msPolicy : loop.getMicroServicePolicies()) {
- jsonArray.add(createPdpDeploymentPayload(msPolicy.getPdpGroup(), msPolicy.getPdpSubGroup(),
+ jsonArray.add(createPdpDeploymentPayload(msPolicy.getPdpGroup(), msPolicy.getPdpSubgroup(),
msPolicy.getPolicyModel().getPolicyModelType(), msPolicy.getPolicyModel().getVersion()));
}
String payload = new GsonBuilder().setPrettyPrinting().create().toJson(jsonObject);
logger.info("PdpGroup policy payload: " + payload);
- return new GsonBuilder().setPrettyPrinting().create().toJson(jsonObject);
+ return payload;
}
private static JsonObject createPdpDeploymentPayload(String pdpGroup, String pdpSubGroup,
diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java
index 66b05f65f..3f45d0551 100644
--- a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java
+++ b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java
@@ -84,6 +84,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
@ManyToMany(mappedBy = "policyModels", fetch = FetchType.EAGER)
private Set<LoopElementModel> usedByElementModels = new HashSet<>();
+ @Expose
@Type(type = "json")
@Column(columnDefinition = "json", name = "policy_pdp_group")
private JsonObject policyPdpGroup;
diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java
index cce9e567f..47dee1ae9 100644
--- a/src/main/java/org/onap/clamp/policy/Policy.java
+++ b/src/main/java/org/onap/clamp/policy/Policy.java
@@ -70,7 +70,7 @@ public abstract class Policy extends AuditEntity {
@Expose
@Column(name = "pdp_sub_group")
- private String pdpSubGroup;
+ private String pdpSubgroup;
public abstract String createPolicyPayload() throws UnsupportedEncodingException;
@@ -159,21 +159,21 @@ public abstract class Policy extends AuditEntity {
}
/**
- * pdpSubGroup getter.
+ * pdpSubgroup getter.
*
- * @return the pdpSubGroup
+ * @return the pdpSubgroup
*/
- public String getPdpSubGroup() {
- return pdpSubGroup;
+ public String getPdpSubgroup() {
+ return pdpSubgroup;
}
/**
- * pdpSubGroup setter.
+ * pdpSubgroup setter.
*
- * @param pdpSubGroup the pdpSubGroup to set
+ * @param pdpSubgroup the pdpSubgroup to set
*/
- public void setPdpSubGroup(String pdpSubGroup) {
- this.pdpSubGroup = pdpSubGroup;
+ public void setPdpSubgroup(String pdpSubgroup) {
+ this.pdpSubgroup = pdpSubgroup;
}
/**
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
index 75efca769..7fd752c31 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
@@ -121,7 +121,7 @@ public class MicroServicePolicy extends Policy implements Serializable {
public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared, LoopElementModel loopElementModel) {
this(name,policyModel,shared,JsonUtils.GSON_JPA_MODEL
.fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyModel.getPolicyModelTosca(),
- policyModel.getPolicyModelType()), JsonObject.class),loopElementModel);
+ policyModel.getPolicyModelType()), JsonObject.class),loopElementModel, null, null);
}
private JsonObject createJsonFromPolicyTosca() {
@@ -138,15 +138,19 @@ public class MicroServicePolicy extends Policy implements Serializable {
* @param shared The flag indicate whether the MicroService is
* shared
* @param jsonRepresentation The UI representation in json format
- * @param loopElementModel The loop element model from which this instance should be created
+ * @param loopElementModel The loop element model from which this instance should be created
+ * @param pdpGroup The Pdp Group info
+ * @param pdpSubgroup The Pdp Subgrouop info
*/
public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared,
- JsonObject jsonRepresentation, LoopElementModel loopElementModel) {
+ JsonObject jsonRepresentation, LoopElementModel loopElementModel, String pdpGroup, String pdpSubgroup) {
this.name = name;
this.policyModel = policyModel;
this.shared = shared;
this.setJsonRepresentation(jsonRepresentation);
this.setLoopElementModel(loopElementModel);
+ this.setPdpGroup(pdpGroup);
+ this.setPdpSubgroup(pdpSubgroup);
}
@Override
@@ -284,8 +288,7 @@ public class MicroServicePolicy extends Policy implements Serializable {
}
} else if (!name.equals(other.name)) {
return false;
- }
- return true;
+ } return true;
}
private String getMicroServicePropertyNameFromTosca(JsonObject object) {
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
index 2af8ec720..3ad97c598 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
@@ -63,7 +63,7 @@ public class MicroServicePolicyService implements PolicyService<MicroServicePoli
return repository.save(
repository.findById(policy.getName()).map(p -> updateMicroservicePolicyProperties(p, policy, loop))
.orElse(new MicroServicePolicy(policy.getName(), policy.getPolicyModel(),
- policy.getShared(), policy.getJsonRepresentation(),null)));
+ policy.getShared(), policy.getJsonRepresentation(),null, policy.getPdpGroup(), policy.getPdpSubgroup())));
}
private MicroServicePolicy updateMicroservicePolicyProperties(MicroServicePolicy oldPolicy,
@@ -72,6 +72,8 @@ public class MicroServicePolicyService implements PolicyService<MicroServicePoli
if (!oldPolicy.getUsedByLoops().contains(loop)) {
oldPolicy.getUsedByLoops().add(loop);
}
+ oldPolicy.setPdpGroup(newPolicy.getPdpGroup());
+ oldPolicy.setPdpSubgroup(newPolicy.getPdpSubgroup());
return oldPolicy;
}
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
index 1c7840579..aab30bfb6 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
@@ -98,20 +98,24 @@ public class OperationalPolicy extends Policy implements Serializable {
* json
* @param policyModel The policy model associated if any, can be null
* @param loopElementModel The loop element from which this instance is supposed to be created
+ * @param pdpGroup The Pdp Group info
+ * @param pdpSubgroup The Pdp Subgroup info
*/
public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson, PolicyModel policyModel,
- LoopElementModel loopElementModel) {
+ LoopElementModel loopElementModel, String pdpGroup, String pdpSubgroup) {
this.name = name;
this.loop = loop;
this.setPolicyModel(policyModel);
this.setConfigurationsJson(configurationsJson);
+ this.setPdpGroup(pdpGroup);
+ this.setPdpSubgroup(pdpSubgroup);
this.setLoopElementModel(loopElementModel);
if (policyModel != null && policyModel.getPolicyModelType().contains("legacy")) {
LegacyOperationalPolicy.preloadConfiguration(configurationsJson, loop);
}
try {
this.setJsonRepresentation(
- OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(loop.getModelService()));
+ OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(loop.getModelService()));
} catch (JsonSyntaxException | IOException | NullPointerException e) {
logger.error("Unable to generate the operational policy Schema ... ", e);
this.setJsonRepresentation(new JsonObject());
@@ -252,11 +256,13 @@ public class OperationalPolicy extends Policy implements Serializable {
public Map<String, String> createGuardPolicyPayloads() {
Map<String, String> result = new HashMap<>();
- JsonElement guardsList = this.getConfigurationsJson().get("guard_policies");
- if (guardsList != null) {
- for (JsonElement guardElem : guardsList.getAsJsonArray()) {
- result.put(guardElem.getAsJsonObject().get("policy-id").getAsString(),
+ if (this.getConfigurationsJson() != null) {
+ JsonElement guardsList = this.getConfigurationsJson().get("guard_policies");
+ if (guardsList != null) {
+ for (JsonElement guardElem : guardsList.getAsJsonArray()) {
+ result.put(guardElem.getAsJsonObject().get("policy-id").getAsString(),
new GsonBuilder().create().toJson(guardElem));
+ }
}
}
logger.info("Guard policy payload: " + result);
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java
index cc636babb..357a96d21 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java
@@ -49,10 +49,10 @@ public class OperationalPolicyService implements PolicyService<OperationalPolicy
.map(policy ->
operationalPolicyRepository
.findById(policy.getName())
- .map(p -> setConfigurationJson(p, policy.getConfigurationsJson()))
+ .map(p -> setConfigurationJson(p, policy))
.orElse(new OperationalPolicy(policy.getName(), loop,
policy.getConfigurationsJson(),
- policy.getPolicyModel(), null)))
+ policy.getPolicyModel(), null, policy.getPdpGroup(), policy.getPdpSubgroup())))
.collect(Collectors.toSet());
}
@@ -61,8 +61,10 @@ public class OperationalPolicyService implements PolicyService<OperationalPolicy
return operationalPolicyRepository.existsById(policyName);
}
- private OperationalPolicy setConfigurationJson(OperationalPolicy policy, JsonObject configurationsJson) {
- policy.setConfigurationsJson(configurationsJson);
+ private OperationalPolicy setConfigurationJson(OperationalPolicy policy, OperationalPolicy newPolicy) {
+ policy.setConfigurationsJson(newPolicy.getConfigurationsJson());
+ policy.setPdpGroup(newPolicy.getPdpGroup());
+ policy.setPdpSubgroup(newPolicy.getPdpSubgroup());
return policy;
}
}
diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java
index 2ccecf3e8..184a391d7 100644
--- a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java
+++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java
@@ -70,7 +70,7 @@ public class ClampGraphBuilderTest {
null);
OperationalPolicy opPolicy = new OperationalPolicy("OperationalPolicy", new Loop(), new JsonObject(),
- new PolicyModel("org.onap.opolicy", null, "1.0.0", "opolicy1"), null);
+ new PolicyModel("org.onap.opolicy", null, "1.0.0", "opolicy1"), null, null, null);
final Set<OperationalPolicy> opPolicies = Set.of(opPolicy);
final Set<MicroServicePolicy> microServices = Set.of(ms1, ms2);
diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/SvgLoopGeneratorTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/SvgLoopGeneratorTest.java
index 7b83a4c35..a320131c4 100644
--- a/src/test/java/org/onap/clamp/clds/util/drawing/SvgLoopGeneratorTest.java
+++ b/src/test/java/org/onap/clamp/clds/util/drawing/SvgLoopGeneratorTest.java
@@ -44,7 +44,7 @@ public class SvgLoopGeneratorTest {
new MicroServicePolicy("ms2", new PolicyModel("org.onap.ms2", "", "1.0.0", "short.ms2"),
false, null);
OperationalPolicy opPolicy = new OperationalPolicy("OperationalPolicy", new Loop(), new JsonObject(),
- new PolicyModel("org.onap.opolicy", null, "1.0.0", "short.OperationalPolicy"), null);
+ new PolicyModel("org.onap.opolicy", null, "1.0.0", "short.OperationalPolicy"), null, null, null);
Loop loop = new Loop();
loop.addMicroServicePolicy(ms1);
loop.addMicroServicePolicy(ms2);
diff --git a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
index 50e2e8d39..fc7e1c90a 100644
--- a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
+++ b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
@@ -54,7 +54,7 @@ public class DcaeComponentTest {
MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", new PolicyModel("policy1",
"tosca_definitions_version: tosca_simple_yaml_1_0_0","1.0.0"), true,
- new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), null);
+ new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), null, null, null);
microServicePolicy.setConfigurationsJson(new Gson().fromJson("{\"param1\":\"value1\"}", JsonObject.class));
loopTest.addMicroServicePolicy(microServicePolicy);
diff --git a/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java b/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java
index 3c2ce17ed..f1d299226 100644
--- a/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java
@@ -297,7 +297,7 @@ public class DeployFlowTestItCase {
policyModelsService.saveOrUpdatePolicyModel(policyModel);
MicroServicePolicy microService = new MicroServicePolicy(name, policyModel,
shared,
- gson.fromJson(jsonRepresentation, JsonObject.class), null);
+ gson.fromJson(jsonRepresentation, JsonObject.class), null, null, null);
microService.setConfigurationsJson(new Gson().fromJson(jsonProperties, JsonObject.class));
return microService;
diff --git a/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java
index 714cbd592..f017dd899 100644
--- a/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java
@@ -135,7 +135,7 @@ public class LoopControllerTestItCase {
"tosca_definitions_version: tosca_simple_yaml_1_0_0","1.0.0");
policyModelsService.saveOrUpdatePolicyModel(policyModel);
MicroServicePolicy policy = new MicroServicePolicy("policyName", policyModel, false,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
loopController.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, policy);
assertThat(microServicePolicyService.isExisting("policyName")).isTrue();
}
diff --git a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java
index acde66d9a..47b4b65c3 100644
--- a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java
@@ -90,7 +90,7 @@ public class LoopRepositoriesItCase {
}
private OperationalPolicy getOperationalPolicy(String configJson, String name, PolicyModel policyModel) {
- return new OperationalPolicy(name, null, new Gson().fromJson(configJson, JsonObject.class), policyModel, null);
+ return new OperationalPolicy(name, null, new Gson().fromJson(configJson, JsonObject.class), policyModel, null, null, null);
}
private LoopElementModel getLoopElementModel(String yaml, String name, String policyType, String createdBy,
@@ -130,7 +130,7 @@ public class LoopRepositoriesItCase {
private MicroServicePolicy getMicroServicePolicy(String name, String jsonRepresentation, String jsonProperties,
boolean shared, PolicyModel policyModel) {
MicroServicePolicy microService = new MicroServicePolicy(name, policyModel, shared,
- gson.fromJson(jsonRepresentation, JsonObject.class), null);
+ gson.fromJson(jsonRepresentation, JsonObject.class), null, null, null);
microService.setConfigurationsJson(new Gson().fromJson(jsonProperties, JsonObject.class));
return microService;
}
diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
index 849ca5cfe..5449ada1a 100644
--- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
@@ -101,7 +101,7 @@ public class LoopServiceTestItCase {
// given
saveTestLoopToDb();
OperationalPolicy operationalPolicy = new OperationalPolicy("policyName", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null);
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null, null);
// when
Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
@@ -129,7 +129,7 @@ public class LoopServiceTestItCase {
"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,
@@ -159,11 +159,11 @@ public class LoopServiceTestItCase {
"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
@@ -203,11 +203,11 @@ public class LoopServiceTestItCase {
"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,
@@ -232,11 +232,11 @@ public class LoopServiceTestItCase {
JsonObject newJsonConfiguration = JsonUtils.GSON.fromJson("{}", JsonObject.class);
OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, 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, null);
+ newJsonConfiguration, null, null, null, null);
// when
firstOperationalPolicy.setConfigurationsJson(newJsonConfiguration);
@@ -263,11 +263,11 @@ public class LoopServiceTestItCase {
saveTestLoopToDb();
OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, 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, null);
+ JsonUtils.GSON.fromJson("{}", JsonObject.class), null, null, "pdpGroup1", "pdpSubgroup1");
// when
Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
@@ -319,7 +319,7 @@ public class LoopServiceTestItCase {
loop = loopService.saveOrUpdateLoop(loop);
// Add op policy
OperationalPolicy operationalPolicy = new OperationalPolicy("opPolicy", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, 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",
@@ -327,7 +327,7 @@ public class LoopServiceTestItCase {
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
@@ -371,7 +371,7 @@ public class LoopServiceTestItCase {
"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();
}
diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
index 6c6fb0c87..de2ef145a 100644
--- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
+++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
@@ -52,7 +52,7 @@ public class LoopToJsonTest {
private OperationalPolicy getOperationalPolicy(String configJson, String name) {
return new OperationalPolicy(name, null, gson.fromJson(configJson, JsonObject.class),
- getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools", "type1"), null);
+ getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools", "type1"), null, null, null);
}
private Loop getLoop(String name, String svgRepresentation, String blueprint, String globalPropertiesJson,
@@ -70,7 +70,7 @@ public class LoopToJsonTest {
String policyTosca, String jsonProperties, boolean shared) {
MicroServicePolicy microService = new MicroServicePolicy(name, new PolicyModel(modelType, policyTosca, "1.0.0"),
shared,
- gson.fromJson(jsonRepresentation, JsonObject.class), null);
+ gson.fromJson(jsonRepresentation, JsonObject.class), null, null, null);
microService.setConfigurationsJson(new Gson().fromJson(jsonProperties, JsonObject.class));
return microService;
}
diff --git a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
index 52e10d2db..370c319b3 100644
--- a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
+++ b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
@@ -26,7 +26,9 @@ package org.onap.clamp.loop;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
+
import java.io.IOException;
+import java.util.HashSet;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.junit.Test;
@@ -258,18 +260,12 @@ public class PolicyComponentTest {
PolicyModel policyModel1 = new PolicyModel("onap.policies.monitoring.test", null, "1.0.0");
MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", policyModel1, true,
- new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), null);
- microServicePolicy.setPdpGroup("pdpGroup1");
- microServicePolicy.setPdpSubGroup("pdpSubgroup1");
-
+ new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), null, "pdpGroup1", "pdpSubgroup1");
loopTest.addMicroServicePolicy(microServicePolicy);
PolicyModel policyModel2 = new PolicyModel("onap.policies.controlloop.Operational", null, "1.0.0");
OperationalPolicy opPolicy = new OperationalPolicy("opPolicy", loopTest,
- new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), policyModel2, null);
- opPolicy.setPdpGroup("pdpGroup2");
- opPolicy.setPdpSubGroup("pdpSubgroup2");
-
+ new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), policyModel2, null, "pdpGroup2", "pdpSubgroup2");
loopTest.addOperationalPolicy(opPolicy);
LoopTemplate loopTemplate = new LoopTemplate("test", "yaml", "svg", 1, null);
@@ -278,6 +274,7 @@ public class PolicyComponentTest {
String payload = PolicyComponent.createPoliciesPayloadPdpGroup(loopTest);
String expectedRes = ResourceFileUtil.getResourceAsString("tosca/pdp-group-policy-payload.json");
+
assertThat(payload).isEqualTo(expectedRes);
}
}
diff --git a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
index bdc7e80de..5686bc161 100644
--- a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
+++ b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
@@ -41,7 +41,7 @@ public class OperationalPolicyPayloadTest {
public void testOperationalPolicyPayloadConstruction() throws IOException {
JsonObject jsonConfig = new GsonBuilder().create().fromJson(
ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class);
- OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig, null, null);
+ OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig, null, null, null, null);
assertThat(policy.createPolicyPayloadYaml())
.isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.yaml"));
@@ -63,7 +63,7 @@ public class OperationalPolicyPayloadTest {
JsonObject jsonConfig = new GsonBuilder().create().fromJson(
ResourceFileUtil.getResourceAsString("tosca/operational-policy-no-guard-properties.json"),
JsonObject.class);
- OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig, null, null);
+ OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig, null, null, null, null);
Map<String, String> guardsMap = policy.createGuardPolicyPayloads();
assertThat(guardsMap).isEmpty();
assertThat(guardsMap.entrySet()).isEmpty();
@@ -73,7 +73,7 @@ public class OperationalPolicyPayloadTest {
public void testGuardPolicyPayloadConstruction() throws IOException {
JsonObject jsonConfig = new GsonBuilder().create().fromJson(
ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class);
- OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig, null, null);
+ OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig, null, null, null, null);
Map<String, String> guardsMap = policy.createGuardPolicyPayloads();