Remove code smells and increase code coverage
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / repository / Service.java
index 6458dbb..f0863a5 100644 (file)
@@ -23,7 +23,10 @@ package org.oransc.policyagent.repository;
 import java.time.Duration;
 import java.time.Instant;
 
+import lombok.Getter;
+
 public class Service {
+    @Getter
     private final String name;
     private final Duration keepAliveInterval;
     private Instant lastPing;
@@ -36,10 +39,6 @@ public class Service {
         ping();
     }
 
-    public synchronized String getName() {
-        return this.name;
-    }
-
     public synchronized Duration getKeepAliveInterval() {
         return this.keepAliveInterval;
     }
@@ -49,7 +48,7 @@ public class Service {
     }
 
     public synchronized boolean isExpired() {
-        return timeSinceLastPing().compareTo(this.keepAliveInterval) > 0;
+        return this.keepAliveInterval.getSeconds() > 0 && timeSinceLastPing().compareTo(this.keepAliveInterval) > 0;
     }
 
     public synchronized Duration timeSinceLastPing() {