use of com.qcadoo.model.api.types.FieldType in project qcadoo by qcadoo.
the class FieldTypeFactoryTest method shouldReturnDecimalType.
@Test
public void shouldReturnDecimalType() throws Exception {
// when
FieldType fieldType = new DecimalType();
// then
assertEquals(BigDecimal.class, fieldType.getType());
assertTrue(fieldType.toObject(fieldDefinition, BigDecimal.valueOf(1.21)).isValid());
assertTrue(fieldType.toObject(fieldDefinition, BigDecimal.valueOf(1)).isValid());
assertTrue(fieldType.toObject(fieldDefinition, BigDecimal.valueOf(1)).isValid());
assertTrue(fieldType.toObject(fieldDefinition, BigDecimal.valueOf(1234567)).isValid());
}
use of com.qcadoo.model.api.types.FieldType in project qcadoo by qcadoo.
the class FieldTypeFactoryTest method shouldReturnBooleanType.
@Test
public void shouldReturnBooleanType() throws Exception {
// when
FieldType fieldType = new BooleanType();
// then
assertEquals(Boolean.class, fieldType.getType());
assertTrue(fieldType.toObject(fieldDefinition, false).isValid());
}
use of com.qcadoo.model.api.types.FieldType in project qcadoo by qcadoo.
the class FieldTypeFactoryTest method shouldReturnPriorityType.
@Test
public void shouldReturnPriorityType() throws Exception {
// given
FieldDefinition fieldDefinition = new FieldDefinitionImpl(null, "aaa");
// when
FieldType fieldType = new PriorityType(fieldDefinition);
// then
assertEquals(Integer.class, fieldType.getType());
assertTrue(fieldType.toObject(fieldDefinition, 1).isValid());
assertEquals(fieldDefinition, ((PriorityType) fieldType).getScopeFieldDefinition());
}
use of com.qcadoo.model.api.types.FieldType in project qcadoo by qcadoo.
the class FieldTypeFactoryTest method shouldReturnDateType.
@Test
public void shouldReturnDateType() throws Exception {
// when
FieldType fieldType = new DateType();
// then
assertEquals(Date.class, fieldType.getType());
assertTrue(fieldType.toObject(fieldDefinition, new Date()).isValid());
}
use of com.qcadoo.model.api.types.FieldType in project qcadoo by qcadoo.
the class FieldTypeFactoryTest method shouldReturnStringType.
@Test
public void shouldReturnStringType() throws Exception {
// when
FieldType fieldType = new StringType();
// then
assertEquals(String.class, fieldType.getType());
assertTrue(fieldType.toObject(fieldDefinition, "test").isValid());
assertTrue(fieldType.toObject(fieldDefinition, StringUtils.repeat("a", 255)).isValid());
assertTrue(fieldType.toObject(fieldDefinition, StringUtils.repeat("a", 300)).isValid());
}
Aggregations