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());
}
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());
}
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());
}
}
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);
}
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());
}
Aggregations