[awattar] comply to naming convertion, simplify calc, fix typo

Signed-off-by: Thomas Leber <thomas@tl-photography.at>
This commit is contained in:
Thomas Leber 2024-12-07 11:27:05 +01:00
parent 11f60da2d6
commit a5a7e7c3c9
3 changed files with 11 additions and 11 deletions

View File

@ -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);
}

View File

@ -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<Field> fields = ReflectionSupport.findFields(AwattarBridgeHandler.class,

View File

@ -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<Arguments> testBestpriceHandler_channels() {
public static Stream<Arguments> 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<String, Object> 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);
}