aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-07-29 20:39:23 +0100
committerMichael Morris <michael.morris@est.tech>2022-08-06 22:43:00 +0000
commit7b0009c2bebe54214f920baf6b2aa4058921777b (patch)
tree1e5a24cea14540b1e6b8777719487aa47497fa42 /catalog-be/src/test/java
parentc2f19bdcf5b5d5647770a5d3435d942fb3dd0efa (diff)
Support for TOSCA functions for Service Import
Reads, interprets and persists property values that uses TOSCA functions during a Service import. Change-Id: I6943c447cc743213cb9807d6433cb25fa5effbc3 Issue-ID: SDC-4120 Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandlerTest.java150
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java19
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ToscaFunctionServiceTest.java148
4 files changed, 309 insertions, 10 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandlerTest.java
new file mode 100644
index 0000000000..5b0096bb3f
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandlerTest.java
@@ -0,0 +1,150 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.openecomp.sdc.be.components.csar;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.datatypes.elements.ToscaConcatFunction;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunction;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType;
+import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaStringParameter;
+import org.openecomp.sdc.be.datatypes.enums.PropertySource;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
+
+class ToscaFunctionYamlParsingHandlerTest {
+
+ final ToscaFunctionYamlParsingHandler toscaFunctionYamlParsingHandler = new ToscaFunctionYamlParsingHandler();
+
+ @Test
+ void buildToscaFunctionBasedOnPropertyValue_NotAToscaFunctionTest() {
+ assertEquals(Optional.empty(), toscaFunctionYamlParsingHandler.buildToscaFunctionBasedOnPropertyValue(null));
+ }
+
+ @Test
+ void buildToscaFunctionBasedOnPropertyValue_GetInputTest() {
+ final List<String> getInputParameters = List.of("input", "subProperty");
+ final Map<String, Object> getInput = Map.of(ToscaFunctionType.GET_INPUT.getName(), getInputParameters);
+ final Optional<ToscaFunction> actualToscaFunctionOpt = toscaFunctionYamlParsingHandler.buildToscaFunctionBasedOnPropertyValue(getInput);
+ assertTrue(actualToscaFunctionOpt.isPresent());
+ final ToscaFunction actualToscaFunction = actualToscaFunctionOpt.get();
+ assertGetInput(actualToscaFunction, getInputParameters);
+ }
+
+ @Test
+ void buildToscaFunctionBasedOnPropertyValue_GetPropertyTest() {
+ final List<String> getPropertyValue = List.of(PropertySource.SELF.getName(), "aProperty", "aSubProperty");
+ final Map<String, Object> getProperty = Map.of(ToscaFunctionType.GET_PROPERTY.getName(), getPropertyValue);
+
+ final Optional<ToscaFunction> actualToscaFunctionOpt = toscaFunctionYamlParsingHandler.buildToscaFunctionBasedOnPropertyValue(getProperty);
+ assertTrue(actualToscaFunctionOpt.isPresent());
+ final ToscaFunction actualToscaFunction = actualToscaFunctionOpt.get();
+ assertEquals(ToscaFunctionType.GET_PROPERTY, actualToscaFunction.getType());
+ assertTrue(actualToscaFunction instanceof ToscaGetFunctionDataDefinition);
+ final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) actualToscaFunction;
+ assertEquals(ToscaGetFunctionType.GET_PROPERTY, toscaGetFunction.getFunctionType());
+ assertEquals("aSubProperty", toscaGetFunction.getPropertyName());
+ assertEquals(PropertySource.SELF, toscaGetFunction.getPropertySource());
+ assertEquals(getPropertyValue.subList(1, getPropertyValue.size()), toscaGetFunction.getPropertyPathFromSource());
+ assertNull(toscaGetFunction.getPropertyUniqueId());
+ assertNull(toscaGetFunction.getSourceName());
+ }
+
+ @Test
+ void buildToscaFunctionBasedOnPropertyValue_GetAttributeTest() {
+ final List<String> getPropertyValue = List.of(PropertySource.INSTANCE.getName(), "anAttribute", "aSubAttribute");
+ final Map<String, Object> getProperty = Map.of(ToscaFunctionType.GET_ATTRIBUTE.getName(), getPropertyValue);
+
+ final Optional<ToscaFunction> actualToscaFunctionOpt = toscaFunctionYamlParsingHandler.buildToscaFunctionBasedOnPropertyValue(getProperty);
+ assertTrue(actualToscaFunctionOpt.isPresent());
+ final ToscaFunction actualToscaFunction = actualToscaFunctionOpt.get();
+ assertEquals(ToscaFunctionType.GET_ATTRIBUTE, actualToscaFunction.getType());
+ assertTrue(actualToscaFunction instanceof ToscaGetFunctionDataDefinition);
+ final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) actualToscaFunction;
+ assertEquals(ToscaGetFunctionType.GET_ATTRIBUTE, toscaGetFunction.getFunctionType());
+ assertEquals("aSubAttribute", toscaGetFunction.getPropertyName());
+ assertEquals(PropertySource.INSTANCE, toscaGetFunction.getPropertySource());
+ assertEquals(getPropertyValue.subList(1, getPropertyValue.size()), toscaGetFunction.getPropertyPathFromSource());
+ assertEquals(getPropertyValue.get(0), toscaGetFunction.getSourceName());
+ assertNull(toscaGetFunction.getPropertyUniqueId());
+ }
+
+ @Test
+ void buildToscaFunctionBasedOnPropertyValue_ConcatTest() {
+ final List<Object> concatValue = List.of("string1", "-", Map.of(ToscaFunctionType.GET_INPUT.getName(), "inputName"));
+ final Map<String, Object> concatValueMap = Map.of(ToscaFunctionType.CONCAT.getName(), concatValue);
+
+ final Optional<ToscaFunction> actualToscaFunctionOpt = toscaFunctionYamlParsingHandler.buildToscaFunctionBasedOnPropertyValue(concatValueMap);
+ assertTrue(actualToscaFunctionOpt.isPresent());
+ final ToscaFunction actualToscaFunction = actualToscaFunctionOpt.get();
+ assertEquals(ToscaFunctionType.CONCAT, actualToscaFunction.getType());
+ assertTrue(actualToscaFunction instanceof ToscaConcatFunction);
+ final ToscaConcatFunction toscaConcatFunction = (ToscaConcatFunction) actualToscaFunction;
+ assertEquals(3, toscaConcatFunction.getParameters().size());
+ assertTrue(toscaConcatFunction.getParameters().get(0) instanceof ToscaStringParameter);
+ final ToscaStringParameter parameter1 = (ToscaStringParameter) toscaConcatFunction.getParameters().get(0);
+ assertEquals("string1", parameter1.getValue());
+ assertTrue(toscaConcatFunction.getParameters().get(1) instanceof ToscaStringParameter);
+ final ToscaStringParameter parameter2 = (ToscaStringParameter) toscaConcatFunction.getParameters().get(1);
+ assertEquals("-", parameter2.getValue());
+ assertTrue(toscaConcatFunction.getParameters().get(2) instanceof ToscaGetFunctionDataDefinition);
+ final ToscaGetFunctionDataDefinition getFunction = (ToscaGetFunctionDataDefinition) toscaConcatFunction.getParameters().get(2);
+ assertGetInput(getFunction, List.of("inputName"));
+ }
+
+
+ @Test
+ void isPropertyValueToscaFunctionTest() {
+ assertFalse(toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(ToscaFunctionType.GET_INPUT.getName()));
+ assertFalse(toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(new HashMap<>()));
+ assertFalse(toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(
+ Map.of(ToscaFunctionType.GET_ATTRIBUTE.getName(), "", ToscaFunctionType.GET_INPUT.getName(), "")
+ )
+ );
+ assertTrue(toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(Map.of(ToscaFunctionType.GET_ATTRIBUTE.getName(), "")));
+ assertTrue(toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(Map.of(ToscaFunctionType.GET_INPUT.getName(), "")));
+ assertTrue(toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(Map.of(ToscaFunctionType.GET_PROPERTY.getName(), "")));
+ assertTrue(toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(Map.of(ToscaFunctionType.CONCAT.getName(), "")));
+ assertFalse(toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(Map.of(ToscaFunctionType.YAML.getName(), "")));
+ assertFalse(toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(Map.of(ToscaFunctionType.STRING.getName(), "")));
+ }
+
+ private static void assertGetInput(final ToscaFunction actualGetInputFunction, final List<String> expectedGetInputParameters) {
+ assertEquals(ToscaFunctionType.GET_INPUT, actualGetInputFunction.getType());
+ assertTrue(actualGetInputFunction instanceof ToscaGetFunctionDataDefinition);
+ final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) actualGetInputFunction;
+ assertEquals(ToscaGetFunctionType.GET_INPUT, toscaGetFunction.getFunctionType());
+ assertEquals(expectedGetInputParameters.get(expectedGetInputParameters.size() - 1), toscaGetFunction.getPropertyName());
+ assertEquals(PropertySource.SELF, toscaGetFunction.getPropertySource());
+ assertEquals(expectedGetInputParameters, toscaGetFunction.getPropertyPathFromSource());
+ assertNull(toscaGetFunction.getPropertyUniqueId());
+ assertNull(toscaGetFunction.getSourceName());
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java
index 6d779a192e..d9525b1590 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java
@@ -90,6 +90,8 @@ public class YamlTemplateParsingHandlerTest {
private User user;
@Mock
private PolicyTypeBusinessLogic policyTypeBusinessLogic;
+ @Mock
+ private ToscaFunctionYamlParsingHandler toscaFunctionYamlParsingHandler;
private YamlTemplateParsingHandler handler;
@@ -135,10 +137,9 @@ public class YamlTemplateParsingHandlerTest {
@BeforeEach
public void setup() {
-
- AnnotationBusinessLogic annotationBusinessLogic = new AnnotationBusinessLogic(annotationTypeOperations,
- annotationValidator);
- handler = new YamlTemplateParsingHandler(janusGraphDao, groupTypeBusinessLogic, annotationBusinessLogic, policyTypeBusinessLogic);
+ final var annotationBusinessLogic = new AnnotationBusinessLogic(annotationTypeOperations, annotationValidator);
+ handler = new YamlTemplateParsingHandler(janusGraphDao, groupTypeBusinessLogic, annotationBusinessLogic, policyTypeBusinessLogic,
+ toscaFunctionYamlParsingHandler);
ReflectionTestUtils.setField(handler, "policyTypeBusinessLogic", policyTypeBusinessLogic);
}
@@ -315,15 +316,15 @@ public class YamlTemplateParsingHandlerTest {
assertEquals(5, resourceInstanceWithAttributes.getAttributes().size());
assertTrue(resourceInstanceWithAttributes.getAttributes().containsKey("fq_name"));
- assertEquals(resourceInstanceWithAttributes.getAttributes().get("fq_name").getValue(), "fq_name_value");
+ assertEquals("fq_name_value", resourceInstanceWithAttributes.getAttributes().get("fq_name").getValue());
assertTrue(resourceInstanceWithAttributes.getAttributes().containsKey("tosca_name"));
- assertEquals(resourceInstanceWithAttributes.getAttributes().get("tosca_name").getValue(), "tosca_name_value");
+ assertEquals("tosca_name_value", resourceInstanceWithAttributes.getAttributes().get("tosca_name").getValue());
assertTrue(resourceInstanceWithAttributes.getAttributes().containsKey("subnets_show"));
- assertEquals(resourceInstanceWithAttributes.getAttributes().get("subnets_show").getValue(), expectedSubnetsShowList);
+ assertEquals(expectedSubnetsShowList, resourceInstanceWithAttributes.getAttributes().get("subnets_show").getValue());
assertTrue(resourceInstanceWithAttributes.getAttributes().containsKey("subnets_name"));
- assertEquals(resourceInstanceWithAttributes.getAttributes().get("subnets_name").getValue(), expectedSubnetsNameMap);
+ assertEquals(expectedSubnetsNameMap, resourceInstanceWithAttributes.getAttributes().get("subnets_name").getValue());
assertTrue(resourceInstanceWithAttributes.getAttributes().containsKey("new_attribute"));
- assertEquals(resourceInstanceWithAttributes.getAttributes().get("new_attribute").getValue(), "new_attribute_value");
+ assertEquals("new_attribute_value", resourceInstanceWithAttributes.getAttributes().get("new_attribute").getValue());
}
private void validateParsedYaml(ParsedToscaYamlInfo parsedYaml, String group, List<String> expectedProp) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
index d85ad38120..ff47d75509 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
@@ -1483,7 +1483,7 @@ class ResourceBusinessLogicTest {
String resourceYml = new String(csar.get("Definitions/my_vnf.yaml"));
YamlTemplateParsingHandler yamlTemplateParser = new YamlTemplateParsingHandler(mockJanusGraphDao, null,
- Mockito.mock(AnnotationBusinessLogic.class), null);
+ Mockito.mock(AnnotationBusinessLogic.class), null, null);
final ParsedToscaYamlInfo parsedToscaYamlInfo = yamlTemplateParser.parseResourceInfoFromYAML("Definitions/my_vnf.yml", resourceYml,
Collections.EMPTY_MAP, Collections.EMPTY_MAP, "myVnf", resourceResponse, "");
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ToscaFunctionServiceTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ToscaFunctionServiceTest.java
new file mode 100644
index 0000000000..89507d43dd
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ToscaFunctionServiceTest.java
@@ -0,0 +1,148 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.openecomp.sdc.be.components.impl;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.datatypes.elements.ToscaConcatFunction;
+import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.PropertySource;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
+import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.Service;
+
+class ToscaFunctionServiceTest {
+
+ private final ToscaFunctionService toscaFunctionService = new ToscaFunctionService();
+
+
+ @Test
+ void updateFunctionWithDataFromSelfComponentTest() {
+ //given a component with one property, one attribute, one instance. The instance have one property and one attribute.
+ final Component component = new Service();
+ component.setUniqueId("componentId");
+ component.setName("componentName");
+ final var componentInput1 = new InputDefinition();
+ componentInput1.setUniqueId("input1Id");
+ componentInput1.setName("input1Name");
+ component.setInputs(List.of(componentInput1));
+
+ final var componentAttribute1 = new AttributeDefinition();
+ componentAttribute1.setUniqueId("componentAttribute1Id");
+ componentAttribute1.setName("componentAttribute1Name");
+ component.setAttributes(List.of(componentAttribute1));
+
+ final var componentProperty1 = new PropertyDefinition();
+ componentProperty1.setUniqueId("componentProperty1Id");
+ componentProperty1.setName("componentProperty1Name");
+ component.setProperties(List.of(componentProperty1));
+
+ final var componentInstance1 = new ComponentInstance();
+ componentInstance1.setName("componentInstance1Name");
+ componentInstance1.setUniqueId("componentInstance1Id");
+ component.setComponentInstances(List.of(componentInstance1));
+
+ final Map<String, List<ComponentInstanceProperty>> instancePropertyMap = new HashMap<>();
+ final var componentInstanceProperty = new ComponentInstanceProperty();
+ final String instancePropertyId1 = "instancePropertyId1";
+ componentInstanceProperty.setUniqueId(instancePropertyId1);
+ final String instancePropertyName1 = "instancePropertyName1";
+ componentInstanceProperty.setName(instancePropertyName1);
+ instancePropertyMap.put(componentInstance1.getUniqueId(), List.of(componentInstanceProperty));
+
+ final Map<String, List<AttributeDefinition>> instanceAttributeMap = new HashMap<>();
+ final AttributeDefinition instanceAttribute1 = new ComponentInstanceAttribute();
+ instanceAttribute1.setUniqueId("instanceAttribute1Id");
+ instanceAttribute1.setName("instanceAttribute1Name");
+ instanceAttributeMap.put(componentInstance1.getUniqueId(), List.of(instanceAttribute1));
+
+ final ToscaConcatFunction toscaConcatFunction = new ToscaConcatFunction();
+
+ final ToscaGetFunctionDataDefinition toscaGetInput = new ToscaGetFunctionDataDefinition();
+ toscaGetInput.setFunctionType(ToscaGetFunctionType.GET_INPUT);
+ toscaGetInput.setPropertyName(componentInput1.getName());
+ toscaGetInput.setPropertySource(PropertySource.SELF);
+ toscaConcatFunction.setParameters(List.of(toscaGetInput));
+
+ final ToscaGetFunctionDataDefinition toscaGetPropertyFromInstance = new ToscaGetFunctionDataDefinition();
+ toscaGetPropertyFromInstance.setFunctionType(ToscaGetFunctionType.GET_PROPERTY);
+ toscaGetPropertyFromInstance.setPropertyName(instancePropertyName1);
+ toscaGetPropertyFromInstance.setSourceName(componentInstance1.getName());
+ toscaGetPropertyFromInstance.setPropertySource(PropertySource.INSTANCE);
+ toscaGetPropertyFromInstance.setPropertyPathFromSource(List.of(instancePropertyName1));
+
+ final ToscaGetFunctionDataDefinition toscaGetPropertyFromSelf = new ToscaGetFunctionDataDefinition();
+ toscaGetPropertyFromSelf.setFunctionType(ToscaGetFunctionType.GET_PROPERTY);
+ toscaGetPropertyFromSelf.setPropertyName(componentProperty1.getName());
+ toscaGetPropertyFromSelf.setPropertySource(PropertySource.SELF);
+ toscaGetPropertyFromSelf.setPropertyPathFromSource(List.of(componentProperty1.getName()));
+
+ final ToscaGetFunctionDataDefinition toscaGetAttributeFromInstance = new ToscaGetFunctionDataDefinition();
+ toscaGetAttributeFromInstance.setFunctionType(ToscaGetFunctionType.GET_ATTRIBUTE);
+ toscaGetAttributeFromInstance.setPropertyName(instanceAttribute1.getUniqueId());
+ toscaGetAttributeFromInstance.setSourceName(componentInstance1.getName());
+ toscaGetAttributeFromInstance.setPropertySource(PropertySource.INSTANCE);
+ toscaGetAttributeFromInstance.setPropertyPathFromSource(List.of(instanceAttribute1.getName()));
+
+ final ToscaGetFunctionDataDefinition toscaGetAttributeFromSelf = new ToscaGetFunctionDataDefinition();
+ toscaGetAttributeFromSelf.setFunctionType(ToscaGetFunctionType.GET_ATTRIBUTE);
+ toscaGetAttributeFromSelf.setPropertyName(componentAttribute1.getName());
+ toscaGetAttributeFromSelf.setPropertySource(PropertySource.SELF);
+ toscaGetAttributeFromSelf.setPropertyPathFromSource(List.of(componentAttribute1.getName()));
+
+ toscaConcatFunction.setParameters(
+ List.of(toscaGetInput, toscaGetPropertyFromSelf, toscaGetPropertyFromInstance, toscaGetAttributeFromSelf, toscaGetAttributeFromInstance)
+ );
+
+ //when
+ toscaFunctionService.updateFunctionWithDataFromSelfComponent(toscaConcatFunction, component, instancePropertyMap, instanceAttributeMap);
+
+ //then
+ assertEquals(componentInput1.getUniqueId(), toscaGetInput.getPropertyUniqueId());
+ assertEquals(component.getUniqueId(), toscaGetInput.getSourceUniqueId());
+ assertEquals(component.getName(), toscaGetInput.getSourceName());
+
+ assertEquals(instancePropertyId1, toscaGetPropertyFromInstance.getPropertyUniqueId());
+ assertEquals(componentInstance1.getUniqueId(), toscaGetPropertyFromInstance.getSourceUniqueId());
+
+ assertEquals(instanceAttribute1.getUniqueId(), toscaGetAttributeFromInstance.getPropertyUniqueId());
+ assertEquals(componentInstance1.getUniqueId(), toscaGetAttributeFromInstance.getSourceUniqueId());
+
+ assertEquals(componentAttribute1.getUniqueId(), toscaGetAttributeFromSelf.getPropertyUniqueId());
+ assertEquals(component.getUniqueId(), toscaGetAttributeFromSelf.getSourceUniqueId());
+ assertEquals(component.getName(), toscaGetAttributeFromSelf.getSourceName());
+
+ assertEquals(componentProperty1.getUniqueId(), toscaGetPropertyFromSelf.getPropertyUniqueId());
+ assertEquals(component.getUniqueId(), toscaGetPropertyFromSelf.getSourceUniqueId());
+ assertEquals(component.getName(), toscaGetPropertyFromSelf.getSourceName());
+ }
+} \ No newline at end of file