Search in sources :

Example 11 with FieldType

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());
}
Also used : DecimalType(com.qcadoo.model.internal.types.DecimalType) FieldType(com.qcadoo.model.api.types.FieldType) DataAccessTest(com.qcadoo.model.internal.DataAccessTest) Test(org.junit.Test)

Example 12 with FieldType

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());
}
Also used : BooleanType(com.qcadoo.model.internal.types.BooleanType) FieldType(com.qcadoo.model.api.types.FieldType) DataAccessTest(com.qcadoo.model.internal.DataAccessTest) Test(org.junit.Test)

Example 13 with FieldType

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());
}
Also used : PriorityType(com.qcadoo.model.internal.types.PriorityType) FieldDefinition(com.qcadoo.model.api.FieldDefinition) FieldDefinitionImpl(com.qcadoo.model.internal.FieldDefinitionImpl) FieldType(com.qcadoo.model.api.types.FieldType) DataAccessTest(com.qcadoo.model.internal.DataAccessTest) Test(org.junit.Test)

Example 14 with FieldType

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());
}
Also used : DateType(com.qcadoo.model.internal.types.DateType) Date(java.util.Date) FieldType(com.qcadoo.model.api.types.FieldType) DataAccessTest(com.qcadoo.model.internal.DataAccessTest) Test(org.junit.Test)

Example 15 with FieldType

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());
}
Also used : StringType(com.qcadoo.model.internal.types.StringType) FieldType(com.qcadoo.model.api.types.FieldType) DataAccessTest(com.qcadoo.model.internal.DataAccessTest) Test(org.junit.Test)

Aggregations

FieldType (com.qcadoo.model.api.types.FieldType)19 Test (org.junit.Test)15 DataAccessTest (com.qcadoo.model.internal.DataAccessTest)11 FieldDefinition (com.qcadoo.model.api.FieldDefinition)4 DefaultEntity (com.qcadoo.model.internal.DefaultEntity)3 DataDefinition (com.qcadoo.model.api.DataDefinition)2 Entity (com.qcadoo.model.api.Entity)2 BelongsToType (com.qcadoo.model.api.types.BelongsToType)2 FieldDefinitionImpl (com.qcadoo.model.internal.FieldDefinitionImpl)2 Date (java.util.Date)2 HasManyType (com.qcadoo.model.api.types.HasManyType)1 BelongsToEntityType (com.qcadoo.model.internal.types.BelongsToEntityType)1 BooleanType (com.qcadoo.model.internal.types.BooleanType)1 DateTimeType (com.qcadoo.model.internal.types.DateTimeType)1 DateType (com.qcadoo.model.internal.types.DateType)1 DecimalType (com.qcadoo.model.internal.types.DecimalType)1 IntegerType (com.qcadoo.model.internal.types.IntegerType)1 ManyToManyEntitiesType (com.qcadoo.model.internal.types.ManyToManyEntitiesType)1 PasswordType (com.qcadoo.model.internal.types.PasswordType)1 PriorityType (com.qcadoo.model.internal.types.PriorityType)1