Search in sources :

Example 1 with Time

use of org.alien4cloud.tosca.normative.primitives.Time in project alien4cloud by alien4cloud.

the class ToscaTypeConverterTest method convert_time_to_property_value.

@Test
public void convert_time_to_property_value() throws Exception {
    PropertyDefinition propertyDefinition = new PropertyDefinition();
    propertyDefinition.setType(ToscaTypes.TIME);
    PropertyValue propertyValue = converter.toPropertyValue("2 d", propertyDefinition);
    Object time = ToscaTypes.fromYamlTypeName(propertyDefinition.getType()).parse(propertyValue.getValue().toString());
    assertThat(time).isInstanceOf(Time.class);
    assertThat(time).isEqualTo(new Time(2, TimeUnit.D));
}
Also used : ComplexPropertyValue(org.alien4cloud.tosca.model.definitions.ComplexPropertyValue) ScalarPropertyValue(org.alien4cloud.tosca.model.definitions.ScalarPropertyValue) PropertyValue(org.alien4cloud.tosca.model.definitions.PropertyValue) Time(org.alien4cloud.tosca.normative.primitives.Time) PropertyDefinition(org.alien4cloud.tosca.model.definitions.PropertyDefinition) Test(org.junit.Test)

Aggregations

ComplexPropertyValue (org.alien4cloud.tosca.model.definitions.ComplexPropertyValue)1 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)1 PropertyValue (org.alien4cloud.tosca.model.definitions.PropertyValue)1 ScalarPropertyValue (org.alien4cloud.tosca.model.definitions.ScalarPropertyValue)1 Time (org.alien4cloud.tosca.normative.primitives.Time)1 Test (org.junit.Test)1