MvcGraph { public <T> void use(final Class<T> type, final Consumer<T> consumer) { if (uiThreadRunner.isOnUiThread()) { try { graph.use(type, Inject.class, consumer); } catch (PokeException e) { throw new MvcGraphException(e.getMessage(), e); } } else { uiThreadRunner.post(new Runnable() { @Override public void run() { try { graph.use(type, Inject.class, consumer); } catch (PokeException e) { throw new MvcGraphException(e.getMessage(), e); } } }); } }  void registerMonitor(final Graph.Monitor monitor); void unregisterMonitor(final Graph.Monitor monitor); void clearMonitors(); T reference(Class<T> type, Annotation qualifier); void dereference(T instance, Class<T> type, Annotation qualifier); void use(final Class<T> type, final Consumer<T> consumer); void use(final Class<T> type, final Annotation qualifier, final Consumer<T> consumer); void inject(final Object target); void release(final Object target); void setRootComponent(final MvcComponent component); MvcComponent getRootComponent(); void registerDereferencedListener(
            final Provider.DereferenceListener onProviderFreedListener); void unregisterDereferencedListener(
            final Provider.DereferenceListener onProviderFreedListener); void clearDereferencedListeners();  }
@Test(expected = MvcGraphException.class) public void should_raise_mvc_graph_exception_when_use_on_poke_exception_on_non_ui_thread() { when(graph.uiThreadRunner.isOnUiThread()).thenReturn(false); class View { @Inject UnimplementedInterface unimplementedInterface; } graph.use(UnimplementedInterface.class, null, mock(Consumer.class)); }
@Test(expected = MvcGraphException.class) public void should_raise_mvc_graph_exception_when_use_on_poke_exception() { class View { @Inject UnimplementedInterface unimplementedInterface; } graph.use(UnimplementedInterface.class, new Consumer<UnimplementedInterface>() { @Override public void consume(UnimplementedInterface instance) { } }); }
@Test public void should_throw_exception_when_mvc_graph_use_consumer_on_non_main_thread() { when(graph.uiThreadRunner.isOnUiThread()).thenReturn(false); graph.use(String.class, mock(Consumer.class)); }
@Test public void should_throw_exception_when_mvc_graph_use_consumer_without_annotation_on_non_main_thread() { when(graph.uiThreadRunner.isOnUiThread()).thenReturn(false); graph.use(String.class, null, mock(Consumer.class)); }