mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
[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:
parent
c3a6aa5814
commit
183fb0e390
@ -183,7 +183,7 @@ public class ModbusPollerThingHandler extends BaseBridgeHandler {
|
|||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ModbusPollerThingHandler.class);
|
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());
|
.keySet().stream().sorted().collect(Collectors.toUnmodifiableList());
|
||||||
|
|
||||||
private @NonNullByDefault({}) ModbusPollerConfiguration config;
|
private @NonNullByDefault({}) ModbusPollerConfiguration config;
|
||||||
|
@ -16,11 +16,13 @@ import static org.hamcrest.CoreMatchers.*;
|
|||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sami Salonen - Initial contribution
|
* @author Sami Salonen - Initial contribution
|
||||||
*/
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
public class AtomicStampedKeyValueTest {
|
public class AtomicStampedKeyValueTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -14,6 +14,7 @@ package org.openhab.binding.modbus.internal;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
@ -21,6 +22,7 @@ import org.osgi.framework.BundleContext;
|
|||||||
/**
|
/**
|
||||||
* @author Sami Salonen - Initial contribution
|
* @author Sami Salonen - Initial contribution
|
||||||
*/
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
public class CascadedValueTransformationImplTest {
|
public class CascadedValueTransformationImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -14,6 +14,7 @@ package org.openhab.binding.modbus.internal;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
@ -21,6 +22,7 @@ import org.osgi.framework.BundleContext;
|
|||||||
/**
|
/**
|
||||||
* @author Sami Salonen - Initial contribution
|
* @author Sami Salonen - Initial contribution
|
||||||
*/
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
public class SingleValueTransformationTest {
|
public class SingleValueTransformationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -46,7 +46,7 @@ import org.openhab.core.types.UnDefType;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ModbusGainOffsetProfileTest {
|
public class ModbusGainOffsetProfileTest {
|
||||||
|
|
||||||
private static Stream<Arguments> provideArgsForBoth() {
|
static Stream<Arguments> provideArgsForBoth() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
// dimensionless
|
// dimensionless
|
||||||
Arguments.of("100", "0.5", "250", "175.0"), Arguments.of("0", "1 %", "250", "250 %"),
|
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(
|
return Stream.of(
|
||||||
|
|
||||||
// Dimensionless conversion 2.5/1% = 250%/1% = 250
|
// Dimensionless conversion 2.5/1% = 250%/1% = 250
|
||||||
Arguments.of("0", "1 %", "250", "250 %"), Arguments.of("2 %", "1 %", "249.9800", "250.0000 %"),
|
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"),
|
Arguments.of("50", "2 m/s", new DecimalType("3"), "106 m/s"),
|
||||||
@ -169,17 +168,11 @@ public class ModbusGainOffsetProfileTest {
|
|||||||
Type expectedStateUpdateTowardsItem = (expectedUpdateTowardsItemObj instanceof String)
|
Type expectedStateUpdateTowardsItem = (expectedUpdateTowardsItemObj instanceof String)
|
||||||
? new QuantityType((String) expectedUpdateTowardsItemObj)
|
? new QuantityType((String) expectedUpdateTowardsItemObj)
|
||||||
: (Type) expectedUpdateTowardsItemObj;
|
: (Type) expectedUpdateTowardsItemObj;
|
||||||
// Workaround for errors like "java.lang.UnsupportedOperationException: °C is non-linear, cannot convert"
|
assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
|
||||||
if (expectedStateUpdateTowardsItem instanceof QuantityType<?>) {
|
|
||||||
assertTrue(actualStateUpdateTowardsItem instanceof QuantityType<?>);
|
|
||||||
assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
|
|
||||||
} else {
|
|
||||||
assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
|
|
||||||
}
|
|
||||||
verifyNoMoreInteractions(callback);
|
verifyNoMoreInteractions(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Stream<Arguments> provideAdditionalArgsForCommandFromItem() {
|
static Stream<Arguments> provideAdditionalArgsForCommandFromItem() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
// Dimensionless conversion 2.5/1% = 250%/1% = 250
|
// Dimensionless conversion 2.5/1% = 250%/1% = 250
|
||||||
// gain in %, command as bare ratio and the other way around
|
// 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 preGainOffset profile pre-gain-offset
|
||||||
* @param gain profile gain
|
* @param gain profile gain
|
||||||
|
Loading…
Reference in New Issue
Block a user