use of com.qcadoo.model.internal.validators.LengthValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasErrorsIfStringIsTooShort.
@Test
public void shouldHasErrorsIfStringIsTooShort() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("name", "Qcadoo Framework RLZ!");
fieldDefinitionName.withValidator(new LengthValidator(50, null, null));
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
use of com.qcadoo.model.internal.validators.LengthValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasErrorsIfStringValueIsTooLong.
@Test
public void shouldHasErrorsIfStringValueIsTooLong() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("name", "qwerty");
fieldDefinitionName.withValidator(new LengthValidator(null, null, 5));
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
use of com.qcadoo.model.internal.validators.LengthValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldIgnoreLengthValidatorForIntegerValue.
@Test
public void shouldIgnoreLengthValidatorForIntegerValue() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("age", new Integer("123456"));
fieldDefinitionAge.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 shouldHasNoCheckLenghtOfBoolean.
@Test
public void shouldHasNoCheckLenghtOfBoolean() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("retired", false);
fieldDefinitionRetired.withValidator(new LengthValidator(null, null, 0));
// 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 shouldHasErrorsIfStringLengthIsNotEqual.
@Test
public void shouldHasErrorsIfStringLengthIsNotEqual() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("name", "Qcadoo Framework RLZ!");
fieldDefinitionName.withValidator(new LengthValidator(null, 4, null));
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
Aggregations