use of com.qcadoo.model.internal.hooks.EntityHookDefinitionImpl in project qcadoo by qcadoo.
the class ValidatorTest method shouldHaveErrorIfCustomEntityValidatorReturnsFalse.
@Test
public void shouldHaveErrorIfCustomEntityValidatorReturnsFalse() throws Exception {
// given
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("name", "Mr");
entity.setField("age", "18");
dataDefinition.addValidatorHook(new CustomEntityValidator(new EntityHookDefinitionImpl(CustomEntityService.class.getName(), "hasAge18AndNameMrT", PLUGIN_IDENTIFIER, applicationContext)));
// when
entity = dataDefinition.save(entity);
// then
verify(session, never()).save(any(SampleSimpleDatabaseObject.class));
assertFalse(entity.isValid());
}
Aggregations