diff --git a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/handler/AwattarBestPriceHandler.java b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/handler/AwattarBestPriceHandler.java index 574df27ddd7..c0ca4ca935c 100644 --- a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/handler/AwattarBestPriceHandler.java +++ b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/handler/AwattarBestPriceHandler.java @@ -224,7 +224,7 @@ public class AwattarBestPriceHandler extends BaseThingHandler { * @return the range */ protected TimeRange getRange(int start, int duration, ZoneId zoneId) { - ZonedDateTime startTime = getStarTime(start, zoneId); + ZonedDateTime startTime = getStartTime(start, zoneId); ZonedDateTime endTime = startTime.plusHours(duration); ZonedDateTime now = getNow(zoneId); if (now.getHour() < start) { @@ -232,7 +232,7 @@ public class AwattarBestPriceHandler extends BaseThingHandler { startTime = startTime.minusDays(1); endTime = endTime.minusDays(1); } - if (endTime.toInstant().toEpochMilli() < now.toInstant().toEpochMilli()) { + if (endTime.isBefore(now)) { // span is in the past, add one day startTime = startTime.plusDays(1); endTime = endTime.plusDays(1); @@ -247,7 +247,7 @@ public class AwattarBestPriceHandler extends BaseThingHandler { * @param zoneId the time zone * @return the start time */ - protected ZonedDateTime getStarTime(int start, ZoneId zoneId) { + protected ZonedDateTime getStartTime(int start, ZoneId zoneId) { return getCalendarForHour(start, zoneId); } diff --git a/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/handler/AwattarBridgeHandlerRefreshTest.java b/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/handler/AwattarBridgeHandlerRefreshTest.java index 879fc437e67..1963b9ebcaa 100644 --- a/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/handler/AwattarBridgeHandlerRefreshTest.java +++ b/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/handler/AwattarBridgeHandlerRefreshTest.java @@ -95,7 +95,7 @@ class AwattarBridgeHandlerRefreshTest extends JavaTest { * @throws AwattarApiException */ @Test - void testRefreshIfNeeded_ThingOffline() throws SecurityException, AwattarApiException { + void testRefreshIfNeededThingOffline() throws SecurityException, AwattarApiException { when(bridgeMock.getStatus()).thenReturn(ThingStatus.OFFLINE); bridgeHandler.refreshIfNeeded(); @@ -113,7 +113,7 @@ class AwattarBridgeHandlerRefreshTest extends JavaTest { * @throws AwattarApiException */ @Test - void testRefreshIfNeeded_DataEmpty() throws SecurityException, AwattarApiException { + void testRefreshIfNeededDataEmpty() throws SecurityException, AwattarApiException { when(bridgeMock.getStatus()).thenReturn(ThingStatus.ONLINE); bridgeHandler.refreshIfNeeded(); @@ -124,7 +124,7 @@ class AwattarBridgeHandlerRefreshTest extends JavaTest { } @Test - void testNeedRefresh_ThingOffline() throws SecurityException { + void testNeedRefreshThingOffline() throws SecurityException { when(bridgeMock.getStatus()).thenReturn(ThingStatus.OFFLINE); // get private method via reflection @@ -136,7 +136,7 @@ class AwattarBridgeHandlerRefreshTest extends JavaTest { } @Test - void testNeedRefresh_DataEmpty() throws SecurityException, IllegalArgumentException, IllegalAccessException { + void testNeedRefreshDataEmpty() throws SecurityException, IllegalArgumentException, IllegalAccessException { when(bridgeMock.getStatus()).thenReturn(ThingStatus.ONLINE); List fields = ReflectionSupport.findFields(AwattarBridgeHandler.class, diff --git a/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/handler/AwattarBridgeHandlerTest.java b/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/handler/AwattarBridgeHandlerTest.java index a846e07b462..70f5fbb0246 100644 --- a/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/handler/AwattarBridgeHandlerTest.java +++ b/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/handler/AwattarBridgeHandlerTest.java @@ -202,7 +202,7 @@ public class AwattarBridgeHandlerTest extends JavaTest { when(bestpriceMock.getConfiguration()).thenReturn(new Configuration(config)); AwattarBestPriceHandler handler = new AwattarBestPriceHandler(bestpriceMock, timeZoneProviderMock) { - protected ZonedDateTime getStarTime(int start, ZoneId zoneId) { + protected ZonedDateTime getStartTime(int start, ZoneId zoneId) { return ZonedDateTime.of(2024, 6, 15, 12, 0, 0, 0, zoneId); } @@ -218,7 +218,7 @@ public class AwattarBridgeHandlerTest extends JavaTest { verify(bestPriceCallbackMock).stateUpdated(channelUID, expectedState); } - public static Stream testBestpriceHandler_channels() { + public static Stream testBestpriceHandlerChannels() { return Stream.of( // Arguments.of(12, 0, 24, 1, true, CHANNEL_HOURS, new StringType("14")), Arguments.of(12, 0, 24, 1, true, CHANNEL_ACTIVE, OnOffType.from(false)), @@ -250,7 +250,7 @@ public class AwattarBridgeHandlerTest extends JavaTest { @ParameterizedTest @MethodSource - void testBestpriceHandler_channels(int currentHour, int currentMinute, int rangeDuration, int length, + void testBestpriceHandlerChannels(int currentHour, int currentMinute, int rangeDuration, int length, boolean consecutive, String channelId, State expectedState) { ThingUID bestPriceUid = new ThingUID(AwattarBindingConstants.THING_TYPE_BESTPRICE, "foo"); Map config = Map.of("rangeDuration", rangeDuration, "length", length, "consecutive", @@ -258,7 +258,7 @@ public class AwattarBridgeHandlerTest extends JavaTest { when(bestpriceMock.getConfiguration()).thenReturn(new Configuration(config)); AwattarBestPriceHandler handler = new AwattarBestPriceHandler(bestpriceMock, timeZoneProviderMock) { - protected ZonedDateTime getStarTime(int start, ZoneId zoneId) { + protected ZonedDateTime getStartTime(int start, ZoneId zoneId) { return ZonedDateTime.of(2024, 6, 15, 0, 0, 0, 0, zoneId); }