mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Fix build in localized environments (#2855)
Signed-off-by: Jan N. Klug <github@klug.nrw>
This commit is contained in:
+15
-1
@@ -18,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
@@ -57,6 +58,7 @@ import org.openhab.core.config.core.validation.ConfigValidationException;
|
||||
import org.openhab.core.events.Event;
|
||||
import org.openhab.core.events.EventFilter;
|
||||
import org.openhab.core.events.EventSubscriber;
|
||||
import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.openhab.core.i18n.TranslationProvider;
|
||||
import org.openhab.core.library.CoreItemFactory;
|
||||
import org.openhab.core.test.java.JavaOSGiTest;
|
||||
@@ -74,12 +76,14 @@ import org.openhab.core.thing.binding.builder.BridgeBuilder;
|
||||
import org.openhab.core.thing.binding.builder.ChannelBuilder;
|
||||
import org.openhab.core.thing.binding.builder.ThingBuilder;
|
||||
import org.openhab.core.thing.binding.builder.ThingStatusInfoBuilder;
|
||||
import org.openhab.core.thing.testutil.i18n.DefaultLocaleSetter;
|
||||
import org.openhab.core.thing.type.ThingType;
|
||||
import org.openhab.core.thing.type.ThingTypeBuilder;
|
||||
import org.openhab.core.thing.type.ThingTypeRegistry;
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.RefreshType;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.service.cm.ConfigurationAdmin;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
|
||||
/**
|
||||
@@ -103,11 +107,21 @@ public class BindingBaseClassesOSGiTest extends JavaOSGiTest {
|
||||
|
||||
private @NonNullByDefault({}) ManagedThingProvider managedThingProvider;
|
||||
private @NonNullByDefault({}) ThingRegistry thingRegistry;
|
||||
private @NonNullByDefault({}) ConfigurationAdmin configurationAdmin;
|
||||
|
||||
private @Mock @NonNullByDefault({}) ComponentContext componentContextMock;
|
||||
|
||||
@BeforeEach
|
||||
public void beforeEach() {
|
||||
public void beforeEach() throws IOException {
|
||||
configurationAdmin = getService(ConfigurationAdmin.class);
|
||||
assertNotNull(configurationAdmin);
|
||||
|
||||
LocaleProvider localeProvider = getService(LocaleProvider.class);
|
||||
assertThat(localeProvider, is(notNullValue()));
|
||||
|
||||
new DefaultLocaleSetter(configurationAdmin).setDefaultLocale(Locale.ENGLISH);
|
||||
waitForAssert(() -> assertThat(localeProvider.getLocale(), is(Locale.ENGLISH)));
|
||||
|
||||
registerVolatileStorageService();
|
||||
managedThingProvider = getService(ManagedThingProvider.class);
|
||||
assertThat(managedThingProvider, is(notNullValue()));
|
||||
|
||||
+9
-1
@@ -19,6 +19,7 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
@@ -133,7 +134,7 @@ public class ThingManagerOSGiTest extends JavaOSGiTest {
|
||||
|
||||
@BeforeEach
|
||||
@SuppressWarnings("null")
|
||||
public void setUp() {
|
||||
public void setUp() throws IOException {
|
||||
thing = ThingBuilder.create(THING_TYPE_UID, THING_UID)
|
||||
.withChannels(ChannelBuilder.create(CHANNEL_UID, CoreItemFactory.SWITCH).withKind(ChannelKind.STATE)
|
||||
.withType(CHANNEL_TYPE_UID).build())
|
||||
@@ -144,6 +145,12 @@ public class ThingManagerOSGiTest extends JavaOSGiTest {
|
||||
configurationAdmin = getService(ConfigurationAdmin.class);
|
||||
assertNotNull(configurationAdmin);
|
||||
|
||||
LocaleProvider localeProvider = getService(LocaleProvider.class);
|
||||
assertThat(localeProvider, is(notNullValue()));
|
||||
|
||||
new DefaultLocaleSetter(configurationAdmin).setDefaultLocale(Locale.ENGLISH);
|
||||
waitForAssert(() -> assertThat(localeProvider.getLocale(), is(Locale.ENGLISH)));
|
||||
|
||||
channelTypeProvider = mock(ChannelTypeProvider.class);
|
||||
when(channelTypeProvider.getChannelType(any(ChannelTypeUID.class), nullable(Locale.class)))
|
||||
.thenReturn(ChannelTypeBuilder.state(CHANNEL_TYPE_UID, "label", CoreItemFactory.SWITCH).build());
|
||||
@@ -1565,6 +1572,7 @@ public class ThingManagerOSGiTest extends JavaOSGiTest {
|
||||
.create(ThingStatus.UNINITIALIZED, ThingStatusDetail.HANDLER_CONFIGURATION_PENDING)
|
||||
.withDescription("{parameter=The parameter is required.}").build();
|
||||
verify(thingHandler, never()).initialize();
|
||||
|
||||
assertThat(thing.getStatusInfo(), is(uninitializedPending));
|
||||
|
||||
// set required configuration parameter
|
||||
|
||||
Reference in New Issue
Block a user