@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("")); }
@Test public void should_throw_IllegalRootComponentException_on_graph_preparation_with_attached_component() throws Component.MultiParentException, ProviderConflictException { MvcComponent parent = new MvcComponent(""); MvcComponent child = new MvcComponent(""); parent.attach(child); boolean caught = false; try { graph.prepareInternalGraph(new Graph(), child); } catch (MvcGraphException e) { if (e.getCause() instanceof Graph.IllegalRootComponentException) { caught = true; } } Assert.assertTrue(caught); }
MvcComponent component = new MvcComponent(""); component.register(new Object(){ @Provides
graph.setRootComponent((MvcComponent) new MvcComponent("TestRootComponent").register(new Object(){ @Provides @EventBusC
@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
@Test public void should_throw_ProviderConflictException_on_graph_preparation_by_duplicate_registration() throws Component.MultiParentException, ProviderConflictException, ProvideException { MvcComponent component = new MvcComponent(""); component.register(new Object() { @Provides public UiThreadRunner uiThreadRunner() { return mock(UiThreadRunner.class); } }); boolean caught = false; try { graph.prepareInternalGraph(new Graph(), component); } catch (MvcGraphException e) { if (e.getCause() instanceof ProviderConflictException) { caught = true; } } Assert.assertTrue(caught); }
overridingComponent = new MvcComponent("TestOverridingComponent"); overridingComponent.register(new Object(){ @Provides
@Test public void run_car_with_better_components() throws Exception { MvcComponent testComponent = new MvcComponent("TestComponent");
@Test public void test_injection_with_different_component_for_different_scoping() throws Exception{ MvcComponent componentWithCache = new MvcComponent("SmallLender"); componentWithCache.register(new Object(){ @Provides MvcComponent componentWithoutCache = new MvcComponent("BigLender", useScopeCache); componentWithoutCache.register(new Object(){ @Provides
@Test public void test_injection_with_different_component_for_different_scoping() throws Exception{ MvcComponent componentWithCache = new MvcComponent("SmallLender"); componentWithCache.register(new Object(){ @Provides MvcComponent componentWithoutCache = new MvcComponent("BigLender", useScopeCache); componentWithoutCache.register(new Object(){ @Provides