EventDispatcher { @VisibleForTesting Handler.Callback getHandlerCallback() { return mHandlerCallback; } @VisibleForTesting  EventDispatcher(Iterable<EventRecorder> recorders, Looper looper); void dispatch(BaseEvent event);  }
@Test public void handler_handleMessage_shouldCallRecordOnAllRecorders() throws Exception { Message message = new Message(); message.obj = mock(Event.class); subject = new EventDispatcher(recorders, Looper.getMainLooper()); subject.getHandlerCallback().handleMessage(message); verify(mockEventRecorder1).record(eq((Event) message.obj)); verify(mockEventRecorder2).record(eq((Event) message.obj)); }
@Test public void handler_handleMessage_withNonBaseEventTypeMessageShouldNotRecordOnAnyRecorders() throws Exception { Message message = new Message(); message.obj = mock(Activity.class); subject = new EventDispatcher(recorders, Looper.getMainLooper()); subject.getHandlerCallback().handleMessage(message); verify(mockEventRecorder1, never()).record(any(BaseEvent.class)); verify(mockEventRecorder2, never()).record(any(BaseEvent.class)); }