Search in sources :

Example 6 with FieldType

use of com.qcadoo.model.api.types.FieldType in project qcadoo by qcadoo.

the class FieldTypeFactoryTest method shouldReturnManyToManyType.

@Test
public void shouldReturnManyToManyType() throws Exception {
    // when
    FieldType fieldType = new ManyToManyEntitiesType("parent", "entity", "joinFieldName", ManyToManyType.Cascade.NULLIFY, true, false, dataDefinitionService);
    // then
    assertEquals(Set.class, fieldType.getType());
    assertTrue(fieldType.toObject(fieldDefinition, new DefaultEntity(dataDefinition)).isValid());
}
Also used : DefaultEntity(com.qcadoo.model.internal.DefaultEntity) ManyToManyEntitiesType(com.qcadoo.model.internal.types.ManyToManyEntitiesType) FieldType(com.qcadoo.model.api.types.FieldType) DataAccessTest(com.qcadoo.model.internal.DataAccessTest) Test(org.junit.Test)

Example 7 with FieldType

use of com.qcadoo.model.api.types.FieldType in project qcadoo by qcadoo.

the class FieldTypeFactoryTest method shouldReturnDateTimeType.

@Test
public void shouldReturnDateTimeType() throws Exception {
    // when
    FieldType fieldType = new DateTimeType();
    // then
    assertEquals(Date.class, fieldType.getType());
    assertTrue(fieldType.toObject(fieldDefinition, new Date()).isValid());
}
Also used : DateTimeType(com.qcadoo.model.internal.types.DateTimeType) Date(java.util.Date) FieldType(com.qcadoo.model.api.types.FieldType) DataAccessTest(com.qcadoo.model.internal.DataAccessTest) Test(org.junit.Test)

Example 8 with FieldType

use of com.qcadoo.model.api.types.FieldType in project mes by qcadoo.

the class BatchUtilTest method shouldThrowIllegalArgumentExceptionIfFieldIsNotAKindOfTheBelongsToType.

@Test
public void shouldThrowIllegalArgumentExceptionIfFieldIsNotAKindOfTheBelongsToType() {
    // given
    FieldType notABelongsToType = mock(FieldType.class);
    stubFieldDefinition(notABelongsToType);
    // when & then
    try {
        BatchUtil.extractNumberFrom(entity, BATCH_FIELD_NAME);
        Assert.fail();
    } catch (IllegalArgumentException iae) {
        verify(entity, never()).getBelongsToField(Mockito.anyString());
    }
}
Also used : FieldType(com.qcadoo.model.api.types.FieldType) Test(org.junit.Test)

Example 9 with FieldType

use of com.qcadoo.model.api.types.FieldType in project qcadoo by qcadoo.

the class DefaultEntityTest method shouldGetBelongsToFieldThrowIllegalArgumentExceptionIfFieldIsNotABelongsToType.

@Test(expected = IllegalArgumentException.class)
public final void shouldGetBelongsToFieldThrowIllegalArgumentExceptionIfFieldIsNotABelongsToType() throws Exception {
    // given
    FieldType wrongFieldType = mock(FieldType.class);
    when(belongsToFieldDefinition.getType()).thenReturn(wrongFieldType);
    defaultEntity.setField(BELONGS_TO_FIELD_NAME, "some wrong type value");
    // when
    defaultEntity.getBelongsToField(BELONGS_TO_FIELD_NAME);
}
Also used : FieldType(com.qcadoo.model.api.types.FieldType) Test(org.junit.Test)

Example 10 with FieldType

use of com.qcadoo.model.api.types.FieldType in project qcadoo by qcadoo.

the class FieldTypeFactoryTest method shouldReturnPasswordType.

@Test
public void shouldReturnPasswordType() throws Exception {
    // when
    PasswordEncoder passwordEncoder = mock(PasswordEncoder.class);
    FieldType fieldType = new PasswordType(passwordEncoder);
    // then
    assertEquals(String.class, fieldType.getType());
}
Also used : PasswordEncoder(org.springframework.security.authentication.encoding.PasswordEncoder) PasswordType(com.qcadoo.model.internal.types.PasswordType) 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