*/
private final BatteryLevelService batteryLevelService;
- public AbstractBatteryPoweredDeviceHandler(Thing thing) {
+ protected AbstractBatteryPoweredDeviceHandler(Thing thing) {
super(thing);
this.batteryLevelService = new BatteryLevelService();
}
switch (channelUID.getId()) {
case CHANNEL_POWER_SWITCH:
- if (command instanceof OnOffType) {
- updatePowerSwitchState((OnOffType) command);
+ if (command instanceof OnOffType onOffCommand) {
+ updatePowerSwitchState(onOffCommand);
}
break;
}
private SmokeDetectorCheckService smokeDetectorCheckService;
- public AbstractSmokeDetectorHandler(Thing thing) {
+ protected AbstractSmokeDetectorHandler(Thing thing) {
super(thing);
this.smokeDetectorCheckService = new SmokeDetectorCheckService();
}
*/
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.CHANNEL_PRIVACY_MODE;
+import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.*;
import java.util.List;
* Handler for security cameras.
* <p>
* This implementation handles services and commands that are common to all cameras, which are currently:
- *
+ *
* <ul>
* <li><code>PrivacyMode</code> - Controls whether the camera records images</li>
* <li><code>CameraNotification</code> - Enables or disables notifications for the camera</li>
* </ul>
- *
+ *
* <p>
* The Eyes outdoor camera advertises a <code>CameraLight</code> service, which unfortunately does not work properly.
* Valid states are <code>ON</code> and <code>OFF</code>.
* One of my two cameras returns <code>HTTP 204 (No Content)</code> when requesting the state.
* Once Bosch supports this service properly, a new subclass may be introduced for the Eyes outdoor camera.
- *
+ *
* @author David Pace - Initial contribution
*
*/
switch (channelUID.getId()) {
case CHANNEL_PRIVACY_MODE:
- if (command instanceof OnOffType) {
- updatePrivacyModeState((OnOffType) command);
+ if (command instanceof OnOffType onOffCommand) {
+ updatePrivacyModeState(onOffCommand);
}
break;
case CHANNEL_CAMERA_NOTIFICATION:
- if (command instanceof OnOffType) {
- updateCameraNotificationState((OnOffType) command);
+ if (command instanceof OnOffType onOffCommand) {
+ updateCameraNotificationState(onOffCommand);
}
break;
}
public void handleCommand(ChannelUID channelUID, Command command) {
super.handleCommand(channelUID, command);
- if (command instanceof UpDownType) {
+ if (command instanceof UpDownType upDownCommand) {
// Set full close/open as target state
- UpDownType upDownType = (UpDownType) command;
ShutterControlServiceState state = new ShutterControlServiceState();
- if (upDownType == UpDownType.UP) {
+ if (upDownCommand == UpDownType.UP) {
state.level = 1.0;
- } else if (upDownType == UpDownType.DOWN) {
+ } else if (upDownCommand == UpDownType.DOWN) {
state.level = 0.0;
} else {
- logger.warn("Received unknown UpDownType command: {}", upDownType);
+ logger.warn("Received unknown UpDownType command: {}", upDownCommand);
return;
}
this.updateServiceState(this.shutterControlService, state);
- } else if (command instanceof StopMoveType) {
- StopMoveType stopMoveType = (StopMoveType) command;
- if (stopMoveType == StopMoveType.STOP) {
+ } else if (command instanceof StopMoveType stopMoveCommand) {
+ if (stopMoveCommand == StopMoveType.STOP) {
// Set STOPPED operation state
ShutterControlServiceState state = new ShutterControlServiceState();
state.operationState = OperationState.STOPPED;
this.updateServiceState(this.shutterControlService, state);
}
- } else if (command instanceof PercentType) {
+ } else if (command instanceof PercentType percentCommand) {
// Set specific level
- PercentType percentType = (PercentType) command;
- double level = DataConversion.openPercentageToLevel(percentType.doubleValue());
+ double level = DataConversion.openPercentageToLevel(percentCommand.doubleValue());
this.updateServiceState(this.shutterControlService, new ShutterControlServiceState(level));
}
}
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
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
switch (channelUID.getId()) {
case CHANNEL_POWER_SWITCH:
- if (command instanceof OnOffType) {
- updateBinarySwitchState((OnOffType) command);
+ if (command instanceof OnOffType onOffCommand) {
+ updateBinarySwitchState(onOffCommand);
}
break;
case CHANNEL_BRIGHTNESS:
- if (command instanceof PercentType) {
- updateMultiLevelSwitchState((PercentType) command);
+ if (command instanceof PercentType percentCommand) {
+ updateMultiLevelSwitchState(percentCommand);
}
break;
case CHANNEL_COLOR:
- if (command instanceof HSBType) {
- updateColorState((HSBType) command);
+ if (command instanceof HSBType hsbCommand) {
+ updateColorState(hsbCommand);
}
break;
}
}
- private void updateBinarySwitchState(OnOffType command) {
+ private void updateBinarySwitchState(OnOffType onOffCommand) {
BinarySwitchServiceState serviceState = new BinarySwitchServiceState();
- serviceState.on = command == OnOffType.ON;
+ serviceState.on = onOffCommand == OnOffType.ON;
this.updateServiceState(binarySwitchService, serviceState);
}
- private void updateMultiLevelSwitchState(PercentType command) {
+ private void updateMultiLevelSwitchState(PercentType percentCommand) {
MultiLevelSwitchServiceState serviceState = new MultiLevelSwitchServiceState();
- serviceState.level = command.intValue();
+ serviceState.level = percentCommand.intValue();
this.updateServiceState(multiLevelSwitchService, serviceState);
}
- private void updateColorState(HSBType command) {
+ private void updateColorState(HSBType hsbCommand) {
HSBColorActuatorServiceState serviceState = new HSBColorActuatorServiceState();
- serviceState.rgb = command.getRGB();
+ serviceState.rgb = ColorUtil.hsbTosRgb(hsbCommand);
this.updateServiceState(hsbColorActuatorService, serviceState);
}
switch (this) {
case LOW_BATTERY:
return new DecimalType(10);
- case CRITICAL_LOW:
- case CRITICALLY_LOW_BATTERY:
+ case CRITICAL_LOW, CRITICALLY_LOW_BATTERY:
return new DecimalType(1);
case NOT_AVAILABLE:
return UnDefType.UNDEF;
*/
public OnOffType toLowBatteryState() {
switch (this) {
- case LOW_BATTERY:
- case CRITICAL_LOW:
- case CRITICALLY_LOW_BATTERY:
+ case LOW_BATTERY, CRITICAL_LOW, CRITICALLY_LOW_BATTERY:
return OnOffType.ON;
default:
return OnOffType.OFF;
MODE_NORMAL,
MODE_SILENT;
- public static SilentModeState fromOnOffType(OnOffType onOffType) {
- return onOffType == OnOffType.ON ? SilentModeState.MODE_SILENT : SilentModeState.MODE_NORMAL;
+ public static SilentModeState fromOnOffType(OnOffType onOffCommand) {
+ return onOffCommand == OnOffType.ON ? SilentModeState.MODE_SILENT : SilentModeState.MODE_NORMAL;
}
}
*
*/
@NonNullByDefault
-public class BoschSHCHandlerFactoryTest {
+class BoschSHCHandlerFactoryTest {
private @NonNullByDefault({}) BoschSHCHandlerFactory fixture;
}
@Test
- public void testSupportsThingType() {
+ void testSupportsThingType() {
assertTrue(fixture.supportsThingType(BoschSHCBindingConstants.THING_TYPE_SHC));
assertTrue(fixture.supportsThingType(BoschSHCBindingConstants.THING_TYPE_INWALL_SWITCH));
assertTrue(fixture.supportsThingType(BoschSHCBindingConstants.THING_TYPE_TWINGUARD));
}
@Test
- public void testCreateHandler() {
+ void testCreateHandler() {
Thing thing = mock(Thing.class);
when(thing.getThingTypeUID()).thenReturn(BoschSHCBindingConstants.THING_TYPE_SMART_PLUG_COMPACT);
assertTrue(fixture.createHandler(thing) instanceof PlugHandler);
*
*/
@NonNullByDefault
-public class BridgeConfigurationTest {
+class BridgeConfigurationTest {
@Test
void testConstructor() {
*
*/
@NonNullByDefault
-public class JsonRpcRequestTest {
+class JsonRpcRequestTest {
private @NonNullByDefault({}) JsonRpcRequest fixture;
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals("2.0", fixture.getJsonrpc());
assertEquals("RE/longPoll", fixture.getMethod());
assertArrayEquals(new String[] { "subscriptionId", "20" }, fixture.getParams());
}
@Test
- public void testNoArgConstructor() {
+ void testNoArgConstructor() {
fixture = new JsonRpcRequest();
assertEquals("", fixture.getJsonrpc());
assertEquals("", fixture.getMethod());
}
@Test
- public void testSetJsonrpc() {
+ void testSetJsonrpc() {
fixture.setJsonrpc("test");
assertEquals("test", fixture.getJsonrpc());
}
@Test
- public void testSetMethod() {
+ void testSetMethod() {
fixture.setMethod("RE/subscribe");
assertEquals("RE/subscribe", fixture.getMethod());
}
@Test
- public void testSetParams() {
+ void testSetParams() {
fixture.setParams(new String[] { "com/bosch/sh/remote/*", null });
assertArrayEquals(new String[] { "com/bosch/sh/remote/*", null }, fixture.getParams());
}
*/
@NonNullByDefault
@ExtendWith(MockitoExtension.class)
-public class LongPollingTest {
+class LongPollingTest {
/**
* A dummy implementation of {@link ScheduledFuture}.
* @author David Pace - Initial contribution
*
*/
-public class DeviceServiceDataTest {
+class DeviceServiceDataTest {
private DeviceServiceData fixture;
}
@Test
- public void testToString() {
+ void testToString() {
assertEquals("64-da-a0-02-14-9b state: DeviceServiceData", fixture.toString());
}
}
}
@Test
- public void testToString() {
+ void testToString() {
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 ",
fixture.toString());
* @author Christian Oeing - Initial contribution
*/
@NonNullByDefault
-public class LongPollResultTest {
+class LongPollResultTest {
@Test
void noResultsForErrorResult() {
*
*/
@NonNullByDefault
-public class CameraHandlerTest extends AbstractBoschSHCDeviceHandlerTest<CameraHandler> {
+class CameraHandlerTest extends AbstractBoschSHCDeviceHandlerTest<CameraHandler> {
private @Captor @NonNullByDefault({}) ArgumentCaptor<PrivacyModeServiceState> privacyModeServiceStateCaptor;
}
@Test
- public void testHandleCommandPrivacyMode()
+ void testHandleCommandPrivacyMode()
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_PRIVACY_MODE),
OnOffType.ON);
}
@Test
- public void testHandleCommandCameraNotification()
+ void testHandleCommandCameraNotification()
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
getFixture().handleCommand(
new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_CAMERA_NOTIFICATION),
}
@Test
- public void testUpdateChannelsPrivacyModeState() {
+ void testUpdateChannelsPrivacyModeState() {
JsonElement jsonObject = JsonParser.parseString("{\"@type\":\"privacyModeState\",\"value\":\"ENABLED\"}");
getFixture().processUpdate("PrivacyMode", jsonObject);
verify(getCallback()).stateUpdated(
}
@Test
- public void testUpdateChannelsCameraNotificationState() {
+ void testUpdateChannelsCameraNotificationState() {
JsonElement jsonObject = JsonParser
.parseString("{\"@type\":\"cameraNotificationState\",\"value\":\"ENABLED\"}");
getFixture().processUpdate("CameraNotification", jsonObject);
*
*/
@NonNullByDefault
-public class ClimateControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<ClimateControlHandler> {
+class ClimateControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<ClimateControlHandler> {
private @Captor @NonNullByDefault({}) ArgumentCaptor<RoomClimateControlServiceState> roomClimateControlServiceStateCaptor;
}
@Test
- public void testHandleCommandRoomClimateControlService()
+ void testHandleCommandRoomClimateControlService()
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
QuantityType<Temperature> temperature = new QuantityType<>(21.5, SIUnits.CELSIUS);
getFixture().handleCommand(
}
@Test
- public void testUpdateChannelsTemperatureLevelService() {
+ void testUpdateChannelsTemperatureLevelService() {
JsonElement jsonObject = JsonParser.parseString(
"{\n" + " \"@type\": \"temperatureLevelState\",\n" + " \"temperature\": 21.5\n" + " }");
getFixture().processUpdate("TemperatureLevel", jsonObject);
}
@Test
- public void testUpdateChannelsRoomClimateControlService() {
+ void testUpdateChannelsRoomClimateControlService() {
JsonElement jsonObject = JsonParser.parseString(
"{\n" + " \"@type\": \"climateControlState\",\n" + " \"setpointTemperature\": 21.5\n" + " }");
getFixture().processUpdate("RoomClimateControl", jsonObject);
*
*/
@NonNullByDefault
-public class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<IntrusionDetectionHandler> {
+class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<IntrusionDetectionHandler> {
private @Captor @NonNullByDefault({}) ArgumentCaptor<ArmActionRequest> armActionRequestCaptor;
}
@Test
- public void testHandleCommandArmAction() throws InterruptedException, TimeoutException, ExecutionException {
+ void testHandleCommandArmAction() throws InterruptedException, TimeoutException, ExecutionException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_ARM_ACTION),
new StringType("0"));
verify(getBridgeHandler()).postAction(eq("intrusion/actions/arm"), armActionRequestCaptor.capture());
}
@Test
- public void testHandleCommandDisarmAction() throws InterruptedException, TimeoutException, ExecutionException {
+ void testHandleCommandDisarmAction() throws InterruptedException, TimeoutException, ExecutionException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_DISARM_ACTION),
OnOffType.ON);
verify(getBridgeHandler()).postAction("intrusion/actions/disarm");
}
@Test
- public void testHandleCommandMuteAction() throws InterruptedException, TimeoutException, ExecutionException {
+ void testHandleCommandMuteAction() throws InterruptedException, TimeoutException, ExecutionException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_MUTE_ACTION),
OnOffType.ON);
verify(getBridgeHandler()).postAction("intrusion/actions/mute");
}
@Test
- public void testUpdateChannelsIntrusionDetectionSystemState() {
+ void testUpdateChannelsIntrusionDetectionSystemState() {
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"systemState\",\n"
+ " \"systemAvailability\": {\n" + " \"@type\": \"systemAvailabilityState\",\n"
+ " \"available\": true,\n" + " \"deleted\": false\n" + " },\n"
}
@Test
- public void testUpdateChannelsIntrusionDetectionControlState() {
+ void testUpdateChannelsIntrusionDetectionControlState() {
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"intrusionDetectionControlState\",\n"
+ " \"activeProfile\": \"0\",\n" + " \"alarmActivationDelayTime\": 30,\n" + " \"actuators\": [\n"
+ " {\n" + " \"readonly\": false,\n" + " \"active\": true,\n"
}
@Test
- public void testUpdateChannelsSurveillanceAlarmState() {
+ void testUpdateChannelsSurveillanceAlarmState() {
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"surveillanceAlarmState\",\n"
+ " \"incidents\": [\n" + " {\n" + " \"triggerName\": \"Motion Detector\",\n"
+ " \"locationId\": \"hz_5\",\n" + " \"location\": \"Living Room\",\n"
*
*/
@NonNullByDefault
-public class MotionDetectorHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<MotionDetectorHandler> {
+class MotionDetectorHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<MotionDetectorHandler> {
@Override
protected MotionDetectorHandler createFixture() {
}
@Test
- public void testUpdateChannelsLatestMotionService() {
+ void testUpdateChannelsLatestMotionService() {
JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"latestMotionState\",\n"
+ " \"latestMotionDetected\": \"2020-04-03T19:02:19.054Z\"\n" + " }");
getFixture().processUpdate("LatestMotion", jsonObject);
*
*/
@NonNullByDefault
-public class ShutterControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<ShutterControlHandler> {
+class ShutterControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<ShutterControlHandler> {
private @Captor @NonNullByDefault({}) ArgumentCaptor<ShutterControlServiceState> shutterControlServiceStateCaptor;
}
@Test
- public void testHandleCommandUpDownType()
+ void testHandleCommandUpDownType()
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LEVEL),
UpDownType.UP);
}
@Test
- public void testHandleCommandStopMoveType()
+ void testHandleCommandStopMoveType()
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LEVEL),
StopMoveType.STOP);
}
@Test
- public void testHandleCommandPercentType()
+ void testHandleCommandPercentType()
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LEVEL),
new PercentType(42));
}
@Test
- public void testUpdateChannelsShutterControlService() {
+ void testUpdateChannelsShutterControlService() {
JsonElement jsonObject = JsonParser
.parseString("{\n" + " \"@type\": \"shutterControlState\",\n" + " \"level\": 0.58\n" + " }");
getFixture().processUpdate("ShutterControl", jsonObject);
*
*/
@NonNullByDefault
-public class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<SmartBulbHandler> {
+class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<SmartBulbHandler> {
private @Captor @NonNullByDefault({}) ArgumentCaptor<BinarySwitchServiceState> binarySwitchServiceStateCaptor;
}
@Test
- public void testHandleCommandBinarySwitch()
+ void testHandleCommandBinarySwitch()
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_POWER_SWITCH),
OnOffType.ON);
}
@Test
- public void testHandleCommandMultiLevelSwitch()
+ void testHandleCommandMultiLevelSwitch()
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_BRIGHTNESS),
new PercentType(42));
}
@Test
- public void testHandleCommandHSBColorActuator()
+ void testHandleCommandHSBColorActuator()
throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
getFixture().handleCommand(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_COLOR),
HSBType.BLUE);
}
@Test
- public void testUpdateChannelBinarySwitchState() {
+ void testUpdateChannelBinarySwitchState() {
JsonElement jsonObject = JsonParser.parseString("{\"@type\":\"binarySwitchState\",\"on\":true}");
getFixture().processUpdate("BinarySwitch", jsonObject);
verify(getCallback()).stateUpdated(
}
@Test
- public void testUpdateChannelMultiLevelSwitchState() {
+ void testUpdateChannelMultiLevelSwitchState() {
JsonElement jsonObject = JsonParser.parseString("{\"@type\":\"multiLevelSwitchState\",\"level\":16}");
getFixture().processUpdate("MultiLevelSwitch", jsonObject);
verify(getCallback()).stateUpdated(
}
@Test
- public void testUpdateChannelHSBColorActuatorState() {
+ void testUpdateChannelHSBColorActuatorState() {
JsonElement jsonObject = JsonParser.parseString("{\"colorTemperatureRange\": {\n" + " \"minCt\": 153,\n"
+ " \"maxCt\": 526\n" + " },\n" + " \"@type\": \"colorState\",\n"
+ " \"gamut\": \"LEDVANCE_GAMUT_A\",\n" + " \"rgb\": -12427}");
*
*/
@NonNullByDefault
-public class TwinguardHandlerTest extends AbstractSmokeDetectorHandlerTest<TwinguardHandler> {
+class TwinguardHandlerTest extends AbstractSmokeDetectorHandlerTest<TwinguardHandler> {
@Override
protected TwinguardHandler createFixture() {
}
@Test
- public void testUpdateChannelsAirQualityLevelService() {
+ void testUpdateChannelsAirQualityLevelService() {
JsonElement jsonObject = JsonParser.parseString(
"{\"temperatureRating\":\"GOOD\",\"humidityRating\":\"MEDIUM\",\"purity\":620,\"@type\":\"airQualityLevelState\",\n"
+ " \"purityRating\":\"GOOD\",\"temperature\":23.77,\"description\":\"LITTLE_DRY\",\"humidity\":32.69,\"combinedRating\":\"MEDIUM\"}");
*
*/
@NonNullByDefault
-public class WallThermostatHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<WallThermostatHandler> {
+class WallThermostatHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<WallThermostatHandler> {
@Override
protected WallThermostatHandler createFixture() {
}
@Test
- public void testUpdateChannelsTemperatureLevelService() {
+ void testUpdateChannelsTemperatureLevelService() {
JsonElement jsonObject = JsonParser.parseString(
"{\n" + " \"@type\": \"temperatureLevelState\",\n" + " \"temperature\": 21.5\n" + " }");
getFixture().processUpdate("TemperatureLevel", jsonObject);
}
@Test
- public void testUpdateChannelsHumidityLevelService() {
+ void testUpdateChannelsHumidityLevelService() {
JsonElement jsonObject = JsonParser
.parseString("{\n" + " \"@type\": \"humidityLevelState\",\n" + " \"humidity\": 42.5\n" + " }");
getFixture().processUpdate("HumidityLevel", jsonObject);
*
*/
@NonNullByDefault
-public class WindowContactHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<WindowContactHandler> {
+class WindowContactHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<WindowContactHandler> {
@Override
protected WindowContactHandler createFixture() {
}
@Test
- public void testUpdateChannelsShutterContactService() {
+ void testUpdateChannelsShutterContactService() {
JsonElement jsonObject = JsonParser
.parseString("{\n" + " \"@type\": \"shutterContactState\",\n" + " \"value\": \"OPEN\"\n" + " }");
getFixture().processUpdate("ShutterContact", jsonObject);
*/
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.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import javax.jmdns.ServiceInfo;
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
@NonNullByDefault
-public class BridgeDiscoveryParticipantTest {
+class BridgeDiscoveryParticipantTest {
@Nullable
private BridgeDiscoveryParticipant fixture;
}
/**
- *
+ *
* Method: getSupportedThingTypeUIDs()
- *
+ *
*/
@Test
- public void testGetSupportedThingTypeUIDs() {
+ void testGetSupportedThingTypeUIDs() {
assert fixture != null;
assertTrue(fixture.getSupportedThingTypeUIDs().contains(BoschSHCBindingConstants.THING_TYPE_SHC));
}
/**
- *
+ *
* Method: getServiceType()
- *
+ *
*/
@Test
- public void testGetServiceType() throws Exception {
+ void testGetServiceType() throws Exception {
assert fixture != null;
assertThat(fixture.getServiceType(), is("_http._tcp.local."));
}
@Test
- public void testCreateResult() throws Exception {
+ void testCreateResult() throws Exception {
assert fixture != null;
DiscoveryResult result = fixture.createResult(shcBridge);
assertNotNull(result);
}
@Test
- public void testCreateResultOtherDevice() throws Exception {
+ void testCreateResultOtherDevice() throws Exception {
assert fixture != null;
DiscoveryResult result = fixture.createResult(otherDevice);
assertNull(result);
}
@Test
- public void testGetThingUID() throws Exception {
+ void testGetThingUID() throws Exception {
assert fixture != null;
ThingUID thingUID = fixture.getThingUID(shcBridge);
assertNotNull(thingUID);
}
@Test
- public void testGetThingUIDOtherDevice() throws Exception {
+ void testGetThingUIDOtherDevice() throws Exception {
assert fixture != null;
assertNull(fixture.getThingUID(otherDevice));
}
@Test
- public void testGetBridgeAddress() throws Exception {
+ void testGetBridgeAddress() throws Exception {
assert fixture != null;
assertThat(fixture.discoverBridge(shcBridge).shcIpAddress, is("192.168.0.123"));
}
@Test
- public void testGetBridgeAddressOtherDevice() throws Exception {
+ void testGetBridgeAddressOtherDevice() throws Exception {
assert fixture != null;
assertThat(fixture.discoverBridge(otherDevice).shcIpAddress, is(""));
}
@Test
- public void testGetPublicInformationFromPossibleBridgeAddress() throws Exception {
+ void testGetPublicInformationFromPossibleBridgeAddress() throws Exception {
assert fixture != null;
assertThat(fixture.getPublicInformationFromPossibleBridgeAddress("192.168.0.123").shcIpAddress,
is("192.168.0.123"));
}
@Test
- public void testGetPublicInformationFromPossibleBridgeAddressInvalidContent() throws Exception {
+ void testGetPublicInformationFromPossibleBridgeAddressInvalidContent() throws Exception {
assert fixture != null;
ContentResponse contentResponse = mock(ContentResponse.class);
}
@Test
- public void testGetPublicInformationFromPossibleBridgeAddressInvalidStatus() throws Exception {
+ void testGetPublicInformationFromPossibleBridgeAddressInvalidStatus() throws Exception {
assert fixture != null;
ContentResponse contentResponse = mock(ContentResponse.class);
*/
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.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
*/
@ExtendWith(MockitoExtension.class)
@NonNullByDefault
-public class ThingDiscoveryServiceTest {
+class ThingDiscoveryServiceTest {
private @NonNullByDefault({}) ThingDiscoveryService fixture;
}
@Test
- public void testStartScan() throws InterruptedException {
+ void testStartScan() throws InterruptedException {
mockBridgeCalls();
fixture.activate();
}
@Test
- public void testStartScanWithoutBridgeHandler() {
+ void testStartScanWithoutBridgeHandler() {
mockBridgeCalls();
// No fixture.setThingHandler(bridgeHandler);
}
@Test
- public void testSetGetThingHandler() {
+ void testSetGetThingHandler() {
fixture.setThingHandler(bridgeHandler);
assertThat(fixture.getThingHandler(), is(bridgeHandler));
}
@Test
- public void testAddDevices() {
+ void testAddDevices() {
mockBridgeCalls();
ArrayList<Device> devices = new ArrayList<>();
}
@Test
- public void testAddDevicesWithNoDevices() {
+ void testAddDevicesWithNoDevices() {
ArrayList<Device> emptyDevices = new ArrayList<>();
ArrayList<Room> emptyRooms = new ArrayList<>();
}
@Test
- public void testAddDevice() {
+ void testAddDevice() {
mockBridgeCalls();
Device device = new Device();
assertThat(result.getThingUID().getId(), is("testDevice_ID"));
assertThat(result.getBridgeUID().getId(), is("testSHC"));
assertThat(result.getLabel(), is("Test Name"));
- assertThat(result.getProperties().get("Location").toString(), is("TestRoom"));
+ assertThat(String.valueOf(result.getProperties().get("Location")), is("TestRoom"));
}
@Test
- public void testAddDeviceWithNiceNameAndAppendedRoomName() {
+ void testAddDeviceWithNiceNameAndAppendedRoomName() {
assertDeviceNiceName("-RoomClimateControl-", "TestRoom", "Room Climate Control TestRoom");
}
@Test
- public void testAddDeviceWithNiceNameWithEmtpyRoomName() {
+ void testAddDeviceWithNiceNameWithEmtpyRoomName() {
assertDeviceNiceName("-RoomClimateControl-", "", "Room Climate Control");
}
@Test
- public void testAddDeviceWithNiceNameWithoutAppendingRoomName() {
+ void testAddDeviceWithNiceNameWithoutAppendingRoomName() {
assertDeviceNiceName("-SmokeDetectionSystem-", "TestRoom", "Smoke Detection System");
}
@Test
- public void testAddDeviceWithNiceNameWithoutUsualName() {
+ void testAddDeviceWithNiceNameWithoutUsualName() {
assertDeviceNiceName("My other device", "TestRoom", "My other device");
}
}
@Test
- public void testGetRoomForDevice() {
+ void testGetRoomForDevice() {
Device device = new Device();
ArrayList<Room> rooms = new ArrayList<>();
}
@Test
- public void testGetThingTypeUID() {
+ void testGetThingTypeUID() {
Device device = new Device();
device.deviceModel = "invalid";
*
*/
@NonNullByDefault
-public class LongPollingFailedExceptionTest {
+class LongPollingFailedExceptionTest {
@Test
- public void testConstructor() {
+ void testConstructor() {
RuntimeException testException = new RuntimeException("test exception");
LongPollingFailedException longPollingFailedException = new LongPollingFailedException("message",
testException);
*
*/
@NonNullByDefault
-public class PairingFailedExceptionTest {
+class PairingFailedExceptionTest {
@Test
- public void testConstructor() {
+ void testConstructor() {
PairingFailedException fixture = new PairingFailedException();
assertNotNull(fixture);
assertNull(fixture.getMessage());
}
@Test
- public void testConstructorWithMessage() {
+ void testConstructorWithMessage() {
PairingFailedException fixture = new PairingFailedException("message");
assertNotNull(fixture);
assertEquals("message", fixture.getMessage());
}
@Test
- public void testConstructorWithMessageAndCause() {
+ void testConstructorWithMessageAndCause() {
RuntimeException testException = new RuntimeException("test exception");
PairingFailedException fixture = new PairingFailedException("message", testException);
assertNotNull(fixture);
* @author David Pace - Initial contribution
*
*/
-public class BinarySwitchServiceStateTest {
+class BinarySwitchServiceStateTest {
@Test
void testToOnOffType() {
* @author Christian Oeing - Initial contribution
*/
@NonNullByDefault
-public class BoschSHCServiceStateTest {
+class BoschSHCServiceStateTest {
@Test
- public void fromJsonNullStateForDifferentType() {
+ void fromJsonNullStateForDifferentType() {
var state = BoschSHCServiceState.fromJson(
GsonUtils.DEFAULT_GSON_INSTANCE.fromJson("{\"@type\":\"differentState\"}", JsonObject.class),
TestState.class);
}
@Test
- public void fromJsonStateObjectForValidJson() {
+ void fromJsonStateObjectForValidJson() {
var state = BoschSHCServiceState.fromJson(
GsonUtils.DEFAULT_GSON_INSTANCE.fromJson("{\"@type\":\"testState\"}", JsonObject.class),
TestState.class);
* This checks for a bug we had where the expected type stayed the same for different state classes
*/
@Test
- public void fromJsonStateObjectForValidJsonAfterOtherState() {
+ void fromJsonStateObjectForValidJsonAfterOtherState() {
BoschSHCServiceState.fromJson(
GsonUtils.DEFAULT_GSON_INSTANCE.fromJson("{\"@type\":\"testState\"}", JsonObject.class),
TestState.class);
*
*/
@NonNullByDefault
-public class JsonRestExceptionResponseTest {
+class JsonRestExceptionResponseTest {
private @NonNullByDefault({}) JsonRestExceptionResponse fixture;
}
@Test
- public void testIsValid() {
+ void testIsValid() {
assertFalse(JsonRestExceptionResponse.isValid(null));
assertTrue(JsonRestExceptionResponse.isValid(fixture));
fixture.errorCode = null;
* @author David Pace - Initial contribution
*
*/
-public class HSBColorActuatorServiceStateTest {
+class HSBColorActuatorServiceStateTest {
@Test
void testToHSBType() {
* @author David Pace - Initial contribution
*
*/
-public class MultiLevelSwitchServiceStateTest {
+class MultiLevelSwitchServiceStateTest {
@Test
void testToPercentType() {
/**
* Unit tests for {@link SmokeDetectorCheckState}.
- *
+ *
* @author David Pace - Initial contribution
*
*/
@NonNullByDefault
-public class SmokeDetectorCheckStateTest {
+class SmokeDetectorCheckStateTest {
@Test
void testFrom() {