diff --git a/build.gradle b/build.gradle index ecf5c01..31e6458 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,10 @@ subprojects { } } + test { + useJUnitPlatform() + } + // Standard libraries added to all projects dependencies { errorprone(libs.errorprone.core) @@ -43,7 +47,10 @@ subprojects { implementation libs.slf4j.api - testImplementation libs.junit + testImplementation(platform(libs.junit.bom)) + testImplementation libs.junit.jupiter + testRuntimeOnly libs.junit.platform.launcher + testImplementation libs.mockito.core } diff --git a/cayenne/src/test/java/nl/sikken/bertrik/cayenne/CayenneMessageTest.java b/cayenne/src/test/java/nl/sikken/bertrik/cayenne/CayenneMessageTest.java index 65c9f50..9cf803b 100644 --- a/cayenne/src/test/java/nl/sikken/bertrik/cayenne/CayenneMessageTest.java +++ b/cayenne/src/test/java/nl/sikken/bertrik/cayenne/CayenneMessageTest.java @@ -1,12 +1,12 @@ package nl.sikken.bertrik.cayenne; -import java.util.Base64; - -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Base64; + /** * Unit tests for CayenneMessage. */ @@ -18,67 +18,67 @@ public final class CayenneMessageTest { /** * Verifies example from specification. - * + * * @throws CayenneException in case of a parsing exception */ @Test public void testTwoTemperatureSensors() throws CayenneException { - byte[] data = { 0x03, 0x67, 0x01, 0x10, 0x05, 0x67, 0x00, (byte) 0xFF }; + byte[] data = {0x03, 0x67, 0x01, 0x10, 0x05, 0x67, 0x00, (byte) 0xFF}; CayenneMessage payload = new CayenneMessage(); payload.parse(data); LOG.info("payload: {}", payload); - Assert.assertArrayEquals(new String[] { "27.2" }, payload.ofChannel(3).format()); - Assert.assertArrayEquals(new String[] { "25.5" }, payload.ofChannel(5).format()); + Assertions.assertArrayEquals(new String[]{"27.2"}, payload.ofChannel(3).format()); + Assertions.assertArrayEquals(new String[]{"25.5"}, payload.ofChannel(5).format()); } /** * Verifies example from specification. - * + * * @throws CayenneException in case of a parsing exception */ @Test public void testTemperaturePlusAccel() throws CayenneException { - byte[] data = { 0x01, 0x67, (byte) 0xFF, (byte) 0xD7, 0x06, 0x71, 0x04, (byte) 0xD2, (byte) 0xFB, 0x2E, 0x00, - 0x00 }; + byte[] data = {0x01, 0x67, (byte) 0xFF, (byte) 0xD7, 0x06, 0x71, 0x04, (byte) 0xD2, (byte) 0xFB, 0x2E, 0x00, + 0x00}; CayenneMessage payload = new CayenneMessage(); payload.parse(data); - Assert.assertArrayEquals(new String[] { "-4.1" }, payload.ofChannel(1).format()); - Assert.assertArrayEquals(new String[] { "1.234", "-1.234", "0.000" }, payload.ofChannel(6).format()); + Assertions.assertArrayEquals(new String[]{"-4.1"}, payload.ofChannel(1).format()); + Assertions.assertArrayEquals(new String[]{"1.234", "-1.234", "0.000"}, payload.ofChannel(6).format()); } /** * Verifies example from specification. - * + * * @throws CayenneException in case of a parsing exception */ @Test public void testGps() throws CayenneException { - byte[] data = { 0x01, (byte) 0x88, 0x06, 0x076, 0x5f, (byte) 0xf2, (byte) 0x96, 0x0a, 0x00, 0x03, (byte) 0xe8 }; + byte[] data = {0x01, (byte) 0x88, 0x06, 0x076, 0x5f, (byte) 0xf2, (byte) 0x96, 0x0a, 0x00, 0x03, (byte) 0xe8}; CayenneMessage payload = new CayenneMessage(); payload.parse(data); - Assert.assertArrayEquals(new String[] { "42.3519", "-87.9094", "10.00" }, payload.ofChannel(1).format()); + Assertions.assertArrayEquals(new String[]{"42.3519", "-87.9094", "10.00"}, payload.ofChannel(1).format()); } /** * Verifies parsing of humidity value. - * + * * @throws CayenneException in case of a parsing exception */ @Test public void testHumidity() throws CayenneException { - byte[] data = { 1, 104, 100 }; + byte[] data = {1, 104, 100}; CayenneMessage payload = new CayenneMessage(); payload.parse(data); - Assert.assertArrayEquals(new String[] { "50.0" }, payload.ofChannel(1).format()); + Assertions.assertArrayEquals(new String[]{"50.0"}, payload.ofChannel(1).format()); } /** * Verifies parsing of some actual data from a sodaq one. - * + * * @throws CayenneException in case of a parsing exception */ @Test @@ -88,15 +88,15 @@ public void testActualData() throws CayenneException { CayenneMessage payload = new CayenneMessage(); payload.parse(data); - Assert.assertArrayEquals(new String[] { "52.0225", "4.6928", "-2.00" }, payload.ofChannel(1).format()); - Assert.assertArrayEquals(new String[] { "247.84" }, payload.ofChannel(2).format()); - Assert.assertArrayEquals(new String[] { "27.0" }, payload.ofChannel(3).format()); + Assertions.assertArrayEquals(new String[]{"52.0225", "4.6928", "-2.00"}, payload.ofChannel(1).format()); + Assertions.assertArrayEquals(new String[]{"247.84"}, payload.ofChannel(2).format()); + Assertions.assertArrayEquals(new String[]{"27.0"}, payload.ofChannel(3).format()); } /** * Verifies parsing of some actual data from a sodaq one, with a fix applied to * the voltage value. - * + * * @throws CayenneException in case of a parsing exception */ @Test @@ -107,69 +107,64 @@ public void testActualData2() throws CayenneException { payload.parse(data); // verify we can get at the data by channel - Assert.assertArrayEquals(new String[] { "52.0225", "4.6925", "-17.00" }, payload.ofChannel(1).format()); - Assert.assertArrayEquals(new String[] { "4.15" }, payload.ofChannel(2).format()); - Assert.assertArrayEquals(new String[] { "24.0" }, payload.ofChannel(3).format()); + Assertions.assertArrayEquals(new String[]{"52.0225", "4.6925", "-17.00"}, payload.ofChannel(1).format()); + Assertions.assertArrayEquals(new String[]{"4.15"}, payload.ofChannel(2).format()); + Assertions.assertArrayEquals(new String[]{"24.0"}, payload.ofChannel(3).format()); // verify we can also get data by type - Assert.assertArrayEquals(new String[] { "52.0225", "4.6925", "-17.00" }, + Assertions.assertArrayEquals(new String[]{"52.0225", "4.6925", "-17.00"}, payload.ofType(ECayenneItem.GPS_LOCATION).format()); - Assert.assertArrayEquals(new String[] { "4.15" }, payload.ofType(ECayenneItem.ANALOG_INPUT).format()); - Assert.assertArrayEquals(new String[] { "24.0" }, payload.ofType(ECayenneItem.TEMPERATURE).format()); + Assertions.assertArrayEquals(new String[]{"4.15"}, payload.ofType(ECayenneItem.ANALOG_INPUT).format()); + Assertions.assertArrayEquals(new String[]{"24.0"}, payload.ofType(ECayenneItem.TEMPERATURE).format()); // verify non-existing channel and type - Assert.assertNull(payload.ofChannel(0)); - Assert.assertNull(payload.ofType(ECayenneItem.BAROMETER)); + Assertions.assertNull(payload.ofChannel(0)); + Assertions.assertNull(payload.ofType(ECayenneItem.BAROMETER)); // verify toString method - Assert.assertNotNull(payload.toString()); + Assertions.assertNotNull(payload.toString()); } /** * Verifies parsing an empty string. - * + * * @throws CayenneException in case of a parsing exception */ @Test public void testParseEmpty() throws CayenneException { CayenneMessage payload = new CayenneMessage(); payload.parse(new byte[0]); - Assert.assertTrue(payload.getItems().isEmpty()); + Assertions.assertTrue(payload.getItems().isEmpty()); } /** * Verifies parsing a short buffer - * - * @throws CayenneException in case of a parsing exception */ - @Test(expected = CayenneException.class) - public void testShortBuffer() throws CayenneException { - new CayenneMessage().parse(new byte[] { 0 }); + @Test + public void testShortBuffer() { + Assertions.assertThrows(CayenneException.class, () -> new CayenneMessage().parse(new byte[]{0})); } /** * Verifies parsing of a buffer containing a non-supported data type. - * - * @throws CayenneException in case of a parsing exception */ - @Test(expected = CayenneException.class) - public void testInvalidType() throws CayenneException { - new CayenneMessage().parse(new byte[] { 0, 100 }); + @Test + public void testInvalidType() { + Assertions.assertThrows(CayenneException.class, () -> new CayenneMessage().parse(new byte[]{0, 100})); } /** * Verifies parsing of a buffer containing insufficient data during parsing. - * - * @throws CayenneException in case of a parsing exception */ - @Test(expected = CayenneException.class) - public void testShortData() throws CayenneException { - new CayenneMessage().parse(new byte[] { 2, 1 }); + @Test + public void testShortData() { + Assertions.assertThrows(CayenneException.class, () -> + new CayenneMessage().parse(new byte[]{2, 1})); } /** * Verifies encoding of a float value. - * + * * @throws CayenneException in case of a parsing exception */ @Test @@ -181,12 +176,12 @@ public void encodeFloat() throws CayenneException { CayenneMessage decoded = new CayenneMessage(); decoded.parse(encoded); - Assert.assertEquals(-12.34, decoded.getItems().get(0).getValues()[0].doubleValue(), 0.01); + Assertions.assertEquals(-12.34, decoded.getItems().get(0).getValues()[0].doubleValue(), 0.01); } /** * Verifies encoding of a humidity value. - * + * * @throws CayenneException in case of a parsing exception */ @Test @@ -199,14 +194,14 @@ public void encodeHumidity() throws CayenneException { decoded.parse(encoded); CayenneItem item = decoded.getItems().get(0); - Assert.assertEquals(ECayenneItem.HUMIDITY, item.getType()); - Assert.assertEquals(35.5, item.getValues()[0].doubleValue(), 0.1); - Assert.assertEquals("35.5", item.format()[0]); + Assertions.assertEquals(ECayenneItem.HUMIDITY, item.getType()); + Assertions.assertEquals(35.5, item.getValues()[0].doubleValue(), 0.1); + Assertions.assertEquals("35.5", item.format()[0]); } /** * Verifies encoding of a digital input. - * + * * @throws CayenneException in case of a parsing exception */ @Test @@ -219,8 +214,8 @@ public void testDigitalInput() throws CayenneException { decoded.parse(encoded); CayenneItem item = decoded.getItems().get(0); - Assert.assertEquals(ECayenneItem.DIGITAL_INPUT, item.getType()); - Assert.assertEquals(1, item.getValues()[0].intValue()); + Assertions.assertEquals(ECayenneItem.DIGITAL_INPUT, item.getType()); + Assertions.assertEquals(1, item.getValues()[0].intValue()); } /** @@ -236,9 +231,9 @@ public void testPresence() throws CayenneException { decoded.parse(encoded); CayenneItem item = decoded.getItems().get(0); - Assert.assertEquals(ECayenneItem.PRESENCE, item.getType()); - Assert.assertEquals(7, item.getValues()[0].intValue()); - Assert.assertEquals("7", item.format()[0]); + Assertions.assertEquals(ECayenneItem.PRESENCE, item.getType()); + Assertions.assertEquals(7, item.getValues()[0].intValue()); + Assertions.assertEquals("7", item.format()[0]); } /** @@ -247,11 +242,11 @@ public void testPresence() throws CayenneException { @Test public void testPackedFormat() throws CayenneException { CayenneMessage message = new CayenneMessage(ECayennePayloadFormat.PACKED_SENSOR_PAYLOAD); - byte[] data = { 0x67, 0x01, 0x10, 0x67, 0x00, (byte) 0xFF }; + byte[] data = {0x67, 0x01, 0x10, 0x67, 0x00, (byte) 0xFF}; message.parse(data); - Assert.assertEquals(27.2, message.ofChannel(0).getValue().doubleValue(), 0.01); - Assert.assertEquals(25.5, message.ofChannel(1).getValue().doubleValue(), 0.01); + Assertions.assertEquals(27.2, message.ofChannel(0).getValue().doubleValue(), 0.01); + Assertions.assertEquals(25.5, message.ofChannel(1).getValue().doubleValue(), 0.01); } } diff --git a/cayenne/src/test/java/nl/sikken/bertrik/cayenne/CayennePayloadFormatTest.java b/cayenne/src/test/java/nl/sikken/bertrik/cayenne/CayennePayloadFormatTest.java index f9dc264..d793c7c 100644 --- a/cayenne/src/test/java/nl/sikken/bertrik/cayenne/CayennePayloadFormatTest.java +++ b/cayenne/src/test/java/nl/sikken/bertrik/cayenne/CayennePayloadFormatTest.java @@ -1,7 +1,7 @@ package nl.sikken.bertrik.cayenne; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * See https://community.mydevices.com/t/cayenne-lpp-2-0/7510 @@ -10,9 +10,9 @@ public final class CayennePayloadFormatTest { @Test public void testPort() { - Assert.assertNull(ECayennePayloadFormat.fromPort(0)); - Assert.assertEquals(ECayennePayloadFormat.DYNAMIC_SENSOR_PAYLOAD, ECayennePayloadFormat.fromPort(1)); - Assert.assertEquals(ECayennePayloadFormat.PACKED_SENSOR_PAYLOAD, ECayennePayloadFormat.fromPort(2)); + Assertions.assertNull(ECayennePayloadFormat.fromPort(0)); + Assertions.assertEquals(ECayennePayloadFormat.DYNAMIC_SENSOR_PAYLOAD, ECayennePayloadFormat.fromPort(1)); + Assertions.assertEquals(ECayennePayloadFormat.PACKED_SENSOR_PAYLOAD, ECayennePayloadFormat.fromPort(2)); } } diff --git a/cayenne/src/test/java/nl/sikken/bertrik/cayenne/SimpleCayenneTest.java b/cayenne/src/test/java/nl/sikken/bertrik/cayenne/SimpleCayenneTest.java index 01f01dc..fcd2f3f 100644 --- a/cayenne/src/test/java/nl/sikken/bertrik/cayenne/SimpleCayenneTest.java +++ b/cayenne/src/test/java/nl/sikken/bertrik/cayenne/SimpleCayenneTest.java @@ -1,7 +1,7 @@ package nl.sikken.bertrik.cayenne; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,7 +15,7 @@ public final class SimpleCayenneTest { /** * Verifies basic functionality by adding some items and encoding it into a * message - * + * * @throws CayenneException in case of a problem encoding/decoding */ @Test @@ -37,30 +37,31 @@ public void testEncode() throws CayenneException { // encode it byte[] data = cayenne.encode(500); - Assert.assertNotNull(data); + Assertions.assertNotNull(data); // decode it CayenneMessage message = new CayenneMessage(); message.parse(data); - Assert.assertEquals(12, message.getItems().size()); - Assert.assertEquals(3.82, message.ofType(ECayenneItem.ANALOG_INPUT).getValue().doubleValue(), 0.01); - Assert.assertEquals(55, message.ofType(ECayenneItem.DIGITAL_INPUT).getValue().intValue()); - Assert.assertEquals(66, message.ofType(ECayenneItem.DIGITAL_OUTPUT).getValue().intValue()); - Assert.assertEquals(52.0, message.ofType(ECayenneItem.GPS_LOCATION).getValues()[0].doubleValue(), 0.1); - Assert.assertEquals(42, message.ofType(ECayenneItem.PRESENCE).getValue().intValue(), 42); - Assert.assertEquals(19.0, message.ofType(ECayenneItem.TEMPERATURE).getValue().doubleValue(), 0.1); + Assertions.assertEquals(12, message.getItems().size()); + Assertions.assertEquals(3.82, message.ofType(ECayenneItem.ANALOG_INPUT).getValue().doubleValue(), 0.01); + Assertions.assertEquals(55, message.ofType(ECayenneItem.DIGITAL_INPUT).getValue().intValue()); + Assertions.assertEquals(66, message.ofType(ECayenneItem.DIGITAL_OUTPUT).getValue().intValue()); + Assertions.assertEquals(52.0, message.ofType(ECayenneItem.GPS_LOCATION).getValues()[0].doubleValue(), 0.1); + Assertions.assertEquals(42, message.ofType(ECayenneItem.PRESENCE).getValue().intValue(), 42); + Assertions.assertEquals(19.0, message.ofType(ECayenneItem.TEMPERATURE).getValue().doubleValue(), 0.1); } /** * Verifies that a simple cayenne message with non-unique channels is rejected. - * + * * @throws CayenneException in case of a problem encoding/decoding */ - @Test(expected = CayenneException.class) + @Test public void testNonUniqueChannel() throws CayenneException { SimpleCayenne cayenne = new SimpleCayenne(); cayenne.addTemperature(1, 19.0); - cayenne.addAnalogInput(1, 3.90); + Assertions.assertThrows(CayenneException.class, () -> + cayenne.addAnalogInput(1, 3.90)); } } diff --git a/cayenne/src/test/java/nl/sikken/bertrik/cayenne/formatter/GpsFormatterTest.java b/cayenne/src/test/java/nl/sikken/bertrik/cayenne/formatter/GpsFormatterTest.java index fb4a578..9fce2f8 100644 --- a/cayenne/src/test/java/nl/sikken/bertrik/cayenne/formatter/GpsFormatterTest.java +++ b/cayenne/src/test/java/nl/sikken/bertrik/cayenne/formatter/GpsFormatterTest.java @@ -1,9 +1,9 @@ package nl.sikken.bertrik.cayenne.formatter; -import java.nio.ByteBuffer; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -import org.junit.Assert; -import org.junit.Test; +import java.nio.ByteBuffer; public final class GpsFormatterTest { @@ -19,9 +19,9 @@ public void testEncodeDecode() { // decode bb.flip(); Double[] parsed = formatter.parse(bb); - Assert.assertEquals(coords[0], parsed[0], 0.01); - Assert.assertEquals(coords[1], parsed[1], 0.01); - Assert.assertEquals(coords[2], parsed[2], 0.01); + Assertions.assertEquals(coords[0], parsed[0], 0.01); + Assertions.assertEquals(coords[1], parsed[1], 0.01); + Assertions.assertEquals(coords[2], parsed[2], 0.01); } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3e87695..fa28491 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,6 +2,7 @@ errorprone = "2.36.0" jackson = "2.18.1" jersey = "3.1.9" +junit = "5.11.3" mockito = "5.14.2" retrofit = "2.11.0" slf4j = "2.0.16" @@ -21,7 +22,9 @@ retrofit-converter-jackson = { module = "com.squareup.retrofit2:converter-jackso retrofit-converter-scalars = { module = "com.squareup.retrofit2:converter-scalars", version.ref = "retrofit" } retrofit-mock = { module = "com.squareup.retrofit2:retrofit-mock", version.ref = "retrofit" } -junit = "junit:junit:4.13.2" +junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" } +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" } +junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" } paho-client-mqttv3 = "org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5" diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/geo/SimpleGeoModelTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/geo/SimpleGeoModelTest.java index 31ff3fb..71838d3 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/geo/SimpleGeoModelTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/geo/SimpleGeoModelTest.java @@ -1,18 +1,18 @@ package nl.bertriksikken.geo; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public final class SimpleGeoModelTest { @Test public void testDistance() { - double[] gouda = new double[] {52.01667, 4.70833}; - double[] groningen = new double[] {53.21917, 6.56667}; + double[] gouda = new double[]{52.01667, 4.70833}; + double[] groningen = new double[]{53.21917, 6.56667}; SimpleGeoModel model = new SimpleGeoModel(); double d = model.distance(gouda, groningen); - - Assert.assertEquals(183557, d, 1); + + Assertions.assertEquals(183557, d, 1); } - + } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/gls/GeoLocationConfigTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/gls/GeoLocationConfigTest.java index b24f2fc..d065632 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/gls/GeoLocationConfigTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/gls/GeoLocationConfigTest.java @@ -1,10 +1,9 @@ package nl.bertriksikken.gls; -import org.junit.Test; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import org.junit.jupiter.api.Test; public final class GeoLocationConfigTest { diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/helium/HeliumUplinkMessageTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/helium/HeliumUplinkMessageTest.java index 258d031..d007bb0 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/helium/HeliumUplinkMessageTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/helium/HeliumUplinkMessageTest.java @@ -1,14 +1,12 @@ package nl.bertriksikken.helium; -import java.io.IOException; -import java.io.InputStream; - -import org.junit.Assert; -import org.junit.Test; - import com.fasterxml.jackson.databind.ObjectMapper; - import nl.bertriksikken.helium.HeliumUplinkMessage.HotSpot; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.InputStream; public class HeliumUplinkMessageTest { @@ -18,23 +16,23 @@ public void testDecode() throws IOException { try (InputStream is = this.getClass().getResourceAsStream("/helium_uplink.json")) { ObjectMapper mapper = new ObjectMapper(); HeliumUplinkMessage uplink = mapper.readValue(is, HeliumUplinkMessage.class); - Assert.assertNotNull(uplink); + Assertions.assertNotNull(uplink); - Assert.assertEquals("6081F9D16837130E", uplink.appEui); - Assert.assertEquals("5A010048", uplink.devAddr); - Assert.assertEquals("0004A30B001F21FA", uplink.devEui); - Assert.assertEquals(0, uplink.fcnt); - Assert.assertEquals("kissmapper", uplink.name); - Assert.assertEquals(1, uplink.port); - Assert.assertEquals(1631457565832L, uplink.reportedAt); - Assert.assertArrayEquals(new byte[] { 3 }, uplink.payload); + Assertions.assertEquals("6081F9D16837130E", uplink.appEui); + Assertions.assertEquals("5A010048", uplink.devAddr); + Assertions.assertEquals("0004A30B001F21FA", uplink.devEui); + Assertions.assertEquals(0, uplink.fcnt); + Assertions.assertEquals("kissmapper", uplink.name); + Assertions.assertEquals(1, uplink.port); + Assertions.assertEquals(1631457565832L, uplink.reportedAt); + Assertions.assertArrayEquals(new byte[]{3}, uplink.payload); HotSpot hotSpot = uplink.hotSpots.get(0); - Assert.assertEquals(52.01745, hotSpot.latitude, 0.00001); - Assert.assertEquals(4.729876, hotSpot.longitude, 0.00001); - Assert.assertEquals("melted-quartz-antelope", hotSpot.name); - Assert.assertEquals(-120, hotSpot.rssi, 0.1); - Assert.assertEquals(-7.5, hotSpot.snr, 0.1); + Assertions.assertEquals(52.01745, hotSpot.latitude, 0.00001); + Assertions.assertEquals(4.729876, hotSpot.longitude, 0.00001); + Assertions.assertEquals("melted-quartz-antelope", hotSpot.name); + Assertions.assertEquals(-120, hotSpot.rssi, 0.1); + Assertions.assertEquals(-7.5, hotSpot.snr, 0.1); } } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/loraforwarder/SensorDataBridgeConfigTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/loraforwarder/SensorDataBridgeConfigTest.java index d930c67..465c040 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/loraforwarder/SensorDataBridgeConfigTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/loraforwarder/SensorDataBridgeConfigTest.java @@ -1,19 +1,17 @@ package nl.bertriksikken.loraforwarder; -import org.junit.Test; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.POJONode; import com.fasterxml.jackson.databind.node.TextNode; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; - import nl.bertriksikken.pm.ESensorItem; import nl.bertriksikken.pm.json.JsonDecoderConfig; import nl.bertriksikken.pm.json.JsonDecoderItem; import nl.bertriksikken.ttn.TtnAppConfig; import nl.bertriksikken.ttn.TtnAppConfig.DecoderConfig; import nl.bertriksikken.ttn.TtnConfig; +import org.junit.jupiter.api.Test; public final class SensorDataBridgeConfigTest { diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/CdpMessageTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/CdpMessageTest.java index 974c473..09a6a66 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/CdpMessageTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/CdpMessageTest.java @@ -1,34 +1,30 @@ package nl.bertriksikken.nbiot; -import java.io.IOException; -import java.io.InputStream; - -import org.junit.Assert; -import org.junit.Test; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; - import nl.bertriksikken.nbiot.CdpMessage.Report; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.InputStream; public final class CdpMessageTest { @Test - public void testDecodeJson() throws JsonParseException, JsonMappingException, IOException { + public void testDecodeJson() throws IOException { // decode JSON try (InputStream is = this.getClass().getResourceAsStream("/cdp_message.json")) { ObjectMapper mapper = new ObjectMapper(); CdpMessage message = mapper.readValue(is, CdpMessage.class); - Assert.assertFalse(message.reports.isEmpty()); + Assertions.assertFalse(message.reports.isEmpty()); Report report = message.reports.get(0); - Assert.assertEquals("IMEI:868333030676163", report.serialNumber); - Assert.assertEquals(1615660679246L, report.timestamp); - Assert.assertEquals("06f872fc-02b3-4b20-8394-3f19a7006ca9", report.subscriptionId); - Assert.assertEquals("uplinkMsg/0/data", report.resourcePath); - Assert.assertEquals("01a3021c", report.value); + Assertions.assertEquals("IMEI:868333030676163", report.serialNumber); + Assertions.assertEquals(1615660679246L, report.timestamp); + Assertions.assertEquals("06f872fc-02b3-4b20-8394-3f19a7006ca9", report.subscriptionId); + Assertions.assertEquals("uplinkMsg/0/data", report.resourcePath); + Assertions.assertEquals("01a3021c", report.value); } } @@ -36,7 +32,7 @@ public void testDecodeJson() throws JsonParseException, JsonMappingException, IO public void testToString() { CdpMessage message = new CdpMessage(); String s = message.toString(); - Assert.assertNotNull(s); + Assertions.assertNotNull(s); } } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/CdpRestApiTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/CdpRestApiTest.java index cf756ce..a2c9b7d 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/CdpRestApiTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/CdpRestApiTest.java @@ -1,8 +1,7 @@ package nl.bertriksikken.nbiot; -import org.junit.Test; - import nl.bertriksikken.nbiot.CdpMessage.Report; +import org.junit.jupiter.api.Test; public final class CdpRestApiTest { diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/HexConverterTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/HexConverterTest.java index ea97423..2ebbb56 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/HexConverterTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/nbiot/HexConverterTest.java @@ -1,40 +1,41 @@ package nl.bertriksikken.nbiot; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public final class HexConverterTest { @Test public void testHappyFlow() { - Assert.assertArrayEquals(new byte[0], HexConverter.fromString("")); - Assert.assertArrayEquals(new byte[] {0}, HexConverter.fromString("00")); - Assert.assertArrayEquals(new byte[] {1}, HexConverter.fromString("01")); - Assert.assertArrayEquals(new byte[] {(byte) 0x80}, HexConverter.fromString("80")); - Assert.assertArrayEquals(new byte[] {(byte) 0xAB}, HexConverter.fromString("ab")); - Assert.assertArrayEquals(new byte[] {(byte) 0xAB}, HexConverter.fromString("AB")); - Assert.assertArrayEquals(new byte[] {(byte) 0xFF}, HexConverter.fromString("fF")); - - Assert.assertArrayEquals(new byte[] {0, 0}, HexConverter.fromString("0000")); - Assert.assertArrayEquals(new byte[] {0, 1}, HexConverter.fromString("0001")); - Assert.assertArrayEquals(new byte[] {(byte) 0xAB, (byte) 0xCD}, HexConverter.fromString("ABCD")); + Assertions.assertArrayEquals(new byte[0], HexConverter.fromString("")); + Assertions.assertArrayEquals(new byte[]{0}, HexConverter.fromString("00")); + Assertions.assertArrayEquals(new byte[]{1}, HexConverter.fromString("01")); + Assertions.assertArrayEquals(new byte[]{(byte) 0x80}, HexConverter.fromString("80")); + Assertions.assertArrayEquals(new byte[]{(byte) 0xAB}, HexConverter.fromString("ab")); + Assertions.assertArrayEquals(new byte[]{(byte) 0xAB}, HexConverter.fromString("AB")); + Assertions.assertArrayEquals(new byte[]{(byte) 0xFF}, HexConverter.fromString("fF")); + + Assertions.assertArrayEquals(new byte[]{0, 0}, HexConverter.fromString("0000")); + Assertions.assertArrayEquals(new byte[]{0, 1}, HexConverter.fromString("0001")); + Assertions.assertArrayEquals(new byte[]{(byte) 0xAB, (byte) 0xCD}, HexConverter.fromString("ABCD")); } - - @Test(expected = NumberFormatException.class) + + @Test public void testInvalidCharacters() { - HexConverter.fromString("xx"); + Assertions.assertThrows(NumberFormatException.class, () -> + HexConverter.fromString("xx")); } - @Test(expected = NumberFormatException.class) + @Test public void testOddCharacters() { - Assert.assertArrayEquals(new byte[] {0}, HexConverter.fromString("000")); + Assertions.assertThrows(NumberFormatException.class, () -> HexConverter.fromString("000")); } @Test public void testToString() { - Assert.assertEquals("(null)", HexConverter.toString(null)); - Assert.assertEquals("", HexConverter.toString(new byte[0])); - Assert.assertEquals("123481", HexConverter.toString(new byte[] {0x12, 0x34, (byte)0x81})); + Assertions.assertEquals("(null)", HexConverter.toString(null)); + Assertions.assertEquals("", HexConverter.toString(new byte[0])); + Assertions.assertEquals("123481", HexConverter.toString(new byte[]{0x12, 0x34, (byte) 0x81})); } - + } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/SensorDataTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/SensorDataTest.java index e3a3f8d..7094507 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/SensorDataTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/SensorDataTest.java @@ -1,7 +1,7 @@ package nl.bertriksikken.pm; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public final class SensorDataTest { @@ -11,37 +11,37 @@ public void testInRange() { // value in range sensorData.putValue(ESensorItem.HUMIDITY, 100.0); - Assert.assertTrue(sensorData.hasValue(ESensorItem.HUMIDITY)); - Assert.assertTrue(sensorData.hasValid(ESensorItem.HUMIDITY)); - Assert.assertEquals(100.0, sensorData.getValue(ESensorItem.HUMIDITY), 0.1); + Assertions.assertTrue(sensorData.hasValue(ESensorItem.HUMIDITY)); + Assertions.assertTrue(sensorData.hasValid(ESensorItem.HUMIDITY)); + Assertions.assertEquals(100.0, sensorData.getValue(ESensorItem.HUMIDITY), 0.1); // value out of range sensorData.putValue(ESensorItem.PM10, -1.0); - Assert.assertTrue(sensorData.hasValue(ESensorItem.HUMIDITY)); - Assert.assertFalse(sensorData.hasValid(ESensorItem.PM10)); + Assertions.assertTrue(sensorData.hasValue(ESensorItem.HUMIDITY)); + Assertions.assertFalse(sensorData.hasValid(ESensorItem.PM10)); // invalid value sensorData.putValue(ESensorItem.PM2_5, Double.NaN); - Assert.assertTrue(sensorData.hasValue(ESensorItem.HUMIDITY)); - Assert.assertFalse(sensorData.hasValid(ESensorItem.PM2_5)); + Assertions.assertTrue(sensorData.hasValue(ESensorItem.HUMIDITY)); + Assertions.assertFalse(sensorData.hasValid(ESensorItem.PM2_5)); // null value sensorData.putValue(ESensorItem.PM1_0, null); - Assert.assertFalse(sensorData.hasValue(ESensorItem.PM1_0)); - Assert.assertFalse(sensorData.hasValid(ESensorItem.PM1_0)); + Assertions.assertFalse(sensorData.hasValue(ESensorItem.PM1_0)); + Assertions.assertFalse(sensorData.hasValid(ESensorItem.PM1_0)); } @Test public void testString() { SensorData sensorData = new SensorData(); String s = sensorData.toString(); - Assert.assertEquals("{}", s); + Assertions.assertEquals("{}", s); // value in range sensorData.putValue(ESensorItem.PM2_5, 2.5); sensorData.putValue(ESensorItem.PM10, 10.0); sensorData.putValue(ESensorItem.HUMIDITY, 12.3); - Assert.assertEquals("{PM2_5=2.5ug/m3,PM10=10.0ug/m3,HUMIDITY=12.3%}", sensorData.toString()); + Assertions.assertEquals("{PM2_5=2.5ug/m3,PM10=10.0ug/m3,HUMIDITY=12.3%}", sensorData.toString()); } } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/cayenne/TtnCayenneMessageTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/cayenne/TtnCayenneMessageTest.java index e5b44bb..85ab564 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/cayenne/TtnCayenneMessageTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/cayenne/TtnCayenneMessageTest.java @@ -1,23 +1,22 @@ package nl.bertriksikken.pm.cayenne; -import org.junit.Assert; -import org.junit.Test; - import nl.bertriksikken.pm.PayloadParseException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public final class TtnCayenneMessageTest { @Test public void testHappyFlow() throws PayloadParseException { - byte[] raw = new byte[] { 0x01, 0x02, 0x00, 0x64, 0x02, 0x02, 0x00, 0x19, 0x03, 0x67, (byte) 0xFF, (byte) 0xF0, - 0x04, 0x68, 0x77, 0x05, 115, 0x27, (byte)0x88 }; + byte[] raw = new byte[]{0x01, 0x02, 0x00, 0x64, 0x02, 0x02, 0x00, 0x19, 0x03, 0x67, (byte) 0xFF, (byte) 0xF0, + 0x04, 0x68, 0x77, 0x05, 115, 0x27, (byte) 0x88}; TtnCayenneMessage msg = TtnCayenneMessage.parse(raw); - - Assert.assertEquals(1.0, msg.getPm10(), 0.01); - Assert.assertEquals(0.25, msg.getPm2_5(), 0.01); - Assert.assertEquals(-1.6, msg.getTempC(), 0.01); - Assert.assertEquals(59.5, msg.getRhPerc(), 0.01); - Assert.assertEquals(1012.0, msg.getPressureMillibar(), 0.1); + + Assertions.assertEquals(1.0, msg.getPm10(), 0.01); + Assertions.assertEquals(0.25, msg.getPm2_5(), 0.01); + Assertions.assertEquals(-1.6, msg.getTempC(), 0.01); + Assertions.assertEquals(59.5, msg.getRhPerc(), 0.01); + Assertions.assertEquals(1012.0, msg.getPressureMillibar(), 0.1); } } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/json/JsonDecoderConfigTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/json/JsonDecoderConfigTest.java index 9c1f347..4fc0392 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/json/JsonDecoderConfigTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/json/JsonDecoderConfigTest.java @@ -1,16 +1,12 @@ package nl.bertriksikken.pm.json; -import java.io.IOException; - -import org.junit.Assert; -import org.junit.Test; - import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.exc.StreamReadException; -import com.fasterxml.jackson.databind.DatabindException; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; - import nl.bertriksikken.pm.ESensorItem; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.io.IOException; public final class JsonDecoderConfigTest { @@ -26,11 +22,11 @@ public void testSerialize() throws JsonProcessingException { } @Test - public void testDeserialize() throws StreamReadException, DatabindException, IOException { + public void testDeserialize() throws IOException { JsonDecoderConfig config = MAPPER.readValue(getClass().getClassLoader().getResource("JsonDecoderConfig.yaml"), JsonDecoderConfig.class); - Assert.assertEquals(1.0, config.get(0).unit, 0.1); - Assert.assertEquals(100.0, config.get(1).unit, 0.1); + Assertions.assertEquals(1.0, config.get(0).unit, 0.1); + Assertions.assertEquals(100.0, config.get(1).unit, 0.1); } } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/json/JsonDecoderTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/json/JsonDecoderTest.java index 7e1f307..d26fccb 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/json/JsonDecoderTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/json/JsonDecoderTest.java @@ -6,8 +6,8 @@ import com.fasterxml.jackson.databind.node.POJONode; import nl.bertriksikken.pm.ESensorItem; import nl.bertriksikken.pm.SensorData; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URL; @@ -29,7 +29,7 @@ public void testDecode() throws IOException { JsonNode configNode = new POJONode(config); decoder.parse(configNode, json, sensorData); - Assert.assertEquals(35.5, sensorData.getValue(ESensorItem.NOISE_LA_EQ), 0.1); + Assertions.assertEquals(35.5, sensorData.getValue(ESensorItem.NOISE_LA_EQ), 0.1); } @Test @@ -45,8 +45,8 @@ public void testDecodeJsonPayload() throws IOException { SensorData sensorData = new SensorData(); decoder.parse(configNode, json, sensorData); - Assert.assertEquals(99700, sensorData.getValue(ESensorItem.PRESSURE), 0.1); - Assert.assertEquals(10.1, sensorData.getValue(ESensorItem.TEMPERATURE), 0.1); + Assertions.assertEquals(99700, sensorData.getValue(ESensorItem.PRESSURE), 0.1); + Assertions.assertEquals(10.1, sensorData.getValue(ESensorItem.TEMPERATURE), 0.1); } @Test @@ -60,8 +60,8 @@ public void testInvalidHumidity() throws JsonProcessingException { String json = "{\"rh\":-1}"; decoder.parse(configNode, json, sensorData); - Assert.assertTrue(sensorData.hasValue(ESensorItem.HUMIDITY)); - Assert.assertFalse(ESensorItem.HUMIDITY.inRange(sensorData.getValue(ESensorItem.HUMIDITY))); + Assertions.assertTrue(sensorData.hasValue(ESensorItem.HUMIDITY)); + Assertions.assertFalse(ESensorItem.HUMIDITY.inRange(sensorData.getValue(ESensorItem.HUMIDITY))); } } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/sps30/Sps30MessageTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/sps30/Sps30MessageTest.java index d2d31d6..761b07d 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/sps30/Sps30MessageTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/pm/sps30/Sps30MessageTest.java @@ -1,20 +1,20 @@ package nl.bertriksikken.pm.sps30; -import org.junit.Assert; -import org.junit.Test; - import nl.bertriksikken.pm.PayloadParseException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public final class Sps30MessageTest { - @Test(expected = PayloadParseException.class) - public void testEmptyData() throws PayloadParseException { - Sps30Message.parse(new byte[] {}); + @Test + public void testEmptyData() { + Assertions.assertThrows(PayloadParseException.class, () -> + Sps30Message.parse(new byte[]{})); } - + @Test public void testZeroData() throws PayloadParseException { Sps30Message message = Sps30Message.parse(new byte[20]); - Assert.assertNotNull(message); + Assertions.assertNotNull(message); } } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/senscom/SensComMessageTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/senscom/SensComMessageTest.java index 37ecf61..2ab9968 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/senscom/SensComMessageTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/senscom/SensComMessageTest.java @@ -3,8 +3,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import nl.bertriksikken.senscom.SensComMessage.SensComItem; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public final class SensComMessageTest { @@ -15,7 +15,7 @@ public void testSerializeSensComItem() throws JsonProcessingException { Double d = 0.1 * 174; SensComItem item = new SensComItem("name", d); String json = MAPPER.writeValueAsString(item); - Assert.assertEquals("{\"value_type\":\"name\",\"value\":\"17.4\"}", json); + Assertions.assertEquals("{\"value_type\":\"name\",\"value\":\"17.4\"}", json); } @Test @@ -24,7 +24,7 @@ public void testSerialize() throws JsonProcessingException { message.addItem("string", "svalue"); message.addItem("double", "dvalue"); String json = MAPPER.writeValueAsString(message); - Assert.assertEquals("{\"software_version\":\"version\",\"sensordatavalues\":[" + + Assertions.assertEquals("{\"software_version\":\"version\",\"sensordatavalues\":[" + "{\"value_type\":\"string\",\"value\":\"svalue\"},{\"value_type\":\"double\",\"value\":\"dvalue\"}]}", json); } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/senscom/SensComPinTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/senscom/SensComPinTest.java index 1a48a64..4aeee50 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/senscom/SensComPinTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/senscom/SensComPinTest.java @@ -1,14 +1,14 @@ package nl.bertriksikken.senscom; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public final class SensComPinTest { @Test public void testHappyFlow() { ESensComPin pin = ESensComPin.PARTICULATE_MATTER; - Assert.assertEquals("1", pin.getPin()); + Assertions.assertEquals("1", pin.getPin()); } } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/ttn/TtnUplinkMessageTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/ttn/TtnUplinkMessageTest.java index 018e30d..f0cefb0 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/ttn/TtnUplinkMessageTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/ttn/TtnUplinkMessageTest.java @@ -1,14 +1,14 @@ package nl.bertriksikken.ttn; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public final class TtnUplinkMessageTest { @Test public void testString() { TtnUplinkMessage message = new TtnUplinkMessage("app", "device", "eui", new byte[] { 1, 2, 3 }, "{}", 1); - Assert.assertNotNull(message.toString()); + Assertions.assertNotNull(message.toString()); System.out.println(message); } diff --git a/sensor-data-bridge/src/test/java/nl/bertriksikken/ttn/dto/TtnV3UplinkMessageTest.java b/sensor-data-bridge/src/test/java/nl/bertriksikken/ttn/dto/TtnV3UplinkMessageTest.java index 77ff9ae..816baf8 100644 --- a/sensor-data-bridge/src/test/java/nl/bertriksikken/ttn/dto/TtnV3UplinkMessageTest.java +++ b/sensor-data-bridge/src/test/java/nl/bertriksikken/ttn/dto/TtnV3UplinkMessageTest.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import nl.bertriksikken.ttn.TtnUplinkMessage; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.InputStream; @@ -24,10 +24,10 @@ public void testDecode() throws IOException { Ttnv3UplinkMessage ttnv3UplinkMessage = mapper.readValue(is, Ttnv3UplinkMessage.class); TtnUplinkMessage message = ttnv3UplinkMessage.toTtnUplinkMessage(); - Assert.assertEquals("0000547AF1BF713C", message.getDevEui()); - Assert.assertEquals(19, message.getRawPayload().length); - Assert.assertEquals(1, message.getPort()); - Assert.assertEquals(7, message.getSF()); + Assertions.assertEquals("0000547AF1BF713C", message.getDevEui()); + Assertions.assertEquals(19, message.getRawPayload().length); + Assertions.assertEquals(1, message.getPort()); + Assertions.assertEquals(7, message.getSF()); } }