private void supportsEventType(boolean match, Method method, ResolvableType eventType) {
   ApplicationListenerMethodAdapter adapter = createTestInstance(method);
   assertEquals(
       "Wrong match for event '" + eventType + "' on " + method,
       match,
       adapter.supportsEventType(eventType));
 }
 @Test
 public void specifiedOrder() {
   Method method =
       ReflectionUtils.findMethod(SampleEvents.class, "handleRaw", ApplicationEvent.class);
   ApplicationListenerMethodAdapter adapter = createTestInstance(method);
   assertEquals(42, adapter.getOrder());
 }
 @Test
 public void defaultOrder() {
   Method method =
       ReflectionUtils.findMethod(
           SampleEvents.class, "handleGenericString", GenericTestEvent.class);
   ApplicationListenerMethodAdapter adapter = createTestInstance(method);
   assertEquals(0, adapter.getOrder());
 }
  @Test
  public void beanInstanceRetrievedAtEveryInvocation() {
    Method method =
        ReflectionUtils.findMethod(
            SampleEvents.class, "handleGenericString", GenericTestEvent.class);
    when(this.context.getBean("testBean")).thenReturn(this.sampleEvents);
    ApplicationListenerMethodAdapter listener =
        new ApplicationListenerMethodAdapter("testBean", GenericTestEvent.class, method);
    listener.init(this.context, new EventExpressionEvaluator());
    GenericTestEvent<String> event = createGenericTestEvent("test");

    listener.onApplicationEvent(event);
    verify(this.sampleEvents, times(1)).handleGenericString(event);
    verify(this.context, times(1)).getBean("testBean");

    listener.onApplicationEvent(event);
    verify(this.sampleEvents, times(2)).handleGenericString(event);
    verify(this.context, times(2)).getBean("testBean");
  }
 private void invokeListener(Method method, ApplicationEvent event) {
   ApplicationListenerMethodAdapter adapter = createTestInstance(method);
   adapter.onApplicationEvent(event);
 }