FrontendTokenDefinitionImpl implements FrontendTokenDefinition { protected String translateJSON(Locale locale) { if (_resourceBundleLoader == null) { return _json; } try { JSONObject jsonObject = _jsonFactory.createJSONObject(_json); translateJSONObject( jsonObject, _resourceBundleLoader.loadResourceBundle(locale)); return _jsonFactory.looseSerializeDeep(jsonObject); } catch (JSONException jsonException) { _log.error( "Unable to parse frontend-token-definition.json for theme " + _themeId, jsonException); } return _json; } FrontendTokenDefinitionImpl(
		String json, JSONFactory jsonFactory,
		ResourceBundleLoader resourceBundleLoader, String themeId); @Override String getJSON(Locale locale); String getThemeId();  }
@Test public void testTranslateJSON() { ResourceBundleLoader resourceBundleLoader = Mockito.mock( ResourceBundleLoader.class); Package pkg = FrontendTokenDefinitionImplTest.class.getPackage(); Mockito.when( resourceBundleLoader.loadResourceBundle(LocaleUtil.ENGLISH) ).thenReturn( ResourceBundle.getBundle( pkg.getName() + ".dependencies.Language", LocaleUtil.ENGLISH) ); FrontendTokenDefinitionImpl frontendTokenDefinitionImpl = new FrontendTokenDefinitionImpl( _FRONTEND_TOKEN_DEFINITION_JSON, new JSONFactoryImpl(), resourceBundleLoader, "theme_id"); String json = frontendTokenDefinitionImpl.translateJSON( LocaleUtil.ENGLISH); Assert.assertEquals(_TRANSLATED_FRONTEND_TOKEN_DEFINITION_JSON, json); }