Added oparent to sdc main
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / property / ComponentInstancePropertyDeclaratorTest.java
1 /*
2  * Copyright © 2016-2019 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.be.components.property;
18
19 import static org.assertj.core.api.Assertions.assertThat;
20 import static org.mockito.ArgumentMatchers.any;
21 import static org.mockito.ArgumentMatchers.eq;
22 import static org.mockito.Mockito.verifyZeroInteractions;
23 import static org.mockito.Mockito.when;
24 import static org.openecomp.sdc.be.components.property.CapabilityTestUtils.createCapabilityDefinition;
25 import static org.openecomp.sdc.be.components.property.CapabilityTestUtils.createProperties;
26
27 import fj.data.Either;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.Collections;
31 import java.util.HashMap;
32 import java.util.LinkedList;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.stream.Collectors;
36 import java.util.stream.Stream;
37 import org.junit.Assert;
38 import org.junit.Test;
39 import org.junit.runner.RunWith;
40 import org.mockito.ArgumentCaptor;
41 import org.mockito.Captor;
42 import org.mockito.InjectMocks;
43 import org.mockito.Mock;
44 import org.mockito.junit.MockitoJUnitRunner;
45 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
46 import org.openecomp.sdc.be.components.utils.InputsBuilder;
47 import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
48 import org.openecomp.sdc.be.components.utils.ResourceBuilder;
49 import org.openecomp.sdc.be.components.utils.ServiceBuilder;
50 import org.openecomp.sdc.be.dao.utils.MapUtil;
51 import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
52 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
53 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
54 import org.openecomp.sdc.be.model.CapabilityDefinition;
55 import org.openecomp.sdc.be.model.Component;
56 import org.openecomp.sdc.be.model.ComponentInstancePropInput;
57 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
58 import org.openecomp.sdc.be.model.InputDefinition;
59 import org.openecomp.sdc.be.model.PropertyDefinition;
60 import org.openecomp.sdc.be.model.Resource;
61 import org.openecomp.sdc.be.model.Service;
62 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
63 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
64 import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
65 import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
66
67
68 @RunWith(MockitoJUnitRunner.class)
69 public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorTestBase {
70
71     @InjectMocks
72     private ComponentInstancePropertyDeclarator testInstance;
73     @Mock
74     private ToscaOperationFacade toscaOperationFacade;
75     @Mock
76     private ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
77     @Mock
78     private PropertyOperation propertyOperation;
79
80     @Captor
81     private ArgumentCaptor<Map<String, List<ComponentInstanceProperty>>> instancePropertiesCaptor;
82
83     private static final String PROPERTY_ID = "propertyUid";
84     private static final String PROEPRTY_NAME = "propertyName";
85     private static final String SERVICE_ID = "serviceUid";
86     private static final String SERVICE_NAME = "serviceName";
87
88     @Test
89     public void declarePropertiesAsInputs_componentInstanceNotExist() {
90         Component cmpt = new Resource();
91         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(cmpt, "someCmptInstId", Collections.emptyList());
92         assertThat(createdInputs.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND);
93         verifyZeroInteractions(toscaOperationFacade);
94     }
95
96     @Test
97     public void declarePropertiesAsInputs_singleNonComplexProperty() {
98         List<PropertyDataDefinition> properties = Collections.singletonList(prop1);
99         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
100         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor.capture())).thenReturn(Either.left(Collections.emptyMap()));
101         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
102         List<InputDefinition> inputs = createdInputs.left().value();
103         List<ComponentInstanceProperty> capturedInstanceProperties = instancePropertiesCaptor.getValue().get(INSTANCE_ID);
104         verifyCreatedInputs(properties, capturedInstanceProperties, inputs);
105         verifyUpdatedProperties(properties, capturedInstanceProperties, inputs);
106     }
107
108     @Test
109     public void declareCapabilitiesPropertiesAsInputs() {
110         prop1.setParentUniqueId("capUniqueId");
111         List<PropertyDataDefinition> properties = Collections.singletonList(prop1);
112         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
113         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor
114                 .capture())).thenReturn(Either.left(Collections.emptyMap()));
115
116         CapabilityDefinition capabilityDefinition = createCapabilityDefinition();
117
118         List<ComponentInstanceProperty> capPropList = new ArrayList<>();
119         ComponentInstanceProperty instanceProperty = createProperties();
120         capPropList.add(instanceProperty);
121         capabilityDefinition.setProperties(capPropList);
122
123         capabilityDefinition.setPath(Collections.singletonList("path"));
124         Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
125         capabilityMap.put(capabilityDefinition.getType(), Collections.singletonList(capabilityDefinition));
126         resource.setCapabilities(capabilityMap);
127
128         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance
129                 .declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
130         Assert.assertTrue(createdInputs.isLeft());
131     }
132
133     @Test
134     public void testUnDeclarePropertiesAsInputs() throws Exception {
135         Component component = new ResourceBuilder().setComponentType(ComponentTypeEnum.RESOURCE).setUniqueId("resourceId")
136                 .setName("resourceName").build();
137         InputDefinition input = new InputDefinition();
138         input.setUniqueId("ComponentInput1_uniqueId");
139         input.setPropertyId("ComponentInput1_uniqueId");
140
141         CapabilityDefinition capabilityDefinition = createCapabilityDefinition();
142
143         List<ComponentInstanceProperty> properties = new ArrayList<>();
144         ComponentInstanceProperty instanceProperty = createProperties();
145
146         List<GetInputValueDataDefinition> valueDataDefinitionList = new ArrayList<>();
147         GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
148         getInputValueDataDefinition.setInputId("ComponentInput1_uniqueId");
149         getInputValueDataDefinition.setPropName("prop_name");
150         valueDataDefinitionList.add(getInputValueDataDefinition);
151
152         instanceProperty.setGetInputValues(valueDataDefinitionList);
153         properties.add(instanceProperty);
154         capabilityDefinition.setProperties(properties);
155         Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
156         capabilityMap.put(capabilityDefinition.getType(), Collections.singletonList(capabilityDefinition));
157         component.setCapabilities(capabilityMap);
158         component.setInputs(Collections.singletonList(input));
159         when(toscaOperationFacade.updateInstanceCapabilityProperty(any(Resource.class), any(),
160                 any(ComponentInstanceProperty.class), any(CapabilityDefinition.class))).thenReturn(StorageOperationStatus.OK);
161
162         StorageOperationStatus result = testInstance.unDeclarePropertiesAsInputs(component, input);
163         Assert.assertEquals(StorageOperationStatus.OK, result);
164     }
165
166     @Test
167     public void declarePropertiesAsInputs_multipleNonComplexProperty() {
168         List<PropertyDataDefinition> properties = Arrays.asList(prop1, prop2);
169         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
170         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor.capture())).thenReturn(Either.left(Collections.emptyMap()));
171         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
172
173         List<InputDefinition> inputs = createdInputs.left().value();
174         List<ComponentInstanceProperty> capturedInstanceProperties = instancePropertiesCaptor.getValue().get(INSTANCE_ID);
175         verifyCreatedInputs(properties, capturedInstanceProperties, inputs);
176         verifyUpdatedProperties(properties, capturedInstanceProperties, inputs);
177     }
178
179     @Test
180     public void declarePropertiesAsInputs_singleComplexProperty() {
181         PropertyDefinition innerProp1 = new PropertyDataDefinitionBuilder()
182                 .setName(INNER_PROP1)
183                 .setValue("true")
184                 .setType("boolean")
185                 .setUniqueId(complexProperty.getType() + ".datatype.ecomp_generated_naming")
186                 .build();
187         PropertyDefinition innerProp2 = new PropertyDataDefinitionBuilder()
188                 .setName(INNER_PROP2)
189                 .setValue("abc")
190                 .setType("string")
191                 .setUniqueId(complexProperty.getType() + ".datatype.ecomp_generated_naming")
192                 .build();
193         List<ComponentInstancePropInput> propsToDeclare = createComplexPropInputList(innerProp1, innerProp2);
194         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor.capture())).thenReturn(Either.left(Collections.emptyMap()));
195         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
196
197         List<InputDefinition> inputs = createdInputs.left().value();
198         List<ComponentInstanceProperty> capturedInstanceProperties = instancePropertiesCaptor.getValue().get(INSTANCE_ID);
199
200         verifyCreatedInputsFromComplexProperty(propsToDeclare, capturedInstanceProperties, inputs);
201         verifyUpdatedComplexProperty(capturedInstanceProperties, inputs);
202     }
203
204     @Test
205     public void testCreateDeclaredProperty() {
206         PropertyDefinition propertyDefinition = getPropertyForDeclaration();
207         ComponentInstanceProperty declaredProperty = testInstance.createDeclaredProperty(propertyDefinition);
208
209         assertThat(declaredProperty).isNotNull();
210         assertThat(declaredProperty.getUniqueId()).isEqualTo(propertyDefinition.getUniqueId());
211     }
212
213     @Test
214     public void testUndeclareProperty() {
215         Service service = new ServiceBuilder()
216                                   .setUniqueId(SERVICE_ID)
217                                   .setName(SERVICE_NAME)
218                                   .build();
219
220
221
222         InputDefinition inputToDelete = InputsBuilder
223                                                 .create()
224                                                 .setPropertyId(PROPERTY_ID)
225                                                 .setName(PROEPRTY_NAME)
226                                                 .build();
227
228         inputToDelete.setGetInputValues(getGetInputListForDeclaration());
229
230         ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty(getPropertyForDeclaration());
231         List<ComponentInstanceProperty> componentInstanceProperties = new ArrayList<>();
232         componentInstanceProperties.add(componentInstanceProperty);
233
234         when(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(any(), any())).thenReturn(new LinkedList<>());
235
236         StorageOperationStatus undeclareStatus =
237                 testInstance.unDeclarePropertiesAsInputs(service, inputToDelete);
238
239         assertThat(undeclareStatus).isEqualTo(StorageOperationStatus.OK);
240     }
241
242     private List<GetInputValueDataDefinition> getGetInputListForDeclaration() {
243         GetInputValueDataDefinition getInput = new GetInputValueDataDefinition();
244         getInput.setInputId(PROPERTY_ID);
245         getInput.setInputName(PROEPRTY_NAME);
246         getInput.setPropName(PROEPRTY_NAME);
247         List<GetInputValueDataDefinition> getInputList = new ArrayList<>();
248         getInputList.add(getInput);
249         return getInputList;
250     }
251
252     private PropertyDefinition getPropertyForDeclaration() {
253         return new PropertyDataDefinitionBuilder()
254                        .setUniqueId(PROPERTY_ID)
255                        .build();
256     }
257
258     @Test
259     public void declarePropertiesAsListInput() {
260         // construct arguments
261         List<PropertyDataDefinition> properties = Arrays.asList(prop1, prop2);
262         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
263         InputDefinition input = new InputDefinition(new PropertyDataDefinitionBuilder()
264                 .setName("listinput")
265                 .setType("list")
266                 .setDescription("description")
267                 .setSchemaType("org.onap.datatype.listinput")
268                 .build());
269         // mock returns
270         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor.capture())).thenReturn(Either.left(Collections.emptyMap()));
271         Either<InputDefinition, StorageOperationStatus> result = testInstance.declarePropertiesAsListInput(resource, "inst1", propsToDeclare, input);
272         // validate result
273         assertThat(result.isLeft()).isTrue();
274         List<ComponentInstanceProperty> capturedInstanceProperties = instancePropertiesCaptor.getValue().get(INSTANCE_ID);
275         assertThat(capturedInstanceProperties.size()).isEqualTo(2);
276         Map<String, PropertyDataDefinition> propertiesMap =
277                 properties.stream().collect(Collectors.toMap(PropertyDataDefinition::getName, e->e));
278         for(ComponentInstanceProperty instanceProperty: capturedInstanceProperties) {
279             assertThat(propertiesMap.containsKey(instanceProperty.getName())).isTrue();
280             PropertyDataDefinition property = propertiesMap.get(instanceProperty.getName());
281             assertThat(instanceProperty.getType()).isEqualTo(property.getType());
282             assertThat(instanceProperty.isGetInputProperty()).isTrue();
283         }
284     }
285
286     @Test
287     public void declarePropertiesAsListInput_propertyOwnerNotFound() {
288         // construct arguments
289         List<PropertyDataDefinition> properties = Arrays.asList(prop1, prop2);
290         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
291         InputDefinition input = new InputDefinition(new PropertyDataDefinitionBuilder()
292                 .setName("listinput")
293                 .setType("list")
294                 .setDescription("description")
295                 .setSchemaType("org.onap.datatype.listinput")
296                 .build());
297         Either<InputDefinition, StorageOperationStatus> result = testInstance.declarePropertiesAsListInput(resource, "inst2", propsToDeclare, input);
298         // validate result
299         assertThat(result.isRight()).isTrue();
300         assertThat(result.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND);
301     }
302
303     @Test
304     public void unDeclarePropertiesAsListInputsTest() {
305         InputDefinition inputToDelete = new InputDefinition();
306         inputToDelete.setUniqueId(INPUT_ID);
307         inputToDelete.setName(INPUT_ID);
308         inputToDelete.setIsDeclaredListInput(true);
309
310         Component component = createComponentWithListInput(INPUT_ID, "innerPropName");
311         PropertyDefinition prop = new PropertyDataDefinitionBuilder()
312                 .setName("propName")
313                 .setValue(generateGetInputValueAsListInput(INPUT_ID, "innerPropName"))
314                 .setType("list")
315                 .setUniqueId("propName")
316                 .addGetInputValue(INPUT_ID)
317                 .build();
318         component.setProperties(Collections.singletonList(prop));
319
320         List<ComponentInstanceProperty> ciPropList = new ArrayList<>();
321         ComponentInstanceProperty ciProp = new ComponentInstanceProperty();
322         List<String> pathOfComponentInstances = new ArrayList<>();
323         pathOfComponentInstances.add("pathOfComponentInstances");
324         ciProp.setPath(pathOfComponentInstances);
325         ciProp.setUniqueId("componentInstanceId");
326         ciProp.setDefaultValue("default value");
327         ciProp.setComponentInstanceId("componentInstanceId");
328         ciProp.setComponentInstanceName("componentInstanceName");
329         ciProp.setValue(generateGetInputValueAsListInput(INPUT_ID, "innerPropName"));
330         ciPropList.add(ciProp);
331
332         when(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(eq(component), eq(INPUT_ID))).thenReturn(ciPropList);
333         when(propertyOperation.findDefaultValueFromSecondPosition(eq(pathOfComponentInstances), eq(ciProp.getUniqueId()), eq(ciProp.getDefaultValue()))).thenReturn(Either.left(ciProp.getDefaultValue()));
334         when(toscaOperationFacade.updateComponentInstanceProperties(eq(component), eq(ciProp.getComponentInstanceId()), eq(ciPropList))).thenReturn(StorageOperationStatus.OK);
335         StorageOperationStatus storageOperationStatus = testInstance.unDeclarePropertiesAsListInputs(component, inputToDelete);
336
337         assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
338     }
339
340     @Test
341     public void unDeclarePropertiesAsListInputsTest_whenNoListInput_returnOk() {
342         InputDefinition input = new InputDefinition();
343         input.setUniqueId(INPUT_ID);
344         input.setName(INPUT_ID);
345         input.setValue("value");
346         List<ComponentInstanceProperty> resList = new ArrayList<>();
347         when(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(eq(resource), eq(INPUT_ID))).thenReturn(resList);
348         StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
349         Assert.assertEquals(status, StorageOperationStatus.OK);
350     }
351
352     private void verifyUpdatedProperties(List<PropertyDataDefinition> properties, List<ComponentInstanceProperty> capturedInstanceProperties, List<InputDefinition> inputs) {
353         assertThat(capturedInstanceProperties).hasSize(properties.size());
354         Map<String, ComponentInstanceProperty> updatedPropertiesByName = MapUtil.toMap(capturedInstanceProperties, ComponentInstanceProperty::getName);
355         properties.forEach(prop -> verifyUpdatedInstanceProperty(prop, updatedPropertiesByName.get(prop.getName()), inputs));
356     }
357
358     private void verifyUpdatedComplexProperty(List<ComponentInstanceProperty> capturedInstanceProperties, List<InputDefinition> inputs) {
359         assertThat(capturedInstanceProperties).hasSize(1);
360         verifyUpdatedInstanceComplexProperty(capturedInstanceProperties.get(0), inputs);
361     }
362
363     private void verifyCreatedInputs(List<PropertyDataDefinition> originalPropsToDeclare, List<ComponentInstanceProperty> capturedUpdatedProperties, List<InputDefinition> inputs) {
364         assertThat(inputs).hasSize(originalPropsToDeclare.size());
365         Map<String, InputDefinition> propertyIdToCreatedInput = MapUtil.toMap(inputs, InputDefinition::getPropertyId);
366         originalPropsToDeclare.forEach(propToDeclare -> verifyCreatedInput(propToDeclare, propertyIdToCreatedInput.get(propToDeclare.getUniqueId())));
367         capturedUpdatedProperties.forEach(updatedProperty -> verifyInputPropertiesList(updatedProperty, propertyIdToCreatedInput.get(updatedProperty.getUniqueId())));
368     }
369
370     private void verifyCreatedInputsFromComplexProperty(List<ComponentInstancePropInput> propsToDeclare, List<ComponentInstanceProperty> capturedInstanceProperties, List<InputDefinition> inputs) {
371         assertThat(inputs).hasSize(propsToDeclare.size());
372         Map<String, InputDefinition> inputsByName = MapUtil.toMap(inputs, InputDefinition::getName);
373         propsToDeclare.forEach(propToDeclare -> verifyCreatedInputFromComplexProperty(propToDeclare, inputsByName));
374         Map<String, List<InputDefinition>> propertyIdToCreatedInput = MapUtil.groupListBy(inputs, InputDefinition::getPropertyId);
375         capturedInstanceProperties.forEach(updatedProperty -> verifyInputPropertiesListFromComplexProperty(updatedProperty, propertyIdToCreatedInput.get(updatedProperty.getUniqueId())));
376     }
377
378     private void verifyInputPropertiesListFromComplexProperty(ComponentInstanceProperty updatedProperty, List<InputDefinition> inputs) {
379         inputs.forEach(input -> verifyInputPropertiesList(updatedProperty, input));
380     }
381
382     private void verifyCreatedInputFromComplexProperty(ComponentInstancePropInput parentProperty,  Map<String, InputDefinition> inputsByName) {
383         PropertyDefinition innerProperty = parentProperty.getInput();
384         String expectedInputName = generateExpectedInputName(parentProperty, innerProperty);
385         InputDefinition input = inputsByName.get(expectedInputName);
386         assertThat(input.getType()).isEqualTo(innerProperty.getType());
387         assertThat(input.getValue()).isEqualTo(innerProperty.getValue());
388 //        assertThat(input.getDefaultValue()).isEqualTo(innerProperty.getValue());//bug
389         assertThat(input.getUniqueId()).isEqualTo(UniqueIdBuilder.buildPropertyUniqueId(RESOURCE_ID, input.getName()));
390         assertThat(input.getPropertyId()).isEqualTo(parentProperty.getUniqueId());
391         assertThat(input.getInstanceUniqueId()).isEqualTo(INSTANCE_ID);
392
393     }
394
395     private void verifyInputPropertiesList(ComponentInstanceProperty updatedProperty, InputDefinition input) {
396         assertThat(input.getProperties()).hasSize(1);
397         assertThat(updatedProperty).isEqualTo(input.getProperties().get(0));
398     }
399
400
401     private List<ComponentInstancePropInput> createComplexPropInputList(PropertyDefinition ... innerProperties) {
402         return Stream.of(innerProperties).map(this::createComplexPropInput).collect(Collectors.toList());
403     }
404
405     private ComponentInstancePropInput createComplexPropInput(PropertyDefinition innerProp) {
406         ComponentInstancePropInput componentInstancePropInput = new ComponentInstancePropInput(new ComponentInstanceProperty(complexProperty));
407         componentInstancePropInput.setInput(innerProp);
408         componentInstancePropInput.setPropertiesName(complexProperty.getName() + "#" +  innerProp.getName());
409         return componentInstancePropInput;
410     }
411
412     private void verifyUpdatedInstanceProperty(PropertyDataDefinition originalProperty, ComponentInstanceProperty updatedProperty, List<InputDefinition> inputs) {
413         assertThat(updatedProperty.getValue()).isEqualTo(generateGetInputValue(generateExpectedInputName(originalProperty)));
414         assertThat(updatedProperty.isGetInputProperty()).isTrue();
415         assertThat(updatedProperty.getName()).isEqualTo(originalProperty.getName());
416         List<GetInputValueDataDefinition> getInputValues = updatedProperty.getGetInputValues();
417         verifyGetInputValues(getInputValues, inputs);
418     }
419
420     private void verifyUpdatedInstanceComplexProperty(ComponentInstanceProperty updatedComplexProperty, List<InputDefinition> inputs) {
421         assertThat(updatedComplexProperty.getValue()).isEqualTo(generateComplexGetInputValue(inputs));
422         assertThat(updatedComplexProperty.isGetInputProperty()).isTrue();
423         assertThat(updatedComplexProperty.getName()).isEqualTo(complexProperty.getName());
424         List<GetInputValueDataDefinition> getInputValues = updatedComplexProperty.getGetInputValues();
425         verifyGetInputValues(getInputValues, inputs);
426     }
427
428     private void verifyGetInputValues(List<GetInputValueDataDefinition> getInputValues, List<InputDefinition> inputs) {
429         Map<String, InputDefinition> inputsByName = MapUtil.toMap(inputs, InputDefinition::getName);
430         getInputValues.forEach(getInputVal -> {
431             InputDefinition input = inputsByName.get(getInputVal.getInputName());
432             assertThat(input.getUniqueId()).isEqualTo(getInputVal.getInputId());
433         });
434     }
435
436     private String generateComplexGetInputValue(List<InputDefinition> createdInputs) {
437         return String.format("{\"%s\":%s,\"%s\":%s}", INNER_PROP1, generateGetInputValue(createdInputs.get(0).getName()), INNER_PROP2, generateGetInputValue(createdInputs.get(1).getName()));
438     }
439
440     private String generateExpectedInputName(PropertyDataDefinition prop) {
441         return INSTANCE_ID + "_" + prop.getName();
442     }
443
444     private String generateExpectedInputName(PropertyDefinition parentProp, PropertyDefinition innerProperty) {
445         return INSTANCE_ID + "_" + parentProp.getName()+ "_" + innerProperty.getName();
446     }
447
448     private void verifyCreatedInput(PropertyDataDefinition property, InputDefinition input) {
449         assertThat(input.getType()).isEqualTo(property.getType());
450         assertThat(input.getName()).isEqualTo(generateExpectedInputName(property));
451         assertThat(input.getValue()).isEqualTo(property.getValue());
452         assertThat(input.getDefaultValue()).isEqualTo(property.getValue());
453         assertThat(input.getUniqueId()).isEqualTo(UniqueIdBuilder.buildPropertyUniqueId(RESOURCE_ID, input.getName()));
454         assertThat(input.getPropertyId()).isEqualTo(property.getUniqueId());
455         assertThat(input.getInstanceUniqueId()).isEqualTo(INSTANCE_ID);
456     }
457
458     private Component createComponentWithListInput(String inputName, String propName) {
459         InputDefinition input = InputsBuilder.create()
460                 .setName(inputName)
461                 .build();
462
463         input.setUniqueId(INPUT_ID);
464         input.setName(INPUT_ID);
465         input.setDefaultValue("defaultValue");
466         input.setValue(generateGetInputValueAsListInput(inputName, propName));
467
468         return new ResourceBuilder()
469                 .setUniqueId(RESOURCE_ID)
470                 .addInput(input)
471                 .build();
472     }
473 }