use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ToscaTypeConverterTest method convert_complex_data_type_to_property_value.
@Test
public void convert_complex_data_type_to_property_value() throws Exception {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("alien.nodes.test.ComplexDataType");
PropertyValue propertyValue = converter.toPropertyValue(ImmutableMap.of("nested", "nested value", "nested_array", Arrays.asList("item1", "item2", "item3"), "nested_map", ImmutableMap.of("key1", "value1", "key2", "value2")), propertyDefinition);
assertThat(propertyValue).isInstanceOf(ComplexPropertyValue.class);
ComplexPropertyValue complexPropertyValue = (ComplexPropertyValue) propertyValue;
assertThat(complexPropertyValue.getValue().get("nested_map")).isEqualTo(ImmutableMap.of("key1", "value1", "key2", "value2"));
assertThat(complexPropertyValue.getValue().get("nested_array")).isEqualTo(Arrays.asList("item1", "item2", "item3"));
assertThat(complexPropertyValue.getValue().get("nested")).isEqualTo("nested value");
}
use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ToscaTypeConverterTest method findDataType.
@SneakyThrows
private static DataType findDataType(Class<? extends DataType> concreteType, String id) {
switch(id) {
case "alien.nodes.test.ComplexDataType":
DataType dataType = new DataType();
Map<String, PropertyDefinition> propertyDefinitionMap = Maps.newHashMap();
new PropertyDefinition();
propertyDefinitionMap.put("nested", buildPropDef("string"));
propertyDefinitionMap.put("nested_array", buildPropDef("list", "string"));
propertyDefinitionMap.put("nested_map", buildPropDef("map", "string"));
dataType.setProperties(propertyDefinitionMap);
dataType.setElementId("alien.nodes.test.ComplexDataType");
return dataType;
default:
return null;
}
}
use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ToscaPropertyDefaultValueConstraintsValidatorTest method createDefinitions.
private PropertyDefinition createDefinitions(String propertyType, PropertyConstraint constraint, String defaultValue) {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(propertyType);
propertyDefinition.setDefault(new ScalarPropertyValue(defaultValue));
propertyDefinition.setConstraints(Lists.newArrayList(constraint));
return propertyDefinition;
}
use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ToscaPropertyDefaultValueTypeValidatorTest method createDefinitions.
private PropertyDefinition createDefinitions(String propertyType, String defaultValue) {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(propertyType);
propertyDefinition.setDefault(new ScalarPropertyValue(defaultValue));
return propertyDefinition;
}
use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ToscaPropertyTypeValidatorTest method createDefinitions.
private PropertyDefinition createDefinitions() {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(ToscaTypes.STRING.toString());
return propertyDefinition;
}
Aggregations