@Test
public void shouldFireEventForDirectHandlerIfCorrespondingDirectAdapterExists() throws Exception {

    final ArgumentCaptor<ServiceComponentFoundEvent> captor = ArgumentCaptor.forClass(ServiceComponentFoundEvent.class);
    doReturn(new HashSet<Bean<Object>>(asList(TestBean.of(TestDirectQueryViewAdapter.class), TestBean.of(TestDirectQueryApiHandler.class)))).when(beanManager).getBeans(any(), any());
    doReturn(new HashSet<Bean<Object>>(asList(TestBean.of(TestDirectQueryViewAdapter.class)))).when(beanManager).getBeans(SynchronousDirectAdapter.class);
    serviceComponentScanner.afterDeploymentValidation(NOT_USED_AFTER_DEPLOYMENT_VALIDATION, beanManager);
    verify(beanManager).fireEvent(captor.capture());
    assertThat(captor.getValue(), instanceOf(ServiceComponentFoundEvent.class));
    assertThat(captor.getValue().getHandlerBean().getBeanClass(), equalTo(TestDirectQueryApiHandler.class));
    assertThat(captor.getValue().getLocation(), equalTo(ServiceComponentLocation.REMOTE));
}