@SuppressWarnings({"unchecked", "ThrowableInstanceNeverThrown"}) @Test public void event_trigger_throws_validation_exception() throws Exception { ComponentResources resources = mockComponentResources(); FieldValidator fv = mockFieldValidator(); Object value = new Object(); ValidationException ve = new ValidationException("Bah!"); RuntimeException re = new RuntimeException(ve); ComponentEventCallback handler = null; fv.validate(value); expect(resources.triggerEvent(eq(EventConstants.VALIDATE), EasyMock.aryEq(new Object[]{value}), eq(handler))).andThrow(re); replay(); FieldValidationSupport support = new FieldValidationSupportImpl(typeCoercer, propertyAccess); try { support.validate(value, resources, fv); unreachable(); } catch (ValidationException ex) { assertSame(ex, ve); } verify(); }
@SuppressWarnings( {"unchecked"}) public void validate(Object value, ComponentResources componentResources, FieldValidator validator) throws ValidationException { assert componentResources != null; assert validator != null; validator.validate(value); try { componentResources.triggerEvent(EventConstants.VALIDATE, new Object[] {value}, null); } catch (RuntimeException ex) { rethrowValidationException(ex); } }
FieldValidationSupportImpl implements FieldValidationSupport { @SuppressWarnings( {"unchecked"}) public void validate(Object value, ComponentResources componentResources, FieldValidator validator) throws ValidationException { assert componentResources != null; assert validator != null; validator.validate(value); try { componentResources.triggerEvent(EventConstants.VALIDATE, new Object[] {value}, null); } catch (RuntimeException ex) { rethrowValidationException(ex); } } }
FieldValidationSupportImpl implements FieldValidationSupport { @SuppressWarnings( {"unchecked"}) public void validate(Object value, ComponentResources componentResources, FieldValidator validator) throws ValidationException { assert componentResources != null; assert validator != null; validator.validate(value); try { componentResources.triggerEvent(EventConstants.VALIDATE, new Object[] {value}, null); } catch (RuntimeException ex) { rethrowValidationException(ex); } } FieldValidationSupportImpl(TypeCoercer typeCoercer, PropertyAccess propertyAccess); }
FieldValidationSupportImpl implements FieldValidationSupport { @SuppressWarnings( {"unchecked"}) public void validate(Object value, ComponentResources componentResources, FieldValidator validator) throws ValidationException { assert componentResources != null; assert validator != null; validator.validate(value); try { componentResources.triggerEvent(EventConstants.VALIDATE, new Object[] {value}, null); } catch (RuntimeException ex) { rethrowValidationException(ex); } } FieldValidationSupportImpl(TypeCoercer typeCoercer, PropertyAccess propertyAccess); String toClient(Object value, ComponentResources componentResources, FieldTranslator<Object> translator,
                           NullFieldStrategy nullFieldStrategy); Object parseClient(String clientValue, ComponentResources componentResources,
                              FieldTranslator<Object> translator, NullFieldStrategy nullFieldStrategy); @SuppressWarnings( {"unchecked"}) void validate(Object value, ComponentResources componentResources, FieldValidator validator); }
FieldValidationSupportImpl implements FieldValidationSupport { @SuppressWarnings( {"unchecked"}) public void validate(Object value, ComponentResources componentResources, FieldValidator validator) throws ValidationException { assert componentResources != null; assert validator != null; validator.validate(value); try { componentResources.triggerEvent(EventConstants.VALIDATE, new Object[] {value}, null); } catch (RuntimeException ex) { rethrowValidationException(ex); } } FieldValidationSupportImpl(TypeCoercer typeCoercer, PropertyAccess propertyAccess); String toClient(Object value, ComponentResources componentResources, FieldTranslator<Object> translator,
                           NullFieldStrategy nullFieldStrategy); Object parseClient(String clientValue, ComponentResources componentResources,
                              FieldTranslator<Object> translator, NullFieldStrategy nullFieldStrategy); @SuppressWarnings( {"unchecked"}) void validate(Object value, ComponentResources componentResources, FieldValidator validator);  }