### Question:
FragmentNavigator extends Navigator<FragmentNavigator.Destination> { @SuppressWarnings("deprecation") @Override public void navigate(@NonNull Destination destination, @Nullable Bundle args, @Nullable NavOptions navOptions) { final Fragment frag = destination.createFragment(args); final FragmentTransaction ft = mFragmentManager.beginTransaction(); int enterAnim = navOptions != null ? navOptions.getEnterAnim() : -1; int exitAnim = navOptions != null ? navOptions.getExitAnim() : -1; int popEnterAnim = navOptions != null ? navOptions.getPopEnterAnim() : -1; int popExitAnim = navOptions != null ? navOptions.getPopExitAnim() : -1; if (enterAnim != -1 || exitAnim != -1 || popEnterAnim != -1 || popExitAnim != -1) { enterAnim = enterAnim != -1 ? enterAnim : 0; exitAnim = exitAnim != -1 ? exitAnim : 0; popEnterAnim = popEnterAnim != -1 ? popEnterAnim : 0; popExitAnim = popExitAnim != -1 ? popExitAnim : 0; ft.setCustomAnimations(enterAnim, exitAnim, popEnterAnim, popExitAnim); } ft.replace(mContainerId, frag); final @IdRes int destId = destination.getId(); final boolean initialNavigation = mBackStack.isEmpty(); final boolean isClearTask = navOptions != null && navOptions.shouldClearTask(); final boolean isSingleTopReplacement = navOptions != null && !initialNavigation && navOptions.shouldLaunchSingleTop() && mBackStack.peekLast() == destId; int backStackEffect; if (!initialNavigation && !isClearTask && !isSingleTopReplacement) { ft.addToBackStack(getBackStackName(destId)); backStackEffect = BACK_STACK_DESTINATION_ADDED; } else if (isSingleTopReplacement) { if (mBackStack.size() > 1) { mFragmentManager.popBackStack(); ft.addToBackStack(getBackStackName(destId)); } backStackEffect = BACK_STACK_UNCHANGED; } else { backStackEffect = BACK_STACK_DESTINATION_ADDED; } ft.setReorderingAllowed(true); ft.commit(); if (initialNavigation || !isSingleTopReplacement) { mBackStack.add(destId); } dispatchOnNavigatorNavigated(destId, backStackEffect); } FragmentNavigator(@NonNull Context context, @NonNull FragmentManager manager,
            int containerId); @Override boolean popBackStack(); @NonNull @Override Destination createDestination(); @SuppressWarnings("deprecation") @Override void navigate(@NonNull Destination destination, @Nullable Bundle args,
                            @Nullable NavOptions navOptions); @Override @Nullable Bundle onSaveState(); @Override void onRestoreState(@Nullable Bundle savedState);  }### Answer:
@UiThreadTest @Test public void testNavigate() { FragmentNavigator fragmentNavigator = new FragmentNavigator(mEmptyActivity, mFragmentManager, R.id.container); FragmentNavigator.Destination destination = fragmentNavigator.createDestination(); destination.setFragmentClass(EmptyFragment.class); fragmentNavigator.navigate(destination, null, null); mFragmentManager.executePendingTransactions(); Fragment fragment = mFragmentManager.findFragmentById(R.id.container); assertThat("Fragment should be added", fragment, is(notNullValue())); assertThat("Fragment should be the correct type", fragment, is(CoreMatchers.<Fragment>instanceOf(EmptyFragment.class))); }