Skip to content

Commit

Permalink
Re-enable itests after core change
Browse files Browse the repository at this point in the history
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
  • Loading branch information
holgerfriedrich committed May 22, 2023
1 parent d8376aa commit c30c93d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.openhab.core.events.Event;
import org.openhab.core.events.EventFilter;
import org.openhab.core.events.EventSubscriber;
import org.openhab.core.i18n.UnitProvider;
import org.openhab.core.io.transport.modbus.ModbusCommunicationInterface;
import org.openhab.core.io.transport.modbus.ModbusManager;
import org.openhab.core.items.Item;
Expand Down Expand Up @@ -118,6 +119,7 @@ public void receive(Event event) {
private final Logger logger = LoggerFactory.getLogger(AbstractModbusOSGiTest.class);

protected @Mock @NonNullByDefault({}) ModbusManager mockedModbusManager;
protected @Mock @NonNullByDefault({}) UnitProvider mockedUnitProvider;
protected @NonNullByDefault({}) ModbusManager realModbusManager;
protected @NonNullByDefault({}) ManagedThingProvider thingProvider;
protected @NonNullByDefault({}) ManagedItemProvider itemProvider;
Expand Down Expand Up @@ -156,7 +158,7 @@ public void setUpAbstractModbusOSGiTest() {
itemChannelLinkRegistry = getService(ItemChannelLinkRegistry.class);
assertThat("Could not get ItemChannelLinkRegistry", itemChannelLinkRegistry, is(notNullValue()));

coreItemFactory = new CoreItemFactory();
coreItemFactory = new CoreItemFactory(mockedUnitProvider);

// Clean slate for all tests
reset(mockedModbusManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import static org.openhab.binding.mqtt.ruuvigateway.internal.RuuviGatewayBindingConstants.*;

import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -53,12 +54,14 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Mock;
import org.openhab.binding.mqtt.discovery.MQTTTopicDiscoveryService;
import org.openhab.binding.mqtt.ruuvigateway.internal.RuuviGatewayBindingConstants;
import org.openhab.binding.mqtt.ruuvigateway.internal.discovery.RuuviGatewayDiscoveryService;
import org.openhab.binding.mqtt.ruuvigateway.internal.handler.RuuviTagHandler;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.i18n.UnitProvider;
import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
import org.openhab.core.io.transport.mqtt.MqttConnectionObserver;
import org.openhab.core.io.transport.mqtt.MqttConnectionState;
Expand Down Expand Up @@ -95,6 +98,7 @@
*/
@NonNullByDefault
public class RuuviGatewayTest extends MqttOSGiTest {
protected @Mock @NonNullByDefault({}) UnitProvider mockedUnitProvider;
private static final String BASE_TOPIC_RUUVI = "ruuvi";
private static final Map<String, String> CHANNEL_TO_ITEM_TYPE = new HashMap<>();
static {
Expand Down Expand Up @@ -208,7 +212,7 @@ private String itemName(ChannelUID channelUID) {
private String linkChannelToAutogeneratedItem(ChannelUID channelUID) {
String itemName = itemName(channelUID);
String itemType = CHANNEL_TO_ITEM_TYPE.get(channelUID.getId());
GenericItem item = new CoreItemFactory().createItem(itemType, itemName);
GenericItem item = new CoreItemFactory(mockedUnitProvider).createItem(itemType, itemName);
assertNotNull(item, itemType);
itemProvider.add(item);
itemChannelLinkProvider.add(new ItemChannelLink(itemName, channelUID));
Expand Down
8 changes: 2 additions & 6 deletions itests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@
<module>org.openhab.binding.hue.tests</module>
<module>org.openhab.binding.max.tests</module>
<module>org.openhab.binding.mielecloud.tests</module>
<!-- Modbus tests disabled until fixed (CoreItemFactory)
<module>org.openhab.binding.modbus.tests</module>
-->
<module>org.openhab.binding.modbus.tests</module>
<module>org.openhab.binding.mqtt.homeassistant.tests</module>
<module>org.openhab.binding.mqtt.homie.tests</module>
<!-- MQTT ruuvigateway tests disabled until fixed (CoreItemFactory + NumberItem)
<module>org.openhab.binding.mqtt.ruuvigateway.tests</module>
-->
<module>org.openhab.binding.mqtt.ruuvigateway.tests</module>
<module>org.openhab.binding.nest.tests</module>
<module>org.openhab.binding.ntp.tests</module>
<module>org.openhab.binding.systeminfo.tests</module>
Expand Down

0 comments on commit c30c93d

Please sign in to comment.