diff options
author | 2020-06-24 08:34:22 +0100 | |
---|---|---|
committer | 2020-07-09 09:34:30 +0000 | |
commit | bdeb28f273da2494d7eeabbb5329222dfd168e3b (patch) | |
tree | 2cf9e54e83db704ee7215b033a2abde9ab8adee7 /common/onap-tosca-datatype/src | |
parent | 0132d3637a889f84897d6a08688b20ff6f606041 (diff) |
Add support for substitution_filter business logic
Tosca simple YAML profile allows for
substitution_filter to be specified for
a topology template to provide processing
instructions to the orchestrator.
Issue-ID: SDC-3147
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Change-Id: Ia94b8c447d3157e614f9d1524ad4520b3980ba4d
Diffstat (limited to 'common/onap-tosca-datatype/src')
5 files changed, 15 insertions, 192 deletions
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/SubstitutionMapping.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/SubstitutionMapping.java index 3669ae1df4..a8d0718c4e 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/SubstitutionMapping.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/SubstitutionMapping.java @@ -7,9 +7,9 @@ * 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. @@ -22,33 +22,17 @@ package org.onap.sdc.tosca.datatypes.model; import java.util.List; import java.util.Map; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +@Getter +@Setter +@EqualsAndHashCode public class SubstitutionMapping { - private String node_type; - private Map<String, List<String>> capabilities; - private Map<String, List<String>> requirements; - public String getNode_type() { - return node_type; - } - - public void setNode_type(String node_type) { - this.node_type = node_type; - } - - public Map<String, List<String>> getRequirements() { - return requirements; - } - - public void setRequirements(Map<String, List<String>> requirements) { - this.requirements = requirements; - } - - public Map<String, List<String>> getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map<String, List<String>> capabilities) { - this.capabilities = capabilities; - } + private String node_type; + private Map<String, List<String>> capabilities; + private Map<String, List<String>> requirements; + private NodeFilter substitution_filter; } diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionFilter.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionFilter.java deleted file mode 100644 index 8f3aa20a48..0000000000 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionFilter.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2016-2018 European Support Limited - * - * 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. - */ - -package org.onap.sdc.tosca.datatypes.model.extension; - - -import java.util.List; - -import java.util.Map; -import org.onap.sdc.tosca.datatypes.model.Constraint; -import org.onap.sdc.tosca.services.DataModelNormalizeUtil; - -public class SubstitutionFilter { - - private List<Map<String, List<Constraint>>> properties; - - public List<Map<String, List<Constraint>>> getProperties() { - return properties; - } - - public void setProperties(List<Map<String, List<Constraint>>> properties) { - this.properties = DataModelNormalizeUtil.getNormalizePropertiesFilter(properties); - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof SubstitutionFilter)) { - return false; - } - - SubstitutionFilter that = (SubstitutionFilter) o; - - return getProperties() != null ? getProperties().equals(that.getProperties()) : that.getProperties() == null; - } - - @Override - public int hashCode() { - return getProperties() != null ? getProperties().hashCode() : 0; - } -} diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExt.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExt.java deleted file mode 100644 index d60931d180..0000000000 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExt.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright © 2016-2018 European Support Limited - * - * 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. - */ - -package org.onap.sdc.tosca.datatypes.model.extension; - -import org.onap.sdc.tosca.datatypes.model.SubstitutionMapping; - -public class SubstitutionMappingExt extends SubstitutionMapping { - - private SubstitutionFilter substitution_filter; - - public SubstitutionFilter getSubstitution_filter() { - return substitution_filter; - } - - public void setSubstitution_filter(SubstitutionFilter substitution_filter) { - this.substitution_filter = substitution_filter; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof SubstitutionMappingExt)) { - return false; - } - - SubstitutionMappingExt that = (SubstitutionMappingExt) o; - - return getSubstitution_filter() != null ? getSubstitution_filter().equals(that.getSubstitution_filter()) - : that.getSubstitution_filter() == null; - } - - @Override - public int hashCode() { - return getSubstitution_filter() != null ? getSubstitution_filter().hashCode() : 0; - } -} diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/ToscaExtensionYamlUtil.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/ToscaExtensionYamlUtil.java index a6c079ade0..45499d15f4 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/ToscaExtensionYamlUtil.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/ToscaExtensionYamlUtil.java @@ -37,8 +37,6 @@ public class ToscaExtensionYamlUtil extends YamlUtil { "org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignmentExt"; public static final String TOSCA_MODEL_SUBSTITUTION_MAPPING = "org.onap.sdc.tosca.datatypes.model.SubstitutionMapping"; - public static final String TOSCA_MODEL_EXT_SUBSTITUTION_MAPPING = - "org.onap.sdc.tosca.datatypes.model.extension.SubstitutionMappingExt"; @Override public <T> Constructor getConstructor(Class<T> typClass) { @@ -62,9 +60,6 @@ public class ToscaExtensionYamlUtil extends YamlUtil { if (type.equals(Class.forName(TOSCA_MODEL_REQUIREMENT_ASSIGNMENT))) { classType = Class.forName(TOSCA_MODEL_EXT_REQUIREMENT_ASSIGNMENT); } - if (type.equals(Class.forName(TOSCA_MODEL_SUBSTITUTION_MAPPING))) { - classType = Class.forName(TOSCA_MODEL_EXT_SUBSTITUTION_MAPPING); - } } catch (ClassNotFoundException ex) { throw new ToscaRuntimeException(ex); } @@ -85,6 +80,7 @@ public class ToscaExtensionYamlUtil extends YamlUtil { protected Object constructJavaBean2ndStep(MappingNode node, Object object) { Class type = node.getType(); try { + final Class<?> substitutionMappingClass = Class.forName(TOSCA_MODEL_SUBSTITUTION_MAPPING); if (type.equals(Class.forName(TOSCA_MODEL_PARAMETER_DEFINITION))) { Class extendHeatClass = Class.forName(TOSCA_MODEL_EXT_PARAMETER_DEFINITION); Object extendHeatObject = extendHeatClass.newInstance(); @@ -95,11 +91,8 @@ public class ToscaExtensionYamlUtil extends YamlUtil { Object extendHeatObject = extendHeatClass.newInstance(); // create JavaBean return super.constructJavaBean2ndStep(node, extendHeatObject); - } else if (type.equals(Class.forName(TOSCA_MODEL_SUBSTITUTION_MAPPING))) { - Class extendHeatClass = Class.forName(TOSCA_MODEL_EXT_SUBSTITUTION_MAPPING); - Object extendHeatObject = extendHeatClass.newInstance(); - // create JavaBean - return super.constructJavaBean2ndStep(node, extendHeatObject); + } else if (type.equals(substitutionMappingClass)) { + return super.constructJavaBean2ndStep(node, substitutionMappingClass.newInstance()); } else { // create JavaBean return super.constructJavaBean2ndStep(node, object); diff --git a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExtTest.java b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExtTest.java deleted file mode 100644 index aa1290b683..0000000000 --- a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExtTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 Nokia. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.tosca.datatypes.model.extension; - -import org.junit.Test; - -import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding; -import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeExcluding; -import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; -import static org.junit.Assert.assertThat; - -public class SubstitutionMappingExtTest { - @Test - public void shouldHaveValidGettersAndSetters() { - assertThat(SubstitutionMappingExt.class, hasValidGettersAndSetters()); - } - - @Test - public void shouldHaveValidEquals() { - assertThat(SubstitutionMappingExt.class, hasValidBeanEqualsExcluding("capabilities", "node_type", "requirements")); - } - - @Test - public void shouldHaveValidHashCode() { - assertThat(SubstitutionMappingExt.class, hasValidBeanHashCodeExcluding("capabilities", "node_type", "requirements")); - } -}
\ No newline at end of file |