Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.mybmw.internal.MyBMWConstants;
Expand Down Expand Up @@ -60,6 +61,16 @@ public VehicleDiscovery() {
super(MyBMWBridgeHandler.class, MyBMWConstants.SUPPORTED_THING_SET, DISCOVERY_TIMEOUT, false);
}

/**
* Constructor for tests only.
*
* @param scheduler the {@link ScheduledExecutorService} to use during testing.
*/
VehicleDiscovery(ScheduledExecutorService scheduler) {
super(scheduler, MyBMWBridgeHandler.class, MyBMWConstants.SUPPORTED_THING_SET, DISCOVERY_TIMEOUT, false, null,
null);
}

@Override
public void initialize() {
thingHandler.setVehicleDiscovery(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.util.SameThreadExecutorService;

import com.google.gson.Gson;

Expand All @@ -56,7 +57,7 @@ public void testDiscovery() {
String content = FileReader.fileToString("responses/vehicles.json");
List<Vehicle> vehicleList = Arrays.asList(new Gson().fromJson(content, Vehicle[].class));

VehicleDiscovery vehicleDiscovery = new VehicleDiscovery();
VehicleDiscovery vehicleDiscovery = new VehicleDiscovery(new SameThreadExecutorService());

MyBMWBridgeHandler bridgeHandler = mock(MyBMWBridgeHandler.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public SatelDeviceDiscoveryService(SatelBridgeHandler bridgeHandler,
*/
SatelDeviceDiscoveryService(ScheduledExecutorService scheduler, SatelBridgeHandler bridgeHandler,
Function<ThingTypeUID, ThingType> thingTypeProvider) {
super(SUPPORTED_THING_TYPES, 60, false);
super(scheduler, SUPPORTED_THING_TYPES, 60, false, null, null);
this.bridgeHandler = bridgeHandler;
this.thingTypeProvider = thingTypeProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openhab.binding.satel.internal.command.ReadDeviceInfoCommand;
Expand Down Expand Up @@ -65,16 +64,14 @@ class SatelDeviceDiscoveryServiceTest {
@Mock
private DiscoveryListener listener;

@Mock
private SameThreadExecutorService scheduler;

@InjectMocks
private SatelDeviceDiscoveryService testSubject;

@BeforeEach
void setUp() {
when(bridgeHandler.getIntegraType()).thenReturn(IntegraType.I24);
when(bridgeHandler.getEncoding()).thenReturn(bridgeEncoding);
testSubject = new SatelDeviceDiscoveryService(new SameThreadExecutorService(), bridgeHandler,
thingTypeProvider);
testSubject.addDiscoveryListener(listener);
}

Expand Down