Matomo { public void setDispatcherFactory(DispatcherFactory dispatcherFactory) { this.mDispatcherFactory = dispatcherFactory; } private  Matomo(Context context); static synchronized Matomo getInstance(Context context); Context getContext(); SharedPreferences getPreferences(); SharedPreferences getTrackerPreferences(@NonNull Tracker tracker); void setDispatcherFactory(DispatcherFactory dispatcherFactory); DispatcherFactory getDispatcherFactory(); static String tag(Class... classes); static String tag(String... tags); static final String LOGGER_PREFIX; }
@Test public void testSetDispatcherFactory() { final Matomo matomo = Matomo.getInstance(Robolectric.application); Dispatcher dispatcher = mock(Dispatcher.class); DispatcherFactory factory = mock(DispatcherFactory.class); when(factory.build(any(Tracker.class))).thenReturn(dispatcher); assertThat(matomo.getDispatcherFactory(), is(not(nullValue()))); matomo.setDispatcherFactory(factory); assertThat(matomo.getDispatcherFactory(), is(factory)); }