bcbd07db31d4610a058c99cc1d6ba7d94adc36b4
[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 fj.data.Either;
20
21 import org.junit.jupiter.api.Test;
22 import org.junit.jupiter.api.extension.ExtendWith;
23 import org.mockito.ArgumentCaptor;
24 import org.mockito.Captor;
25 import org.mockito.InjectMocks;
26 import org.mockito.Mock;
27 import org.mockito.junit.jupiter.MockitoExtension;
28 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
29 import org.openecomp.sdc.be.components.utils.InputsBuilder;
30 import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
31 import org.openecomp.sdc.be.components.utils.ResourceBuilder;
32 import org.openecomp.sdc.be.components.utils.ServiceBuilder;
33 import org.openecomp.sdc.be.dao.utils.MapUtil;
34 import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
35 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
36 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
37 import org.openecomp.sdc.be.model.CapabilityDefinition;
38 import org.openecomp.sdc.be.model.Component;
39 import org.openecomp.sdc.be.model.ComponentInstancePropInput;
40 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
41 import org.openecomp.sdc.be.model.InputDefinition;
42 import org.openecomp.sdc.be.model.PropertyDefinition;
43 import org.openecomp.sdc.be.model.Resource;
44 import org.openecomp.sdc.be.model.Service;
45 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
46 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
47 import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
48 import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
49
50 import java.util.ArrayList;
51 import java.util.Arrays;
52 import java.util.Collections;
53 import java.util.HashMap;
54 import java.util.LinkedList;
55 import java.util.List;
56 import java.util.Map;
57 import java.util.stream.Collectors;
58 import java.util.stream.Stream;
59
60 import static org.junit.jupiter.api.Assertions.*;
61 import static org.mockito.ArgumentMatchers.any;
62 import static org.mockito.ArgumentMatchers.eq;
63 import static org.mockito.Mockito.verifyZeroInteractions;
64 import static org.mockito.Mockito.when;
65 import static org.openecomp.sdc.be.components.property.CapabilityTestUtils.createCapabilityDefinition;
66 import static org.openecomp.sdc.be.components.property.CapabilityTestUtils.createProperties;
67
68
69 @ExtendWith(MockitoExtension.class)
70 public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorTestBase {
71
72     @InjectMocks
73     private ComponentInstancePropertyDeclarator testInstance;
74     @Mock
75     private ToscaOperationFacade toscaOperationFacade;
76     @Mock
77     private ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
78     @Mock
79     private PropertyOperation propertyOperation;
80
81     @Captor
82     private ArgumentCaptor<Map<String, List<ComponentInstanceProperty>>> instancePropertiesCaptor;
83
84     private static final String PROPERTY_ID = "propertyUid";
85     private static final String PROEPRTY_NAME = "propertyName";
86     private static final String SERVICE_ID = "serviceUid";
87     private static final String SERVICE_NAME = "serviceName";
88
89     @Test
90     public void declarePropertiesAsInputs_componentInstanceNotExist() {
91         Component cmpt = new Resource();
92         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(cmpt, "someCmptInstId", Collections.emptyList());
93         assertEquals(StorageOperationStatus.NOT_FOUND, createdInputs.right().value());
94         verifyZeroInteractions(toscaOperationFacade);
95     }
96
97     @Test
98     public void declarePropertiesAsInputs_singleNonComplexProperty() {
99         List<PropertyDataDefinition> properties = Collections.singletonList(prop1);
100         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
101         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor.capture())).thenReturn(Either.left(Collections.emptyMap()));
102         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
103         List<InputDefinition> inputs = createdInputs.left().value();
104         List<ComponentInstanceProperty> capturedInstanceProperties = instancePropertiesCaptor.getValue().get(INSTANCE_ID);
105         verifyCreatedInputs(properties, capturedInstanceProperties, inputs);
106         verifyUpdatedProperties(properties, capturedInstanceProperties, inputs);
107     }
108
109     @Test
110     public void declareCapabilitiesPropertiesAsInputs() {
111         prop1.setParentUniqueId("capUniqueId");
112         List<PropertyDataDefinition> properties = Collections.singletonList(prop1);
113         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
114         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor
115                 .capture())).thenReturn(Either.left(Collections.emptyMap()));
116
117         CapabilityDefinition capabilityDefinition = createCapabilityDefinition();
118
119         List<ComponentInstanceProperty> capPropList = new ArrayList<>();
120         ComponentInstanceProperty instanceProperty = createProperties();
121         capPropList.add(instanceProperty);
122         capabilityDefinition.setProperties(capPropList);
123
124         capabilityDefinition.setPath(Collections.singletonList("path"));
125         Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
126         capabilityMap.put(capabilityDefinition.getType(), Collections.singletonList(capabilityDefinition));
127         resource.setCapabilities(capabilityMap);
128
129         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance
130                 .declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
131         assertTrue(createdInputs.isLeft());
132     }
133
134     @Test
135     public void testUnDeclarePropertiesAsInputs() throws Exception {
136         Component component = new ResourceBuilder().setComponentType(ComponentTypeEnum.RESOURCE).setUniqueId("resourceId")
137                 .setName("resourceName").build();
138         InputDefinition input = new InputDefinition();
139         input.setUniqueId("ComponentInput1_uniqueId");
140         input.setPropertyId("ComponentInput1_uniqueId");
141
142         CapabilityDefinition capabilityDefinition = createCapabilityDefinition();
143
144         List<ComponentInstanceProperty> properties = new ArrayList<>();
145         ComponentInstanceProperty instanceProperty = createProperties();
146
147         List<GetInputValueDataDefinition> valueDataDefinitionList = new ArrayList<>();
148         GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
149         getInputValueDataDefinition.setInputId("ComponentInput1_uniqueId");
150         getInputValueDataDefinition.setPropName("prop_name");
151         valueDataDefinitionList.add(getInputValueDataDefinition);
152
153         instanceProperty.setGetInputValues(valueDataDefinitionList);
154         properties.add(instanceProperty);
155         capabilityDefinition.setProperties(properties);
156         Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
157         capabilityMap.put(capabilityDefinition.getType(), Collections.singletonList(capabilityDefinition));
158         component.setCapabilities(capabilityMap);
159         component.setInputs(Collections.singletonList(input));
160         when(toscaOperationFacade.updateInstanceCapabilityProperty(any(Resource.class), any(),
161                 any(ComponentInstanceProperty.class), any(CapabilityDefinition.class))).thenReturn(StorageOperationStatus.OK);
162
163         StorageOperationStatus result = testInstance.unDeclarePropertiesAsInputs(component, input);
164         assertEquals(StorageOperationStatus.OK, result);
165     }
166
167     @Test
168     public void declarePropertiesAsInputs_multipleNonComplexProperty() {
169         List<PropertyDataDefinition> properties = Arrays.asList(prop1, prop2);
170         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
171         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor.capture())).thenReturn(Either.left(Collections.emptyMap()));
172         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
173
174         List<InputDefinition> inputs = createdInputs.left().value();
175         List<ComponentInstanceProperty> capturedInstanceProperties = instancePropertiesCaptor.getValue().get(INSTANCE_ID);
176         verifyCreatedInputs(properties, capturedInstanceProperties, inputs);
177         verifyUpdatedProperties(properties, capturedInstanceProperties, inputs);
178     }
179
180     @Test
181     public void declarePropertiesAsInputs_singleComplexProperty() {
182         PropertyDefinition innerProp1 = new PropertyDataDefinitionBuilder()
183                 .setName(INNER_PROP1)
184                 .setValue("true")
185                 .setType("boolean")
186                 .setUniqueId(complexProperty.getType() + ".datatype.ecomp_generated_naming")
187                 .build();
188         PropertyDefinition innerProp2 = new PropertyDataDefinitionBuilder()
189                 .setName(INNER_PROP2)
190                 .setValue("abc")
191                 .setType("string")
192                 .setUniqueId(complexProperty.getType() + ".datatype.ecomp_generated_naming")
193                 .build();
194         List<ComponentInstancePropInput> propsToDeclare = createComplexPropInputList(innerProp1, innerProp2);
195         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor.capture())).thenReturn(Either.left(Collections.emptyMap()));
196         Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
197
198         List<InputDefinition> inputs = createdInputs.left().value();
199         List<ComponentInstanceProperty> capturedInstanceProperties = instancePropertiesCaptor.getValue().get(INSTANCE_ID);
200
201         verifyCreatedInputsFromComplexProperty(propsToDeclare, capturedInstanceProperties, inputs);
202         verifyUpdatedComplexProperty(capturedInstanceProperties, inputs);
203     }
204
205     @Test
206     public void testCreateDeclaredProperty() {
207         PropertyDefinition propertyDefinition = getPropertyForDeclaration();
208         ComponentInstanceProperty declaredProperty = testInstance.createDeclaredProperty(propertyDefinition);
209
210         assertNotNull(declaredProperty);
211         assertEquals(propertyDefinition.getUniqueId(), declaredProperty.getUniqueId());
212     }
213
214     @Test
215     public void testUndeclareProperty() {
216         Service service = new ServiceBuilder()
217                                   .setUniqueId(SERVICE_ID)
218                                   .setName(SERVICE_NAME)
219                                   .build();
220
221
222
223         InputDefinition inputToDelete = InputsBuilder
224                                                 .create()
225                                                 .setPropertyId(PROPERTY_ID)
226                                                 .setName(PROEPRTY_NAME)
227                                                 .build();
228
229         inputToDelete.setGetInputValues(getGetInputListForDeclaration());
230
231         ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty(getPropertyForDeclaration());
232         List<ComponentInstanceProperty> componentInstanceProperties = new ArrayList<>();
233         componentInstanceProperties.add(componentInstanceProperty);
234
235         when(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(any(), any())).thenReturn(new LinkedList<>());
236
237         StorageOperationStatus undeclareStatus =
238                 testInstance.unDeclarePropertiesAsInputs(service, inputToDelete);
239
240         assertEquals(StorageOperationStatus.OK, undeclareStatus);
241     }
242
243     private List<GetInputValueDataDefinition> getGetInputListForDeclaration() {
244         GetInputValueDataDefinition getInput = new GetInputValueDataDefinition();
245         getInput.setInputId(PROPERTY_ID);
246         getInput.setInputName(PROEPRTY_NAME);
247         getInput.setPropName(PROEPRTY_NAME);
248         List<GetInputValueDataDefinition> getInputList = new ArrayList<>();
249         getInputList.add(getInput);
250         return getInputList;
251     }
252
253     private PropertyDefinition getPropertyForDeclaration() {
254         return new PropertyDataDefinitionBuilder()
255                        .setUniqueId(PROPERTY_ID)
256                        .build();
257     }
258
259     @Test
260     public void declarePropertiesAsListInput() {
261         // construct arguments
262         List<PropertyDataDefinition> properties = Arrays.asList(prop1, prop2);
263         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
264         InputDefinition input = new InputDefinition(new PropertyDataDefinitionBuilder()
265                 .setName("listinput")
266                 .setType("list")
267                 .setDescription("description")
268                 .setSchemaType("org.onap.datatype.listinput")
269                 .build());
270         // mock returns
271         when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor.capture())).thenReturn(Either.left(Collections.emptyMap()));
272         Either<InputDefinition, StorageOperationStatus> result = testInstance.declarePropertiesAsListInput(resource, "inst1", propsToDeclare, input);
273         // validate result
274         assertTrue(result.isLeft());
275         List<ComponentInstanceProperty> capturedInstanceProperties = instancePropertiesCaptor.getValue().get(INSTANCE_ID);
276         assertEquals(2, capturedInstanceProperties.size());
277         Map<String, PropertyDataDefinition> propertiesMap =
278                 properties.stream().collect(Collectors.toMap(PropertyDataDefinition::getName, e->e));
279         for(ComponentInstanceProperty instanceProperty: capturedInstanceProperties) {
280             assertTrue(propertiesMap.containsKey(instanceProperty.getName()));
281             PropertyDataDefinition property = propertiesMap.get(instanceProperty.getName());
282             assertEquals(property.getType(), instanceProperty.getType());
283             assertTrue(instanceProperty.isGetInputProperty());
284         }
285     }
286
287     @Test
288     public void declarePropertiesAsListInput_propertyOwnerNotFound() {
289         // construct arguments
290         List<PropertyDataDefinition> properties = Arrays.asList(prop1, prop2);
291         List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
292         InputDefinition input = new InputDefinition(new PropertyDataDefinitionBuilder()
293                 .setName("listinput")
294                 .setType("list")
295                 .setDescription("description")
296                 .setSchemaType("org.onap.datatype.listinput")
297                 .build());
298         Either<InputDefinition, StorageOperationStatus> result = testInstance.declarePropertiesAsListInput(resource, "inst2", propsToDeclare, input);
299         // validate result
300         assertTrue(result.isRight());
301         assertEquals(StorageOperationStatus.NOT_FOUND, result.right().value());
302     }
303
304     @Test
305     public void unDeclarePropertiesAsListInputsTest() {
306         InputDefinition inputToDelete = new InputDefinition();
307         inputToDelete.setUniqueId(INPUT_ID);
308         inputToDelete.setName(INPUT_ID);
309         inputToDelete.setIsDeclaredListInput(true);
310
311         Component component = createComponentWithListInput(INPUT_ID, "innerPropName");
312         PropertyDefinition prop = new PropertyDataDefinitionBuilder()
313                 .setName("propName")
314                 .setValue(generateGetInputValueAsListInput(INPUT_ID, "innerPropName"))
315                 .setType("list")
316                 .setUniqueId("propName")
317                 .addGetInputValue(INPUT_ID)
318                 .build();
319         component.setProperties(Collections.singletonList(prop));
320
321         List<ComponentInstanceProperty> ciPropList = new ArrayList<>();
322         ComponentInstanceProperty ciProp = new ComponentInstanceProperty();
323         List<String> pathOfComponentInstances = new ArrayList<>();
324         pathOfComponentInstances.add("pathOfComponentInstances");
325         ciProp.setPath(pathOfComponentInstances);
326         ciProp.setUniqueId("componentInstanceId");
327         ciProp.setDefaultValue("default value");
328         ciProp.setComponentInstanceId("componentInstanceId");
329         ciProp.setComponentInstanceName("componentInstanceName");
330         ciProp.setValue(generateGetInputValueAsListInput(INPUT_ID, "innerPropName"));
331         ciPropList.add(ciProp);
332
333         when(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(eq(component), eq(INPUT_ID))).thenReturn(ciPropList);
334         when(propertyOperation.findDefaultValueFromSecondPosition(eq(pathOfComponentInstances), eq(ciProp.getUniqueId()), eq(ciProp.getDefaultValue()))).thenReturn(Either.left(ciProp.getDefaultValue()));
335         when(toscaOperationFacade.updateComponentInstanceProperties(eq(component), eq(ciProp.getComponentInstanceId()), eq(ciPropList))).thenReturn(StorageOperationStatus.OK);
336         StorageOperationStatus storageOperationStatus = testInstance.unDeclarePropertiesAsListInputs(component, inputToDelete);
337
338         assertEquals(StorageOperationStatus.OK, storageOperationStatus);
339     }
340
341     @Test
342     public void unDeclarePropertiesAsListInputsTest_whenNoListInput_returnOk() {
343         InputDefinition input = new InputDefinition();
344         input.setUniqueId(INPUT_ID);
345         input.setName(INPUT_ID);
346         input.setValue("value");
347         List<ComponentInstanceProperty> resList = new ArrayList<>();
348         when(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(eq(resource), eq(INPUT_ID))).thenReturn(resList);
349         StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
350         assertEquals(status, StorageOperationStatus.OK);
351     }
352
353     private void verifyUpdatedProperties(List<PropertyDataDefinition> properties, List<ComponentInstanceProperty> capturedInstanceProperties, List<InputDefinition> inputs) {
354         assertEquals(properties.size(), capturedInstanceProperties.size());
355         Map<String, ComponentInstanceProperty> updatedPropertiesByName = MapUtil.toMap(capturedInstanceProperties, ComponentInstanceProperty::getName);
356         properties.forEach(prop -> verifyUpdatedInstanceProperty(prop, updatedPropertiesByName.get(prop.getName()), inputs));
357     }
358
359     private void verifyUpdatedComplexProperty(List<ComponentInstanceProperty> capturedInstanceProperties, List<InputDefinition> inputs) {
360         assertEquals(1, capturedInstanceProperties.size());
361         verifyUpdatedInstanceComplexProperty(capturedInstanceProperties.get(0), inputs);
362     }
363
364     private void verifyCreatedInputs(List<PropertyDataDefinition> originalPropsToDeclare, List<ComponentInstanceProperty> capturedUpdatedProperties, List<InputDefinition> inputs) {
365         assertEquals(originalPropsToDeclare.size(), inputs.size());
366         Map<String, InputDefinition> propertyIdToCreatedInput = MapUtil.toMap(inputs, InputDefinition::getPropertyId);
367         originalPropsToDeclare.forEach(propToDeclare -> verifyCreatedInput(propToDeclare, propertyIdToCreatedInput.get(propToDeclare.getUniqueId())));
368         capturedUpdatedProperties.forEach(updatedProperty -> verifyInputPropertiesList(updatedProperty, propertyIdToCreatedInput.get(updatedProperty.getUniqueId())));
369     }
370
371     private void verifyCreatedInputsFromComplexProperty(List<ComponentInstancePropInput> propsToDeclare, List<ComponentInstanceProperty> capturedInstanceProperties, List<InputDefinition> inputs) {
372         assertEquals(propsToDeclare.size(), inputs.size());
373         Map<String, InputDefinition> inputsByName = MapUtil.toMap(inputs, InputDefinition::getName);
374         propsToDeclare.forEach(propToDeclare -> verifyCreatedInputFromComplexProperty(propToDeclare, inputsByName));
375         Map<String, List<InputDefinition>> propertyIdToCreatedInput = MapUtil.groupListBy(inputs, InputDefinition::getPropertyId);
376         capturedInstanceProperties.forEach(updatedProperty -> verifyInputPropertiesListFromComplexProperty(updatedProperty, propertyIdToCreatedInput.get(updatedProperty.getUniqueId())));
377     }
378
379     private void verifyInputPropertiesListFromComplexProperty(ComponentInstanceProperty updatedProperty, List<InputDefinition> inputs) {
380         inputs.forEach(input -> verifyInputPropertiesList(updatedProperty, input));
381     }
382
383     private void verifyCreatedInputFromComplexProperty(ComponentInstancePropInput parentProperty,  Map<String, InputDefinition> inputsByName) {
384         PropertyDefinition innerProperty = parentProperty.getInput();
385         String expectedInputName = generateExpectedInputName(parentProperty, innerProperty);
386         InputDefinition input = inputsByName.get(expectedInputName);
387         assertEquals(innerProperty.getType(), input.getType());
388         assertEquals(innerProperty.getValue(), input.getValue());
389 //        assertThat(input.getDefaultValue()).isEqualTo(innerProperty.getValue());//bug
390         assertEquals(UniqueIdBuilder.buildPropertyUniqueId(RESOURCE_ID, input.getName()), input.getUniqueId());
391         assertEquals(INSTANCE_ID, input.getInstanceUniqueId());
392
393     }
394
395     private void verifyInputPropertiesList(ComponentInstanceProperty updatedProperty, InputDefinition input) {
396         assertEquals(1, input.getProperties().size());
397         assertEquals(input.getProperties().get(0), updatedProperty);
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         assertEquals(generateGetInputValue(generateExpectedInputName(originalProperty)), updatedProperty.getValue());
414         assertTrue(updatedProperty.isGetInputProperty());
415         assertEquals(originalProperty.getName(), updatedProperty.getName());
416         List<GetInputValueDataDefinition> getInputValues = updatedProperty.getGetInputValues();
417         verifyGetInputValues(getInputValues, inputs);
418     }
419
420     private void verifyUpdatedInstanceComplexProperty(ComponentInstanceProperty updatedComplexProperty, List<InputDefinition> inputs) {
421         assertEquals(generateComplexGetInputValue(inputs), updatedComplexProperty.getValue());
422         assertTrue(updatedComplexProperty.isGetInputProperty());
423         assertEquals(complexProperty.getName(), updatedComplexProperty.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             assertEquals(getInputVal.getInputId(), input.getUniqueId());
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         assertEquals(property.getType(), input.getType());
450         assertEquals(generateExpectedInputName(property), input.getName());
451         assertEquals(property.getValue(), input.getValue());
452         assertEquals(property.getValue(), input.getDefaultValue());
453         assertEquals(UniqueIdBuilder.buildPropertyUniqueId(RESOURCE_ID, input.getName()), input.getUniqueId());
454         assertEquals(property.getUniqueId(), input.getPropertyId());
455         assertEquals(INSTANCE_ID, input.getInstanceUniqueId());
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 }