DATAREST-606 - Polishing.

Moved the accessibility tweak to the EventHandlerMethod's constructor so that the modification only occurs at detection time. Polished unit test.

Original pull request: #187.
This commit is contained in:
Oliver Gierke
2015-07-19 12:53:47 +02:00
parent 698643cf18
commit de5a98d47b
2 changed files with 11 additions and 12 deletions

View File

@@ -31,6 +31,7 @@ import org.springframework.util.MultiValueMap;
* Unit tests for {@link AnnotatedEventHandlerInvoker}.
*
* @author Oliver Gierke
* @author Fabian Trampusch
*/
public class AnnotatedEventHandlerInvokerUnitTests {
@@ -58,15 +59,16 @@ public class AnnotatedEventHandlerInvokerUnitTests {
* @see DATAREST-606
*/
@Test
public void canInvokePrivateEventHandlerMethods() {
public void invokesPrivateEventHandlerMethods() {
SampleWithPrivateHandler sampleHandler = new SampleWithPrivateHandler();
AnnotatedEventHandlerInvoker invoker = new AnnotatedEventHandlerInvoker();
invoker.postProcessAfterInitialization(sampleHandler, "sampleHandler");
BeforeCreateEvent beforeCreateEvent = new BeforeCreateEvent(new Person());
invoker.onApplicationEvent(beforeCreateEvent);
invoker.onApplicationEvent(new BeforeCreateEvent(new Person()));
assertThat(sampleHandler.wasCalled(), is(true));
assertThat(sampleHandler.wasCalled, is(true));
}
@RepositoryEventHandler
@@ -79,15 +81,11 @@ public class AnnotatedEventHandlerInvokerUnitTests {
@RepositoryEventHandler
static class SampleWithPrivateHandler {
private boolean wasCalled = false;
boolean wasCalled = false;
@HandleBeforeCreate
private void method(Person sample) {
wasCalled = true;
}
public boolean wasCalled() {
return wasCalled;
}
}
}