use of com.qcadoo.model.internal.validators.RegexValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHasErrorsIfStringNotMatchExpression.
@Test
public void shouldHasErrorsIfStringNotMatchExpression() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("name", "Qcadoo Framework RLZ!");
fieldDefinitionName.withValidator(new RegexValidator(".*MES.*"));
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
use of com.qcadoo.model.internal.validators.RegexValidator in project qcadoo by qcadoo.
the class ValidatorTest method shouldHaveNoErrorsIfStringMatchExpression.
@Test
public void shouldHaveNoErrorsIfStringMatchExpression() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("name", "Qcadoo Framework RLZ!");
fieldDefinitionName.withValidator(new RegexValidator("^Qcadoo.*"));
// when
entity = dataDefinition.save(entity);
// then
verify(session).save(any(SampleSimpleDatabaseObject.class));
assertTrue(entity.isValid());
}
Aggregations