aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@est.tech>2019-07-23 11:03:52 +0000
committerramverma <ram.krishna.verma@est.tech>2019-07-23 11:03:52 +0000
commit8a43a894dbf9d3f3f1d19277ac295fd7026f4925 (patch)
tree0e8d665279e8e1b9796dfc73bc478da332ab05e7 /plugins
parent38c95a9e7810bb6563667df1933f7ed22cda0db1 (diff)
Update PolicyDecoderCsarPdpx to match policy/api
Lifecycle API's for creating policies & policy types in policy/api expects ToscaServiceTemplate as input instead of ToscaPolicy or ToscaPolicyType. Hence, changing the return type of decoder to generate & return ToscaServiceTemplate instead of ToscaPolicy. Change-Id: I4fb92738e15ee7e2868741f7ca50cf09429d8cde Issue-ID: POLICY-1888 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java10
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java26
2 files changed, 18 insertions, 18 deletions
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
index 165d105a..8bbdaffe 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
@@ -34,7 +34,7 @@ import org.onap.policy.distribution.model.Csar;
import org.onap.policy.distribution.model.PolicyInput;
import org.onap.policy.distribution.reception.decoding.PolicyDecoder;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.onap.sdc.toscaparser.api.NodeTemplate;
@@ -44,15 +44,15 @@ import org.slf4j.LoggerFactory;
/**
* Decodes PDP-X policies from a CSAR file.
*/
-public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, ToscaPolicy> {
+public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, ToscaServiceTemplate> {
private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderCsarPdpx.class);
private final Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().create();
private PolicyDecoderCsarPdpxConfigurationParameterGroup decoderParameters;
@Override
- public Collection<ToscaPolicy> decode(final Csar csar) throws PolicyDecodingException {
- final List<ToscaPolicy> policies = new ArrayList<>();
+ public Collection<ToscaServiceTemplate> decode(final Csar csar) throws PolicyDecodingException {
+ final List<ToscaServiceTemplate> policies = new ArrayList<>();
final ISdcCsarHelper sdcCsarHelper = parseCsar(csar);
final List<NodeTemplate> lnodeVf = sdcCsarHelper.getServiceVfList();
LOGGER.debug("the size of Vf = {}", lnodeVf.size());
@@ -63,7 +63,7 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, ToscaPolicy> {
for (final NodeTemplate node : lnodeVf) {
final Content content = extractFromNode.extractInfo(node);
if (content != null) {
- final ToscaPolicy policy = new ToscaPolicy();
+ final ToscaServiceTemplate policy = new ToscaServiceTemplate();
final String policyName = decoderParameters.getPolicyNamePrefix() + "." + content.getIdentity();
// policy.setOnapName(decoderParameters.getOnapName());
policy.setName(policyName);
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
index 3954b972..0cd8b6f4 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
@@ -33,7 +33,7 @@ import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.Csar;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
* Class to perform unit test of {@link PolicyDecoderCsarPdpx}.
@@ -69,10 +69,10 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
- final Collection<ToscaPolicy> ret = policyDecoderCsarPdpx.decode(csar);
+ final Collection<ToscaServiceTemplate> ret = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, ret.size());
- final ToscaPolicy policy = (ToscaPolicy) ret.toArray()[0];
+ final ToscaServiceTemplate policy = (ToscaServiceTemplate) ret.toArray()[0];
// assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().startsWith("OOF."));
@@ -100,8 +100,8 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
- final Collection<ToscaPolicy> policies = policyDecoderCsarPdpx.decode(csar);
- final ToscaPolicy policy = (ToscaPolicy) policies.toArray()[0];
+ final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
+ final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
// assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().startsWith("OOF."));
@@ -140,9 +140,9 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
- final Collection<ToscaPolicy> policies = policyDecoderCsarPdpx.decode(csar);
+ final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, policies.size());
- final ToscaPolicy policy = (ToscaPolicy) policies.toArray()[0];
+ final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
// assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().startsWith("OOF."));
@@ -183,9 +183,9 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
- final Collection<ToscaPolicy> policies = policyDecoderCsarPdpx.decode(csar);
+ final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, policies.size());
- final ToscaPolicy policy = (ToscaPolicy) policies.toArray()[0];
+ final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
// assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().startsWith("OOF."));
@@ -216,9 +216,9 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
- final Collection<ToscaPolicy> policies = policyDecoderCsarPdpx.decode(csar);
+ final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(1, policies.size());
- final ToscaPolicy policy = (ToscaPolicy) policies.toArray()[0];
+ final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
// assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().startsWith("OOF."));
@@ -250,9 +250,9 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
- final Collection<ToscaPolicy> policies = policyDecoderCsarPdpx.decode(csar);
+ final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(5, policies.size());
- final ToscaPolicy policy = (ToscaPolicy) policies.toArray()[0];
+ final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
// assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().startsWith("OOF."));