]> git.basschouten.com Git - openhab-addons.git/commitdiff
[network] Adressing issue #11503 (#12316)
authorGaël L'hopital <gael@lhopital.org>
Sun, 20 Feb 2022 22:24:49 +0000 (23:24 +0100)
committerGitHub <noreply@github.com>
Sun, 20 Feb 2022 22:24:49 +0000 (23:24 +0100)
Signed-off-by: clinique <gael@lhopital.org>
17 files changed:
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/NetworkBindingConfiguration.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/NetworkBindingConfigurationListener.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/PresenceDetection.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/SpeedTestConfiguration.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/WakeOnLanPacketSender.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/dhcp/DHCPPacketListenerServer.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/SpeedTestHandler.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/utils/LatencyParser.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/utils/NetworkUtils.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/utils/PingResult.java
bundles/org.openhab.binding.network/src/main/resources/OH-INF/thing/thing-types.xml
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/PresenceDetectionTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/WakeOnLanPacketSenderTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/dhcp/DHCPTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/toberemoved/cache/ExpiringCacheAsyncTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/toberemoved/cache/ExpiringCacheHelper.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/utils/LatencyParserTest.java

index 581b609614c4cb1be5d5b7f6b61f3c544088d30b..48704afb9e82ba42b7a2347a7831191b7389ed13 100644 (file)
@@ -29,11 +29,11 @@ import org.openhab.binding.network.internal.utils.NetworkUtils.ArpPingUtilEnum;
 @NonNullByDefault
 public class NetworkBindingConfiguration {
 
-    public Boolean allowSystemPings = true;
-    public Boolean allowDHCPlisten = true;
+    public boolean allowSystemPings = true;
+    public boolean allowDHCPlisten = true;
     public BigDecimal cacheDeviceStateTimeInMS = BigDecimal.valueOf(2000);
     public String arpPingToolPath = "arping";
-    public @NonNullByDefault({}) ArpPingUtilEnum arpPingUtilMethod;
+    public ArpPingUtilEnum arpPingUtilMethod = ArpPingUtilEnum.DISABLED;
     // For backwards compatibility reasons, the default is to use the ping method execution time as latency value
     public boolean preferResponseTimeAsLatency = false;
 
index b9a74762672e821324cfe3eed3cfc372d94f02dd..73f2d118812f7c001479e9db53cfaa8777b5bb5d 100644 (file)
  */
 package org.openhab.binding.network.internal;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * Listener for binding configuration changes.
  *
  * @author Andreas Hirsch - Initial contribution
  */
+@NonNullByDefault
 public interface NetworkBindingConfigurationListener {
 
     void bindingConfigurationChanged();
index 7e6de7766704052547b8bf684eb3d2036e2f4b55..2e3f702fb5e53c8bce56dd350118be1ab62da61d 100644 (file)
@@ -57,10 +57,9 @@ public class PresenceDetection implements IPRequestReceivedCallback {
 
     /// Configuration variables
     private boolean useDHCPsniffing = false;
-    private String arpPingState = "Disabled";
     private String ipPingState = "Disabled";
     protected String arpPingUtilPath = "";
-    protected ArpPingUtilEnum arpPingMethod = ArpPingUtilEnum.UNKNOWN_TOOL;
+    protected ArpPingUtilEnum arpPingMethod = ArpPingUtilEnum.DISABLED;
     protected @Nullable IpPingMethodEnum pingMethod = null;
     private boolean iosDevice;
     private Set<Integer> tcpPorts = new HashSet<>();
@@ -184,40 +183,13 @@ public class PresenceDetection implements IPRequestReceivedCallback {
      * it will be disabled as well.
      *
      * @param enable Enable or disable ARP ping
-     * @param arpPingUtilPath c
+     * @param destinationAddress target ip address
      */
     private void setUseArpPing(boolean enable, @Nullable InetAddress destinationAddress) {
         if (!enable || arpPingUtilPath.isEmpty()) {
-            arpPingState = "Disabled";
-            arpPingMethod = ArpPingUtilEnum.UNKNOWN_TOOL;
-            return;
-        } else if (destinationAddress == null || !(destinationAddress instanceof Inet4Address)) {
-            arpPingState = "Destination is not a valid IPv4 address";
-            arpPingMethod = ArpPingUtilEnum.UNKNOWN_TOOL;
-            return;
-        }
-
-        switch (arpPingMethod) {
-            case UNKNOWN_TOOL: {
-                arpPingState = "Unknown arping tool";
-                break;
-            }
-            case THOMAS_HABERT_ARPING: {
-                arpPingState = "Arping tool by Thomas Habets";
-                break;
-            }
-            case THOMAS_HABERT_ARPING_WITHOUT_TIMEOUT: {
-                arpPingState = "Arping tool by Thomas Habets (old version)";
-                break;
-            }
-            case ELI_FULKERSON_ARP_PING_FOR_WINDOWS: {
-                arpPingState = "Eli Fulkerson ARPing tool for Windows";
-                break;
-            }
-            case IPUTILS_ARPING: {
-                arpPingState = "Ipuitls Arping";
-                break;
-            }
+            arpPingMethod = ArpPingUtilEnum.DISABLED;
+        } else if (!(destinationAddress instanceof Inet4Address)) {
+            arpPingMethod = ArpPingUtilEnum.DISABLED_INVALID_IP;
         }
     }
 
@@ -234,7 +206,7 @@ public class PresenceDetection implements IPRequestReceivedCallback {
     }
 
     public String getArpPingState() {
-        return arpPingState;
+        return arpPingMethod.description;
     }
 
     public String getIPPingState() {
@@ -318,7 +290,7 @@ public class PresenceDetection implements IPRequestReceivedCallback {
         if (pingMethod != null) {
             detectionChecks += 1;
         }
-        if (arpPingMethod != ArpPingUtilEnum.UNKNOWN_TOOL) {
+        if (arpPingMethod.canProceed) {
             interfaceNames = networkUtils.getInterfaceNames();
             detectionChecks += interfaceNames.size();
         }
index 65c5e4edf601a5419be07b2aef170078f1135e12..3ae4e8a04c221aee774f8d35154ae6a901a8f200 100644 (file)
  */
 package org.openhab.binding.network.internal;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  * The {@link SpeedTestConfiguration} is the class used to match the
  * thing configuration.
  *
  * @author Gaël L'hopital - Initial contribution
  */
+@NonNullByDefault
 public class SpeedTestConfiguration {
-    public Integer refreshInterval = 20;
-    public Integer initialDelay = 5;
-    public Integer uploadSize = 1000000;
-    public Integer maxTimeout = 3;
-    private String url;
-    private String fileName;
+    public int refreshInterval = 20;
+    public int initialDelay = 5;
+    public int uploadSize = 1000000;
+    public int maxTimeout = 3;
+    private @Nullable String url;
+    private @Nullable String fileName;
 
-    public String getUploadURL() {
-        return url + (url.endsWith("/") ? "" : "/");
+    public @Nullable String getUploadURL() {
+        String localUrl = url;
+        if (localUrl != null) {
+            localUrl += localUrl.endsWith("/") ? "" : "/";
+        }
+        return localUrl;
     }
 
-    public String getDownloadURL() {
-        return getUploadURL() + fileName;
+    public @Nullable String getDownloadURL() {
+        String result = getUploadURL();
+        if (result != null && fileName != null) {
+            result += fileName;
+        }
+        return result;
     }
 }
index 4741a077776a23aaa180af89fd29bad940dd0c09..c84c58638d01776ad2c96510d8d3961c158c6edf 100644 (file)
 package org.openhab.binding.network.internal;
 
 import java.io.IOException;
-import java.net.*;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.UnknownHostException;
 import java.util.Arrays;
 import java.util.Objects;
 import java.util.function.Consumer;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.net.NetUtil;
@@ -48,11 +53,8 @@ public class WakeOnLanPacketSender {
 
     private final String macAddress;
 
-    @Nullable
-    private final String hostname;
-
-    @Nullable
-    private final Integer port;
+    private final @Nullable String hostname;
+    private final @Nullable Integer port;
 
     private final Consumer<byte[]> magicPacketMacSender;
     private final Consumer<byte[]> magicPacketIpSender;
@@ -131,10 +133,10 @@ public class WakeOnLanPacketSender {
 
     private void sendMagicPacketViaIp(byte[] magicPacket) {
         try (DatagramSocket socket = new DatagramSocket()) {
-            if (!StringUtils.isEmpty(this.hostname)) {
+            if (hostname != null && !hostname.isBlank()) {
                 logger.debug("Sending Wake-on-LAN Packet via IP Address");
-                SocketAddress socketAddress = new InetSocketAddress(this.hostname,
-                        Objects.requireNonNullElse(this.port, WOL_UDP_PORT));
+                SocketAddress socketAddress = new InetSocketAddress(hostname,
+                        Objects.requireNonNullElse(port, WOL_UDP_PORT));
                 sendMagicPacketToIp(magicPacket, socket, socketAddress);
             } else {
                 throw new IllegalStateException("Hostname is not set!");
index 25c9f7a494a481674b4b533b07b210c2797cc94a..2f8b8df2e723b198c982ee436e9062fe0bdceea0 100644 (file)
@@ -70,7 +70,7 @@ public class DHCPPacketListenerServer extends Thread {
 
         Byte dhcpMessageType = request.getDHCPMessageType();
 
-        if (dhcpMessageType != DHCPPacket.DHCPREQUEST) {
+        if (dhcpMessageType == null || dhcpMessageType != DHCPPacket.DHCPREQUEST) {
             return; // skipping non DHCPREQUEST message types
         }
 
index fc1ce354ee344669ff08ee82dee13cfdca309f5e..2a0e002b0f36d64eb2bf1952f7b471179a540c88 100644 (file)
@@ -69,7 +69,8 @@ public class SpeedTestHandler extends BaseThingHandler implements ISpeedTestList
     }
 
     private synchronized void startSpeedTest() {
-        if (speedTestSocket == null) {
+        String url = configuration.getDownloadURL();
+        if (speedTestSocket == null && url != null) {
             logger.debug("Network speedtest started");
             final SpeedTestSocket socket = new SpeedTestSocket(1500);
             speedTestSocket = socket;
@@ -78,7 +79,7 @@ public class SpeedTestHandler extends BaseThingHandler implements ISpeedTestList
             updateState(CHANNEL_TEST_START, new DateTimeType());
             updateState(CHANNEL_TEST_END, UnDefType.NULL);
             updateProgress(new QuantityType<>(0, Units.PERCENT));
-            socket.startDownload(configuration.getDownloadURL());
+            socket.startDownload(url);
         } else {
             logger.info("A speedtest is already in progress, will retry on next refresh");
         }
@@ -109,7 +110,8 @@ public class SpeedTestHandler extends BaseThingHandler implements ISpeedTestList
                 switch (testReport.getSpeedTestMode()) {
                     case DOWNLOAD:
                         updateState(CHANNEL_RATE_DOWN, quantity);
-                        if (speedTestSocket != null && configuration != null) {
+                        String url = configuration.getUploadURL();
+                        if (speedTestSocket != null && url != null) {
                             speedTestSocket.startUpload(configuration.getUploadURL(), configuration.uploadSize);
                         }
                         break;
index 92a714ba3176dfb2c310461f8ef080368530e036..6110e71bdf9225b59d7cef9ab638a30007c754b9 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Optional;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -24,9 +25,10 @@ import org.slf4j.LoggerFactory;
  *
  * @author Andreas Hirsch - Initial contribution
  */
+@NonNullByDefault
 public class LatencyParser {
 
-    private static Pattern LATENCY_PATTERN = Pattern.compile(".*time=(.*) ?ms");
+    private static final Pattern LATENCY_PATTERN = Pattern.compile(".*time=(.*) ?ms");
     private final Logger logger = LoggerFactory.getLogger(LatencyParser.class);
 
     // This is how the input looks like on Mac and Linux:
index de8ca64cddac34dae4fb91ab2a4877c24756cdd2..d657721807b2b5d66464a6ae896e27f99a20a234 100644 (file)
@@ -203,19 +203,19 @@ public class NetworkUtils {
     public ArpPingUtilEnum determineNativeARPpingMethod(String arpToolPath) {
         String result = ExecUtil.executeCommandLineAndWaitResponse(Duration.ofMillis(100), arpToolPath, "--help");
         if (result == null || result.isBlank()) {
-            return ArpPingUtilEnum.UNKNOWN_TOOL;
+            return ArpPingUtilEnum.DISABLED_UNKNOWN_TOOL;
         } else if (result.contains("Thomas Habets")) {
             if (result.matches("(?s)(.*)w sec Specify a timeout(.*)")) {
                 return ArpPingUtilEnum.THOMAS_HABERT_ARPING;
             } else {
                 return ArpPingUtilEnum.THOMAS_HABERT_ARPING_WITHOUT_TIMEOUT;
             }
-        } else if (result.contains("-w timeout")) {
+        } else if (result.contains("-w timeout") || result.contains("-w <timeout>")) {
             return ArpPingUtilEnum.IPUTILS_ARPING;
         } else if (result.contains("Usage: arp-ping.exe")) {
             return ArpPingUtilEnum.ELI_FULKERSON_ARP_PING_FOR_WINDOWS;
         }
-        return ArpPingUtilEnum.UNKNOWN_TOOL;
+        return ArpPingUtilEnum.DISABLED_UNKNOWN_TOOL;
     }
 
     public enum IpPingMethodEnum {
@@ -292,11 +292,21 @@ public class NetworkUtils {
     }
 
     public enum ArpPingUtilEnum {
-        UNKNOWN_TOOL,
-        IPUTILS_ARPING,
-        THOMAS_HABERT_ARPING,
-        THOMAS_HABERT_ARPING_WITHOUT_TIMEOUT,
-        ELI_FULKERSON_ARP_PING_FOR_WINDOWS
+        DISABLED("Disabled", false),
+        DISABLED_INVALID_IP("Destination is not a valid IPv4 address", false),
+        DISABLED_UNKNOWN_TOOL("Unknown arping tool", false),
+        IPUTILS_ARPING("Iputils Arping", true),
+        THOMAS_HABERT_ARPING("Arping tool by Thomas Habets", true),
+        THOMAS_HABERT_ARPING_WITHOUT_TIMEOUT("Arping tool by Thomas Habets (old version)", true),
+        ELI_FULKERSON_ARP_PING_FOR_WINDOWS("Eli Fulkerson ARPing tool for Windows", true);
+
+        public final String description;
+        public final boolean canProceed;
+
+        ArpPingUtilEnum(String description, boolean canProceed) {
+            this.description = description;
+            this.canProceed = canProceed;
+        }
     }
 
     /**
@@ -317,7 +327,7 @@ public class NetworkUtils {
             String interfaceName, String ipV4address, int timeoutInMS) throws IOException, InterruptedException {
         double execStartTimeInMS = System.currentTimeMillis();
 
-        if (arpUtilPath == null || arpingTool == null || arpingTool == ArpPingUtilEnum.UNKNOWN_TOOL) {
+        if (arpUtilPath == null || arpingTool == null || !arpingTool.canProceed) {
             return Optional.empty();
         }
         Process proc;
index e1e674c0f008d3360f1ba60626712191f1b29922..d9fea64551c0a117141a1446d73509e341832872 100644 (file)
@@ -14,15 +14,18 @@ package org.openhab.binding.network.internal.utils;
 
 import java.util.Optional;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * Information about the ping result.
  *
  * @author Andreas Hirsch - Initial contribution
  */
+@NonNullByDefault
 public class PingResult {
 
     private boolean success;
-    private Double responseTimeInMS;
+    private Optional<Double> responseTimeInMS = Optional.empty();
     private double executionTimeInMS;
 
     /**
@@ -46,14 +49,14 @@ public class PingResult {
      *         by ping command is not available.
      */
     public Optional<Double> getResponseTimeInMS() {
-        return responseTimeInMS == null ? Optional.empty() : Optional.of(responseTimeInMS);
+        return responseTimeInMS;
     }
 
     /**
      * @param responseTimeInMS Response time in ms which was returned by the ping command.
      */
     public void setResponseTimeInMS(double responseTimeInMS) {
-        this.responseTimeInMS = responseTimeInMS;
+        this.responseTimeInMS = Optional.of(responseTimeInMS);
     }
 
     @Override
index ba3d4b1d4a2cace56c13e164ef68126dc29ab8d6..23cd4cc0bdc35075bdd03910d734718b223be038 100644 (file)
                <description>States whether a device is online or offline</description>
                <state readOnly="true"></state>
        </channel-type>
+
        <channel-type id="latency">
                <item-type>Number:Time</item-type>
                <label>Latency</label>
                <description>States the latency time</description>
                <state readOnly="true" pattern="%d %unit%"></state>
        </channel-type>
+
        <channel-type id="lastseen">
                <item-type>DateTime</item-type>
                <label>Last Seen</label>
                <description>States the last seen date/time</description>
+               <category>time</category>
                <state readOnly="true"></state>
        </channel-type>
 </thing:thing-descriptions>
index a42e9fbe00e3d756937cdc2da6d1232467c6dc1d..f5c75725c8cd523aca1379f6049047a6f6ad67ea 100644 (file)
@@ -178,8 +178,8 @@ public class PresenceDetectionTest {
 
     @Test
     public void reuseValueTests() throws InterruptedException, IOException {
-        final long START_TIME = 1000L;
-        when(subject.cache.getCurrentNanoTime()).thenReturn(TimeUnit.MILLISECONDS.toNanos(START_TIME));
+        final long startTime = 1000L;
+        when(subject.cache.getCurrentNanoTime()).thenReturn(TimeUnit.MILLISECONDS.toNanos(startTime));
 
         // The PresenceDetectionValue.getLowestLatency() should return the smallest latency
         PresenceDetectionValue v = subject.updateReachableValue(PresenceDetectionType.ICMP_PING, 20);
@@ -188,19 +188,19 @@ public class PresenceDetectionTest {
         assertThat(v.getLowestLatency(), is(19.0));
 
         // Advance in time but not expire the cache (1ms left)
-        final long ALMOST_EXPIRE = START_TIME + CACHETIME - 1;
-        when(subject.cache.getCurrentNanoTime()).thenReturn(TimeUnit.MILLISECONDS.toNanos(ALMOST_EXPIRE));
+        final long almostExpire = startTime + CACHETIME - 1;
+        when(subject.cache.getCurrentNanoTime()).thenReturn(TimeUnit.MILLISECONDS.toNanos(almostExpire));
 
         // Updating should reset the expire timer of the cache
         v2 = subject.updateReachableValue(PresenceDetectionType.ICMP_PING, 28);
         assertEquals(v, v2);
         assertThat(v2.getLowestLatency(), is(19.0));
         assertThat(ExpiringCacheHelper.expireTime(subject.cache),
-                is(TimeUnit.MILLISECONDS.toNanos(ALMOST_EXPIRE + CACHETIME)));
+                is(TimeUnit.MILLISECONDS.toNanos(almostExpire + CACHETIME)));
 
         // Cache expire. A new PresenceDetectionValue instance will be returned
         when(subject.cache.getCurrentNanoTime())
-                .thenReturn(TimeUnit.MILLISECONDS.toNanos(ALMOST_EXPIRE + CACHETIME + CACHETIME + 1));
+                .thenReturn(TimeUnit.MILLISECONDS.toNanos(almostExpire + CACHETIME + CACHETIME + 1));
         v2 = subject.updateReachableValue(PresenceDetectionType.ICMP_PING, 25);
         assertNotEquals(v, v2);
         assertThat(v2.getLowestLatency(), is(25.0));
index 5903941e4de66703e46284474ab34a53d20af02a..16676eeb2cd6a1cacab5a0d58bc29d78dc563ded 100644 (file)
@@ -22,6 +22,8 @@ import java.net.DatagramPacket;
 import java.net.DatagramSocket;
 import java.util.Arrays;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Timeout;
@@ -33,6 +35,7 @@ import org.openhab.core.util.HexUtils;
  * @author Wouter Born - Initial contribution
  */
 @Timeout(value = 10)
+@NonNullByDefault
 public class WakeOnLanPacketSenderTest {
 
     private void assertValidMagicPacket(byte[] macBytes, byte[] packet) {
@@ -102,7 +105,8 @@ public class WakeOnLanPacketSenderTest {
         assertThrows(IllegalStateException.class, () -> sendWOLTest(null, 4444));
     }
 
-    private void sendWOLTest(String hostname, Integer port) throws InterruptedException, IOException {
+    private void sendWOLTest(@Nullable String hostname, @Nullable Integer port)
+            throws InterruptedException, IOException {
         DatagramSocket socket = new DatagramSocket(4444);
 
         byte[] buf = new byte[256];
index 1f313162fea5560c0aa56edff22c4d079e015888..550a59a5c1edb95b4e3b82ddf3993aa11e483ad2 100644 (file)
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.net.SocketException;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.junit.jupiter.api.Test;
 import org.openhab.binding.network.internal.dhcp.DHCPPacket.BadPacketException;
 
@@ -30,6 +31,7 @@ import org.openhab.binding.network.internal.dhcp.DHCPPacket.BadPacketException;
  *
  * @author David Graeff - Initial contribution
  */
+@NonNullByDefault
 public class DHCPTest {
     @Test
     public void testService() throws SocketException {
index fa8fac825a45bced17d34a4c54ff9c4d92c0652d..cd506b080999f1d8e149ec275cded9f2843ca24d 100644 (file)
@@ -17,6 +17,7 @@ import static org.mockito.Mockito.*;
 
 import java.util.function.Consumer;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.openhab.binding.network.internal.toberemoved.cache.ExpiringCacheAsync.ExpiringCacheUpdate;
@@ -26,6 +27,7 @@ import org.openhab.binding.network.internal.toberemoved.cache.ExpiringCacheAsync
  *
  * @author David Graeff - Initial contribution
  */
+@NonNullByDefault
 public class ExpiringCacheAsyncTest {
     @Test
     public void testConstructorWrongCacheTime() {
index 7101d9dad4f46d19e407239140f0f709373fcef6..2142756a6bac88186913b6b0cf4a6982eaba0e81 100644 (file)
  */
 package org.openhab.binding.network.internal.toberemoved.cache;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * Helper class to make the package private cacheUpdater field available for tests.
  *
- * @author David Graeff
+ * @author David Graeff - Initial Contribution
  */
+@NonNullByDefault
 public class ExpiringCacheHelper {
     public static long expireTime(@SuppressWarnings("rawtypes") ExpiringCacheAsync cache) {
         return cache.expiresAt;
index 96ecfbc7ac508e9a4e085de94b75f347b26c6ce4..71d7cfb1d691dc22f5a77114d7764f8ac1bb017a 100644 (file)
@@ -16,6 +16,7 @@ import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Optional;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -23,6 +24,7 @@ import org.junit.jupiter.api.Test;
  *
  * @author Andreas Hirsch - Initial contribution
  */
+@NonNullByDefault
 public class LatencyParserTest {
 
     @Test