]> git.basschouten.com Git - openhab-addons.git/commitdiff
[modbus] Cleanup workaround leftovers and fix a few SAT findings (#10670)
authorWouter Born <github@maindrain.net>
Wed, 12 May 2021 11:15:24 +0000 (13:15 +0200)
committerGitHub <noreply@github.com>
Wed, 12 May 2021 11:15:24 +0000 (13:15 +0200)
- Cleanup workaround leftovers and fix a few SAT findings

Signed-off-by: Wouter Born <github@maindrain.net>
bundles/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/handler/ModbusPollerThingHandler.java
bundles/org.openhab.binding.modbus/src/test/java/org/openhab/binding/modbus/internal/AtomicStampedKeyValueTest.java
bundles/org.openhab.binding.modbus/src/test/java/org/openhab/binding/modbus/internal/CascadedValueTransformationImplTest.java
bundles/org.openhab.binding.modbus/src/test/java/org/openhab/binding/modbus/internal/SingleValueTransformationTest.java
bundles/org.openhab.binding.modbus/src/test/java/org/openhab/binding/modbus/internal/profiles/ModbusGainOffsetProfileTest.java

index c265946385fcaa80cfd0e23b2b352452c8ad06b0..452b3715793d4c73ce17c35917ff4a7a37fe3ef2 100644 (file)
@@ -183,7 +183,7 @@ public class ModbusPollerThingHandler extends BaseBridgeHandler {
 
     private final Logger logger = LoggerFactory.getLogger(ModbusPollerThingHandler.class);
 
-    private final static List<String> SORTED_READ_FUNCTION_CODES = ModbusBindingConstantsInternal.READ_FUNCTION_CODES
+    private static final List<String> SORTED_READ_FUNCTION_CODES = ModbusBindingConstantsInternal.READ_FUNCTION_CODES
             .keySet().stream().sorted().collect(Collectors.toUnmodifiableList());
 
     private @NonNullByDefault({}) ModbusPollerConfiguration config;
index fd7658a05a00b984443d0b0001cde27bf63470eb..2e949f670203af7c811a00dd00fae6412c779d5c 100644 (file)
@@ -16,11 +16,13 @@ import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.junit.jupiter.api.Test;
 
 /**
  * @author Sami Salonen - Initial contribution
  */
+@NonNullByDefault
 public class AtomicStampedKeyValueTest {
 
     @Test
index 303c62b2df0713372656086788fda5d205766cc3..54ef3026ebaef5e947e32d6e6d2a347a5bb2f769 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.modbus.internal;
 
 import static org.junit.jupiter.api.Assertions.*;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.osgi.framework.BundleContext;
@@ -21,6 +22,7 @@ import org.osgi.framework.BundleContext;
 /**
  * @author Sami Salonen - Initial contribution
  */
+@NonNullByDefault
 public class CascadedValueTransformationImplTest {
 
     @Test
index 504f7dd10042918c65f8d92945a84ffaf9c1023a..13cf63032d5764c7b1627628d2d2d14f8217bb61 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.modbus.internal;
 
 import static org.junit.jupiter.api.Assertions.*;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.osgi.framework.BundleContext;
@@ -21,6 +22,7 @@ import org.osgi.framework.BundleContext;
 /**
  * @author Sami Salonen - Initial contribution
  */
+@NonNullByDefault
 public class SingleValueTransformationTest {
 
     @Test
index 5506dbb867da7d86686c41c6fcbcae6785332133..1ad2be1b965394998ceff602fe1acb2aceaa383f 100644 (file)
@@ -46,7 +46,7 @@ import org.openhab.core.types.UnDefType;
 @NonNullByDefault
 public class ModbusGainOffsetProfileTest {
 
-    private static Stream<Arguments> provideArgsForBoth() {
+    static Stream<Arguments> provideArgsForBoth() {
         return Stream.of(
                 // dimensionless
                 Arguments.of("100", "0.5", "250", "175.0"), Arguments.of("0", "1 %", "250", "250 %"),
@@ -81,9 +81,8 @@ public class ModbusGainOffsetProfileTest {
         );
     }
 
-    private static Stream<Arguments> provideAdditionalArgsForStateUpdateFromHandler() {
+    static Stream<Arguments> provideAdditionalArgsForStateUpdateFromHandler() {
         return Stream.of(
-
                 // Dimensionless conversion 2.5/1% = 250%/1% = 250
                 Arguments.of("0", "1 %", "250", "250 %"), Arguments.of("2 %", "1 %", "249.9800", "250.0000 %"),
                 Arguments.of("50", "2 m/s", new DecimalType("3"), "106 m/s"),
@@ -169,17 +168,11 @@ public class ModbusGainOffsetProfileTest {
         Type expectedStateUpdateTowardsItem = (expectedUpdateTowardsItemObj instanceof String)
                 ? new QuantityType((String) expectedUpdateTowardsItemObj)
                 : (Type) expectedUpdateTowardsItemObj;
-        // Workaround for errors like "java.lang.UnsupportedOperationException: °C is non-linear, cannot convert"
-        if (expectedStateUpdateTowardsItem instanceof QuantityType<?>) {
-            assertTrue(actualStateUpdateTowardsItem instanceof QuantityType<?>);
-            assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
-        } else {
-            assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
-        }
+        assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
         verifyNoMoreInteractions(callback);
     }
 
-    private static Stream<Arguments> provideAdditionalArgsForCommandFromItem() {
+    static Stream<Arguments> provideAdditionalArgsForCommandFromItem() {
         return Stream.of(
                 // Dimensionless conversion 2.5/1% = 250%/1% = 250
                 // gain in %, command as bare ratio and the other way around
@@ -208,7 +201,7 @@ public class ModbusGainOffsetProfileTest {
 
     /**
      *
-     * Test profile behaviour when item receives command
+     * Test profile behavior when item receives command
      *
      * @param preGainOffset profile pre-gain-offset
      * @param gain profile gain