@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("")); }
@Test (expected = IllegalStateException.class) public void should_throw_out_exceptions_when_registering_component() throws ProvideException, ProviderConflictException, Graph.IllegalRootComponentException { // Arrange MvcComponent badComponent = mock(MvcComponent.class); MvcGraph mvcGraph = new MvcGraph(); mvcGraph.setRootComponent(badComponent); Object obj = new Object(); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { throw new IllegalStateException(); } }).when(badComponent).register(any(Object.class)); // Act mvcGraph.getRootComponent().register(obj); }
@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); }
graph.setRootComponent((MvcComponent) new MvcComponent("TestRootComponent").register(new Object(){ @Provides @EventBusC
@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); }
@Before public void setUp() throws Exception { graph = new MvcGraph(); graph.setRootComponent((MvcComponent) new MvcComponent("Root").register(new Object() { @Provides @EventBusC public EventBus eventBusC() { return new EventBusImpl(); } @Provides @EventBusV public EventBus eventBusV() { return new EventBusImpl(); } @Provides public ExecutorService provideExe() { return mock(ExecutorService.class); } })); }
graph.setRootComponent((MvcComponent) new MvcComponent("Root").register(new Object() { @Provides @EventBusC