1 package org.openecomp.sdc.be.components.property;
3 import org.junit.Before;
4 import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
5 import org.openecomp.sdc.be.dao.utils.MapUtil;
6 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
7 import org.openecomp.sdc.be.model.ComponentInstancePropInput;
8 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
9 import org.openecomp.sdc.be.model.InputDefinition;
11 import java.util.List;
13 import java.util.stream.Collectors;
15 import static org.assertj.core.api.Assertions.assertThat;
16 import static org.openecomp.sdc.common.api.Constants.GET_INPUT;
18 public class PropertyDeceleratorTestBase {
20 static final String INNER_PROP1 = "ecomp_generated_naming";
21 static final String INNER_PROP2 = "naming_policy";
22 PropertyDataDefinition prop1, prop2, complexProperty;
25 public void setUp() throws Exception {
26 prop1 = new PropertyDataDefinitionBuilder()
33 prop2 = new PropertyDataDefinitionBuilder()
36 .setSchemaType("string")
38 .setValue("[\"a\", \"b\"]")
41 complexProperty = new PropertyDataDefinitionBuilder()
43 .setType("org.openecomp.type1")
45 .setValue("{\"ecomp_generated_naming\":true\",\"naming_policy\":\"abc\"}")
50 List<ComponentInstancePropInput> createInstancePropInputList(List<PropertyDataDefinition> properties) {
51 return properties.stream().map(prop -> new ComponentInstancePropInput(new ComponentInstanceProperty(prop)))
52 .collect(Collectors.toList());
55 void verifyInputPropertiesList(List<InputDefinition> createdInputs, List<PropertyDataDefinition> capturedUpdatedProperties) {
56 Map<String, InputDefinition> propertyIdToCreatedInput = MapUtil.toMap(createdInputs, InputDefinition::getPropertyId);
57 capturedUpdatedProperties.forEach(updatedProperty -> verifyInputPropertiesList(updatedProperty, propertyIdToCreatedInput.get(updatedProperty.getUniqueId())));
60 String generateGetInputValue(String value) {
61 return String.format("{\"%s\":\"%s\"}", GET_INPUT, value);
64 private void verifyInputPropertiesList(PropertyDataDefinition updatedProperty, InputDefinition input) {
65 assertThat(input.getProperties()).hasSize(1);
66 assertThat(new ComponentInstanceProperty(updatedProperty)).isEqualTo(input.getProperties().get(0));