[modbus] Cleanup workaround leftovers and fix a few SAT findings (#10670)

- Cleanup workaround leftovers and fix a few SAT findings

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2021-05-12 13:15:24 +02:00 committed by GitHub
parent c3a6aa5814
commit 183fb0e390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 13 deletions

View 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;

View 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

View 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

View 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

View 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