[fineoffsetweatherstation] Fix failing tests (#15470)

This commit is contained in:
jimtng 2023-08-21 14:41:28 +10:00 committed by GitHub
parent 95ac2eb80b
commit 261456badc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -17,13 +17,13 @@ import java.util.List;
import org.assertj.core.api.Assertions; import org.assertj.core.api.Assertions;
import org.assertj.core.groups.Tuple; import org.assertj.core.groups.Tuple;
import org.bouncycastle.util.encoders.Hex;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.fineoffsetweatherstation.internal.domain.Command; import org.openhab.binding.fineoffsetweatherstation.internal.domain.Command;
import org.openhab.binding.fineoffsetweatherstation.internal.domain.ConversionContext; import org.openhab.binding.fineoffsetweatherstation.internal.domain.ConversionContext;
import org.openhab.binding.fineoffsetweatherstation.internal.domain.Protocol; import org.openhab.binding.fineoffsetweatherstation.internal.domain.Protocol;
import org.openhab.binding.fineoffsetweatherstation.internal.domain.response.MeasuredValue; import org.openhab.binding.fineoffsetweatherstation.internal.domain.response.MeasuredValue;
import org.openhab.core.util.HexUtils;
/** /**
* @author Andreas Berger - Initial contribution * @author Andreas Berger - Initial contribution
@ -32,7 +32,7 @@ import org.openhab.binding.fineoffsetweatherstation.internal.domain.response.Mea
class FineOffsetDataParserTest { class FineOffsetDataParserTest {
@Test @Test
void testLiveDataWH45() { void testLiveDataWH45() {
List<MeasuredValue> data = new FineOffsetDataParser(Protocol.DEFAULT).getMeasuredValues(Hex.decode( List<MeasuredValue> data = new FineOffsetDataParser(Protocol.DEFAULT).getMeasuredValues(HexUtils.hexToBytes(
"FFFF2700510100D306280827EF0927EF020045074F0A00150B00000C0000150000000016000117001900000E0000100000110021120000002113000005850D00007000D12E0060005A005B005502AE028F0633"), "FFFF2700510100D306280827EF0927EF020045074F0A00150B00000C0000150000000016000117001900000E0000100000110021120000002113000005850D00007000D12E0060005A005B005502AE028F0633"),
new ConversionContext(ZoneOffset.UTC)); new ConversionContext(ZoneOffset.UTC));
Assertions.assertThat(data) Assertions.assertThat(data)
@ -56,7 +56,7 @@ class FineOffsetDataParserTest {
@Test @Test
void testLiveDataELV() { void testLiveDataELV() {
byte[] data = Hex.decode( byte[] data = HexUtils.hexToBytes(
"FFFF0B00500401010B0201120300620401120501120629072108254B09254B0A01480B00040C000A0E000000001000000021110000002E120000014F130000100714000012FD15000B4BB816086917056D35"); "FFFF0B00500401010B0201120300620401120501120629072108254B09254B0A01480B00040C000A0E000000001000000021110000002E120000014F130000100714000012FD15000B4BB816086917056D35");
List<MeasuredValue> measuredValues = new FineOffsetDataParser(Protocol.ELV).getMeasuredValues(data, List<MeasuredValue> measuredValues = new FineOffsetDataParser(Protocol.ELV).getMeasuredValues(data,
new ConversionContext(ZoneOffset.UTC)); new ConversionContext(ZoneOffset.UTC));
@ -77,8 +77,8 @@ class FineOffsetDataParserTest {
@Test @Test
void testRainData() { void testRainData() {
byte[] data = Hex byte[] data = HexUtils
.decode("FFFF5700290E000010000000001100000024120000003113000005030D00000F0064880000017A017B0030"); .hexToBytes("FFFF5700290E000010000000001100000024120000003113000005030D00000F0064880000017A017B0030");
List<MeasuredValue> measuredValues = new FineOffsetDataParser(Protocol.DEFAULT).getRainData(data, List<MeasuredValue> measuredValues = new FineOffsetDataParser(Protocol.DEFAULT).getRainData(data,
new ConversionContext(ZoneOffset.UTC)); new ConversionContext(ZoneOffset.UTC));
Assertions.assertThat(measuredValues) Assertions.assertThat(measuredValues)
@ -91,7 +91,7 @@ class FineOffsetDataParserTest {
@Test @Test
void testRainDataW90() { void testRainDataW90() {
byte[] data = Hex.decode( byte[] data = HexUtils.hexToBytes(
"FFFF5700398000008300000009840000000985000000C786000000C7810000870064006400640064006400640064006400640064880900007A02BF"); "FFFF5700398000008300000009840000000985000000C786000000C7810000870064006400640064006400640064006400640064880900007A02BF");
Assertions.assertThat(Command.CMD_READ_RAIN.isResponseValid(data)).isTrue(); Assertions.assertThat(Command.CMD_READ_RAIN.isResponseValid(data)).isTrue();
List<MeasuredValue> measuredValues = new FineOffsetDataParser(Protocol.DEFAULT).getRainData(data, List<MeasuredValue> measuredValues = new FineOffsetDataParser(Protocol.DEFAULT).getRainData(data,
@ -105,7 +105,7 @@ class FineOffsetDataParserTest {
@Test @Test
void testFirmware() { void testFirmware() {
byte[] data = Hex.decode("FFFF501511456173795765617468657256312E362E3400"); byte[] data = HexUtils.hexToBytes("FFFF501511456173795765617468657256312E362E3400");
String firmware = new FineOffsetDataParser(Protocol.ELV).getFirmwareVersion(data); String firmware = new FineOffsetDataParser(Protocol.ELV).getFirmwareVersion(data);
Assertions.assertThat(firmware).isEqualTo("EasyWeatherV1.6.4"); Assertions.assertThat(firmware).isEqualTo("EasyWeatherV1.6.4");
} }