Skip to content

Commit

Permalink
[modbus] Cleanup workaround leftovers and fix a few SAT findings (#10670
Browse files Browse the repository at this point in the history
)

- Cleanup workaround leftovers and fix a few SAT findings

Signed-off-by: Wouter Born <github@maindrain.net>
  • Loading branch information
wborn committed May 12, 2021
1 parent c3a6aa5 commit 183fb0e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public String toString() {

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

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;

/**
* @author Sami Salonen - Initial contribution
*/
@NonNullByDefault
public class CascadedValueTransformationImplTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

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;

/**
* @author Sami Salonen - Initial contribution
*/
@NonNullByDefault
public class SingleValueTransformationTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
@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 %"),
Expand Down Expand Up @@ -81,9 +81,8 @@ private static Stream<Arguments> provideArgsForBoth() {
);
}

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"),
Expand Down Expand Up @@ -169,17 +168,11 @@ private void testOnUpdateFromHandlerGeneric(String preGainOffset, String gain, O
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
Expand Down Expand Up @@ -208,7 +201,7 @@ private static Stream<Arguments> provideAdditionalArgsForCommandFromItem() {

/**
*
* Test profile behaviour when item receives command
* Test profile behavior when item receives command
*
* @param preGainOffset profile pre-gain-offset
* @param gain profile gain
Expand Down

0 comments on commit 183fb0e

Please sign in to comment.