-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[awattar] Refactor and add test coverage (#17752)
* [aWATTar] push test coverage and improve code readability Signed-off-by: Thomas Leber <[email protected]>
- Loading branch information
1 parent
968cc56
commit baaaf7f
Showing
14 changed files
with
362 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...g.awattar/src/main/java/org/openhab/binding/awattar/internal/dto/AwattarTimeProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2010-2025 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.awattar.internal.dto; | ||
|
||
import java.time.Instant; | ||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.core.i18n.TimeZoneProvider; | ||
|
||
/** | ||
* The {@link AwattarTimeProvider} provides a time provider for aWATTar | ||
* | ||
* @author Thomas Leber - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class AwattarTimeProvider { | ||
|
||
private TimeZoneProvider timeZoneProvider; | ||
|
||
public AwattarTimeProvider(TimeZoneProvider timeZoneProvider) { | ||
this.timeZoneProvider = timeZoneProvider; | ||
} | ||
|
||
/** | ||
* Get the current zone id. | ||
* | ||
* @return the current zone id | ||
*/ | ||
public ZoneId getZoneId() { | ||
return timeZoneProvider.getTimeZone(); | ||
} | ||
|
||
/** | ||
* Get the current instant. | ||
* | ||
* @return the current instant | ||
*/ | ||
public Instant getInstantNow() { | ||
return Instant.now(); | ||
} | ||
|
||
/** | ||
* Get the current zoned date time. | ||
* | ||
* @return the current zoned date time | ||
*/ | ||
public ZonedDateTime getZonedDateTimeNow() { | ||
return Instant.now().atZone(getZoneId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.