### Question:
I18n { public static void initialize( Class<?> i18nClass ) { CheckArg.isNotNull(i18nClass, "i18nClass"); if (i18nClass.isInterface()) { throw new IllegalArgumentException(CommonI18n.i18nClassInterface.text(i18nClass.getName())); } synchronized (i18nClass) { try { for (Field fld : i18nClass.getDeclaredFields()) { if (fld.getType() == I18n.class) { if ((fld.getModifiers() & Modifier.PUBLIC) != Modifier.PUBLIC) { throw new SystemFailureException(CommonI18n.i18nFieldNotPublic.text(fld.getName(), i18nClass)); } if ((fld.getModifiers() & Modifier.STATIC) != Modifier.STATIC) { throw new SystemFailureException(CommonI18n.i18nFieldNotStatic.text(fld.getName(), i18nClass)); } if ((fld.getModifiers() & Modifier.FINAL) == Modifier.FINAL) { throw new SystemFailureException(CommonI18n.i18nFieldFinal.text(fld.getName(), i18nClass)); } ClassUtil.makeAccessible(fld); fld.set(null, new I18n(fld.getName(), i18nClass)); } } for (Entry<Locale, Map<Class<?>, Set<String>>> entry : LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) { entry.getValue().remove(i18nClass); } } catch (IllegalAccessException err) { throw new IllegalArgumentException(CommonI18n.i18nClassNotPublic.text(i18nClass)); } } } private  I18n( String id,
                  Class<?> i18nClass ); static Set<Locale> getLocalizationProblemLocales( Class<?> i18nClass ); static Set<String> getLocalizationProblems( Class<?> i18nClass ); static Set<String> getLocalizationProblems( Class<?> i18nClass,
                                                       Locale locale ); static LocalizationRepository getLocalizationRepository(); static void setLocalizationRepository( LocalizationRepository localizationRepository ); static void initialize( Class<?> i18nClass ); String id(); boolean hasProblem(); boolean hasProblem( Locale locale ); String problem(); String problem( Locale locale ); String text( Object... arguments ); String text( Locale locale,
                        Object... arguments ); @Override String toString();  }### Answer:
@Test( expected = IllegalArgumentException.class ) public void shouldFailToInitializeIfNoClassSupplied() { I18n.initialize(null); }
@Test public void shouldInitializeFinalClasses() { I18n.initialize(TestI18nFinal.class); assertThat(TestI18nFinal.testMessage, instanceOf(I18n.class)); }
@Test public void shouldInitializePrivateClasses() { I18n.initialize(TestI18nPrivate.class); assertThat(TestI18nPrivate.testMessage, instanceOf(I18n.class)); }
@Test public void shouldInitializeI18nFields() { I18n.initialize(TestI18n.class); assertThat(TestI18n.testMessage, instanceOf(I18n.class)); }
@Test public void shouldNotInitializeNonI18nFields() { I18n.initialize(TestI18n.class); assertThat(TestI18n.nonI18n, nullValue()); }
@Test public void shouldNotBeLocalizedAfterInitialization() { I18n.initialize(TestI18nDuplicateProperty.class); assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue()); assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue()); }