mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-02-09 13:57:00 +01:00
[boschshc] Code enhancements and Sonar issue fixes (#15160)
* replace call to deprecated HSBType::getRGB() with ColorUtil::hsbTosRgb() * make constructors of abstract classes protected * use instanceof with pattern matching (JEP 305) * enhance switches with combined cases using comma-separated case expressions * remove unnecessary public modifiers in unit tests Signed-off-by: David Pace <dev@davidpace.de>
This commit is contained in:
parent
4775ad2a0d
commit
123982dcc6
@ -37,7 +37,7 @@ public abstract class AbstractBatteryPoweredDeviceHandler extends BoschSHCDevice
|
|||||||
*/
|
*/
|
||||||
private final BatteryLevelService batteryLevelService;
|
private final BatteryLevelService batteryLevelService;
|
||||||
|
|
||||||
public AbstractBatteryPoweredDeviceHandler(Thing thing) {
|
protected AbstractBatteryPoweredDeviceHandler(Thing thing) {
|
||||||
super(thing);
|
super(thing);
|
||||||
this.batteryLevelService = new BatteryLevelService();
|
this.batteryLevelService = new BatteryLevelService();
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ public abstract class AbstractPowerSwitchHandler extends BoschSHCDeviceHandler {
|
|||||||
|
|
||||||
switch (channelUID.getId()) {
|
switch (channelUID.getId()) {
|
||||||
case CHANNEL_POWER_SWITCH:
|
case CHANNEL_POWER_SWITCH:
|
||||||
if (command instanceof OnOffType) {
|
if (command instanceof OnOffType onOffCommand) {
|
||||||
updatePowerSwitchState((OnOffType) command);
|
updatePowerSwitchState(onOffCommand);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public abstract class AbstractSmokeDetectorHandler extends AbstractBatteryPowere
|
|||||||
|
|
||||||
private SmokeDetectorCheckService smokeDetectorCheckService;
|
private SmokeDetectorCheckService smokeDetectorCheckService;
|
||||||
|
|
||||||
public AbstractSmokeDetectorHandler(Thing thing) {
|
protected AbstractSmokeDetectorHandler(Thing thing) {
|
||||||
super(thing);
|
super(thing);
|
||||||
this.smokeDetectorCheckService = new SmokeDetectorCheckService();
|
this.smokeDetectorCheckService = new SmokeDetectorCheckService();
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.boschshc.internal.devices.camera;
|
package org.openhab.binding.boschshc.internal.devices.camera;
|
||||||
|
|
||||||
import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_CAMERA_NOTIFICATION;
|
import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.*;
|
||||||
import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_PRIVACY_MODE;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -77,14 +76,14 @@ public class CameraHandler extends BoschSHCDeviceHandler {
|
|||||||
|
|
||||||
switch (channelUID.getId()) {
|
switch (channelUID.getId()) {
|
||||||
case CHANNEL_PRIVACY_MODE:
|
case CHANNEL_PRIVACY_MODE:
|
||||||
if (command instanceof OnOffType) {
|
if (command instanceof OnOffType onOffCommand) {
|
||||||
updatePrivacyModeState((OnOffType) command);
|
updatePrivacyModeState(onOffCommand);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHANNEL_CAMERA_NOTIFICATION:
|
case CHANNEL_CAMERA_NOTIFICATION:
|
||||||
if (command instanceof OnOffType) {
|
if (command instanceof OnOffType onOffCommand) {
|
||||||
updateCameraNotificationState((OnOffType) command);
|
updateCameraNotificationState(onOffCommand);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -71,31 +71,28 @@ public class ShutterControlHandler extends BoschSHCDeviceHandler {
|
|||||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
if (command instanceof UpDownType) {
|
if (command instanceof UpDownType upDownCommand) {
|
||||||
// Set full close/open as target state
|
// Set full close/open as target state
|
||||||
UpDownType upDownType = (UpDownType) command;
|
|
||||||
ShutterControlServiceState state = new ShutterControlServiceState();
|
ShutterControlServiceState state = new ShutterControlServiceState();
|
||||||
if (upDownType == UpDownType.UP) {
|
if (upDownCommand == UpDownType.UP) {
|
||||||
state.level = 1.0;
|
state.level = 1.0;
|
||||||
} else if (upDownType == UpDownType.DOWN) {
|
} else if (upDownCommand == UpDownType.DOWN) {
|
||||||
state.level = 0.0;
|
state.level = 0.0;
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Received unknown UpDownType command: {}", upDownType);
|
logger.warn("Received unknown UpDownType command: {}", upDownCommand);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.updateServiceState(this.shutterControlService, state);
|
this.updateServiceState(this.shutterControlService, state);
|
||||||
} else if (command instanceof StopMoveType) {
|
} else if (command instanceof StopMoveType stopMoveCommand) {
|
||||||
StopMoveType stopMoveType = (StopMoveType) command;
|
if (stopMoveCommand == StopMoveType.STOP) {
|
||||||
if (stopMoveType == StopMoveType.STOP) {
|
|
||||||
// Set STOPPED operation state
|
// Set STOPPED operation state
|
||||||
ShutterControlServiceState state = new ShutterControlServiceState();
|
ShutterControlServiceState state = new ShutterControlServiceState();
|
||||||
state.operationState = OperationState.STOPPED;
|
state.operationState = OperationState.STOPPED;
|
||||||
this.updateServiceState(this.shutterControlService, state);
|
this.updateServiceState(this.shutterControlService, state);
|
||||||
}
|
}
|
||||||
} else if (command instanceof PercentType) {
|
} else if (command instanceof PercentType percentCommand) {
|
||||||
// Set specific level
|
// Set specific level
|
||||||
PercentType percentType = (PercentType) command;
|
double level = DataConversion.openPercentageToLevel(percentCommand.doubleValue());
|
||||||
double level = DataConversion.openPercentageToLevel(percentType.doubleValue());
|
|
||||||
this.updateServiceState(this.shutterControlService, new ShutterControlServiceState(level));
|
this.updateServiceState(this.shutterControlService, new ShutterControlServiceState(level));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import org.openhab.core.library.types.PercentType;
|
|||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
import org.openhab.core.types.Command;
|
import org.openhab.core.types.Command;
|
||||||
|
import org.openhab.core.util.ColorUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for smart light bulbs connected via Zigbee, e.g. Ledvance Smart+ bulbs
|
* Handler for smart light bulbs connected via Zigbee, e.g. Ledvance Smart+ bulbs
|
||||||
@ -68,38 +69,38 @@ public class SmartBulbHandler extends BoschSHCDeviceHandler {
|
|||||||
|
|
||||||
switch (channelUID.getId()) {
|
switch (channelUID.getId()) {
|
||||||
case CHANNEL_POWER_SWITCH:
|
case CHANNEL_POWER_SWITCH:
|
||||||
if (command instanceof OnOffType) {
|
if (command instanceof OnOffType onOffCommand) {
|
||||||
updateBinarySwitchState((OnOffType) command);
|
updateBinarySwitchState(onOffCommand);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHANNEL_BRIGHTNESS:
|
case CHANNEL_BRIGHTNESS:
|
||||||
if (command instanceof PercentType) {
|
if (command instanceof PercentType percentCommand) {
|
||||||
updateMultiLevelSwitchState((PercentType) command);
|
updateMultiLevelSwitchState(percentCommand);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHANNEL_COLOR:
|
case CHANNEL_COLOR:
|
||||||
if (command instanceof HSBType) {
|
if (command instanceof HSBType hsbCommand) {
|
||||||
updateColorState((HSBType) command);
|
updateColorState(hsbCommand);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBinarySwitchState(OnOffType command) {
|
private void updateBinarySwitchState(OnOffType onOffCommand) {
|
||||||
BinarySwitchServiceState serviceState = new BinarySwitchServiceState();
|
BinarySwitchServiceState serviceState = new BinarySwitchServiceState();
|
||||||
serviceState.on = command == OnOffType.ON;
|
serviceState.on = onOffCommand == OnOffType.ON;
|
||||||
this.updateServiceState(binarySwitchService, serviceState);
|
this.updateServiceState(binarySwitchService, serviceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMultiLevelSwitchState(PercentType command) {
|
private void updateMultiLevelSwitchState(PercentType percentCommand) {
|
||||||
MultiLevelSwitchServiceState serviceState = new MultiLevelSwitchServiceState();
|
MultiLevelSwitchServiceState serviceState = new MultiLevelSwitchServiceState();
|
||||||
serviceState.level = command.intValue();
|
serviceState.level = percentCommand.intValue();
|
||||||
this.updateServiceState(multiLevelSwitchService, serviceState);
|
this.updateServiceState(multiLevelSwitchService, serviceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateColorState(HSBType command) {
|
private void updateColorState(HSBType hsbCommand) {
|
||||||
HSBColorActuatorServiceState serviceState = new HSBColorActuatorServiceState();
|
HSBColorActuatorServiceState serviceState = new HSBColorActuatorServiceState();
|
||||||
serviceState.rgb = command.getRGB();
|
serviceState.rgb = ColorUtil.hsbTosRgb(hsbCommand);
|
||||||
this.updateServiceState(hsbColorActuatorService, serviceState);
|
this.updateServiceState(hsbColorActuatorService, serviceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +88,7 @@ public enum BatteryLevel {
|
|||||||
switch (this) {
|
switch (this) {
|
||||||
case LOW_BATTERY:
|
case LOW_BATTERY:
|
||||||
return new DecimalType(10);
|
return new DecimalType(10);
|
||||||
case CRITICAL_LOW:
|
case CRITICAL_LOW, CRITICALLY_LOW_BATTERY:
|
||||||
case CRITICALLY_LOW_BATTERY:
|
|
||||||
return new DecimalType(1);
|
return new DecimalType(1);
|
||||||
case NOT_AVAILABLE:
|
case NOT_AVAILABLE:
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
@ -108,9 +107,7 @@ public enum BatteryLevel {
|
|||||||
*/
|
*/
|
||||||
public OnOffType toLowBatteryState() {
|
public OnOffType toLowBatteryState() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case LOW_BATTERY:
|
case LOW_BATTERY, CRITICAL_LOW, CRITICALLY_LOW_BATTERY:
|
||||||
case CRITICAL_LOW:
|
|
||||||
case CRITICALLY_LOW_BATTERY:
|
|
||||||
return OnOffType.ON;
|
return OnOffType.ON;
|
||||||
default:
|
default:
|
||||||
return OnOffType.OFF;
|
return OnOffType.OFF;
|
||||||
|
@ -26,7 +26,7 @@ public enum SilentModeState {
|
|||||||
MODE_NORMAL,
|
MODE_NORMAL,
|
||||||
MODE_SILENT;
|
MODE_SILENT;
|
||||||
|
|
||||||
public static SilentModeState fromOnOffType(OnOffType onOffType) {
|
public static SilentModeState fromOnOffType(OnOffType onOffCommand) {
|
||||||
return onOffType == OnOffType.ON ? SilentModeState.MODE_SILENT : SilentModeState.MODE_NORMAL;
|
return onOffCommand == OnOffType.ON ? SilentModeState.MODE_SILENT : SilentModeState.MODE_NORMAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import org.openhab.core.thing.ThingTypeUID;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class BoschSHCHandlerFactoryTest {
|
class BoschSHCHandlerFactoryTest {
|
||||||
|
|
||||||
private @NonNullByDefault({}) BoschSHCHandlerFactory fixture;
|
private @NonNullByDefault({}) BoschSHCHandlerFactory fixture;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class BoschSHCHandlerFactoryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSupportsThingType() {
|
void testSupportsThingType() {
|
||||||
assertTrue(fixture.supportsThingType(BoschSHCBindingConstants.THING_TYPE_SHC));
|
assertTrue(fixture.supportsThingType(BoschSHCBindingConstants.THING_TYPE_SHC));
|
||||||
assertTrue(fixture.supportsThingType(BoschSHCBindingConstants.THING_TYPE_INWALL_SWITCH));
|
assertTrue(fixture.supportsThingType(BoschSHCBindingConstants.THING_TYPE_INWALL_SWITCH));
|
||||||
assertTrue(fixture.supportsThingType(BoschSHCBindingConstants.THING_TYPE_TWINGUARD));
|
assertTrue(fixture.supportsThingType(BoschSHCBindingConstants.THING_TYPE_TWINGUARD));
|
||||||
@ -60,7 +60,7 @@ public class BoschSHCHandlerFactoryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateHandler() {
|
void testCreateHandler() {
|
||||||
Thing thing = mock(Thing.class);
|
Thing thing = mock(Thing.class);
|
||||||
when(thing.getThingTypeUID()).thenReturn(BoschSHCBindingConstants.THING_TYPE_SMART_PLUG_COMPACT);
|
when(thing.getThingTypeUID()).thenReturn(BoschSHCBindingConstants.THING_TYPE_SMART_PLUG_COMPACT);
|
||||||
assertTrue(fixture.createHandler(thing) instanceof PlugHandler);
|
assertTrue(fixture.createHandler(thing) instanceof PlugHandler);
|
||||||
|
@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class BridgeConfigurationTest {
|
class BridgeConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testConstructor() {
|
void testConstructor() {
|
||||||
|
@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class JsonRpcRequestTest {
|
class JsonRpcRequestTest {
|
||||||
|
|
||||||
private @NonNullByDefault({}) JsonRpcRequest fixture;
|
private @NonNullByDefault({}) JsonRpcRequest fixture;
|
||||||
|
|
||||||
@ -35,14 +35,14 @@ public class JsonRpcRequestTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructor() {
|
void testConstructor() {
|
||||||
assertEquals("2.0", fixture.getJsonrpc());
|
assertEquals("2.0", fixture.getJsonrpc());
|
||||||
assertEquals("RE/longPoll", fixture.getMethod());
|
assertEquals("RE/longPoll", fixture.getMethod());
|
||||||
assertArrayEquals(new String[] { "subscriptionId", "20" }, fixture.getParams());
|
assertArrayEquals(new String[] { "subscriptionId", "20" }, fixture.getParams());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoArgConstructor() {
|
void testNoArgConstructor() {
|
||||||
fixture = new JsonRpcRequest();
|
fixture = new JsonRpcRequest();
|
||||||
assertEquals("", fixture.getJsonrpc());
|
assertEquals("", fixture.getJsonrpc());
|
||||||
assertEquals("", fixture.getMethod());
|
assertEquals("", fixture.getMethod());
|
||||||
@ -50,19 +50,19 @@ public class JsonRpcRequestTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetJsonrpc() {
|
void testSetJsonrpc() {
|
||||||
fixture.setJsonrpc("test");
|
fixture.setJsonrpc("test");
|
||||||
assertEquals("test", fixture.getJsonrpc());
|
assertEquals("test", fixture.getJsonrpc());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetMethod() {
|
void testSetMethod() {
|
||||||
fixture.setMethod("RE/subscribe");
|
fixture.setMethod("RE/subscribe");
|
||||||
assertEquals("RE/subscribe", fixture.getMethod());
|
assertEquals("RE/subscribe", fixture.getMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetParams() {
|
void testSetParams() {
|
||||||
fixture.setParams(new String[] { "com/bosch/sh/remote/*", null });
|
fixture.setParams(new String[] { "com/bosch/sh/remote/*", null });
|
||||||
assertArrayEquals(new String[] { "com/bosch/sh/remote/*", null }, fixture.getParams());
|
assertArrayEquals(new String[] { "com/bosch/sh/remote/*", null }, fixture.getParams());
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ import com.google.gson.JsonObject;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class LongPollingTest {
|
class LongPollingTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dummy implementation of {@link ScheduledFuture}.
|
* A dummy implementation of {@link ScheduledFuture}.
|
||||||
|
@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
* @author David Pace - Initial contribution
|
* @author David Pace - Initial contribution
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DeviceServiceDataTest {
|
class DeviceServiceDataTest {
|
||||||
|
|
||||||
private DeviceServiceData fixture;
|
private DeviceServiceData fixture;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public class DeviceServiceDataTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToString() {
|
void testToString() {
|
||||||
assertEquals("64-da-a0-02-14-9b state: DeviceServiceData", fixture.toString());
|
assertEquals("64-da-a0-02-14-9b state: DeviceServiceData", fixture.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class DeviceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToString() {
|
void testToString() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Type device; RootDeviceId: 64-da-a0-02-14-9b; Id: hdm:HomeMaticIP:3014F711A00004953859F31B; Device Service Ids: PowerMeter, PowerSwitch, PowerSwitchProgram, Routing; Manufacturer: BOSCH; Room Id: hz_3; Device Model: PSM; Serial: 3014F711A00004953859F31B; Profile: GENERIC; Name: Coffee Machine; Status: AVAILABLE; Child Device Ids: null ",
|
"Type device; RootDeviceId: 64-da-a0-02-14-9b; Id: hdm:HomeMaticIP:3014F711A00004953859F31B; Device Service Ids: PowerMeter, PowerSwitch, PowerSwitchProgram, Routing; Manufacturer: BOSCH; Room Id: hz_3; Device Model: PSM; Serial: 3014F711A00004953859F31B; Profile: GENERIC; Name: Coffee Machine; Status: AVAILABLE; Child Device Ids: null ",
|
||||||
fixture.toString());
|
fixture.toString());
|
||||||
|
@ -24,7 +24,7 @@ import org.openhab.binding.boschshc.internal.serialization.GsonUtils;
|
|||||||
* @author Christian Oeing - Initial contribution
|
* @author Christian Oeing - Initial contribution
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class LongPollResultTest {
|
class LongPollResultTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void noResultsForErrorResult() {
|
void noResultsForErrorResult() {
|
||||||
|
@ -44,7 +44,7 @@ import com.google.gson.JsonParser;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class CameraHandlerTest extends AbstractBoschSHCDeviceHandlerTest<CameraHandler> {
|
class CameraHandlerTest extends AbstractBoschSHCDeviceHandlerTest<CameraHandler> {
|
||||||
|
|
||||||
private @Captor @NonNullByDefault({}) ArgumentCaptor<PrivacyModeServiceState> privacyModeServiceStateCaptor;
|
private @Captor @NonNullByDefault({}) ArgumentCaptor<PrivacyModeServiceState> privacyModeServiceStateCaptor;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class CameraHandlerTest extends AbstractBoschSHCDeviceHandlerTest<CameraH
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandPrivacyMode()
|
void testHandleCommandPrivacyMode()
|
||||||
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_PRIVACY_MODE),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_PRIVACY_MODE),
|
||||||
OnOffType.ON);
|
OnOffType.ON);
|
||||||
@ -84,7 +84,7 @@ public class CameraHandlerTest extends AbstractBoschSHCDeviceHandlerTest<CameraH
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandCameraNotification()
|
void testHandleCommandCameraNotification()
|
||||||
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
||||||
getFixture().handleCommand(
|
getFixture().handleCommand(
|
||||||
new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_CAMERA_NOTIFICATION),
|
new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_CAMERA_NOTIFICATION),
|
||||||
@ -104,7 +104,7 @@ public class CameraHandlerTest extends AbstractBoschSHCDeviceHandlerTest<CameraH
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsPrivacyModeState() {
|
void testUpdateChannelsPrivacyModeState() {
|
||||||
JsonElement jsonObject = JsonParser.parseString("{\"@type\":\"privacyModeState\",\"value\":\"ENABLED\"}");
|
JsonElement jsonObject = JsonParser.parseString("{\"@type\":\"privacyModeState\",\"value\":\"ENABLED\"}");
|
||||||
getFixture().processUpdate("PrivacyMode", jsonObject);
|
getFixture().processUpdate("PrivacyMode", jsonObject);
|
||||||
verify(getCallback()).stateUpdated(
|
verify(getCallback()).stateUpdated(
|
||||||
@ -117,7 +117,7 @@ public class CameraHandlerTest extends AbstractBoschSHCDeviceHandlerTest<CameraH
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsCameraNotificationState() {
|
void testUpdateChannelsCameraNotificationState() {
|
||||||
JsonElement jsonObject = JsonParser
|
JsonElement jsonObject = JsonParser
|
||||||
.parseString("{\"@type\":\"cameraNotificationState\",\"value\":\"ENABLED\"}");
|
.parseString("{\"@type\":\"cameraNotificationState\",\"value\":\"ENABLED\"}");
|
||||||
getFixture().processUpdate("CameraNotification", jsonObject);
|
getFixture().processUpdate("CameraNotification", jsonObject);
|
||||||
|
@ -44,7 +44,7 @@ import com.google.gson.JsonParser;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ClimateControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<ClimateControlHandler> {
|
class ClimateControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<ClimateControlHandler> {
|
||||||
|
|
||||||
private @Captor @NonNullByDefault({}) ArgumentCaptor<RoomClimateControlServiceState> roomClimateControlServiceStateCaptor;
|
private @Captor @NonNullByDefault({}) ArgumentCaptor<RoomClimateControlServiceState> roomClimateControlServiceStateCaptor;
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class ClimateControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandRoomClimateControlService()
|
void testHandleCommandRoomClimateControlService()
|
||||||
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
||||||
QuantityType<Temperature> temperature = new QuantityType<>(21.5, SIUnits.CELSIUS);
|
QuantityType<Temperature> temperature = new QuantityType<>(21.5, SIUnits.CELSIUS);
|
||||||
getFixture().handleCommand(
|
getFixture().handleCommand(
|
||||||
@ -77,7 +77,7 @@ public class ClimateControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsTemperatureLevelService() {
|
void testUpdateChannelsTemperatureLevelService() {
|
||||||
JsonElement jsonObject = JsonParser.parseString(
|
JsonElement jsonObject = JsonParser.parseString(
|
||||||
"{\n" + " \"@type\": \"temperatureLevelState\",\n" + " \"temperature\": 21.5\n" + " }");
|
"{\n" + " \"@type\": \"temperatureLevelState\",\n" + " \"temperature\": 21.5\n" + " }");
|
||||||
getFixture().processUpdate("TemperatureLevel", jsonObject);
|
getFixture().processUpdate("TemperatureLevel", jsonObject);
|
||||||
@ -87,7 +87,7 @@ public class ClimateControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsRoomClimateControlService() {
|
void testUpdateChannelsRoomClimateControlService() {
|
||||||
JsonElement jsonObject = JsonParser.parseString(
|
JsonElement jsonObject = JsonParser.parseString(
|
||||||
"{\n" + " \"@type\": \"climateControlState\",\n" + " \"setpointTemperature\": 21.5\n" + " }");
|
"{\n" + " \"@type\": \"climateControlState\",\n" + " \"setpointTemperature\": 21.5\n" + " }");
|
||||||
getFixture().processUpdate("RoomClimateControl", jsonObject);
|
getFixture().processUpdate("RoomClimateControl", jsonObject);
|
||||||
|
@ -41,7 +41,7 @@ import com.google.gson.JsonParser;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<IntrusionDetectionHandler> {
|
class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<IntrusionDetectionHandler> {
|
||||||
|
|
||||||
private @Captor @NonNullByDefault({}) ArgumentCaptor<ArmActionRequest> armActionRequestCaptor;
|
private @Captor @NonNullByDefault({}) ArgumentCaptor<ArmActionRequest> armActionRequestCaptor;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandArmAction() throws InterruptedException, TimeoutException, ExecutionException {
|
void testHandleCommandArmAction() throws InterruptedException, TimeoutException, ExecutionException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_ARM_ACTION),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_ARM_ACTION),
|
||||||
new StringType("0"));
|
new StringType("0"));
|
||||||
verify(getBridgeHandler()).postAction(eq("intrusion/actions/arm"), armActionRequestCaptor.capture());
|
verify(getBridgeHandler()).postAction(eq("intrusion/actions/arm"), armActionRequestCaptor.capture());
|
||||||
@ -65,21 +65,21 @@ public class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandDisarmAction() throws InterruptedException, TimeoutException, ExecutionException {
|
void testHandleCommandDisarmAction() throws InterruptedException, TimeoutException, ExecutionException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_DISARM_ACTION),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_DISARM_ACTION),
|
||||||
OnOffType.ON);
|
OnOffType.ON);
|
||||||
verify(getBridgeHandler()).postAction("intrusion/actions/disarm");
|
verify(getBridgeHandler()).postAction("intrusion/actions/disarm");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandMuteAction() throws InterruptedException, TimeoutException, ExecutionException {
|
void testHandleCommandMuteAction() throws InterruptedException, TimeoutException, ExecutionException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_MUTE_ACTION),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_MUTE_ACTION),
|
||||||
OnOffType.ON);
|
OnOffType.ON);
|
||||||
verify(getBridgeHandler()).postAction("intrusion/actions/mute");
|
verify(getBridgeHandler()).postAction("intrusion/actions/mute");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsIntrusionDetectionSystemState() {
|
void testUpdateChannelsIntrusionDetectionSystemState() {
|
||||||
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"systemState\",\n"
|
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"systemState\",\n"
|
||||||
+ " \"systemAvailability\": {\n" + " \"@type\": \"systemAvailabilityState\",\n"
|
+ " \"systemAvailability\": {\n" + " \"@type\": \"systemAvailabilityState\",\n"
|
||||||
+ " \"available\": true,\n" + " \"deleted\": false\n" + " },\n"
|
+ " \"available\": true,\n" + " \"deleted\": false\n" + " },\n"
|
||||||
@ -108,7 +108,7 @@ public class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsIntrusionDetectionControlState() {
|
void testUpdateChannelsIntrusionDetectionControlState() {
|
||||||
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"intrusionDetectionControlState\",\n"
|
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"intrusionDetectionControlState\",\n"
|
||||||
+ " \"activeProfile\": \"0\",\n" + " \"alarmActivationDelayTime\": 30,\n" + " \"actuators\": [\n"
|
+ " \"activeProfile\": \"0\",\n" + " \"alarmActivationDelayTime\": 30,\n" + " \"actuators\": [\n"
|
||||||
+ " {\n" + " \"readonly\": false,\n" + " \"active\": true,\n"
|
+ " {\n" + " \"readonly\": false,\n" + " \"active\": true,\n"
|
||||||
@ -125,7 +125,7 @@ public class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsSurveillanceAlarmState() {
|
void testUpdateChannelsSurveillanceAlarmState() {
|
||||||
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"surveillanceAlarmState\",\n"
|
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"surveillanceAlarmState\",\n"
|
||||||
+ " \"incidents\": [\n" + " {\n" + " \"triggerName\": \"Motion Detector\",\n"
|
+ " \"incidents\": [\n" + " {\n" + " \"triggerName\": \"Motion Detector\",\n"
|
||||||
+ " \"locationId\": \"hz_5\",\n" + " \"location\": \"Living Room\",\n"
|
+ " \"locationId\": \"hz_5\",\n" + " \"location\": \"Living Room\",\n"
|
||||||
|
@ -32,7 +32,7 @@ import com.google.gson.JsonParser;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class MotionDetectorHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<MotionDetectorHandler> {
|
class MotionDetectorHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<MotionDetectorHandler> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MotionDetectorHandler createFixture() {
|
protected MotionDetectorHandler createFixture() {
|
||||||
@ -50,7 +50,7 @@ public class MotionDetectorHandlerTest extends AbstractBatteryPoweredDeviceHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsLatestMotionService() {
|
void testUpdateChannelsLatestMotionService() {
|
||||||
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"latestMotionState\",\n"
|
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"latestMotionState\",\n"
|
||||||
+ " \"latestMotionDetected\": \"2020-04-03T19:02:19.054Z\"\n" + " }");
|
+ " \"latestMotionDetected\": \"2020-04-03T19:02:19.054Z\"\n" + " }");
|
||||||
getFixture().processUpdate("LatestMotion", jsonObject);
|
getFixture().processUpdate("LatestMotion", jsonObject);
|
||||||
|
@ -44,7 +44,7 @@ import com.google.gson.JsonParser;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ShutterControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<ShutterControlHandler> {
|
class ShutterControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<ShutterControlHandler> {
|
||||||
|
|
||||||
private @Captor @NonNullByDefault({}) ArgumentCaptor<ShutterControlServiceState> shutterControlServiceStateCaptor;
|
private @Captor @NonNullByDefault({}) ArgumentCaptor<ShutterControlServiceState> shutterControlServiceStateCaptor;
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class ShutterControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandUpDownType()
|
void testHandleCommandUpDownType()
|
||||||
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LEVEL),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LEVEL),
|
||||||
UpDownType.UP);
|
UpDownType.UP);
|
||||||
@ -82,7 +82,7 @@ public class ShutterControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandStopMoveType()
|
void testHandleCommandStopMoveType()
|
||||||
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LEVEL),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LEVEL),
|
||||||
StopMoveType.STOP);
|
StopMoveType.STOP);
|
||||||
@ -93,7 +93,7 @@ public class ShutterControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandPercentType()
|
void testHandleCommandPercentType()
|
||||||
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LEVEL),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LEVEL),
|
||||||
new PercentType(42));
|
new PercentType(42));
|
||||||
@ -104,7 +104,7 @@ public class ShutterControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsShutterControlService() {
|
void testUpdateChannelsShutterControlService() {
|
||||||
JsonElement jsonObject = JsonParser
|
JsonElement jsonObject = JsonParser
|
||||||
.parseString("{\n" + " \"@type\": \"shutterControlState\",\n" + " \"level\": 0.58\n" + " }");
|
.parseString("{\n" + " \"@type\": \"shutterControlState\",\n" + " \"level\": 0.58\n" + " }");
|
||||||
getFixture().processUpdate("ShutterControl", jsonObject);
|
getFixture().processUpdate("ShutterControl", jsonObject);
|
||||||
|
@ -46,7 +46,7 @@ import com.google.gson.JsonParser;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<SmartBulbHandler> {
|
class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<SmartBulbHandler> {
|
||||||
|
|
||||||
private @Captor @NonNullByDefault({}) ArgumentCaptor<BinarySwitchServiceState> binarySwitchServiceStateCaptor;
|
private @Captor @NonNullByDefault({}) ArgumentCaptor<BinarySwitchServiceState> binarySwitchServiceStateCaptor;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<Smar
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandBinarySwitch()
|
void testHandleCommandBinarySwitch()
|
||||||
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_POWER_SWITCH),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_POWER_SWITCH),
|
||||||
OnOffType.ON);
|
OnOffType.ON);
|
||||||
@ -88,7 +88,7 @@ public class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<Smar
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandMultiLevelSwitch()
|
void testHandleCommandMultiLevelSwitch()
|
||||||
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_BRIGHTNESS),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_BRIGHTNESS),
|
||||||
new PercentType(42));
|
new PercentType(42));
|
||||||
@ -99,7 +99,7 @@ public class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<Smar
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleCommandHSBColorActuator()
|
void testHandleCommandHSBColorActuator()
|
||||||
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
|
||||||
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_COLOR),
|
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_COLOR),
|
||||||
HSBType.BLUE);
|
HSBType.BLUE);
|
||||||
@ -110,7 +110,7 @@ public class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<Smar
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelBinarySwitchState() {
|
void testUpdateChannelBinarySwitchState() {
|
||||||
JsonElement jsonObject = JsonParser.parseString("{\"@type\":\"binarySwitchState\",\"on\":true}");
|
JsonElement jsonObject = JsonParser.parseString("{\"@type\":\"binarySwitchState\",\"on\":true}");
|
||||||
getFixture().processUpdate("BinarySwitch", jsonObject);
|
getFixture().processUpdate("BinarySwitch", jsonObject);
|
||||||
verify(getCallback()).stateUpdated(
|
verify(getCallback()).stateUpdated(
|
||||||
@ -123,7 +123,7 @@ public class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<Smar
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelMultiLevelSwitchState() {
|
void testUpdateChannelMultiLevelSwitchState() {
|
||||||
JsonElement jsonObject = JsonParser.parseString("{\"@type\":\"multiLevelSwitchState\",\"level\":16}");
|
JsonElement jsonObject = JsonParser.parseString("{\"@type\":\"multiLevelSwitchState\",\"level\":16}");
|
||||||
getFixture().processUpdate("MultiLevelSwitch", jsonObject);
|
getFixture().processUpdate("MultiLevelSwitch", jsonObject);
|
||||||
verify(getCallback()).stateUpdated(
|
verify(getCallback()).stateUpdated(
|
||||||
@ -131,7 +131,7 @@ public class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<Smar
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelHSBColorActuatorState() {
|
void testUpdateChannelHSBColorActuatorState() {
|
||||||
JsonElement jsonObject = JsonParser.parseString("{\"colorTemperatureRange\": {\n" + " \"minCt\": 153,\n"
|
JsonElement jsonObject = JsonParser.parseString("{\"colorTemperatureRange\": {\n" + " \"minCt\": 153,\n"
|
||||||
+ " \"maxCt\": 526\n" + " },\n" + " \"@type\": \"colorState\",\n"
|
+ " \"maxCt\": 526\n" + " },\n" + " \"@type\": \"colorState\",\n"
|
||||||
+ " \"gamut\": \"LEDVANCE_GAMUT_A\",\n" + " \"rgb\": -12427}");
|
+ " \"gamut\": \"LEDVANCE_GAMUT_A\",\n" + " \"rgb\": -12427}");
|
||||||
|
@ -38,7 +38,7 @@ import com.google.gson.JsonParser;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class TwinguardHandlerTest extends AbstractSmokeDetectorHandlerTest<TwinguardHandler> {
|
class TwinguardHandlerTest extends AbstractSmokeDetectorHandlerTest<TwinguardHandler> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TwinguardHandler createFixture() {
|
protected TwinguardHandler createFixture() {
|
||||||
@ -56,7 +56,7 @@ public class TwinguardHandlerTest extends AbstractSmokeDetectorHandlerTest<Twing
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsAirQualityLevelService() {
|
void testUpdateChannelsAirQualityLevelService() {
|
||||||
JsonElement jsonObject = JsonParser.parseString(
|
JsonElement jsonObject = JsonParser.parseString(
|
||||||
"{\"temperatureRating\":\"GOOD\",\"humidityRating\":\"MEDIUM\",\"purity\":620,\"@type\":\"airQualityLevelState\",\n"
|
"{\"temperatureRating\":\"GOOD\",\"humidityRating\":\"MEDIUM\",\"purity\":620,\"@type\":\"airQualityLevelState\",\n"
|
||||||
+ " \"purityRating\":\"GOOD\",\"temperature\":23.77,\"description\":\"LITTLE_DRY\",\"humidity\":32.69,\"combinedRating\":\"MEDIUM\"}");
|
+ " \"purityRating\":\"GOOD\",\"temperature\":23.77,\"description\":\"LITTLE_DRY\",\"humidity\":32.69,\"combinedRating\":\"MEDIUM\"}");
|
||||||
|
@ -37,7 +37,7 @@ import com.google.gson.JsonParser;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class WallThermostatHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<WallThermostatHandler> {
|
class WallThermostatHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<WallThermostatHandler> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WallThermostatHandler createFixture() {
|
protected WallThermostatHandler createFixture() {
|
||||||
@ -55,7 +55,7 @@ public class WallThermostatHandlerTest extends AbstractBatteryPoweredDeviceHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsTemperatureLevelService() {
|
void testUpdateChannelsTemperatureLevelService() {
|
||||||
JsonElement jsonObject = JsonParser.parseString(
|
JsonElement jsonObject = JsonParser.parseString(
|
||||||
"{\n" + " \"@type\": \"temperatureLevelState\",\n" + " \"temperature\": 21.5\n" + " }");
|
"{\n" + " \"@type\": \"temperatureLevelState\",\n" + " \"temperature\": 21.5\n" + " }");
|
||||||
getFixture().processUpdate("TemperatureLevel", jsonObject);
|
getFixture().processUpdate("TemperatureLevel", jsonObject);
|
||||||
@ -65,7 +65,7 @@ public class WallThermostatHandlerTest extends AbstractBatteryPoweredDeviceHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsHumidityLevelService() {
|
void testUpdateChannelsHumidityLevelService() {
|
||||||
JsonElement jsonObject = JsonParser
|
JsonElement jsonObject = JsonParser
|
||||||
.parseString("{\n" + " \"@type\": \"humidityLevelState\",\n" + " \"humidity\": 42.5\n" + " }");
|
.parseString("{\n" + " \"@type\": \"humidityLevelState\",\n" + " \"humidity\": 42.5\n" + " }");
|
||||||
getFixture().processUpdate("HumidityLevel", jsonObject);
|
getFixture().processUpdate("HumidityLevel", jsonObject);
|
||||||
|
@ -32,7 +32,7 @@ import com.google.gson.JsonParser;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class WindowContactHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<WindowContactHandler> {
|
class WindowContactHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<WindowContactHandler> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WindowContactHandler createFixture() {
|
protected WindowContactHandler createFixture() {
|
||||||
@ -50,7 +50,7 @@ public class WindowContactHandlerTest extends AbstractBatteryPoweredDeviceHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateChannelsShutterContactService() {
|
void testUpdateChannelsShutterContactService() {
|
||||||
JsonElement jsonObject = JsonParser
|
JsonElement jsonObject = JsonParser
|
||||||
.parseString("{\n" + " \"@type\": \"shutterContactState\",\n" + " \"value\": \"OPEN\"\n" + " }");
|
.parseString("{\n" + " \"@type\": \"shutterContactState\",\n" + " \"value\": \"OPEN\"\n" + " }");
|
||||||
getFixture().processUpdate("ShutterContact", jsonObject);
|
getFixture().processUpdate("ShutterContact", jsonObject);
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.boschshc.internal.discovery;
|
package org.openhab.binding.boschshc.internal.discovery;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import javax.jmdns.ServiceInfo;
|
import javax.jmdns.ServiceInfo;
|
||||||
@ -45,7 +46,7 @@ import org.openhab.core.thing.ThingUID;
|
|||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class BridgeDiscoveryParticipantTest {
|
class BridgeDiscoveryParticipantTest {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private BridgeDiscoveryParticipant fixture;
|
private BridgeDiscoveryParticipant fixture;
|
||||||
@ -82,7 +83,7 @@ public class BridgeDiscoveryParticipantTest {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSupportedThingTypeUIDs() {
|
void testGetSupportedThingTypeUIDs() {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
assertTrue(fixture.getSupportedThingTypeUIDs().contains(BoschSHCBindingConstants.THING_TYPE_SHC));
|
assertTrue(fixture.getSupportedThingTypeUIDs().contains(BoschSHCBindingConstants.THING_TYPE_SHC));
|
||||||
}
|
}
|
||||||
@ -93,13 +94,13 @@ public class BridgeDiscoveryParticipantTest {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetServiceType() throws Exception {
|
void testGetServiceType() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
assertThat(fixture.getServiceType(), is("_http._tcp.local."));
|
assertThat(fixture.getServiceType(), is("_http._tcp.local."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateResult() throws Exception {
|
void testCreateResult() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
DiscoveryResult result = fixture.createResult(shcBridge);
|
DiscoveryResult result = fixture.createResult(shcBridge);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
@ -110,14 +111,14 @@ public class BridgeDiscoveryParticipantTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateResultOtherDevice() throws Exception {
|
void testCreateResultOtherDevice() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
DiscoveryResult result = fixture.createResult(otherDevice);
|
DiscoveryResult result = fixture.createResult(otherDevice);
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetThingUID() throws Exception {
|
void testGetThingUID() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
ThingUID thingUID = fixture.getThingUID(shcBridge);
|
ThingUID thingUID = fixture.getThingUID(shcBridge);
|
||||||
assertNotNull(thingUID);
|
assertNotNull(thingUID);
|
||||||
@ -126,32 +127,32 @@ public class BridgeDiscoveryParticipantTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetThingUIDOtherDevice() throws Exception {
|
void testGetThingUIDOtherDevice() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
assertNull(fixture.getThingUID(otherDevice));
|
assertNull(fixture.getThingUID(otherDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBridgeAddress() throws Exception {
|
void testGetBridgeAddress() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
assertThat(fixture.discoverBridge(shcBridge).shcIpAddress, is("192.168.0.123"));
|
assertThat(fixture.discoverBridge(shcBridge).shcIpAddress, is("192.168.0.123"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBridgeAddressOtherDevice() throws Exception {
|
void testGetBridgeAddressOtherDevice() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
assertThat(fixture.discoverBridge(otherDevice).shcIpAddress, is(""));
|
assertThat(fixture.discoverBridge(otherDevice).shcIpAddress, is(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPublicInformationFromPossibleBridgeAddress() throws Exception {
|
void testGetPublicInformationFromPossibleBridgeAddress() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
assertThat(fixture.getPublicInformationFromPossibleBridgeAddress("192.168.0.123").shcIpAddress,
|
assertThat(fixture.getPublicInformationFromPossibleBridgeAddress("192.168.0.123").shcIpAddress,
|
||||||
is("192.168.0.123"));
|
is("192.168.0.123"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPublicInformationFromPossibleBridgeAddressInvalidContent() throws Exception {
|
void testGetPublicInformationFromPossibleBridgeAddressInvalidContent() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
|
|
||||||
ContentResponse contentResponse = mock(ContentResponse.class);
|
ContentResponse contentResponse = mock(ContentResponse.class);
|
||||||
@ -170,7 +171,7 @@ public class BridgeDiscoveryParticipantTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPublicInformationFromPossibleBridgeAddressInvalidStatus() throws Exception {
|
void testGetPublicInformationFromPossibleBridgeAddressInvalidStatus() throws Exception {
|
||||||
assert fixture != null;
|
assert fixture != null;
|
||||||
|
|
||||||
ContentResponse contentResponse = mock(ContentResponse.class);
|
ContentResponse contentResponse = mock(ContentResponse.class);
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.boschshc.internal.discovery;
|
package org.openhab.binding.boschshc.internal.discovery;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -44,7 +45,7 @@ import org.openhab.core.thing.ThingUID;
|
|||||||
*/
|
*/
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ThingDiscoveryServiceTest {
|
class ThingDiscoveryServiceTest {
|
||||||
|
|
||||||
private @NonNullByDefault({}) ThingDiscoveryService fixture;
|
private @NonNullByDefault({}) ThingDiscoveryService fixture;
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ public class ThingDiscoveryServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStartScan() throws InterruptedException {
|
void testStartScan() throws InterruptedException {
|
||||||
mockBridgeCalls();
|
mockBridgeCalls();
|
||||||
|
|
||||||
fixture.activate();
|
fixture.activate();
|
||||||
@ -83,7 +84,7 @@ public class ThingDiscoveryServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStartScanWithoutBridgeHandler() {
|
void testStartScanWithoutBridgeHandler() {
|
||||||
mockBridgeCalls();
|
mockBridgeCalls();
|
||||||
|
|
||||||
// No fixture.setThingHandler(bridgeHandler);
|
// No fixture.setThingHandler(bridgeHandler);
|
||||||
@ -96,13 +97,13 @@ public class ThingDiscoveryServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetGetThingHandler() {
|
void testSetGetThingHandler() {
|
||||||
fixture.setThingHandler(bridgeHandler);
|
fixture.setThingHandler(bridgeHandler);
|
||||||
assertThat(fixture.getThingHandler(), is(bridgeHandler));
|
assertThat(fixture.getThingHandler(), is(bridgeHandler));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddDevices() {
|
void testAddDevices() {
|
||||||
mockBridgeCalls();
|
mockBridgeCalls();
|
||||||
|
|
||||||
ArrayList<Device> devices = new ArrayList<>();
|
ArrayList<Device> devices = new ArrayList<>();
|
||||||
@ -128,7 +129,7 @@ public class ThingDiscoveryServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddDevicesWithNoDevices() {
|
void testAddDevicesWithNoDevices() {
|
||||||
ArrayList<Device> emptyDevices = new ArrayList<>();
|
ArrayList<Device> emptyDevices = new ArrayList<>();
|
||||||
ArrayList<Room> emptyRooms = new ArrayList<>();
|
ArrayList<Room> emptyRooms = new ArrayList<>();
|
||||||
|
|
||||||
@ -141,7 +142,7 @@ public class ThingDiscoveryServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddDevice() {
|
void testAddDevice() {
|
||||||
mockBridgeCalls();
|
mockBridgeCalls();
|
||||||
|
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
@ -159,26 +160,26 @@ public class ThingDiscoveryServiceTest {
|
|||||||
assertThat(result.getThingUID().getId(), is("testDevice_ID"));
|
assertThat(result.getThingUID().getId(), is("testDevice_ID"));
|
||||||
assertThat(result.getBridgeUID().getId(), is("testSHC"));
|
assertThat(result.getBridgeUID().getId(), is("testSHC"));
|
||||||
assertThat(result.getLabel(), is("Test Name"));
|
assertThat(result.getLabel(), is("Test Name"));
|
||||||
assertThat(result.getProperties().get("Location").toString(), is("TestRoom"));
|
assertThat(String.valueOf(result.getProperties().get("Location")), is("TestRoom"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddDeviceWithNiceNameAndAppendedRoomName() {
|
void testAddDeviceWithNiceNameAndAppendedRoomName() {
|
||||||
assertDeviceNiceName("-RoomClimateControl-", "TestRoom", "Room Climate Control TestRoom");
|
assertDeviceNiceName("-RoomClimateControl-", "TestRoom", "Room Climate Control TestRoom");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddDeviceWithNiceNameWithEmtpyRoomName() {
|
void testAddDeviceWithNiceNameWithEmtpyRoomName() {
|
||||||
assertDeviceNiceName("-RoomClimateControl-", "", "Room Climate Control");
|
assertDeviceNiceName("-RoomClimateControl-", "", "Room Climate Control");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddDeviceWithNiceNameWithoutAppendingRoomName() {
|
void testAddDeviceWithNiceNameWithoutAppendingRoomName() {
|
||||||
assertDeviceNiceName("-SmokeDetectionSystem-", "TestRoom", "Smoke Detection System");
|
assertDeviceNiceName("-SmokeDetectionSystem-", "TestRoom", "Smoke Detection System");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddDeviceWithNiceNameWithoutUsualName() {
|
void testAddDeviceWithNiceNameWithoutUsualName() {
|
||||||
assertDeviceNiceName("My other device", "TestRoom", "My other device");
|
assertDeviceNiceName("My other device", "TestRoom", "My other device");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +198,7 @@ public class ThingDiscoveryServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRoomForDevice() {
|
void testGetRoomForDevice() {
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
|
|
||||||
ArrayList<Room> rooms = new ArrayList<>();
|
ArrayList<Room> rooms = new ArrayList<>();
|
||||||
@ -221,7 +222,7 @@ public class ThingDiscoveryServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetThingTypeUID() {
|
void testGetThingTypeUID() {
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
|
|
||||||
device.deviceModel = "invalid";
|
device.deviceModel = "invalid";
|
||||||
|
@ -24,10 +24,10 @@ import org.junit.jupiter.api.Test;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class LongPollingFailedExceptionTest {
|
class LongPollingFailedExceptionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructor() {
|
void testConstructor() {
|
||||||
RuntimeException testException = new RuntimeException("test exception");
|
RuntimeException testException = new RuntimeException("test exception");
|
||||||
LongPollingFailedException longPollingFailedException = new LongPollingFailedException("message",
|
LongPollingFailedException longPollingFailedException = new LongPollingFailedException("message",
|
||||||
testException);
|
testException);
|
||||||
|
@ -24,10 +24,10 @@ import org.junit.jupiter.api.Test;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class PairingFailedExceptionTest {
|
class PairingFailedExceptionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructor() {
|
void testConstructor() {
|
||||||
PairingFailedException fixture = new PairingFailedException();
|
PairingFailedException fixture = new PairingFailedException();
|
||||||
assertNotNull(fixture);
|
assertNotNull(fixture);
|
||||||
assertNull(fixture.getMessage());
|
assertNull(fixture.getMessage());
|
||||||
@ -35,7 +35,7 @@ public class PairingFailedExceptionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructorWithMessage() {
|
void testConstructorWithMessage() {
|
||||||
PairingFailedException fixture = new PairingFailedException("message");
|
PairingFailedException fixture = new PairingFailedException("message");
|
||||||
assertNotNull(fixture);
|
assertNotNull(fixture);
|
||||||
assertEquals("message", fixture.getMessage());
|
assertEquals("message", fixture.getMessage());
|
||||||
@ -43,7 +43,7 @@ public class PairingFailedExceptionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructorWithMessageAndCause() {
|
void testConstructorWithMessageAndCause() {
|
||||||
RuntimeException testException = new RuntimeException("test exception");
|
RuntimeException testException = new RuntimeException("test exception");
|
||||||
PairingFailedException fixture = new PairingFailedException("message", testException);
|
PairingFailedException fixture = new PairingFailedException("message", testException);
|
||||||
assertNotNull(fixture);
|
assertNotNull(fixture);
|
||||||
|
@ -23,7 +23,7 @@ import org.openhab.core.library.types.OnOffType;
|
|||||||
* @author David Pace - Initial contribution
|
* @author David Pace - Initial contribution
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BinarySwitchServiceStateTest {
|
class BinarySwitchServiceStateTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testToOnOffType() {
|
void testToOnOffType() {
|
||||||
|
@ -48,10 +48,10 @@ class TestState2 extends BoschSHCServiceState {
|
|||||||
* @author Christian Oeing - Initial contribution
|
* @author Christian Oeing - Initial contribution
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class BoschSHCServiceStateTest {
|
class BoschSHCServiceStateTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fromJsonNullStateForDifferentType() {
|
void fromJsonNullStateForDifferentType() {
|
||||||
var state = BoschSHCServiceState.fromJson(
|
var state = BoschSHCServiceState.fromJson(
|
||||||
GsonUtils.DEFAULT_GSON_INSTANCE.fromJson("{\"@type\":\"differentState\"}", JsonObject.class),
|
GsonUtils.DEFAULT_GSON_INSTANCE.fromJson("{\"@type\":\"differentState\"}", JsonObject.class),
|
||||||
TestState.class);
|
TestState.class);
|
||||||
@ -59,7 +59,7 @@ public class BoschSHCServiceStateTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fromJsonStateObjectForValidJson() {
|
void fromJsonStateObjectForValidJson() {
|
||||||
var state = BoschSHCServiceState.fromJson(
|
var state = BoschSHCServiceState.fromJson(
|
||||||
GsonUtils.DEFAULT_GSON_INSTANCE.fromJson("{\"@type\":\"testState\"}", JsonObject.class),
|
GsonUtils.DEFAULT_GSON_INSTANCE.fromJson("{\"@type\":\"testState\"}", JsonObject.class),
|
||||||
TestState.class);
|
TestState.class);
|
||||||
@ -70,7 +70,7 @@ public class BoschSHCServiceStateTest {
|
|||||||
* This checks for a bug we had where the expected type stayed the same for different state classes
|
* This checks for a bug we had where the expected type stayed the same for different state classes
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void fromJsonStateObjectForValidJsonAfterOtherState() {
|
void fromJsonStateObjectForValidJsonAfterOtherState() {
|
||||||
BoschSHCServiceState.fromJson(
|
BoschSHCServiceState.fromJson(
|
||||||
GsonUtils.DEFAULT_GSON_INSTANCE.fromJson("{\"@type\":\"testState\"}", JsonObject.class),
|
GsonUtils.DEFAULT_GSON_INSTANCE.fromJson("{\"@type\":\"testState\"}", JsonObject.class),
|
||||||
TestState.class);
|
TestState.class);
|
||||||
|
@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class JsonRestExceptionResponseTest {
|
class JsonRestExceptionResponseTest {
|
||||||
|
|
||||||
private @NonNullByDefault({}) JsonRestExceptionResponse fixture;
|
private @NonNullByDefault({}) JsonRestExceptionResponse fixture;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class JsonRestExceptionResponseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsValid() {
|
void testIsValid() {
|
||||||
assertFalse(JsonRestExceptionResponse.isValid(null));
|
assertFalse(JsonRestExceptionResponse.isValid(null));
|
||||||
assertTrue(JsonRestExceptionResponse.isValid(fixture));
|
assertTrue(JsonRestExceptionResponse.isValid(fixture));
|
||||||
fixture.errorCode = null;
|
fixture.errorCode = null;
|
||||||
|
@ -23,7 +23,7 @@ import org.openhab.core.library.types.HSBType;
|
|||||||
* @author David Pace - Initial contribution
|
* @author David Pace - Initial contribution
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class HSBColorActuatorServiceStateTest {
|
class HSBColorActuatorServiceStateTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testToHSBType() {
|
void testToHSBType() {
|
||||||
|
@ -23,7 +23,7 @@ import org.openhab.core.library.types.PercentType;
|
|||||||
* @author David Pace - Initial contribution
|
* @author David Pace - Initial contribution
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MultiLevelSwitchServiceStateTest {
|
class MultiLevelSwitchServiceStateTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testToPercentType() {
|
void testToPercentType() {
|
||||||
|
@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class SmokeDetectorCheckStateTest {
|
class SmokeDetectorCheckStateTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFrom() {
|
void testFrom() {
|
||||||
|
Loading…
Reference in New Issue
Block a user