From ccc3e28512988345e640097381d2ae0be46fe986 Mon Sep 17 00:00:00 2001 From: Ram Krishna Verma Date: Mon, 2 Mar 2020 15:27:21 -0500 Subject: Remove policy/engine & apex dependency from distribution Issue-ID: POLICY-2404 Change-Id: Ia3084c55ea65a3119354079d9afd3ee35689b7d4 Signed-off-by: Ram Krishna Verma --- .../reception/decoding/hpa/CommonTestData.java | 53 ++++ .../reception/decoding/hpa/TestAttribute.java | 50 ++++ .../reception/decoding/hpa/TestContent.java | 75 ++++++ .../reception/decoding/hpa/TestDirective.java | 54 ++++ .../reception/decoding/hpa/TestFlavorFeature.java | 66 +++++ .../reception/decoding/hpa/TestFlavorProperty.java | 73 ++++++ .../decoding/hpa/TestHpaFeatureAttribute.java | 57 +++++ .../decoding/hpa/TestPolicyDecoderCsarHpa.java | 267 ++++++++++++++++++++ .../hpa/TestPolicyDecoderCsarHpaParameters.java | 66 +++++ .../reception/decoding/pdpx/CommonTestData.java | 53 ---- .../reception/decoding/pdpx/TestAttribute.java | 49 ---- .../reception/decoding/pdpx/TestContent.java | 73 ------ .../reception/decoding/pdpx/TestDirective.java | 52 ---- .../reception/decoding/pdpx/TestFlavorFeature.java | 63 ----- .../decoding/pdpx/TestFlavorProperty.java | 70 ------ .../decoding/pdpx/TestHpaFeatureAttribute.java | 56 ----- .../decoding/pdpx/TestPolicyDecoderCsarPdpx.java | 278 --------------------- ...DecoderCsarPdpxConfigurationParameterGroup.java | 69 ----- .../TestPolicyDecoderCsarPdpxLifecycleApi.java | 270 -------------------- ...olicyDecoderCsarPdpxLifecycleApiParameters.java | 66 ----- ...ecoderFileInCsarToPolicyParameterGroupTest.java | 2 +- .../file/PolicyDecoderFileInCsarToPolicyTest.java | 2 +- ...eceptionHandlerConfigurationParameterGroup.java | 2 +- 23 files changed, 764 insertions(+), 1102 deletions(-) create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/CommonTestData.java create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestContent.java create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpa.java create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpaParameters.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/CommonTestData.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestAttribute.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestDirective.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestFlavorFeature.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestFlavorProperty.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestHpaFeatureAttribute.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxConfigurationParameterGroup.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxLifecycleApi.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxLifecycleApiParameters.java (limited to 'plugins/reception-plugins/src/test/java/org') diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/CommonTestData.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/CommonTestData.java new file mode 100644 index 00000000..62a6ba4d --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/CommonTestData.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * 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.hpa; + +import java.io.File; + +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; + +/** + * Class to create parameters for test cases. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public class CommonTestData { + + public static final Coder coder = new StandardCoder(); + + /** + * Returns PolicyDecoderParameters for test cases. + * + * @param fileName the file name to load the parameters + * @param clazz the parameter class to be returned + * @return the specific PolicyDecoderParameters object + */ + public static T getPolicyDecoderParameters(final String fileName, final Class clazz) { + final StandardCoder coder = new StandardCoder(); + try { + return coder.decode(new File(fileName), clazz); + } catch (final CoderException exp) { + throw new RuntimeException("cannot read/decode " + fileName, exp); + } + } +} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java new file mode 100644 index 00000000..cf03ff30 --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.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}. + * + */ +public class TestAttribute { + + @Test + public void testAttribute() { + final String attributeName = "dummyName"; + final String attributeValue = "dummyValue"; + + final Attribute attribute = new Attribute(); + attribute.setAttributeName(attributeName); + attribute.setAttributeValue(attributeValue); + + validateReport(attributeName, attributeValue, attribute); + } + + private void validateReport(final String name, final String value, final Attribute attribute) { + assertEquals(name, attribute.getAttributeName()); + assertEquals(value, attribute.getAttributeValue()); + } +} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestContent.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestContent.java new file mode 100644 index 00000000..3770bc77 --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestContent.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.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}. + * + */ +public class TestContent { + + @Test + public void testContent() { + final String identity = "dummyidentity"; + final String policyType = "optimization"; + + final Content content = new Content(); + content.setIdentity(identity); + content.setPolicyType(policyType); + + validateReport(identity, policyType, content); + } + + 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()); + content.getPolicyScope().add("vFW"); + 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); + assertEquals(1, content.getFlavorFeatures().size()); + content.getFlavorFeatures().remove(flavorFeature); + assertEquals(0, content.getFlavorFeatures().size()); + assertEquals(0, content.getResources().size()); + content.getResources().add("vGW"); + assertEquals(1, content.getResources().size()); + content.getResources().remove("vGW"); + assertEquals(0, content.getResources().size()); + } +} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java new file mode 100644 index 00000000..9ab53931 --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.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}. + * + */ +public class TestDirective { + + @Test + public void testDirective() { + final String type = "dummytype"; + + final Directive directive = new Directive(); + directive.setType(type); + + validateReport(type, directive); + } + + private void validateReport(final String type, final Directive directive) { + assertEquals(type, directive.getType()); + assertEquals(0, directive.getAttributes().size()); + Attribute attribute = new Attribute(); + directive.getAttributes().add(attribute); + assertEquals(1, directive.getAttributes().size()); + directive.getAttributes().remove(attribute); + assertEquals(0, directive.getAttributes().size()); + } +} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java new file mode 100644 index 00000000..47b74c71 --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.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}. + * + */ +public class TestFlavorFeature { + + @Test + public void testFlavorFeature() { + final String id = "dummyid"; + final String type = "dummytype"; + + final FlavorFeature flavorFeature = new FlavorFeature(); + flavorFeature.setId(id); + flavorFeature.setType(type); + + validateReport(id, type, flavorFeature); + } + + private void validateReport(final String id, final String type, final FlavorFeature flavorFeature) { + assertEquals(id, flavorFeature.getId()); + assertEquals(type, flavorFeature.getType()); + + assertEquals(0, flavorFeature.getDirectives().size()); + Directive directive = new Directive(); + flavorFeature.getDirectives().add(directive); + assertEquals(1, flavorFeature.getDirectives().size()); + flavorFeature.getDirectives().remove(directive); + assertEquals(0, flavorFeature.getDirectives().size()); + + assertEquals(0, flavorFeature.getFlavorProperties().size()); + FlavorProperty flavorProperty = new FlavorProperty(); + flavorFeature.getFlavorProperties().add(flavorProperty); + assertEquals(1, flavorFeature.getFlavorProperties().size()); + flavorFeature.getFlavorProperties().remove(flavorProperty); + assertEquals(0, flavorFeature.getFlavorProperties().size()); + } +} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java new file mode 100644 index 00000000..2d0504da --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.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}. + * + */ +public class TestFlavorProperty { + + @Test + public void testFlavorProperty() { + final String hpaFeature = "dummyid"; + final String mandatory = "false"; + final String architecture = "generic"; + final String hpaVersion = "v1"; + + final FlavorProperty flavorProperty = new FlavorProperty(); + flavorProperty.setHpaFeature(hpaFeature); + flavorProperty.setMandatory(mandatory); + flavorProperty.setArchitecture(architecture); + flavorProperty.setHpaVersion(hpaVersion); + + validateReport(hpaFeature, mandatory, architecture, hpaVersion, flavorProperty); + } + + private void validateReport(final String hpaFeature, final String mandatory, final String architecture, + final String hpaVersion, final FlavorProperty flavorProperty) { + assertEquals(hpaFeature, flavorProperty.getHpaFeature()); + assertEquals(mandatory, flavorProperty.getMandatory()); + assertEquals(architecture, flavorProperty.getArchitecture()); + assertEquals(hpaVersion, flavorProperty.getHpaVersion()); + + assertEquals(0, flavorProperty.getDirectives().size()); + Directive directive = new Directive(); + flavorProperty.getDirectives().add(directive); + assertEquals(1, flavorProperty.getDirectives().size()); + flavorProperty.getDirectives().remove(directive); + assertEquals(0, flavorProperty.getDirectives().size()); + + assertEquals(0, flavorProperty.getHpaFeatureAttributes().size()); + HpaFeatureAttribute hpaFeatureAttribute = new HpaFeatureAttribute(); + flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute); + assertEquals(1, flavorProperty.getHpaFeatureAttributes().size()); + flavorProperty.getHpaFeatureAttributes().remove(hpaFeatureAttribute); + assertEquals(0, flavorProperty.getHpaFeatureAttributes().size()); + } +} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java new file mode 100644 index 00000000..fddeb168 --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.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}. + * + */ +public class TestHpaFeatureAttribute { + + @Test + public void testHpaFeatureAttribute() { + final String hpaAttributeKey = "dummykey"; + final String hpaAttributeValue = "4096"; + final String operator = ">="; + final String unit = "MB"; + + final HpaFeatureAttribute hpaFeatureAttribute = new HpaFeatureAttribute(); + hpaFeatureAttribute.setHpaAttributeKey(hpaAttributeKey); + hpaFeatureAttribute.setHpaAttributeValue(hpaAttributeValue); + hpaFeatureAttribute.setOperator(operator); + hpaFeatureAttribute.setUnit(unit); + + validateReport(hpaAttributeKey, hpaAttributeValue, operator, unit, hpaFeatureAttribute); + } + + private void validateReport(final String hpaAttributeKey, final String hpaAttributeValue, final String operator, + final String unit, final HpaFeatureAttribute hpaFeatureAttribute) { + assertEquals(hpaAttributeKey, hpaFeatureAttribute.getHpaAttributeKey()); + assertEquals(hpaAttributeValue, hpaFeatureAttribute.getHpaAttributeValue()); + assertEquals(operator, hpaFeatureAttribute.getOperator()); + assertEquals(unit, hpaFeatureAttribute.getUnit()); + } +} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpa.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpa.java new file mode 100644 index 00000000..552f430e --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpa.java @@ -0,0 +1,267 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2020 AT&T Intellectual Property. 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.hpa; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.Collection; +import java.util.Map; +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.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.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 PolicyDecoderCsarHpa}. + */ +public class TestPolicyDecoderCsarHpa { + + private final StandardCoder encoder = new StandardCoder(); + + /** + * Set up for test cases. + */ + @BeforeClass + public static void setUp() { + final ParameterGroup parameterGroup = CommonTestData.getPolicyDecoderParameters( + "src/test/resources/parameters/HpaPolicyDecoderParameters.json", + PolicyDecoderCsarHpaParameters.class); + parameterGroup.setName(PolicyDecoderCsarHpaParameters.class.getSimpleName()); + ParameterService.register(parameterGroup); + } + + /** + * Tear down. + */ + @AfterClass + public static void tearDown() { + 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 PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); + + final Collection entities = policyDecoderCsarHpa.decode(csar); + + assertEquals(2, entities.size()); + final ToscaServiceTemplate entity = entities.iterator().next(); + ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); + Map map = topologyTemplate.getPolicies().get(0); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); + Map props = policy.getProperties(); + Object 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\"")); + assertTrue(features.contains("\"type\":\"flavor_directives\"")); + assertTrue(features.contains("\"hpa-feature\":\"basicCapabilities\"")); + assertTrue(features.contains("\"mandatory\":\"True\"")); + assertTrue(features.contains("\"architecture\":\"generic\"")); + assertTrue(features.contains("\"hpa-version\":\"v1\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"virtualMemSize\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"MB\"")); + } + + @Test + public void testHpaPolicySriov() throws IOException, PolicyDecodingException, CoderException { + final Csar csar = new Csar("src/test/resources/hpaPolicySriov.csar"); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); + + final Collection entities = policyDecoderCsarHpa.decode(csar); + final ToscaServiceTemplate entity = entities.iterator().next(); + ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); + Map map = topologyTemplate.getPolicies().get(0); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); + Map props = policy.getProperties(); + Object 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\"")); + assertTrue(features.contains("\"type\":\"flavor_directives\"")); + assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); + assertTrue(features.contains("\"attribute_value\":\"\"")); + assertTrue(features.contains("\"hpa-feature\":\"sriovNICNetwork\"")); + assertTrue(features.contains("\"mandatory\":\"True\"")); + assertTrue(features.contains("\"architecture\":\"generic\"")); + assertTrue(features.contains("\"hpa-version\":\"v1\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"pciVendorId\"")); + assertTrue(features.contains("\"hpa-attribute-value\":\"1234\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"pciDeviceId\"")); + assertTrue(features.contains("\"hpa-attribute-value\":\"5678\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"pciNumDevices\"")); + assertTrue(features.contains("\"hpa-attribute-value\":\"1\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"\"")); + } + + @Test + public void testHpaPolicyPciePassthrough() throws IOException, PolicyDecodingException, CoderException { + final Csar csar = new Csar("src/test/resources/hpaPolicyPciePassthrough.csar"); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); + + final Collection entities = policyDecoderCsarHpa.decode(csar); + assertEquals(2, entities.size()); + final ToscaServiceTemplate entity = entities.iterator().next(); + ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); + Map map = topologyTemplate.getPolicies().get(0); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); + Map props = policy.getProperties(); + Object 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\"")); + assertTrue(features.contains("\"type\":\"flavor_directives\"")); + assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); + assertTrue(features.contains("\"attribute_value\":\"\"")); + assertTrue(features.contains("\"hpa-feature\":\"pciePassthrough\"")); + assertTrue(features.contains("\"mandatory\":\"True\"")); + assertTrue(features.contains("\"architecture\":\"generic\"")); + assertTrue(features.contains("\"hpa-version\":\"v1\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"pciVendorId\"")); + assertTrue(features.contains("\"hpa-attribute-value\":\"1234\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"pciDeviceId\"")); + assertTrue(features.contains("\"hpa-attribute-value\":\"5678\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"pciNumDevices\"")); + assertTrue(features.contains("\"hpa-attribute-value\":\"1\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"\"")); + } + + @Test + public void testHpaPolicyHugePage() throws IOException, PolicyDecodingException, CoderException { + final Csar csar = new Csar("src/test/resources/hpaPolicyHugePage.csar"); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); + + final Collection entities = policyDecoderCsarHpa.decode(csar); + assertEquals(2, entities.size()); + final ToscaServiceTemplate entity = entities.iterator().next(); + ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); + Map map = topologyTemplate.getPolicies().get(0); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); + Map props = policy.getProperties(); + Object 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\"")); + assertTrue(features.contains("\"type\":\"flavor_directives\"")); + assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); + assertTrue(features.contains("\"attribute_value\":\"\"")); + assertTrue(features.contains("\"hpa-feature\":\"hugePages\"")); + assertTrue(features.contains("\"mandatory\":\"true\"")); + assertTrue(features.contains("\"architecture\":\"generic\"")); + assertTrue(features.contains("\"hpa-version\":\"v1\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"memoryPageSize\"")); + assertTrue(features.contains("\"hpa-attribute-value\":\"2\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"MB\"")); + } + + @Test + public void testS3p0PciVendorId() throws IOException, PolicyDecodingException, CoderException { + final Csar csar = new Csar("src/test/resources/s3p_0_pciVendorId.csar"); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); + + final Collection entities = policyDecoderCsarHpa.decode(csar); + assertEquals(1, entities.size()); + final ToscaServiceTemplate entity = entities.iterator().next(); + ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); + Map map = topologyTemplate.getPolicies().get(0); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); + Map props = policy.getProperties(); + Object 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\"")); + assertTrue(features.contains("\"type\":\"flavor_directives\"")); + assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); + assertTrue(features.contains("\"attribute_value\":\"\"")); + assertTrue(features.contains("\"hpa-feature\":\"pciePassthrough\"")); + assertTrue(features.contains("\"mandatory\":\"True\"")); + assertTrue(features.contains("\"architecture\":\"generic\"")); + assertTrue(features.contains("\"hpa-version\":\"v1\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"pciVendorId\"")); + assertTrue(features.contains("\"hpa-attribute-value\":\"1234\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"\"")); + } + + @Test + public void testserviceVcpeWithAll() throws IOException, PolicyDecodingException, CoderException { + final Csar csar = new Csar("src/test/resources/service-VcpeWithAll-csar.csar"); + final PolicyDecoderCsarHpa policyDecoderCsarHpa = new PolicyDecoderCsarHpa(); + policyDecoderCsarHpa.configure(PolicyDecoderCsarHpaParameters.class.getSimpleName()); + + final Collection entities = policyDecoderCsarHpa.decode(csar); + assertEquals(5, entities.size()); + final ToscaServiceTemplate entity = entities.iterator().next(); + ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); + Map map = topologyTemplate.getPolicies().get(0); + ToscaPolicy policy = map.get(PolicyDecoderCsarHpa.TOSCA_POLICY_HPA_OOF); + Map props = policy.getProperties(); + Object 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\"")); + assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); + assertTrue(features.contains("\"attribute_value\":\"\"")); + assertTrue(features.contains("\"hpa-feature\":\"sriovNICNetwork\"")); + assertTrue(features.contains("\"mandatory\":\"True\"")); + assertTrue(features.contains("\"architecture\":\"generic\"")); + assertTrue(features.contains("\"hpa-version\":\"v1\"")); + assertTrue(features.contains("\"hpa-attribute-key\":\"pciVendorId\"")); + assertTrue(features.contains("\"hpa-attribute-value\":\"1234\"")); + assertTrue(features.contains("\"operator\":\"=\"")); + assertTrue(features.contains("\"unit\":\"\"")); + } +} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpaParameters.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpaParameters.java new file mode 100644 index 00000000..1ca9e1a1 --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestPolicyDecoderCsarHpaParameters.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * 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.hpa; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.policy.common.parameters.ValidationStatus; + +/** + * Class to perform unit test of {@link PolicyDecoderCsarHpaParameters}. + */ +public class TestPolicyDecoderCsarHpaParameters { + + @Test + public void testValidParameters() { + final PolicyDecoderCsarHpaParameters parameterGroup = CommonTestData.getPolicyDecoderParameters( + "src/test/resources/parameters/HpaPolicyDecoderParameters.json", + PolicyDecoderCsarHpaParameters.class); + + assertEquals(PolicyDecoderCsarHpaParameters.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 PolicyDecoderCsarHpaParameters parameterGroup = CommonTestData.getPolicyDecoderParameters( + "src/test/resources/parameters/HpaPolicyDecoderParametersInvalid.json", + PolicyDecoderCsarHpaParameters.class); + + assertEquals(ValidationStatus.INVALID, parameterGroup.validate().getStatus()); + } + + @Test + public void testEmptyParameters() { + final PolicyDecoderCsarHpaParameters configurationParameters = + CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json", + PolicyDecoderCsarHpaParameters.class); + + assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus()); + } +} 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/pdpx/CommonTestData.java deleted file mode 100644 index 5006e078..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/CommonTestData.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * 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 java.io.File; - -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; - -/** - * Class to create parameters for test cases. - * - * @author Ram Krishna Verma (ram.krishna.verma@est.tech) - */ -public class CommonTestData { - - public static final Coder coder = new StandardCoder(); - - /** - * Returns PolicyDecoderParameters for test cases. - * - * @param fileName the file name to load the parameters - * @param clazz the parameter class to be returned - * @return the specific PolicyDecoderParameters object - */ - public static T getPolicyDecoderParameters(final String fileName, final Class clazz) { - final StandardCoder coder = new StandardCoder(); - try { - return coder.decode(new File(fileName), clazz); - } catch (final CoderException exp) { - throw new RuntimeException("cannot read/decode " + fileName, exp); - } - } -} 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/pdpx/TestAttribute.java deleted file mode 100644 index 565f17d3..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestAttribute.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. 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 static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * Class to perform unit test for Attribute 0f {@link Attribute}. - * - */ -public class TestAttribute { - - @Test - public void testAttribute() { - final String attributeName = "dummyName"; - final String attributeValue = "dummyValue"; - - final Attribute attribute = new Attribute(); - attribute.setAttributeName(attributeName); - attribute.setAttributeValue(attributeValue); - - validateReport(attributeName, attributeValue, attribute); - } - - private void validateReport(final String name, final String value, final Attribute attribute) { - assertEquals(name, attribute.getAttributeName()); - assertEquals(value, attribute.getAttributeValue()); - } -} 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 deleted file mode 100644 index da77eefb..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. 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 static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * Class to perform unit test for Content 0f {@link Content}. - * - */ -public class TestContent { - - @Test - public void testContent() { - final String identity = "dummyidentity"; - final String policyType = "optimization"; - - final Content content = new Content(); - content.setIdentity(identity); - content.setPolicyType(policyType); - - validateReport(identity, policyType, content); - } - - 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()); - content.getPolicyScope().add("vFW"); - 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); - assertEquals(1, content.getFlavorFeatures().size()); - content.getFlavorFeatures().remove(flavorFeature); - assertEquals(0, content.getFlavorFeatures().size()); - assertEquals(0, content.getResources().size()); - content.getResources().add("vGW"); - assertEquals(1, content.getResources().size()); - content.getResources().remove("vGW"); - assertEquals(0, content.getResources().size()); - } -} 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/pdpx/TestDirective.java deleted file mode 100644 index cc8d946f..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestDirective.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. 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 static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * Class to perform unit test for Directive 0f {@link Directive}. - * - */ -public class TestDirective { - - @Test - public void testDirective() { - final String type = "dummytype"; - - final Directive directive = new Directive(); - directive.setType(type); - - validateReport(type, directive); - } - - private void validateReport(final String type, final Directive directive) { - assertEquals(type, directive.getType()); - assertEquals(0, directive.getAttributes().size()); - Attribute attribute = new Attribute(); - directive.getAttributes().add(attribute); - assertEquals(1, directive.getAttributes().size()); - directive.getAttributes().remove(attribute); - assertEquals(0, directive.getAttributes().size()); - } -} 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/pdpx/TestFlavorFeature.java deleted file mode 100644 index e4de2759..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestFlavorFeature.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. 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 static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * Class to perform unit test for FlavorFeature 0f {@link FlavorFeature}. - * - */ -public class TestFlavorFeature { - - @Test - public void testFlavorFeature() { - final String id = "dummyid"; - final String type = "dummytype"; - - final FlavorFeature flavorFeature = new FlavorFeature(); - flavorFeature.setId(id); - flavorFeature.setType(type); - - validateReport(id, type, flavorFeature); - } - - private void validateReport(final String id, final String type, final FlavorFeature flavorFeature) { - assertEquals(id, flavorFeature.getId()); - assertEquals(type, flavorFeature.getType()); - - assertEquals(0, flavorFeature.getDirectives().size()); - Directive directive = new Directive(); - flavorFeature.getDirectives().add(directive); - assertEquals(1, flavorFeature.getDirectives().size()); - flavorFeature.getDirectives().remove(directive); - assertEquals(0, flavorFeature.getDirectives().size()); - - assertEquals(0, flavorFeature.getFlavorProperties().size()); - FlavorProperty flavorProperty = new FlavorProperty(); - flavorFeature.getFlavorProperties().add(flavorProperty); - assertEquals(1, flavorFeature.getFlavorProperties().size()); - flavorFeature.getFlavorProperties().remove(flavorProperty); - assertEquals(0, flavorFeature.getFlavorProperties().size()); - } -} 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/pdpx/TestFlavorProperty.java deleted file mode 100644 index da6c26fc..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestFlavorProperty.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. 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 static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * Class to perform unit test for FlavorProperty 0f {@link FlavorProperty}. - * - */ -public class TestFlavorProperty { - - @Test - public void testFlavorProperty() { - final String hpaFeature = "dummyid"; - final String mandatory = "false"; - final String architecture = "generic"; - final String hpaVersion = "v1"; - - final FlavorProperty flavorProperty = new FlavorProperty(); - flavorProperty.setHpaFeature(hpaFeature); - flavorProperty.setMandatory(mandatory); - flavorProperty.setArchitecture(architecture); - flavorProperty.setHpaVersion(hpaVersion); - - validateReport(hpaFeature, mandatory, architecture, hpaVersion, flavorProperty); - } - - private void validateReport(final String hpaFeature, final String mandatory, final String architecture, - final String hpaVersion, final FlavorProperty flavorProperty) { - assertEquals(hpaFeature, flavorProperty.getHpaFeature()); - assertEquals(mandatory, flavorProperty.getMandatory()); - assertEquals(architecture, flavorProperty.getArchitecture()); - assertEquals(hpaVersion, flavorProperty.getHpaVersion()); - - assertEquals(0, flavorProperty.getDirectives().size()); - Directive directive = new Directive(); - flavorProperty.getDirectives().add(directive); - assertEquals(1, flavorProperty.getDirectives().size()); - flavorProperty.getDirectives().remove(directive); - assertEquals(0, flavorProperty.getDirectives().size()); - - assertEquals(0, flavorProperty.getHpaFeatureAttributes().size()); - HpaFeatureAttribute hpaFeatureAttribute = new HpaFeatureAttribute(); - flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute); - assertEquals(1, flavorProperty.getHpaFeatureAttributes().size()); - flavorProperty.getHpaFeatureAttributes().remove(hpaFeatureAttribute); - assertEquals(0, flavorProperty.getHpaFeatureAttributes().size()); - } -} 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/pdpx/TestHpaFeatureAttribute.java deleted file mode 100644 index f2f514d0..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestHpaFeatureAttribute.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. 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 static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * Class to perform unit test for HpaFeatureAttribute 0f {@link HpaFeatureAttribute}. - * - */ -public class TestHpaFeatureAttribute { - - @Test - public void testHpaFeatureAttribute() { - final String hpaAttributeKey = "dummykey"; - final String hpaAttributeValue = "4096"; - final String operator = ">="; - final String unit = "MB"; - - final HpaFeatureAttribute hpaFeatureAttribute = new HpaFeatureAttribute(); - hpaFeatureAttribute.setHpaAttributeKey(hpaAttributeKey); - hpaFeatureAttribute.setHpaAttributeValue(hpaAttributeValue); - hpaFeatureAttribute.setOperator(operator); - hpaFeatureAttribute.setUnit(unit); - - validateReport(hpaAttributeKey, hpaAttributeValue, operator, unit, hpaFeatureAttribute); - } - - private void validateReport(final String hpaAttributeKey, final String hpaAttributeValue, final String operator, - final String unit, final HpaFeatureAttribute hpaFeatureAttribute) { - assertEquals(hpaAttributeKey, hpaFeatureAttribute.getHpaAttributeKey()); - assertEquals(hpaAttributeValue, hpaFeatureAttribute.getHpaAttributeValue()); - assertEquals(operator, hpaFeatureAttribute.getOperator()); - assertEquals(unit, hpaFeatureAttribute.getUnit()); - } -} 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 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 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 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 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 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 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/pdpx/TestPolicyDecoderCsarPdpxLifecycleApi.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxLifecycleApi.java deleted file mode 100644 index 3b8339a9..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxLifecycleApi.java +++ /dev/null @@ -1,270 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Intellectual Property. 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 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; -import org.onap.policy.common.parameters.ParameterGroup; -import org.onap.policy.common.parameters.ParameterService; -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}. - */ -public class TestPolicyDecoderCsarPdpxLifecycleApi { - - private final StandardCoder encoder = new StandardCoder(); - - /** - * Set up for test cases. - */ - @BeforeClass - public static void setUp() { - final ParameterGroup parameterGroup = CommonTestData.getPolicyDecoderParameters( - "src/test/resources/parameters/PdpxPolicyDecoderParameters.json", - PolicyDecoderCsarPdpxLifecycleApiParameters.class); - parameterGroup.setName(PolicyDecoderCsarPdpxLifecycleApiParameters.class.getSimpleName()); - ParameterService.register(parameterGroup); - } - - /** - * Tear down. - */ - @AfterClass - public static void tearDown() { - ParameterService.deregister(PolicyDecoderCsarPdpxLifecycleApiParameters.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 Collection entities = policyDecoderCsarPdpx.decode(csar); - - assertEquals(2, entities.size()); - final ToscaServiceTemplate entity = entities.iterator().next(); - ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); - Map map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); - Map props = policy.getProperties(); - Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); - String features = encoder.encode(flavorFeatures); - assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(features.contains("\"type\":\"flavor_directives\"")); - assertTrue(features.contains("\"hpa-feature\":\"basicCapabilities\"")); - assertTrue(features.contains("\"mandatory\":\"True\"")); - assertTrue(features.contains("\"architecture\":\"generic\"")); - assertTrue(features.contains("\"hpa-version\":\"v1\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"virtualMemSize\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"MB\"")); - } - - @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 Collection entities = policyDecoderCsarPdpx.decode(csar); - final ToscaServiceTemplate entity = entities.iterator().next(); - ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); - Map map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); - Map props = policy.getProperties(); - Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); - String features = encoder.encode(flavorFeatures); - assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(features.contains("\"type\":\"flavor_directives\"")); - assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); - assertTrue(features.contains("\"attribute_value\":\"\"")); - assertTrue(features.contains("\"hpa-feature\":\"sriovNICNetwork\"")); - assertTrue(features.contains("\"mandatory\":\"True\"")); - assertTrue(features.contains("\"architecture\":\"generic\"")); - assertTrue(features.contains("\"hpa-version\":\"v1\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"pciVendorId\"")); - assertTrue(features.contains("\"hpa-attribute-value\":\"1234\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"pciDeviceId\"")); - assertTrue(features.contains("\"hpa-attribute-value\":\"5678\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"pciNumDevices\"")); - assertTrue(features.contains("\"hpa-attribute-value\":\"1\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"\"")); - } - - @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 Collection entities = policyDecoderCsarPdpx.decode(csar); - assertEquals(2, entities.size()); - final ToscaServiceTemplate entity = entities.iterator().next(); - ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); - Map map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); - Map props = policy.getProperties(); - Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); - String features = encoder.encode(flavorFeatures); - assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(features.contains("\"type\":\"flavor_directives\"")); - assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); - assertTrue(features.contains("\"attribute_value\":\"\"")); - assertTrue(features.contains("\"hpa-feature\":\"pciePassthrough\"")); - assertTrue(features.contains("\"mandatory\":\"True\"")); - assertTrue(features.contains("\"architecture\":\"generic\"")); - assertTrue(features.contains("\"hpa-version\":\"v1\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"pciVendorId\"")); - assertTrue(features.contains("\"hpa-attribute-value\":\"1234\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"pciDeviceId\"")); - assertTrue(features.contains("\"hpa-attribute-value\":\"5678\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"pciNumDevices\"")); - assertTrue(features.contains("\"hpa-attribute-value\":\"1\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"\"")); - } - - @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 Collection entities = policyDecoderCsarPdpx.decode(csar); - assertEquals(2, entities.size()); - final ToscaServiceTemplate entity = entities.iterator().next(); - ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); - Map map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); - Map props = policy.getProperties(); - Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); - String features = encoder.encode(flavorFeatures); - assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(features.contains("\"type\":\"flavor_directives\"")); - assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); - assertTrue(features.contains("\"attribute_value\":\"\"")); - assertTrue(features.contains("\"hpa-feature\":\"hugePages\"")); - assertTrue(features.contains("\"mandatory\":\"true\"")); - assertTrue(features.contains("\"architecture\":\"generic\"")); - assertTrue(features.contains("\"hpa-version\":\"v1\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"memoryPageSize\"")); - assertTrue(features.contains("\"hpa-attribute-value\":\"2\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"MB\"")); - } - - @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 Collection entities = policyDecoderCsarPdpx.decode(csar); - assertEquals(1, entities.size()); - final ToscaServiceTemplate entity = entities.iterator().next(); - ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); - Map map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); - Map props = policy.getProperties(); - Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); - String features = encoder.encode(flavorFeatures); - assertTrue(features.contains("\"id\":\"VDU_vgw_0\"")); - assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(features.contains("\"type\":\"flavor_directives\"")); - assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); - assertTrue(features.contains("\"attribute_value\":\"\"")); - assertTrue(features.contains("\"hpa-feature\":\"pciePassthrough\"")); - assertTrue(features.contains("\"mandatory\":\"True\"")); - assertTrue(features.contains("\"architecture\":\"generic\"")); - assertTrue(features.contains("\"hpa-version\":\"v1\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"pciVendorId\"")); - assertTrue(features.contains("\"hpa-attribute-value\":\"1234\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"\"")); - } - - @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 Collection entities = policyDecoderCsarPdpx.decode(csar); - assertEquals(5, entities.size()); - final ToscaServiceTemplate entity = entities.iterator().next(); - ToscaTopologyTemplate topologyTemplate = entity.getToscaTopologyTemplate(); - Map map = topologyTemplate.getPolicies().get(0); - ToscaPolicy policy = map.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_HPA_OOF); - Map props = policy.getProperties(); - Object flavorFeatures = - props.get(PolicyDecoderCsarPdpxLifecycleApi.TOSCA_POLICY_FLAVORFEATURES); - String features = encoder.encode(flavorFeatures); - assertTrue(features.contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\"")); - assertTrue(features.contains("\"type\":\"flavor_directives\"")); - assertTrue(features.contains("\"attribute_name\":\"flavorName\"")); - assertTrue(features.contains("\"attribute_value\":\"\"")); - assertTrue(features.contains("\"hpa-feature\":\"sriovNICNetwork\"")); - assertTrue(features.contains("\"mandatory\":\"True\"")); - assertTrue(features.contains("\"architecture\":\"generic\"")); - assertTrue(features.contains("\"hpa-version\":\"v1\"")); - assertTrue(features.contains("\"hpa-attribute-key\":\"pciVendorId\"")); - assertTrue(features.contains("\"hpa-attribute-value\":\"1234\"")); - assertTrue(features.contains("\"operator\":\"=\"")); - assertTrue(features.contains("\"unit\":\"\"")); - } -} 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/pdpx/TestPolicyDecoderCsarPdpxLifecycleApiParameters.java deleted file mode 100644 index 47971ad3..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxLifecycleApiParameters.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * 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 PolicyDecoderCsarPdpxLifecycleApiParameters}. - */ -public class TestPolicyDecoderCsarPdpxLifecycleApiParameters { - - @Test - public void testValidParameters() { - final PolicyDecoderCsarPdpxLifecycleApiParameters parameterGroup = CommonTestData.getPolicyDecoderParameters( - "src/test/resources/parameters/PdpxPolicyDecoderParameters.json", - PolicyDecoderCsarPdpxLifecycleApiParameters.class); - - assertEquals(PolicyDecoderCsarPdpxLifecycleApiParameters.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 PolicyDecoderCsarPdpxLifecycleApiParameters parameterGroup = CommonTestData.getPolicyDecoderParameters( - "src/test/resources/parameters/PdpxPolicyDecoderParametersInvalid.json", - PolicyDecoderCsarPdpxLifecycleApiParameters.class); - - assertEquals(ValidationStatus.INVALID, parameterGroup.validate().getStatus()); - } - - @Test - public void testEmptyParameters() { - final PolicyDecoderCsarPdpxLifecycleApiParameters configurationParameters = - CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json", - PolicyDecoderCsarPdpxLifecycleApiParameters.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}. -- cgit 1.2.3-korg