use of org.alien4cloud.tosca.model.definitions.ScalarPropertyValue in project alien4cloud by alien4cloud.
the class ToscaTypeConverterTest method convert_version.
@Test
public void convert_version() throws Exception {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(ToscaTypes.VERSION);
Object value = converter.toPropertyValue("3.4-SNAPSHOT", propertyDefinition);
assertThat(value).isInstanceOf(ScalarPropertyValue.class);
assertThat(value).isEqualTo(new ScalarPropertyValue("3.4-SNAPSHOT"));
}
use of org.alien4cloud.tosca.model.definitions.ScalarPropertyValue 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.ScalarPropertyValue 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.ScalarPropertyValue in project alien4cloud by alien4cloud.
the class ToscaSerializerUtilsTest method testMapIsNotEmptyAndContainsNotnullValues.
@Test
public void testMapIsNotEmptyAndContainsNotnullValues() {
Assert.assertFalse(utils.mapIsNotEmptyAndContainsNotnullValues(null));
Assert.assertFalse(utils.mapIsNotEmptyAndContainsNotnullValues(Maps.newHashMap()));
Map<String, Object> map = Maps.newHashMap();
map.put("key1", null);
Assert.assertFalse(utils.mapIsNotEmptyAndContainsNotnullValues(map));
map.put("key2", "something");
Assert.assertTrue(utils.mapIsNotEmptyAndContainsNotnullValues(map));
// inner collection
Map<String, Set<String>> mapOfSet = Maps.newHashMap();
Set<String> set = Sets.newHashSet();
mapOfSet.put("key1", set);
// the set is empty
Assert.assertFalse(utils.mapIsNotEmptyAndContainsNotnullValues(mapOfSet));
Set<String> filledSet = Sets.newHashSet("something");
mapOfSet.put("key2", filledSet);
// the second set contains something
Assert.assertTrue(utils.mapIsNotEmptyAndContainsNotnullValues(mapOfSet));
// inner map
Map<String, Map<String, Set<String>>> mapOfmap = Maps.newHashMap();
Map<String, Set<String>> innerMap = Maps.newHashMap();
mapOfmap.put("key1", innerMap);
// the inner map is empty
Assert.assertFalse(utils.mapIsNotEmptyAndContainsNotnullValues(mapOfmap));
Map<String, Set<String>> innerMap2 = Maps.newHashMap();
Set<String> emptySet = Sets.newHashSet();
innerMap2.put("key21", emptySet);
mapOfmap.put("key2", innerMap2);
// the inner set is empty
Assert.assertFalse(utils.mapIsNotEmptyAndContainsNotnullValues(mapOfmap));
filledSet = Sets.newHashSet("something");
innerMap2.put("key22", filledSet);
Assert.assertTrue(utils.mapIsNotEmptyAndContainsNotnullValues(mapOfmap));
// ScalarPropertyValue
ScalarPropertyValue spv = new ScalarPropertyValue();
Map<String, AbstractPropertyValue> apvMap = new HashMap<String, AbstractPropertyValue>();
apvMap.put("key1", spv);
Assert.assertFalse(utils.mapIsNotEmptyAndContainsNotnullValues(apvMap));
spv.setValue("value");
Assert.assertTrue(utils.mapIsNotEmptyAndContainsNotnullValues(apvMap));
}
use of org.alien4cloud.tosca.model.definitions.ScalarPropertyValue in project alien4cloud by alien4cloud.
the class ToscaSerializerTest method buildSamplePropertyValueMap.
private Map<String, AbstractPropertyValue> buildSamplePropertyValueMap() {
Map<String, AbstractPropertyValue> result = new HashMap<String, AbstractPropertyValue>();
result.put("prop1", new ScalarPropertyValue("value1"));
FunctionPropertyValue fpv1 = new FunctionPropertyValue();
fpv1.setFunction("get_property");
fpv1.setParameters(Lists.newArrayList("p1", "p2"));
result.put("prop2", fpv1);
FunctionPropertyValue fpv2 = new FunctionPropertyValue();
fpv2.setFunction("get_input");
fpv2.setParameters(Lists.newArrayList("p1"));
result.put("prop3", fpv2);
result.put("prop4", null);
result.put("prop5", new ScalarPropertyValue("a value containing a ["));
result.put("prop6", new ScalarPropertyValue("a value containing a ]"));
result.put("prop7", new ScalarPropertyValue("a value containing a {"));
result.put("prop8", new ScalarPropertyValue("a value containing a }"));
result.put("prop9", new ScalarPropertyValue("a value containing a :"));
result.put("prop9", new ScalarPropertyValue("a value containing a \""));
result.put("prop9", new ScalarPropertyValue("a value containing a : and a \""));
result.put("prop10", new ScalarPropertyValue(" a value starting with a space"));
result.put("prop11", new ScalarPropertyValue("a value ending with a space "));
return result;
}
Aggregations