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 org.apache.camel.Message;
import org.junit.Test;
import org.mockito.Mockito;
-import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.clamp.clds.util.ResourceFileUtils;
import org.onap.clamp.loop.components.external.ExternalComponentState;
import org.onap.clamp.loop.components.external.PolicyComponent;
import org.onap.clamp.loop.template.LoopTemplate;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class PolicyComponentTest {
/**
*/
@Test
public void createPoliciesPayloadPdpGroupTest() throws IOException {
- Loop loopTest = new Loop("ControlLoopTest", "<xml></xml>");
+ Loop loopTest = new Loop("ControlLoopTest");
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, "pdpGroup2", "pdpSubgroup1");
loopTest.addMicroServicePolicy(microServicePolicy2);
- PolicyModel policyModel2 = new PolicyModel("onap.policies.controlloop.Operational", null, "1.0.0");
+ PolicyModel policyModel2 = new PolicyModel("onap.policies.monitoring.test2", null,
+ "1.0.0");
OperationalPolicy opPolicy =
new OperationalPolicy("opPolicy", new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class),
new Gson().fromJson("{\"jsonschema\":\"schema\"}", JsonObject.class), policyModel2, null,
"pdpSubgroup2");
loopTest.addOperationalPolicy(opPolicy);
+ OperationalPolicy opLegacyPolicy =
+ new OperationalPolicy("opLegacyPolicy", new Gson().fromJson(
+ "{\"guard_policies\":[{\"policy-id\":\"guard1\"}]}", JsonObject.class),
+ new Gson().fromJson("{\"jsonschema\":\"schema\"}", JsonObject.class), policyModel2, null,
+ "pdpGroup2",
+ "pdpSubgroup2");
- LoopTemplate loopTemplate = new LoopTemplate("test", "yaml", "svg", 1, null);
+ loopTest.addOperationalPolicy(opLegacyPolicy);
+
+ LoopTemplate loopTemplate = new LoopTemplate("test", "yaml", 1, null);
loopTemplate.setDcaeBlueprintId("UUID-blueprint");
loopTest.setLoopTemplate(loopTemplate);
- String payload = PolicyComponent.createPoliciesPayloadPdpGroup(loopTest);
- String expectedRes = ResourceFileUtil.getResourceAsString("tosca/pdp-group-policy-payload.json");
+ String payload = PolicyComponent.createPoliciesPayloadPdpGroup(loopTest, "POST");
+ String expectedRes = ResourceFileUtils.getResourceAsString("tosca/pdp-group-policy-payload.json");
assertThat(payload).isEqualTo(expectedRes);
-
- assertThat(PolicyComponent.listPolicyNamesPdpGroup(loopTest)).containsExactlyInAnyOrder("opPolicy","configPolicyTest","configPolicyTest2");
}
}