From 6df52982d9e22fc1ff7a56eea8714a2598a51639 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 3 Sep 2019 00:35:54 -0700 Subject: changes in policy decoder per hpa OOF definition Change-Id: I25f956c863f93c998c681535f5ef7ec43ca88cde Issue-ID: POLICY-2029 Signed-off-by: Liang Ding --- .../reception/decoding/pdpx/Content.java | 34 ++++------------------ .../reception/decoding/pdpx/ExtractFromNode.java | 2 ++ .../reception/decoding/pdpx/TestContent.java | 7 +++++ 3 files changed, 14 insertions(+), 29 deletions(-) (limited to 'plugins/reception-plugins/src') diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java index 6e708977..ef4584cb 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java @@ -22,45 +22,21 @@ package org.onap.policy.distribution.reception.decoding.pdpx; import java.util.ArrayList; import java.util.List; +import lombok.Data; /** * The content acts the high level abstraction which to be used by OOF to do Optimization. * * @author Libo Zhu (libo.zhu@intel.com) */ +@Data class Content { + private List scope = new ArrayList<>(); /* keep scope as empty for now */ + private List services = new ArrayList<>(); private List resources = new ArrayList<>(); + private List geography = new ArrayList<>(); /* keep geography as empty for now */ private String identity; private List policyScope = new ArrayList<>(); private String policyType = "Optimization"; private List flavorFeatures = new ArrayList<>(); - - public List getResources() { - return resources; - } - - public void setIdentity(final String identity) { - this.identity = identity; - } - - public String getIdentity() { - return identity; - } - - public List getPolicyScope() { - return policyScope; - } - - public void setPolicyType(final String policyType) { - this.policyType = policyType; - } - - public String getPolicyType() { - return policyType; - } - - public List getFlavorFeatures() { - return flavorFeatures; - } } - diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java index fc4ed13f..a7313876 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java @@ -88,6 +88,7 @@ public class ExtractFromNode { */ public Content extractInfo(final NodeTemplate node) throws PolicyDecodingException { final Metadata metaData = sdcCsarHelper.getNodeTemplateMetadata(node); + final Metadata metaDataOfService = sdcCsarHelper.getServiceMetadata(); LOGGER.debug("the meta data of this nodetemplate = {}", metaData); final List lnodeChild = sdcCsarHelper.getNodeTemplateChildren(node); LOGGER.debug("the size of lnodeChild = {}", lnodeChild.size()); @@ -111,6 +112,7 @@ public class ExtractFromNode { final Content content = new Content(); content.getResources().add(metaData.getValue("name")); + content.getServices().add(metaDataOfService.getValue("name")); content.setIdentity(content.getPolicyType() + "_" + metaData.getValue("name")); extractInfoVdu(lnodeVdu, content); extractInfoVduCp(lnodeVduCp, content); diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java index d678239f..da77eefb 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java @@ -44,6 +44,8 @@ public class TestContent { private void validateReport(final String identity, final String policyType, final Content content) { + assertEquals(0, content.getScope().size()); + assertEquals(0, content.getGeography().size()); assertEquals(identity, content.getIdentity()); assertEquals(policyType, content.getPolicyType()); assertEquals(0, content.getPolicyScope().size()); @@ -51,6 +53,11 @@ public class TestContent { assertEquals(1, content.getPolicyScope().size()); content.getPolicyScope().remove("vFW"); assertEquals(0, content.getPolicyScope().size()); + assertEquals(0, content.getServices().size()); + content.getServices().add("vCPE"); + assertEquals(1, content.getServices().size()); + content.getServices().remove("vCPE"); + assertEquals(0, content.getServices().size()); assertEquals(0, content.getFlavorFeatures().size()); FlavorFeature flavorFeature = new FlavorFeature(); content.getFlavorFeatures().add(flavorFeature); -- cgit 1.2.3-korg