BaseFragmentFactory implements FragmentFactory { protected boolean providesFragment(final int fragmentId) { return items != null && items.indexOfKey(fragmentId) >= 0; } BaseFragmentFactory(); @Nullable static String createFragmentTag(@NonNull final Class<?> classOfFactory, @NonNull final String fragmentName); @Override boolean isFragmentProvided(final int fragmentId); @Override @Nullable Fragment createFragment(final int fragmentId); @Override @Nullable String createFragmentTag(final int fragmentId);  }
@Test public void testProvidesFragment() { final BaseFragmentFactory factory = new TestFactory(); assertThat(factory.providesFragment(TestFactory.FRAGMENT_NOT_PROVIDED), is(false)); for (final int providedFragmentId : TestFactory.providedFragmentIds) { assertThat(factory.providesFragment(providedFragmentId), is(true)); } }
@Test public void testProvidesFragmentOnFactoryWithoutFragments() { final BaseFragmentFactory factory = new TestFactoryWithoutFragments(); assertThat(factory.providesFragment(0), is(false)); }