BaseFragmentFactory implements FragmentFactory { @Nullable public static String createFragmentTag(@NonNull final Class<?> classOfFactory, @NonNull final String fragmentName) { if (TextUtils.isEmpty(fragmentName)) { return null; } return classOfFactory.getName() + ".TAG." + fragmentName; } 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);  }
@SuppressWarnings("ConstantConditions") @Test public void testCreateFragmentTag() { final BaseFragmentFactory factory = new TestFactory(); assertThat( factory.createFragmentTag(TestFactory.FRAGMENT_NOT_PROVIDED), nullValue() ); for (final int providedFragmentId : TestFactory.providedFragmentIds) { assertThat( factory.createFragmentTag(providedFragmentId), is(factory.getAnnotationHandler().getFragmentItems().get(providedFragmentId).tag) ); } }
@Test public void testCreateFragmentTagUtility() { assertThat( BaseFragmentFactory.createFragmentTag(TestFactory.class, "TestFragment"), is(TestFactory.class.getName() + ".TAG.TestFragment") ); }
@Test public void testCreateFragmentTagUtilityWithEmptyName() { assertThat(BaseFragmentFactory.createFragmentTag(TestFactory.class, ""), is(nullValue())); }