@Test(expected=ValidationException.class) public void onXMLSerializationResultShouldThrowExceptionOnlyOnSerializeMethod() throws Exception { JSONSerialization serialization = mock(JSONSerialization.class); serializerBuilder = mock(SerializerBuilder.class, new Answer<SerializerBuilder>() { public SerializerBuilder answer(InvocationOnMock invocation) throws Throwable { return serializerBuilder; } }); when(result.use(JSONSerialization.class)).thenReturn(serialization); when(serialization.from(any())).thenReturn(serializerBuilder); try { factory.instanceFor(JSONSerialization.class, errors).from(new Object()); factory.instanceFor(JSONSerialization.class, errors).from(new Object()).include("abc"); factory.instanceFor(JSONSerialization.class, errors).from(new Object()).exclude("abc"); } catch (ValidationException e) { Assert.fail("Should not throw exception yet"); } factory.instanceFor(JSONSerialization.class, errors).from(new Object()).serialize(); }
public <T extends View> T instanceFor(final Class<T> view, final List<Message> errors) { if (view.equals(EmptyResult.class)) { throw new ValidationException(errors); } return proxifier.proxify(view, throwValidationErrorOnFinalMethods(view, errors, result.use(view))); }
DefaultValidationViewsFactory implements ValidationViewsFactory { public <T extends View> T instanceFor(final Class<T> view, final List<Message> errors) { if (view.equals(EmptyResult.class)) { throw new ValidationException(errors); } return proxifier.proxify(view, throwValidationErrorOnFinalMethods(view, errors, result.use(view))); } }
DefaultValidationViewsFactory implements ValidationViewsFactory { public <T extends View> T instanceFor(final Class<T> view, final List<Message> errors) { if (view.equals(EmptyResult.class)) { throw new ValidationException(errors); } return proxifier.proxify(view, throwValidationErrorOnFinalMethods(view, errors, result.use(view))); } DefaultValidationViewsFactory(Result result, Proxifier proxifier); }
DefaultValidationViewsFactory implements ValidationViewsFactory { public <T extends View> T instanceFor(final Class<T> view, final List<Message> errors) { if (view.equals(EmptyResult.class)) { throw new ValidationException(errors); } return proxifier.proxify(view, throwValidationErrorOnFinalMethods(view, errors, result.use(view))); } DefaultValidationViewsFactory(Result result, Proxifier proxifier); T instanceFor(final Class<T> view, final List<Message> errors); }
DefaultValidationViewsFactory implements ValidationViewsFactory { public <T extends View> T instanceFor(final Class<T> view, final List<Message> errors) { if (view.equals(EmptyResult.class)) { throw new ValidationException(errors); } return proxifier.proxify(view, throwValidationErrorOnFinalMethods(view, errors, result.use(view))); } DefaultValidationViewsFactory(Result result, Proxifier proxifier); T instanceFor(final Class<T> view, final List<Message> errors);  }