use of org.openhab.core.i18n.LocaleProvider in project openhab-addons by openhab.
the class NetatmoModuleDiscoveryServiceTest method before.
@BeforeEach
public void before() {
Bridge bridgeMock = mock(Bridge.class);
when(bridgeMock.getUID()).thenReturn(new ThingUID("netatmo", "bridge"));
bridgeHandlerSpy = spy(new NetatmoBridgeHandler(bridgeMock, null));
LocaleProvider localeProviderMock = mock(LocaleProvider.class);
TranslationProvider translationProvider = mock(TranslationProvider.class);
service = new NetatmoModuleDiscoveryServiceAccessible(bridgeHandlerSpy, localeProviderMock, translationProvider);
}
use of org.openhab.core.i18n.LocaleProvider in project openhab-addons by openhab.
the class PS4Handler method updateApplicationTitleid.
/**
* Sets the cached TitleId and tries to download artwork
* for application if CHANNEL_APPLICATION_IMAGE is linked.
*
* @param titleId Id of application.
*/
private void updateApplicationTitleid(String titleId) {
currentApplicationId = titleId;
updateState(CHANNEL_APPLICATION_ID, StringType.valueOf(titleId));
logger.debug("Current application title id: {}", titleId);
if (!isLinked(CHANNEL_APPLICATION_IMAGE)) {
return;
}
LocaleProvider lProvider = localeProvider;
Locale locale = (lProvider != null) ? lProvider.getLocale() : Locale.US;
RawType artWork = PS4ArtworkHandler.fetchArtworkForTitleid(titleId, config.artworkSize, locale);
if (artWork != null) {
currentArtwork = artWork;
updateState(CHANNEL_APPLICATION_IMAGE, artWork);
} else if (!titleId.isEmpty()) {
logger.debug("Couldn't fetch artwork for title id: {}", titleId);
}
}
use of org.openhab.core.i18n.LocaleProvider in project openhab-addons by openhab.
the class OpenHabLanguageProviderTest method whenTheLocaleIsSetToGermanyThenTheLanguageCodeIsDe.
@Test
public void whenTheLocaleIsSetToGermanyThenTheLanguageCodeIsDe() {
// given:
LocaleProvider localeProvider = mock(LocaleProvider.class);
when(localeProvider.getLocale()).thenReturn(Locale.GERMANY);
LanguageProvider languageProvider = new OpenHabLanguageProvider(localeProvider);
// when:
Optional<String> language = languageProvider.getLanguage();
// then:
assertEquals(Optional.of("de"), language);
}
use of org.openhab.core.i18n.LocaleProvider in project openhab-core by openhab.
the class BindingInfoI18nTest method assertUsingDefaultLocale.
@Test
public void assertUsingDefaultLocale() throws Exception {
// Set german locale
ConfigurationAdmin configAdmin = getService(ConfigurationAdmin.class);
assertThat(configAdmin, is(notNullValue()));
Configuration config = configAdmin.getConfiguration(I18nProviderImpl.CONFIGURATION_PID, null);
assertThat(config, is(notNullValue()));
Dictionary<String, Object> properties = config.getProperties();
if (properties == null) {
properties = new Hashtable<>();
}
properties.put("language", "de");
properties.put("region", "DE");
config.update(properties);
// before running the test with a default locale make sure the locale has been set
LocaleProvider localeProvider = getService(LocaleProvider.class);
assertThat(localeProvider, is(notNullValue()));
waitForAssert(() -> assertThat(localeProvider.getLocale().toString(), is("de_DE")));
bindingInstaller.exec(TEST_BUNDLE_NAME, () -> {
// use default locale
Set<BindingInfo> bindingInfos = bindingInfoRegistry.getBindingInfos(null);
BindingInfo bindingInfo = bindingInfos.iterator().next();
assertThat(bindingInfo, is(notNullValue()));
assertThat(bindingInfo.getName(), is("ACME Wetter Binding"));
assertThat(bindingInfo.getDescription(), is("Das ACME Wetter Binding stellt verschiedene Wetterdaten wie die Temperatur, die Luftfeuchtigkeit und den Luftdruck für konfigurierbare Orte vom ACME Wetterdienst bereit"));
});
}
use of org.openhab.core.i18n.LocaleProvider in project openhab-core by openhab.
the class TranslationProviderOSGiTest method setup.
@BeforeEach
public void setup() {
translationProvider = getService(TranslationProvider.class);
LocaleProvider localeProvider = getService(LocaleProvider.class);
Map<String, Object> localeCfg = new HashMap<>();
localeCfg.put("language", "de");
localeCfg.put("region", "DE");
((I18nProviderImpl) localeProvider).modified(localeCfg);
}
Aggregations