Rework ThingActions (#8755)
* Remove duplication by making use of default Java generated exceptions * Make ThingActions labels/descriptions more consistent Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -55,12 +55,8 @@ public class AVMFritzHeatingActions implements ThingActions {
|
||||
actionsHandler.setBoostMode(duration.longValue());
|
||||
}
|
||||
|
||||
public static void setBoostMode(@Nullable ThingActions actions, @Nullable Long duration) {
|
||||
if (actions instanceof AVMFritzHeatingActions) {
|
||||
((AVMFritzHeatingActions) actions).setBoostMode(duration);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of AVMFritzHeatingActions");
|
||||
}
|
||||
public static void setBoostMode(ThingActions actions, @Nullable Long duration) {
|
||||
((AVMFritzHeatingActions) actions).setBoostMode(duration);
|
||||
}
|
||||
|
||||
@RuleAction(label = "@text/setWindowOpenModeActionLabel", description = "@text/setWindowOpenModeActionDescription")
|
||||
@@ -76,11 +72,7 @@ public class AVMFritzHeatingActions implements ThingActions {
|
||||
actionsHandler.setWindowOpenMode(duration.longValue());
|
||||
}
|
||||
|
||||
public static void setWindowOpenMode(@Nullable ThingActions actions, @Nullable Long duration) {
|
||||
if (actions instanceof AVMFritzHeatingActions) {
|
||||
((AVMFritzHeatingActions) actions).setWindowOpenMode(duration);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of AVMFritzHeatingActions");
|
||||
}
|
||||
public static void setWindowOpenMode(ThingActions actions, @Nullable Long duration) {
|
||||
((AVMFritzHeatingActions) actions).setWindowOpenMode(duration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# thing actions
|
||||
setBoostModeModeActionLabel = Set Boost Mode
|
||||
setBoostModeModeActionLabel = set the Boost mode
|
||||
setBoostModeActionDescription = Activates the Boost mode of the heating thermostat.
|
||||
setBoostModeDurationInputLabel = Duration
|
||||
setBoostModeDurationInputDescription = Duration in seconds, min. 1, max. 86400, 0 for deactivation.
|
||||
|
||||
setWindowOpenModeActionLabel = Set Window Open Mode
|
||||
setWindowOpenModeActionLabel = set the Window Open mode
|
||||
setWindowOpenModeActionDescription = Activates the Window Open mode of the heating thermostat.
|
||||
setWindowOpenModeDurationInputLabel = Duration
|
||||
setWindowOpenModeDurationInputDescription = Duration in seconds, min. 1, max. 86400, 0 for deactivation.
|
||||
|
||||
@@ -52,13 +52,8 @@ public class AVMFritzHeatingActionsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetBoostModeThingActionsIsNull() {
|
||||
assertThrows(IllegalArgumentException.class, () -> AVMFritzHeatingActions.setBoostMode(null, Long.valueOf(5L)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetBoostModeThingActionsIsNotPushoverThingActions() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
public void testSetBoostModeThingActionsIsNotAVMFritzHeatingActions() {
|
||||
assertThrows(ClassCastException.class,
|
||||
() -> AVMFritzHeatingActions.setBoostMode(thingActionsStub, Long.valueOf(5L)));
|
||||
}
|
||||
|
||||
@@ -81,14 +76,8 @@ public class AVMFritzHeatingActionsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetWindowOpenModeThingActionsIsNull() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> AVMFritzHeatingActions.setWindowOpenMode(null, Long.valueOf(5L)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetWindowOpenModeThingActionsIsNotPushoverThingActions() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
public void testSetWindowOpenModeThingActionsIsNotAVMFritzHeatingActions() {
|
||||
assertThrows(ClassCastException.class,
|
||||
() -> AVMFritzHeatingActions.setWindowOpenMode(thingActionsStub, Long.valueOf(5L)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user