use of com.qcadoo.model.internal.DefaultEntity 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.DefaultEntity 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.DefaultEntity 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.DefaultEntity in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasErrorIfIntegerTypeIsWrong.
@Test
public void shouldHasErrorIfIntegerTypeIsWrong() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("age", "21w");
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
use of com.qcadoo.model.internal.DefaultEntity in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasErrorsIfBigDecimalUnscaledValueIsNotEqual.
@Test
public void shouldHasErrorsIfBigDecimalUnscaledValueIsNotEqual() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("money", new BigDecimal("123.45"));
fieldDefinitionMoney.withValidator(new UnscaledValueValidator(null, 4, null));
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
Aggregations