PresenterLifeCycleLinker { public void initializeLifeCycle(Object source, RosiePresenter.View view) { if (source == null) { throw new IllegalArgumentException( "The source instance used to initialize the presenters can't be null"); } if (view == null) { throw new IllegalArgumentException( "The view instance used to initialize the presenters can't be null"); } addAnnotatedPresenter(source); setView(view); initializePresenters(); }  void initializeLifeCycle(Object source, RosiePresenter.View view); void initializePresenters(); void updatePresenters(RosiePresenter.View view); void pausePresenters(); void destroyPresenters(); void registerPresenter(RosiePresenter presenter); void setView(RosiePresenter.View view);  }
@Test public void shouldInitializePresentersLifecycleOnInitializeLifecycleIsCalled() { PresenterLifeCycleLinker presenterLifeCycleLinker = givenAPresenterLifecycleLinker(); Object source = givenAnyClassWithAnAnnotatedPresenter(anyPresenter1); presenterLifeCycleLinker.initializeLifeCycle(source, anyView); verify(anyPresenter1).initialize(); }
@Test(expected = PresenterNotAccessibleException.class) public void shouldThrowExceptionIfTheAnnotatedPresenterVisibilityIsPrivate() { AnyClassWithAPrivatePresenterAnnotated source = new AnyClassWithAPrivatePresenterAnnotated(); PresenterLifeCycleLinker presenterLifeCycleLinker = givenAPresenterLifecycleLinker(); presenterLifeCycleLinker.initializeLifeCycle(source, anyView); }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullSourcesToInitializeTheLifeCycle() { PresenterLifeCycleLinker presenterLifeCycleLinker = givenAPresenterLifecycleLinker(); presenterLifeCycleLinker.initializeLifeCycle(null, anyView); }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullViewsToInitializeTheLifeCycle() { PresenterLifeCycleLinker presenterLifeCycleLinker = givenAPresenterLifecycleLinker(); Object source = givenAnyClassWithAnAnnotatedPresenter(anyPresenter1); presenterLifeCycleLinker.initializeLifeCycle(source, null); }