use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ConstraintPropertyServiceTest method testInvalidFloatPropertyWithConstraint.
@Test(expected = ConstraintValueDoNotMatchPropertyTypeException.class)
public void testInvalidFloatPropertyWithConstraint() throws Exception {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setConstraints(new ArrayList<PropertyConstraint>());
LengthConstraint lengthConstraint = new LengthConstraint();
lengthConstraint.setLength(3);
propertyDefinition.getConstraints().add(lengthConstraint);
propertyDefinition.setType(ToscaTypes.FLOAT);
ConstraintPropertyService.checkPropertyConstraint("test", "aaa", propertyDefinition);
}
use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ConstraintPropertyServiceTest method testInvalidMapLengthConstraintProperty.
@Test(expected = ConstraintViolationException.class)
public void testInvalidMapLengthConstraintProperty() throws Exception {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(ToscaTypes.MAP);
PropertyDefinition entrySchema = new PropertyDefinition();
entrySchema.setType(ToscaTypes.STRING);
propertyDefinition.setEntrySchema(entrySchema);
Object propertyValue = ImmutableMap.builder().put("aa", "bb").build();
// invalid length constraint
LengthConstraint lengthConstraint = new LengthConstraint();
lengthConstraint.setLength(4);
List<PropertyConstraint> constraints = Lists.newArrayList();
constraints.add(lengthConstraint);
propertyDefinition.setConstraints(constraints);
ConstraintPropertyService.checkPropertyConstraint("test", propertyValue, propertyDefinition);
}
use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ConstraintPropertyServiceTest method testValidIntegerProperty.
@Test
public void testValidIntegerProperty() throws Exception {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(ToscaTypes.INTEGER);
ConstraintPropertyService.checkPropertyConstraint("test", "128", propertyDefinition);
}
use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ConstraintPropertyServiceTest method testValidVersionProperty.
@Test
public void testValidVersionProperty() throws Exception {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(ToscaTypes.VERSION);
ConstraintPropertyService.checkPropertyConstraint("test", "2.0", propertyDefinition);
ConstraintPropertyService.checkPropertyConstraint("test", "1.0.0-SNAPSHOT", propertyDefinition);
}
use of org.alien4cloud.tosca.model.definitions.PropertyDefinition in project alien4cloud by alien4cloud.
the class ConstraintPropertyServiceTest method testInvalidIntegerProperty.
// invalid value tests
@Test(expected = ConstraintValueDoNotMatchPropertyTypeException.class)
public void testInvalidIntegerProperty() throws Exception {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(ToscaTypes.INTEGER);
ConstraintPropertyService.checkPropertyConstraint("test", "aaaa128", propertyDefinition);
}
Aggregations