MvcGraph { public void setRootComponent(final MvcComponent component) { if (uiThreadRunner.isOnUiThread()) { try { graph.setRootComponent(component); } catch (Graph.IllegalRootComponentException e) { throw new MvcGraphException(e.getMessage(), e); } } else { uiThreadRunner.post(new Runnable() { @Override public void run() { try { graph.setRootComponent(component); } catch (Graph.IllegalRootComponentException 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_throw_exception_when_set_attached_root_component_to_graph_on_main_thread() throws Graph.IllegalRootComponentException, Component.MultiParentException, ProviderConflictException { MvcComponent parent = new MvcComponent("parent"); MvcComponent child = new MvcComponent(""); parent.attach(child); graph.setRootComponent(child); }
@Test(expected = MvcGraphException.class) public void should_throw_exception_when_set_attached_root_component_to_graph_on_non_main_thread() throws Graph.IllegalRootComponentException, Component.MultiParentException, ProviderConflictException { when(graph.uiThreadRunner.isOnUiThread()).thenReturn(false); MvcComponent parent = new MvcComponent("parent"); MvcComponent child = new MvcComponent(""); parent.attach(child); graph.setRootComponent(child); }
@Test public void should_throw_exception_when_mvc_graph_set_rootComponent_on_non_main_thread() throws Graph.IllegalRootComponentException { graph.setRootComponent(new MvcComponent("")); when(graph.uiThreadRunner.isOnUiThread()).thenReturn(false); graph.setRootComponent(new MvcComponent("")); }