Translator { public String getString(String key) { if (key == null) { throw new NullPointerException("Key is null"); } if (localizationDisabled) { return key; } if (bundle == null) { return key; } try { return bundle.getString(key); } catch (MissingResourceException e) { return key; } } private  Translator(); static Translator getInstance(); String getString(String key); void setLocale(Locale locale); void setLocalizationDisabled(boolean localizationDisabled);  }
@Test public void testStd() { String output = translator.getString("greet"); assertEquals("hi", output); }
@Test public void testMissingKey() { String output = translator.getString("branch"); assertEquals("branch", output); }
@Test(expected = NullPointerException.class) public void testNullKey() { String output = translator.getString(null); }