diff options
Diffstat (limited to 'plugins/reception-plugins')
29 files changed, 125 insertions, 880 deletions
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Attribute.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/Attribute.java index 9962894e..37f79f6b 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Attribute.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/Attribute.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import com.google.gson.annotations.SerializedName; 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/hpa/Content.java index ef4584cb..a6e70bd9 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/hpa/Content.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import java.util.ArrayList; import java.util.List; diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Directive.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/Directive.java index 6df5bc38..87889cc1 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Directive.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/Directive.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import java.util.ArrayList; import java.util.List; 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/hpa/ExtractFromNode.java index a7313876..0406020c 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/hpa/ExtractFromNode.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; @@ -61,13 +61,13 @@ public class ExtractFromNode { private static final String CPU_ARCHITECTURE_PATH = "virtual_cpu#cpu_architecture"; private static final String MEMORY_PAGE_SIZE_PATH = "virtual_memory#vdu_mem_requirements#memoryPageSize"; private static final String NETWORK_INTERFACE_TYPE_PATH = - "virtual_network_interface_requirements#network_interface_requirements#interfaceType"; + "virtual_network_interface_requirements#network_interface_requirements#interfaceType"; private static final String NETWORK_PCI_PATH = - "virtual_network_interface_requirements#nic_io_requirements#logical_node_requirements"; + "virtual_network_interface_requirements#nic_io_requirements#logical_node_requirements"; private static final String BASIC_CAPABILITIES_HPA_FEATURE = "basicCapabilities"; private static final String HUGE_PAGES_HPA_FEATURE = "hugePages"; private static final Map<String, String> NETWORK_HPA_FEATURE_MAP = - ImmutableMap.of("SR-IOV", "sriovNICNetwork", "PCI-Passthrough", "pciePassthrough"); + ImmutableMap.of("SR-IOV", "sriovNICNetwork", "PCI-Passthrough", "pciePassthrough"); private static final Pattern PATTERN = Pattern.compile("(\\D*)(\\d+)(\\D*)"); private ISdcCsarHelper sdcCsarHelper; final Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().create(); @@ -77,8 +77,8 @@ public class ExtractFromNode { } /** - * ExtractInfo from VNF , each VNF may includes more than one VDUs and CPs return new generated PdpxPolicy if it has - * got Hpa feature info or else return null. + * ExtractInfo from VNF , each VNF may includes more than one VDUs and CPs return new + * generated OptimizationPolicy if it has got Hpa feature info or else return null. * * @param node the NodeTemplate * @@ -124,7 +124,8 @@ public class ExtractFromNode { /** - * ExtractInfofromVdu, supported hpa features, All under the capability of tosca.nodes.nfv.Vdu.Compute. + * ExtractInfofromVdu, supported hpa features, All under the capability of + * tosca.nodes.nfv.Vdu.Compute. * * @param lnodeVdu the list of Vdu node * @@ -146,7 +147,7 @@ public class ExtractFromNode { final CapabilityAssignments capabilityAssignments = sdcCsarHelper.getCapabilitiesOf(node); final CapabilityAssignment capabilityAssignment = - capabilityAssignments.getCapabilityByName("virtual_compute"); + capabilityAssignments.getCapabilityByName("virtual_compute"); if (capabilityAssignment != null) { generateBasicCapability(capabilityAssignment, flavorFeature); generateHugePages(capabilityAssignment, flavorFeature); @@ -156,21 +157,22 @@ public class ExtractFromNode { } /** - * GenerateBasicCapability, supported hpa features, All under the capability of tosca.nodes.nfv.Vdu.Compute. + * GenerateBasicCapability, supported hpa features, All under the capability of + * tosca.nodes.nfv.Vdu.Compute. * * @param capabilityAssignment represents the capability of node * * @param flavorFeature represents all the features of specified flavor */ private void generateBasicCapability(final CapabilityAssignment capabilityAssignment, - final FlavorFeature flavorFeature) { + final FlavorFeature flavorFeature) { // the format is xxx MB/GB like 4096 MB final String virtualMemSize = - sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, VIRTUAL_MEM_SIZE_PATH); + sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, VIRTUAL_MEM_SIZE_PATH); if (virtualMemSize != null) { LOGGER.debug("the virtualMemSize = {}", virtualMemSize); final HpaFeatureAttribute hpaFeatureAttribute = - generateHpaFeatureAttribute("virtualMemSize", virtualMemSize); + generateHpaFeatureAttribute("virtualMemSize", virtualMemSize); final FlavorProperty flavorProperty = new FlavorProperty(); flavorProperty.setHpaFeature(BASIC_CAPABILITIES_HPA_FEATURE); flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute); @@ -179,12 +181,12 @@ public class ExtractFromNode { // the format is int like 2 final String numVirtualCpu = - sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, NUM_VIRTUAL_CPU_PATH); + sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, NUM_VIRTUAL_CPU_PATH); if (numVirtualCpu != null) { LOGGER.debug("the numVirtualCpu = {}", numVirtualCpu); final HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("numVirtualCpu", numVirtualCpu); final String cpuArchitecture = - sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, CPU_ARCHITECTURE_PATH); + sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, CPU_ARCHITECTURE_PATH); final FlavorProperty flavorProperty = new FlavorProperty(); flavorProperty.setHpaFeature(BASIC_CAPABILITIES_HPA_FEATURE); if (cpuArchitecture != null) { @@ -196,8 +198,9 @@ public class ExtractFromNode { } /** - * GenerateHpaFeatureAttribute based on the value of featureValue. the format: "hpa-attribute-key": "pciVendorId", - * "hpa-attribute-value": "1234", "operator": "=", "unit": "xxx". + * GenerateHpaFeatureAttribute based on the value of featureValue. the format: + * "hpa-attribute-key": "pciVendorId", "hpa-attribute-value": "1234", "operator": "=", + * "unit": "xxx". * * @param hpaAttributeKey get from the high layer tosca DM * @@ -227,8 +230,9 @@ public class ExtractFromNode { } /** - * GenerateHugePages, supported hpa features, All under the capability of tosca.nodes.nfv.Vdu.Compute. The format is - * a map like: {"schemaVersion": "0", "schemaSelector": "", "hardwarePlatform": "generic", "mandatory": "true", + * GenerateHugePages, supported hpa features, All under the capability of + * tosca.nodes.nfv.Vdu.Compute. The format is a map like: {"schemaVersion": "0", + * "schemaSelector": "", "hardwarePlatform": "generic", "mandatory": "true", * "configurationValue": "2 MB"} * * @param capabilityAssignment represents the capability of node @@ -237,11 +241,11 @@ public class ExtractFromNode { */ private void generateHugePages(final CapabilityAssignment capabilityAssignment, final FlavorFeature flavorFeature) { final String memoryPageSize = - sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, MEMORY_PAGE_SIZE_PATH); + sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, MEMORY_PAGE_SIZE_PATH); LOGGER.debug("the memoryPageSize = {}", memoryPageSize); if (memoryPageSize != null) { final Map<String, String> retMap = - gson.fromJson(memoryPageSize, new TypeToken<HashMap<String, String>>() {}.getType()); + gson.fromJson(memoryPageSize, new TypeToken<HashMap<String, String>>() {}.getType()); LOGGER.debug("the retMap = {}", retMap); final String memoryPageSizeValue = retMap.get(CONFIGURATION_VALUE); final String mandatory = retMap.get("mandatory"); @@ -249,7 +253,7 @@ public class ExtractFromNode { return; } final HpaFeatureAttribute hpaFeatureAttribute = - generateHpaFeatureAttribute("memoryPageSize", memoryPageSizeValue); + generateHpaFeatureAttribute("memoryPageSize", memoryPageSizeValue); final FlavorProperty flavorProperty = new FlavorProperty(); flavorProperty.setHpaFeature(HUGE_PAGES_HPA_FEATURE); if (mandatory != null) { @@ -261,8 +265,8 @@ public class ExtractFromNode { } /** - * ExtractInfoVduCp, supported hpa features, under the virtual_network_interface_requirements of - * tosca.nodes.nfv.VduCp. + * ExtractInfoVduCp, supported hpa features, under the + * virtual_network_interface_requirements of tosca.nodes.nfv.VduCp. * * @param lnodeVduCp the list of VduCp node * @@ -270,7 +274,7 @@ public class ExtractFromNode { * @throws PolicyDecodingException if extract CP fails */ public void extractInfoVduCp(final List<NodeTemplate> lnodeVduCp, final Content content) - throws PolicyDecodingException { + throws PolicyDecodingException { // each CP will binds to a VDU so need the vdu flavor map info. final Map<String, FlavorFeature> vduFlavorMap = new HashMap<>(); for (final FlavorFeature flavorFeature : content.getFlavorFeatures()) { @@ -288,10 +292,10 @@ public class ExtractFromNode { * @throws PolicyDecodingException if any error occurs */ private void parseNodeVduCp(final List<NodeTemplate> lnodeVduCp, final Map<String, FlavorFeature> vduFlavorMap) - throws PolicyDecodingException { + throws PolicyDecodingException { for (final NodeTemplate node : lnodeVduCp) { final String interfaceType = - sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, NETWORK_INTERFACE_TYPE_PATH); + sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, NETWORK_INTERFACE_TYPE_PATH); LOGGER.debug("the interfaceType = {}", interfaceType); Map<String, Object> retMap = new HashMap<>(); if (interfaceType != null) { @@ -301,7 +305,7 @@ public class ExtractFromNode { String networkHpaFeature; if (retMap.containsKey(CONFIGURATION_VALUE) - && NETWORK_HPA_FEATURE_MAP.containsKey(retMap.get(CONFIGURATION_VALUE).toString())) { + && NETWORK_HPA_FEATURE_MAP.containsKey(retMap.get(CONFIGURATION_VALUE).toString())) { final String interfaceTypeValue = retMap.get(CONFIGURATION_VALUE).toString(); networkHpaFeature = NETWORK_HPA_FEATURE_MAP.get(interfaceTypeValue); LOGGER.debug(" the networkHpaFeature is = {}", networkHpaFeature); @@ -311,7 +315,7 @@ public class ExtractFromNode { } final RequirementAssignments requriements = - sdcCsarHelper.getRequirementsOf(node).getRequirementsByName("virtual_binding"); + sdcCsarHelper.getRequirementsOf(node).getRequirementsByName("virtual_binding"); for (final RequirementAssignment requriement : requriements.getAll()) { final String nodeTemplateName = requriement.getNodeTemplateName(); LOGGER.debug("getNodeTemplateName = {}", nodeTemplateName); @@ -327,19 +331,19 @@ public class ExtractFromNode { } /** - * GenerateNetworkFeature, all pci feature are grouped into FlavorFeature together. The format is a map like: - * {"schemaVersion": "0", "schemaSelector": "", "hardwarePlatform": "generic", "mandatory": "true", - * "configurationValue": "2 MB"} + * GenerateNetworkFeature, all pci feature are grouped into FlavorFeature together. + * The format is a map like: {"schemaVersion": "0", "schemaSelector": "", + * "hardwarePlatform": "generic", "mandatory": "true", "configurationValue": "2 MB"} * * @param networkHpaFeature represents the specified Hpa feature * @param node represents the CP Node * @param flavorFeature represents all the features of specified flavor */ private void generateNetworkFeature(final String networkHpaFeature, final NodeTemplate node, - final FlavorFeature flavorFeature) { + final FlavorFeature flavorFeature) { final FlavorProperty flavorProperty = new FlavorProperty(); flavorProperty.setHpaFeature(networkHpaFeature); - final String[] pciKeys = { "pciVendorId", "pciDeviceId", "pciNumDevices", "physicalNetwork" }; + final String[] pciKeys = {"pciVendorId", "pciDeviceId", "pciNumDevices", "physicalNetwork"}; for (final String pciKey : pciKeys) { LOGGER.debug("the pciKey = {}", pciKey); final String pciKeyPath = NETWORK_PCI_PATH + "#" + pciKey; @@ -347,7 +351,7 @@ public class ExtractFromNode { if (pciValue != null) { LOGGER.debug("the pciValue = {}", pciValue); final Map<String, String> retMap = - gson.fromJson(pciValue, new TypeToken<HashMap<String, String>>() {}.getType()); + gson.fromJson(pciValue, new TypeToken<HashMap<String, String>>() {}.getType()); final String pciConfigValue = retMap.get(CONFIGURATION_VALUE); if (pciConfigValue == null) { return; diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorFeature.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/FlavorFeature.java index c29378de..75643a72 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorFeature.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/FlavorFeature.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import java.util.ArrayList; import java.util.List; diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorProperty.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/FlavorProperty.java index 0453370d..f849ebaa 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorProperty.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/FlavorProperty.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import com.google.gson.annotations.SerializedName; diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/HpaFeatureAttribute.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/HpaFeatureAttribute.java index 91008aa5..8bb078ad 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/HpaFeatureAttribute.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/HpaFeatureAttribute.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import com.google.gson.annotations.SerializedName; diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/PolicyDecoderCsarHpa.java index 8cfc6857..e1e1a9a9 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/PolicyDecoderCsarHpa.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import java.io.File; import java.util.ArrayList; @@ -26,17 +26,12 @@ import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; - import org.onap.policy.common.parameters.ParameterService; -import org.onap.policy.common.utils.coder.StandardCoder; 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.ToscaEntityKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; @@ -48,11 +43,10 @@ import org.slf4j.LoggerFactory; /** * Decodes PDP-X policies from a CSAR file and creates ToscaServiceTemplate for Policy Lifecycle API's. */ -public class PolicyDecoderCsarPdpxLifecycleApi implements PolicyDecoder<Csar, ToscaServiceTemplate> { +public class PolicyDecoderCsarHpa implements PolicyDecoder<Csar, ToscaServiceTemplate> { - private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderCsarPdpxLifecycleApi.class); - private final StandardCoder coder = new StandardCoder(); - private PolicyDecoderCsarPdpxLifecycleApiParameters decoderParameters; + private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderCsarHpa.class); + private PolicyDecoderCsarHpaParameters decoderParameters; public static final String TOSCA_POLICY_SCOPE = "scope"; public static final String TOSCA_POLICY_SERVICES = "services"; @@ -118,9 +112,7 @@ public class PolicyDecoderCsarPdpxLifecycleApi implements PolicyDecoder<Csar, To final File csarFile = new File(csar.getCsarPath()); sdcCsarHelper = factory.getSdcCsarHelper(csarFile.getAbsolutePath()); } catch (final Exception exp) { - final String message = "Failed passing the csar file"; - LOGGER.error(message, exp); - throw new PolicyDecodingException(message, exp); + throw new PolicyDecodingException( "Failed passing the csar file", exp); } return sdcCsarHelper; } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApiParameters.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/PolicyDecoderCsarHpaParameters.java index a66a53a8..7d26335c 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApiParameters.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/PolicyDecoderCsarHpaParameters.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import lombok.Getter; @@ -28,12 +28,12 @@ import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup; /** - * This class handles the parameters needed for {@link PolicyDecoderCsarPdpxLifecycleApi}. + * This class handles the parameters needed for {@link PolicyDecoderCsarHpa}. */ @Getter @NotNull @NotBlank -public class PolicyDecoderCsarPdpxLifecycleApiParameters extends PolicyDecoderConfigurationParameterGroup { +public class PolicyDecoderCsarHpaParameters extends PolicyDecoderConfigurationParameterGroup { private String policyNamePrefix; private String onapName; @@ -42,8 +42,8 @@ public class PolicyDecoderCsarPdpxLifecycleApiParameters extends PolicyDecoderCo private String riskType; private String riskLevel; - public PolicyDecoderCsarPdpxLifecycleApiParameters() { - super(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); + public PolicyDecoderCsarHpaParameters() { + super(PolicyDecoderCsarHpaParameters.class.getSimpleName()); } } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ConfigBody.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ConfigBody.java deleted file mode 100644 index 521fcfd6..00000000 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ConfigBody.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.reception.decoding.pdpx; - -public class ConfigBody { - - private String service; - private String policyName; - private String description; - private String templateVersion; - private String version; - private String priority; - private String riskType; - private String riskLevel; - private String guard; - private Content content; - - public String getService() { - return service; - } - - public void setService(String service) { - this.service = service; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getTemplateVersion() { - return templateVersion; - } - - public void setTemplateVersion(String templateVersion) { - this.templateVersion = templateVersion; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getPriority() { - return priority; - } - - public void setPriority(String priority) { - this.priority = priority; - } - - public String getRiskType() { - return riskType; - } - - public void setRiskType(String riskType) { - this.riskType = riskType; - } - - public String getRiskLevel() { - return riskLevel; - } - - public void setRiskLevel(String riskLevel) { - this.riskLevel = riskLevel; - } - - public String getGuard() { - return guard; - } - - public void setGuard(String guard) { - this.guard = guard; - } - - public Content getContent() { - return content; - } - - public void setContent(Content content) { - this.content = content; - } -} diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java deleted file mode 100644 index e7a0e8ab..00000000 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.reception.decoding.pdpx; - -import org.onap.policy.distribution.model.Policy; -import org.onap.policy.distribution.reception.decoding.PolicyDecoder; - -/** - * A PDP-X Policy, decoded by a {@link PolicyDecoder}. - */ -public class PdpxPolicy implements Policy { - - private String guard; - private String service; - private String policyName; - private String description; - private String templateVersion; - private String version; - private String riskType; - private String priority; - private String riskLevel; - private Content content = new Content(); - - @Override - public String getPolicyName() { - return policyName; - } - - @Override - public String getPolicyType() { - return content.getPolicyType(); - } - - public String getGuard() { - return guard; - } - - public String getService() { - return service; - } - - public String getDescription() { - return description; - } - - public String getTemplateVersion() { - return templateVersion; - } - - public String getVersion() { - return version; - } - - public String getRiskType() { - return riskType; - } - - public String getPriority() { - return priority; - } - - public String getRiskLevel() { - return riskLevel; - } - - public Content getContent() { - return content; - } - - public void setGuard(final String guard) { - this.guard = guard; - } - - public void setService(final String service) { - this.service = service; - } - - public void setPolicyName(final String policyName) { - this.policyName = policyName; - } - - public void setDescription(final String description) { - this.description = description; - } - - public void setTemplateVersion(final String templateVersion) { - this.templateVersion = templateVersion; - } - - public void setVersion(final String version) { - this.version = version; - } - - public void setRiskType(final String riskType) { - this.riskType = riskType; - } - - public void setPriority(final String priority) { - this.priority = priority; - } - - public void setRiskLevel(final String riskLevel) { - this.riskLevel = riskLevel; - } - - public void setContent(final Content content) { - this.content = content; - } -} 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 deleted file mode 100644 index 842245c0..00000000 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.reception.decoding.pdpx; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.onap.policy.common.parameters.ParameterService; -import org.onap.policy.distribution.model.Csar; -import org.onap.policy.distribution.model.OptimizationPolicy; -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.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Decodes PDP-X policies from a CSAR file. - */ -public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPolicy> { - - private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderCsarPdpx.class); - private final Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().create(); - private PolicyDecoderCsarPdpxConfigurationParameterGroup decoderParameters; - - @Override - public Collection<OptimizationPolicy> decode(final Csar csar) throws PolicyDecodingException { - final List<OptimizationPolicy> policies = new ArrayList<>(); - final ISdcCsarHelper sdcCsarHelper = parseCsar(csar); - final List<NodeTemplate> lnodeVf = sdcCsarHelper.getServiceVfList(); - LOGGER.debug("the size of Vf = {}", lnodeVf.size()); - final ExtractFromNode extractFromNode = new ExtractFromNode(); - extractFromNode.setSdcCsarHelper(sdcCsarHelper); - final String serviceName = sdcCsarHelper.getServiceMetadata().getValue("name"); - LOGGER.debug("the name of the service = {}", serviceName); - for (final NodeTemplate node : lnodeVf) { - final Content content = extractFromNode.extractInfo(node); - if (content != null) { - final OptimizationPolicy policy = new OptimizationPolicy(); - final String policyName = decoderParameters.getPolicyNamePrefix() + "." + content.getIdentity(); - policy.setOnapName(decoderParameters.getOnapName()); - policy.setName(policyName); - final ConfigBody configBody = new ConfigBody(); - configBody.setService("hpaPolicy"); - configBody.setPolicyName(policyName); - configBody.setDescription("OOF Policy"); - configBody.setTemplateVersion("OpenSource.version.1"); - configBody.setVersion(decoderParameters.getVersion()); - configBody.setPriority(decoderParameters.getPriority()); - configBody.setRiskLevel(decoderParameters.getRiskLevel()); - configBody.setRiskType(decoderParameters.getRiskType()); - configBody.setGuard("False"); - content.setPolicyType("hpa"); - content.getPolicyScope().add("HPA"); - content.getPolicyScope().add(serviceName); - configBody.setContent(content); - policy.setConfigBody(gson.toJson(configBody)); - policies.add(policy); - } - } - return policies; - } - - @Override - public boolean canHandle(final PolicyInput policyInput) { - return policyInput.getClass().isAssignableFrom(Csar.class); - } - - /** - * Parse the input Csar using SDC TOSCA parser. - * - * @param csar represents the service TOSCA Csar - * @return the object to represents the content of input csar - * @throws PolicyDecodingException if parse fails - */ - public ISdcCsarHelper parseCsar(final Csar csar) throws PolicyDecodingException { - ISdcCsarHelper sdcCsarHelper; - try { - final SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance(); - LOGGER.debug("Csar File Path = {}", csar.getCsarPath()); - final File csarFile = new File(csar.getCsarPath()); - sdcCsarHelper = factory.getSdcCsarHelper(csarFile.getAbsolutePath()); - } catch (final Exception exp) { - final String message = "Failed passing the csar file"; - LOGGER.error(message, exp); - throw new PolicyDecodingException(message, exp); - } - return sdcCsarHelper; - } - - @Override - public void configure(final String parameterGroupName) { - decoderParameters = ParameterService.get(parameterGroupName); - } -} diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterGroup.java deleted file mode 100644 index f376c391..00000000 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterGroup.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.reception.decoding.pdpx; - -import lombok.Getter; - -import org.onap.policy.common.parameters.annotations.NotBlank; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup; - -/** - * This class handles reading, parsing and validating of the paramaters for the {@link PolicyDecoderCsarPdpx}. - */ -@Getter -@NotNull -@NotBlank -public class PolicyDecoderCsarPdpxConfigurationParameterGroup extends PolicyDecoderConfigurationParameterGroup { - - private String policyNamePrefix; - private String onapName; - private String version; - private String priority; - private String riskType; - private String riskLevel; - - public PolicyDecoderCsarPdpxConfigurationParameterGroup() { - super(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); - } -} - diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/CommonTestData.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/CommonTestData.java index 5006e078..62a6ba4d 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/CommonTestData.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/CommonTestData.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import java.io.File; diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestAttribute.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java index 565f17d3..cf03ff30 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestAttribute.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java @@ -18,11 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.onap.policy.distribution.reception.decoding.hpa.Attribute; /** * Class to perform unit test for Attribute 0f {@link Attribute}. 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/hpa/TestContent.java index da77eefb..3770bc77 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/hpa/TestContent.java @@ -18,11 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.onap.policy.distribution.reception.decoding.hpa.Content; +import org.onap.policy.distribution.reception.decoding.hpa.FlavorFeature; /** * Class to perform unit test for Content 0f {@link Content}. diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestDirective.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java index cc8d946f..9ab53931 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestDirective.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java @@ -18,11 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.onap.policy.distribution.reception.decoding.hpa.Attribute; +import org.onap.policy.distribution.reception.decoding.hpa.Directive; /** * Class to perform unit test for Directive 0f {@link Directive}. diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestFlavorFeature.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java index e4de2759..47b74c71 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestFlavorFeature.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java @@ -18,11 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.onap.policy.distribution.reception.decoding.hpa.Directive; +import org.onap.policy.distribution.reception.decoding.hpa.FlavorFeature; +import org.onap.policy.distribution.reception.decoding.hpa.FlavorProperty; /** * Class to perform unit test for FlavorFeature 0f {@link FlavorFeature}. diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestFlavorProperty.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java index da6c26fc..2d0504da 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestFlavorProperty.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java @@ -18,11 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.onap.policy.distribution.reception.decoding.hpa.Directive; +import org.onap.policy.distribution.reception.decoding.hpa.FlavorProperty; +import org.onap.policy.distribution.reception.decoding.hpa.HpaFeatureAttribute; /** * Class to perform unit test for FlavorProperty 0f {@link FlavorProperty}. diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestHpaFeatureAttribute.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java index f2f514d0..fddeb168 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestHpaFeatureAttribute.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java @@ -18,11 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.onap.policy.distribution.reception.decoding.hpa.HpaFeatureAttribute; /** * Class to perform unit test for HpaFeatureAttribute 0f {@link HpaFeatureAttribute}. diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxLifecycleApi.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpa.java index 3b8339a9..552f430e 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxLifecycleApi.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpa.java @@ -19,16 +19,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.IOException; -import java.lang.String; import java.util.Collection; import java.util.Map; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -38,15 +36,14 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.distribution.model.Csar; import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; -import org.onap.policy.distribution.reception.decoding.pdpx.PolicyDecoderCsarPdpxLifecycleApi; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; /** - * Class to perform unit test of {@link PolicyDecoderCsarPdpxLifecycleApiLifecycleApi}. + * Class to perform unit test of {@link PolicyDecoderCsarHpa}. */ -public class TestPolicyDecoderCsarPdpxLifecycleApi { +public class TestPolicyDecoderCsarHpa { private final StandardCoder encoder = new StandardCoder(); @@ -56,9 +53,9 @@ public class TestPolicyDecoderCsarPdpxLifecycleApi { @BeforeClass public static void setUp() { final ParameterGroup parameterGroup = CommonTestData.getPolicyDecoderParameters( - "src/test/resources/parameters/PdpxPolicyDecoderParameters.json", - PolicyDecoderCsarPdpxLifecycleApiParameters.class); - parameterGroup.setName(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); + "src/test/resources/parameters/HpaPolicyDecoderParameters.json", + PolicyDecoderCsarHpaParameters.class); + parameterGroup.setName(PolicyDecoderCsarHpaParameters.class.getSimpleName()); ParameterService.register(parameterGroup); } @@ -67,25 +64,25 @@ public class TestPolicyDecoderCsarPdpxLifecycleApi { */ @AfterClass public static void tearDown() { - ParameterService.deregister(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); + ParameterService.deregister(PolicyDecoderCsarHpaParameters.class.getSimpleName()); } @Test public void testHpaPolicy2Vnf() throws IOException, PolicyDecodingException, CoderException { final Csar csar = new Csar("src/test/resources/service-TestNs8-csar.csar"); - final PolicyDecoderCsarPdpxLifecycleApi policyDecoderCsarPdpx = new PolicyDecoderCsarPdpxLifecycleApi(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); - final Collection<ToscaServiceTemplate> entities = policyDecoderCsarPdpx.decode(csar); + final Collection<ToscaServiceTemplate> entities = policyDecoderCsarHpa.decode(csar); assertEquals(2, entities.size()); final ToscaServiceTemplate entity = entities.iterator().next(); ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); Map<String, ToscaPolicy> map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); Map<String, Object> props = policy.getProperties(); Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); + props.get(PolicyDecoderCsarHpa.TOSCA_POLICY_FLAVORFEATURES); String features = encoder.encode(flavorFeatures); assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); @@ -102,17 +99,17 @@ public class TestPolicyDecoderCsarPdpxLifecycleApi { @Test public void testHpaPolicySriov() throws IOException, PolicyDecodingException, CoderException { final Csar csar = new Csar("src/test/resources/hpaPolicySriov.csar"); - final PolicyDecoderCsarPdpxLifecycleApi policyDecoderCsarPdpx = new PolicyDecoderCsarPdpxLifecycleApi(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); - final Collection<ToscaServiceTemplate> entities = policyDecoderCsarPdpx.decode(csar); + final Collection<ToscaServiceTemplate> entities = policyDecoderCsarHpa.decode(csar); final ToscaServiceTemplate entity = entities.iterator().next(); ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); Map<String, ToscaPolicy> map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); Map<String, Object> props = policy.getProperties(); Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); + props.get(PolicyDecoderCsarHpa.TOSCA_POLICY_FLAVORFEATURES); String features = encoder.encode(flavorFeatures); assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); @@ -140,18 +137,18 @@ public class TestPolicyDecoderCsarPdpxLifecycleApi { @Test public void testHpaPolicyPciePassthrough() throws IOException, PolicyDecodingException, CoderException { final Csar csar = new Csar("src/test/resources/hpaPolicyPciePassthrough.csar"); - final PolicyDecoderCsarPdpxLifecycleApi policyDecoderCsarPdpx = new PolicyDecoderCsarPdpxLifecycleApi(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); - final Collection<ToscaServiceTemplate> entities = policyDecoderCsarPdpx.decode(csar); + final Collection<ToscaServiceTemplate> entities = policyDecoderCsarHpa.decode(csar); assertEquals(2, entities.size()); final ToscaServiceTemplate entity = entities.iterator().next(); ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); Map<String, ToscaPolicy> map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); Map<String, Object> props = policy.getProperties(); Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); + props.get(PolicyDecoderCsarHpa.TOSCA_POLICY_FLAVORFEATURES); String features = encoder.encode(flavorFeatures); assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); @@ -179,18 +176,18 @@ public class TestPolicyDecoderCsarPdpxLifecycleApi { @Test public void testHpaPolicyHugePage() throws IOException, PolicyDecodingException, CoderException { final Csar csar = new Csar("src/test/resources/hpaPolicyHugePage.csar"); - final PolicyDecoderCsarPdpxLifecycleApi policyDecoderCsarPdpx = new PolicyDecoderCsarPdpxLifecycleApi(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); - final Collection<ToscaServiceTemplate> entities = policyDecoderCsarPdpx.decode(csar); + final Collection<ToscaServiceTemplate> entities = policyDecoderCsarHpa.decode(csar); assertEquals(2, entities.size()); final ToscaServiceTemplate entity = entities.iterator().next(); ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); Map<String, ToscaPolicy> map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); Map<String, Object> props = policy.getProperties(); Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); + props.get(PolicyDecoderCsarHpa.TOSCA_POLICY_FLAVORFEATURES); String features = encoder.encode(flavorFeatures); assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); @@ -210,18 +207,18 @@ public class TestPolicyDecoderCsarPdpxLifecycleApi { @Test public void testS3p0PciVendorId() throws IOException, PolicyDecodingException, CoderException { final Csar csar = new Csar("src/test/resources/s3p_0_pciVendorId.csar"); - final PolicyDecoderCsarPdpxLifecycleApi policyDecoderCsarPdpx = new PolicyDecoderCsarPdpxLifecycleApi(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); - final Collection<ToscaServiceTemplate> entities = policyDecoderCsarPdpx.decode(csar); + final Collection<ToscaServiceTemplate> entities = policyDecoderCsarHpa.decode(csar); assertEquals(1, entities.size()); final ToscaServiceTemplate entity = entities.iterator().next(); ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); Map<String, ToscaPolicy> map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); Map<String, Object> props = policy.getProperties(); Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); + props.get(PolicyDecoderCsarHpa.TOSCA_POLICY_FLAVORFEATURES); String features = encoder.encode(flavorFeatures); assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); @@ -241,18 +238,18 @@ public class TestPolicyDecoderCsarPdpxLifecycleApi { @Test public void testserviceVcpeWithAll() throws IOException, PolicyDecodingException, CoderException { final Csar csar = new Csar("src/test/resources/service-VcpeWithAll-csar.csar"); - final PolicyDecoderCsarPdpxLifecycleApi policyDecoderCsarPdpx = new PolicyDecoderCsarPdpxLifecycleApi(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); - final Collection<ToscaServiceTemplate> entities = policyDecoderCsarPdpx.decode(csar); + final Collection<ToscaServiceTemplate> entities = policyDecoderCsarHpa.decode(csar); assertEquals(5, entities.size()); final ToscaServiceTemplate entity = entities.iterator().next(); ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); Map<String, ToscaPolicy> map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); Map<String, Object> props = policy.getProperties(); Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); + props.get(PolicyDecoderCsarHpa.TOSCA_POLICY_FLAVORFEATURES); String features = encoder.encode(flavorFeatures); assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); assertTrue(features.contains("\"type\":\"flavor_directives\"")); diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxLifecycleApiParameters.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpaParameters.java index 47971ad3..1ca9e1a1 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxLifecycleApiParameters.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpaParameters.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.decoding.pdpx; +package org.onap.policy.distribution.reception.decoding.hpa; import static org.junit.Assert.assertEquals; @@ -26,17 +26,17 @@ import org.junit.Test; import org.onap.policy.common.parameters.ValidationStatus; /** - * Class to perform unit test of {@link PolicyDecoderCsarPdpxLifecycleApiParameters}. + * Class to perform unit test of {@link PolicyDecoderCsarHpaParameters}. */ -public class TestPolicyDecoderCsarPdpxLifecycleApiParameters { +public class TestPolicyDecoderCsarHpaParameters { @Test public void testValidParameters() { - final PolicyDecoderCsarPdpxLifecycleApiParameters parameterGroup = CommonTestData.getPolicyDecoderParameters( - "src/test/resources/parameters/PdpxPolicyDecoderParameters.json", - PolicyDecoderCsarPdpxLifecycleApiParameters.class); + final PolicyDecoderCsarHpaParameters parameterGroup = CommonTestData.getPolicyDecoderParameters( + "src/test/resources/parameters/HpaPolicyDecoderParameters.json", + PolicyDecoderCsarHpaParameters.class); - assertEquals(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName(), parameterGroup.getName()); + assertEquals(PolicyDecoderCsarHpaParameters.class.getSimpleName(), parameterGroup.getName()); assertEquals("onapName", parameterGroup.getOnapName()); assertEquals("OOF", parameterGroup.getPolicyNamePrefix()); assertEquals("5", parameterGroup.getPriority()); @@ -48,18 +48,18 @@ public class TestPolicyDecoderCsarPdpxLifecycleApiParameters { @Test public void testInvalidParameters() { - final PolicyDecoderCsarPdpxLifecycleApiParameters parameterGroup = CommonTestData.getPolicyDecoderParameters( - "src/test/resources/parameters/PdpxPolicyDecoderParametersInvalid.json", - PolicyDecoderCsarPdpxLifecycleApiParameters.class); + final PolicyDecoderCsarHpaParameters parameterGroup = CommonTestData.getPolicyDecoderParameters( + "src/test/resources/parameters/HpaPolicyDecoderParametersInvalid.json", + PolicyDecoderCsarHpaParameters.class); assertEquals(ValidationStatus.INVALID, parameterGroup.validate().getStatus()); } @Test public void testEmptyParameters() { - final PolicyDecoderCsarPdpxLifecycleApiParameters configurationParameters = + final PolicyDecoderCsarHpaParameters configurationParameters = CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json", - PolicyDecoderCsarPdpxLifecycleApiParameters.class); + PolicyDecoderCsarHpaParameters.class); assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus()); } 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 deleted file mode 100644 index 0eac8bf6..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java +++ /dev/null @@ -1,278 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.reception.decoding.pdpx; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.Collection; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -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.model.OptimizationPolicy; -import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; - -/** - * Class to perform unit test of {@link PolicyDecoderCsarPdpx}. - * - */ -public class TestPolicyDecoderCsarPdpx { - - /** - * Set up for test cases. - */ - @BeforeClass - public static void setUp() { - final ParameterGroup parameterGroup = CommonTestData.getPolicyDecoderParameters( - "src/test/resources/parameters/PdpxPolicyDecoderParameters.json", - PolicyDecoderCsarPdpxConfigurationParameterGroup.class); - parameterGroup.setName(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); - ParameterService.register(parameterGroup); - } - - /** - * Tear down. - */ - @AfterClass - public static void tearDown() { - ParameterService.deregister(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); - } - - @Test - public void testHpaPolicy2Vnf() throws IOException, PolicyDecodingException { - final Csar csar = new Csar("src/test/resources/service-TestNs8-csar.csar"); - final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); - - final Collection<OptimizationPolicy> ret = policyDecoderCsarPdpx.decode(csar); - - assertEquals(2, ret.size()); - final OptimizationPolicy policy = (OptimizationPolicy) ret.toArray()[0]; - - assertEquals("onapName", policy.getOnapName()); - assertTrue(policy.getName().startsWith("OOF.")); - assertTrue(policy.getConfigBody().contains("\"priority\":\"5\"")); - assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\"")); - assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\"")); - assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\"")); - assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\"")); - - assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"basicCapabilities\"")); - assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\"")); - assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"virtualMemSize\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"MB\"")); - } - - @Test - public void testHpaPolicySriov() throws IOException, PolicyDecodingException { - final Csar csar = new Csar("src/test/resources/hpaPolicySriov.csar"); - final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); - - final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar); - final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0]; - - assertEquals("onapName", policy.getOnapName()); - assertTrue(policy.getName().startsWith("OOF.")); - assertTrue(policy.getConfigBody().contains("\"priority\":\"5\"")); - assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\"")); - assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\"")); - assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\"")); - assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\"")); - - assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"sriovNICNetwork\"")); - assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\"")); - assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciVendorId\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1234\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciDeviceId\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"5678\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciNumDevices\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"\"")); - } - - @Test - public void testHpaPolicyPciePassthrough() throws IOException, PolicyDecodingException { - final Csar csar = new Csar("src/test/resources/hpaPolicyPciePassthrough.csar"); - final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); - - final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar); - assertEquals(2, policies.size()); - final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0]; - - assertEquals("onapName", policy.getOnapName()); - assertTrue(policy.getName().startsWith("OOF.")); - assertTrue(policy.getConfigBody().contains("\"priority\":\"5\"")); - assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\"")); - assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\"")); - assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\"")); - assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\"")); - - assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"pciePassthrough\"")); - assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\"")); - assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciVendorId\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1234\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciDeviceId\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"5678\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciNumDevices\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"\"")); - - - } - - @Test - public void testHpaPolicyHugePage() throws IOException, PolicyDecodingException { - final Csar csar = new Csar("src/test/resources/hpaPolicyHugePage.csar"); - final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); - - final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar); - assertEquals(2, policies.size()); - final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0]; - - assertEquals("onapName", policy.getOnapName()); - assertTrue(policy.getName().startsWith("OOF.")); - assertTrue(policy.getConfigBody().contains("\"priority\":\"5\"")); - assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\"")); - assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\"")); - assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\"")); - assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\"")); - - assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"hugePages\"")); - assertTrue(policy.getConfigBody().contains("\"mandatory\":\"true\"")); - assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"memoryPageSize\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"2\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"MB\"")); - } - - @Test - public void testS3p0PciVendorId() throws IOException, PolicyDecodingException { - final Csar csar = new Csar("src/test/resources/s3p_0_pciVendorId.csar"); - final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); - - final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar); - assertEquals(1, policies.size()); - final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0]; - - assertEquals("onapName", policy.getOnapName()); - assertTrue(policy.getName().startsWith("OOF.")); - assertTrue(policy.getConfigBody().contains("\"priority\":\"5\"")); - assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\"")); - assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\"")); - assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\"")); - assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\"")); - - assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"pciePassthrough\"")); - assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\"")); - assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciVendorId\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1234\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"\"")); - - } - - @Test - public void testserviceVcpeWithAll() throws IOException, PolicyDecodingException { - final Csar csar = new Csar("src/test/resources/service-VcpeWithAll-csar.csar"); - final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx(); - policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); - - final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar); - assertEquals(5, policies.size()); - final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0]; - - assertEquals("onapName", policy.getOnapName()); - assertTrue(policy.getName().startsWith("OOF.")); - assertTrue(policy.getConfigBody().contains("\"priority\":\"5\"")); - assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\"")); - assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\"")); - assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\"")); - assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\"")); - - assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\"")); - assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"sriovNICNetwork\"")); - assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\"")); - assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciVendorId\"")); - assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1234\"")); - assertTrue(policy.getConfigBody().contains("\"operator\":\"=\"")); - assertTrue(policy.getConfigBody().contains("\"unit\":\"\"")); - - } -} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxConfigurationParameterGroup.java deleted file mode 100644 index d0de432a..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxConfigurationParameterGroup.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.reception.decoding.pdpx; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.policy.common.parameters.ValidationStatus; - -/** - * Class to perform unit test of {@link PolicyDecoderCsarPdpxConfigurationParameterGroup}. - * - * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) - */ -public class TestPolicyDecoderCsarPdpxConfigurationParameterGroup { - - @Test - public void testValidParameters() { - final PolicyDecoderCsarPdpxConfigurationParameterGroup parameterGroup = CommonTestData - .getPolicyDecoderParameters("src/test/resources/parameters/PdpxPolicyDecoderParameters.json", - PolicyDecoderCsarPdpxConfigurationParameterGroup.class); - - assertEquals(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName(), parameterGroup.getName()); - assertEquals("onapName", parameterGroup.getOnapName()); - assertEquals("OOF", parameterGroup.getPolicyNamePrefix()); - assertEquals("5", parameterGroup.getPriority()); - assertEquals("2", parameterGroup.getRiskLevel()); - assertEquals("Test", parameterGroup.getRiskType()); - assertEquals("1.0", parameterGroup.getVersion()); - assertEquals(ValidationStatus.CLEAN, parameterGroup.validate().getStatus()); - } - - @Test - public void testInvalidParameters() { - final PolicyDecoderCsarPdpxConfigurationParameterGroup parameterGroup = CommonTestData - .getPolicyDecoderParameters("src/test/resources/parameters/PdpxPolicyDecoderParametersInvalid.json", - PolicyDecoderCsarPdpxConfigurationParameterGroup.class); - - assertEquals(ValidationStatus.INVALID, parameterGroup.validate().getStatus()); - } - - @Test - public void testEmptyParameters() { - final PolicyDecoderCsarPdpxConfigurationParameterGroup configurationParameters = - CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json", - PolicyDecoderCsarPdpxConfigurationParameterGroup.class); - - assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus()); - } -} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java index 56ddc406..c3e69037 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java @@ -25,7 +25,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.distribution.reception.decoding.pdpx.CommonTestData; +import org.onap.policy.distribution.reception.decoding.hpa.CommonTestData; /** * Class to perform unit test of {@link PolicyDecoderFileInCsarToPolicyParameterGroup}. diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java index 451e4f1b..d619671f 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java @@ -37,7 +37,7 @@ import org.mockito.runners.MockitoJUnitRunner; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.distribution.model.Csar; -import org.onap.policy.distribution.reception.decoding.pdpx.CommonTestData; +import org.onap.policy.distribution.reception.decoding.hpa.CommonTestData; import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; /** diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java index 30bcdf11..f5845de8 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java @@ -36,7 +36,7 @@ import java.util.Arrays; import org.junit.Test; import org.onap.policy.common.parameters.GroupValidationResult; import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.distribution.reception.decoding.pdpx.CommonTestData; +import org.onap.policy.distribution.reception.decoding.hpa.CommonTestData; /** * Class to perform unit test of {@link SdcConfiguration}. diff --git a/plugins/reception-plugins/src/test/resources/parameters/PdpxPolicyDecoderParameters.json b/plugins/reception-plugins/src/test/resources/parameters/HpaPolicyDecoderParameters.json index 9f686632..9f686632 100644 --- a/plugins/reception-plugins/src/test/resources/parameters/PdpxPolicyDecoderParameters.json +++ b/plugins/reception-plugins/src/test/resources/parameters/HpaPolicyDecoderParameters.json diff --git a/plugins/reception-plugins/src/test/resources/parameters/PdpxPolicyDecoderParametersInvalid.json b/plugins/reception-plugins/src/test/resources/parameters/HpaPolicyDecoderParametersInvalid.json index a716452e..a716452e 100644 --- a/plugins/reception-plugins/src/test/resources/parameters/PdpxPolicyDecoderParametersInvalid.json +++ b/plugins/reception-plugins/src/test/resources/parameters/HpaPolicyDecoderParametersInvalid.json |