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