use of com.qcadoo.model.internal.validators.RangeValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasErrorsIfIntegerValueIsOutsideTheRange.
@Test
public void shouldHasErrorsIfIntegerValueIsOutsideTheRange() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("age", "11");
fieldDefinitionAge.withValidator(new RangeValidator(null, 10, true));
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
use of com.qcadoo.model.internal.validators.RangeValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasNoErrorsIfDateValueIsInsideTheRange.
@Test
public void shouldHasNoErrorsIfDateValueIsInsideTheRange() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("birthDate", "2010-01-01");
fieldDefinitionBirthDate.withValidator(new RangeValidator(null, new Date(), true));
// when
entity = dataDefinition.save(entity);
// then
verify(session).save(any(SampleSimpleDatabaseObject.class));
assertTrue(entity.isValid());
}
use of com.qcadoo.model.internal.validators.RangeValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasErrorsIfStringValueIsOutsideTheRange.
@Test
public void shouldHasErrorsIfStringValueIsOutsideTheRange() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("name", "ddd");
fieldDefinitionName.withValidator(new RangeValidator("a", "c", true));
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
use of com.qcadoo.model.internal.validators.RangeValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasNoErrorsIfBigDecimalValueIsInsideTheRange.
@Test
public void shouldHasNoErrorsIfBigDecimalValueIsInsideTheRange() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("money", "31.22");
fieldDefinitionMoney.withValidator(new RangeValidator(30, 40, true));
// when
entity = dataDefinition.save(entity);
// then
verify(session).save(any(SampleSimpleDatabaseObject.class));
assertTrue(entity.isValid());
}
use of com.qcadoo.model.internal.validators.RangeValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasErrorsIfDateValueIsOutsideTheRange.
@Test
public void shouldHasErrorsIfDateValueIsOutsideTheRange() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("birthDate", "2010-01-01");
fieldDefinitionBirthDate.withValidator(new RangeValidator(new Date(), new Date(), true));
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
Aggregations