2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.components.property;
23 import static org.assertj.core.api.Assertions.assertThat;
24 import static org.openecomp.sdc.common.api.Constants.GET_INPUT;
26 import java.util.List;
28 import java.util.stream.Collectors;
30 import org.junit.Before;
31 import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
32 import org.openecomp.sdc.be.dao.utils.MapUtil;
33 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
34 import org.openecomp.sdc.be.model.ComponentInstancePropInput;
35 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
36 import org.openecomp.sdc.be.model.InputDefinition;
38 public class PropertyDeceleratorTestBase {
40 static final String INNER_PROP1 = "ecomp_generated_naming";
41 static final String INNER_PROP2 = "naming_policy";
42 PropertyDataDefinition prop1, prop2, complexProperty;
45 public void setUp() throws Exception {
46 prop1 = new PropertyDataDefinitionBuilder()
53 prop2 = new PropertyDataDefinitionBuilder()
56 .setSchemaType("string")
58 .setValue("[\"a\", \"b\"]")
61 complexProperty = new PropertyDataDefinitionBuilder()
63 .setType("org.openecomp.type1")
65 .setValue("{\"ecomp_generated_naming\":true\",\"naming_policy\":\"abc\"}")
70 List<ComponentInstancePropInput> createInstancePropInputList(List<PropertyDataDefinition> properties) {
71 return properties.stream().map(prop -> new ComponentInstancePropInput(new ComponentInstanceProperty(prop)))
72 .collect(Collectors.toList());
75 void verifyInputPropertiesList(List<InputDefinition> createdInputs, List<PropertyDataDefinition> capturedUpdatedProperties) {
76 Map<String, InputDefinition> propertyIdToCreatedInput = MapUtil.toMap(createdInputs, InputDefinition::getPropertyId);
77 capturedUpdatedProperties.forEach(updatedProperty -> verifyInputPropertiesList(updatedProperty, propertyIdToCreatedInput.get(updatedProperty.getUniqueId())));
80 String generateGetInputValue(String value) {
81 return String.format("{\"%s\":\"%s\"}", GET_INPUT, value);
84 private void verifyInputPropertiesList(PropertyDataDefinition updatedProperty, InputDefinition input) {
85 assertThat(input.getProperties()).hasSize(1);
86 assertThat(new ComponentInstanceProperty(updatedProperty)).isEqualTo(input.getProperties().get(0));