@Test public final void shouldCallCreateAndSaveHooks() throws Exception { when(genericEntity.getId()).thenReturn(null); validationService.validateGenericEntity(dataDefinition, genericEntity, existingGenericEntity); verify(dataDefinition).callCreateHook(genericEntity); verify(dataDefinition).callSaveHook(genericEntity); }
@Override public void validateGenericEntity(final InternalDataDefinition dataDefinition, final Entity genericEntity, final Entity existingGenericEntity) { validateEntityAgainstVersion(existingGenericEntity, genericEntity, dataDefinition); copyReadOnlyAndMissingFields(dataDefinition, genericEntity, existingGenericEntity); parseFields(dataDefinition, genericEntity); if (genericEntity.getId() == null) { dataDefinition.callCreateHook(genericEntity); parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); } else { parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); dataDefinition.callUpdateHook(genericEntity); } dataDefinition.callSaveHook(genericEntity); }
ValidationServiceImpl implements ValidationService { @Override public void validateGenericEntity(final InternalDataDefinition dataDefinition, final Entity genericEntity, final Entity existingGenericEntity) { validateEntityAgainstVersion(existingGenericEntity, genericEntity, dataDefinition); copyReadOnlyAndMissingFields(dataDefinition, genericEntity, existingGenericEntity); parseFields(dataDefinition, genericEntity); if (genericEntity.getId() == null) { dataDefinition.callCreateHook(genericEntity); parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); } else { parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); dataDefinition.callUpdateHook(genericEntity); } dataDefinition.callSaveHook(genericEntity); } }
ValidationServiceImpl implements ValidationService { @Override public void validateGenericEntity(final InternalDataDefinition dataDefinition, final Entity genericEntity, final Entity existingGenericEntity) { validateEntityAgainstVersion(existingGenericEntity, genericEntity, dataDefinition); copyReadOnlyAndMissingFields(dataDefinition, genericEntity, existingGenericEntity); parseFields(dataDefinition, genericEntity); if (genericEntity.getId() == null) { dataDefinition.callCreateHook(genericEntity); parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); } else { parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); dataDefinition.callUpdateHook(genericEntity); } dataDefinition.callSaveHook(genericEntity); }  }
ValidationServiceImpl implements ValidationService { @Override public void validateGenericEntity(final InternalDataDefinition dataDefinition, final Entity genericEntity, final Entity existingGenericEntity) { validateEntityAgainstVersion(existingGenericEntity, genericEntity, dataDefinition); copyReadOnlyAndMissingFields(dataDefinition, genericEntity, existingGenericEntity); parseFields(dataDefinition, genericEntity); if (genericEntity.getId() == null) { dataDefinition.callCreateHook(genericEntity); parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); } else { parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); dataDefinition.callUpdateHook(genericEntity); } dataDefinition.callSaveHook(genericEntity); }  @Override void validateGenericEntity(final InternalDataDefinition dataDefinition, final Entity genericEntity,
            final Entity existingGenericEntity); }
ValidationServiceImpl implements ValidationService { @Override public void validateGenericEntity(final InternalDataDefinition dataDefinition, final Entity genericEntity, final Entity existingGenericEntity) { validateEntityAgainstVersion(existingGenericEntity, genericEntity, dataDefinition); copyReadOnlyAndMissingFields(dataDefinition, genericEntity, existingGenericEntity); parseFields(dataDefinition, genericEntity); if (genericEntity.getId() == null) { dataDefinition.callCreateHook(genericEntity); parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); } else { parseAndValidateEntity(dataDefinition, genericEntity, existingGenericEntity); dataDefinition.callUpdateHook(genericEntity); } dataDefinition.callSaveHook(genericEntity); }  @Override void validateGenericEntity(final InternalDataDefinition dataDefinition, final Entity genericEntity,
            final Entity existingGenericEntity);  }