use of com.qcadoo.model.internal.validators.LengthValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasNoErrorsIfStringValueLenghtIsOk.
@Test
public void shouldHasNoErrorsIfStringValueLenghtIsOk() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("name", "qwert");
fieldDefinitionName.withValidator(new LengthValidator(null, null, 5));
// when
entity = dataDefinition.save(entity);
// then
verify(session).save(any(SampleSimpleDatabaseObject.class));
assertTrue(entity.isValid());
}
use of com.qcadoo.model.internal.validators.LengthValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldIgnoreLengthValidatorForBigDecimalValue.
@Test
public void shouldIgnoreLengthValidatorForBigDecimalValue() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("money", new BigDecimal("123.456"));
fieldDefinitionMoney.withValidator(new LengthValidator(null, 1, null));
// when
entity = dataDefinition.save(entity);
// then
verify(session).save(any(SampleSimpleDatabaseObject.class));
assertTrue(entity.isValid());
}
use of com.qcadoo.model.internal.validators.LengthValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasNoCheckLenghtOfDate.
@Test
public void shouldHasNoCheckLenghtOfDate() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("birthDate", "2010-01-01");
fieldDefinitionBirthDate.withValidator(new LengthValidator(null, null, 0));
// when
entity = dataDefinition.save(entity);
// then
verify(session).save(any(SampleSimpleDatabaseObject.class));
assertTrue(entity.isValid());
}
Aggregations