/**
  * Subscribe the annotated command handler to the given command bus.
  *
  * @param annotatedCommandHandler The annotated command handler that is to be subscribed to the
  *     command bus
  * @param commandBus The command bus that gets the handler's subscription
  * @return the Adapter created for the command handler target. Can be used to unsubscribe.
  */
 public static AnnotationCommandHandlerAdapter subscribe(
     Object annotatedCommandHandler, CommandBus commandBus) {
   AnnotationCommandHandlerAdapter adapter =
       new AnnotationCommandHandlerAdapter(annotatedCommandHandler, commandBus);
   adapter.subscribe();
   return adapter;
 }
  @Test
  public void testSubscribe() {
    testSubject.subscribe();

    verify(mockBus).subscribe(Long.class, testSubject);
    verify(mockBus).subscribe(String.class, testSubject);
    verify(mockBus).subscribe(HashSet.class, testSubject);
    verify(mockBus).subscribe(ArrayList.class, testSubject);
    verifyNoMoreInteractions(mockBus);
  }
  /** This test should make sure the problem described in issue #91 does not occur anymore */
  @Test
  public void testCallbackCalled() {
    SimpleCommandBus scb = new SimpleCommandBus();
    AnnotationCommandHandlerAdapter.subscribe(this, scb);

    scb.dispatch(
        GenericCommandMessage.asCommandMessage("Hello"),
        new VoidCallback() {
          @Override
          protected void onSuccess() {
            // what I expected
          }

          @Override
          public void onFailure(Throwable cause) {
            cause.printStackTrace();
            fail("Did not expect a failure");
          }
        });
  }