use of com.qcadoo.model.internal.api.EntityHookDefinition in project qcadoo by qcadoo.
the class DataAccessServiceSaveTest method shouldNotOmitCreateHooksExceptOnCopy.
@Test
public void shouldNotOmitCreateHooksExceptOnCopy() throws Exception {
EntityHookDefinition onCreateHook = mock(EntityHookDefinition.class);
given(onCreateHook.isEnabled()).willReturn(true);
dataDefinition.addCreateHook(onCreateHook);
Entity entity = new DefaultEntity(dataDefinition);
entity.setField("name", "Mr T");
entity.setField("age", 66);
SampleSimpleDatabaseObject databaseObject = new SampleSimpleDatabaseObject();
databaseObject.setName("Mr T");
databaseObject.setAge(66);
// when
entity = dataDefinition.save(entity);
// then
verify(session).save(databaseObject);
assertTrue(entity.isValid());
verify(onCreateHook, times(1)).isEnabled();
verify(onCreateHook, times(1)).call(Mockito.any(Entity.class));
}
use of com.qcadoo.model.internal.api.EntityHookDefinition in project qcadoo by qcadoo.
the class DataDefinitionImpl method getHook.
@Override
public EntityHookDefinition getHook(final String type, final String className, final String methodName) {
EntityHookDefinition hook = hooksByMethodPath.get(type.toUpperCase(Locale.ENGLISH) + "." + className + "." + methodName);
checkNotNull(hook, "Cannot find hook " + type.toUpperCase(Locale.ENGLISH) + "." + className + "." + methodName + " for dataDefinition " + this);
return hook;
}
use of com.qcadoo.model.internal.api.EntityHookDefinition in project qcadoo by qcadoo.
the class ModelXmlToDefinitionConverterTest method shouldSetEntityValidators.
@Test
public void shouldSetEntityValidators() {
assertEquals(1, ((DataDefinitionImpl) dataDefinition).getValidators().size());
EntityHookDefinition validator = ((DataDefinitionImpl) dataDefinition).getValidators().get(0);
assertThat(validator, instanceOf(CustomEntityValidator.class));
testHookDefinition(validator, "entityHook", CustomHook.class, "validate");
}
Aggregations