WolmoFragmentHandler { void onCreate(@NonNull IWolmoFragment wolmoFragment) { mLogger.setTag(WolmoFragmentHandler.class.getSimpleName()); setFragment(wolmoFragment); final @Nullable Boolean handleArgs = mWolmoFragment.handleArguments(mFragment.getArguments()); if (handleArgs == null || !handleArgs) { mLogger.e(mFragment.getClass().getSimpleName() + " - The fragment's handleArguments() returned false."); mToastFactory.show(R.string.unknown_error); mFragment.requireActivity().finish(); } } @Inject  WolmoFragmentHandler(@NonNull ToastFactory toastFactory,
	                     @NonNull Logger logger,
	                     @NonNull T presenter); @NonNull T getPresenter();  }
@Test public void setWolmoFragmentNotExtendingFragment() { IWolmoFragment wolmoFragment = mock(IWolmoFragment.class); exception.expect(IllegalArgumentException.class); mWolmoFragmentHandler.onCreate(wolmoFragment); }
@Test public void handlerFinishActivityIfWrongArguments() { FragmentActivity activity = mock(FragmentActivity.class); when(mWolmoFragmentMock.handleArguments(nullable(Bundle.class))).thenReturn(false); when(mWolmoFragmentMock.requireActivity()).thenReturn(activity); mWolmoFragmentHandler.onCreate(mWolmoFragmentMock); verify(mLoggerMock, times(1)).setTag(eq(WolmoFragmentHandler.class.getSimpleName())); verify(activity, times(1)).finish(); verify(mToastFactoryMock, times(1)).show(R.string.unknown_error); verify(mLoggerMock, times(1)).e(eq(mWolmoFragmentMock.getClass().getSimpleName() + " - The fragment's handleArguments() returned false.")); }