diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt index fac539d635..eac55c8d88 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt @@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecry import app.aaps.core.utils.toHex import app.aaps.shared.tests.AAPSLoggerTest +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.spongycastle.util.encoders.Hex @@ -32,7 +32,7 @@ import org.spongycastle.util.encoders.Hex val msg = MessagePacket.parse(encryptedMessage) val decryptedMsg = enDecrypt.decrypt(msg) - Assertions.assertEquals(decrypted.toHex(), decryptedMsg.payload.toHex()) + assertThat(decryptedMsg.payload.toHex()).isEqualTo(decrypted.toHex()) } @Test @@ -56,6 +56,6 @@ import org.spongycastle.util.encoders.Hex val encrypted = enDecrypt.encrypt(msg) - Assertions.assertEquals(encryptedMessage.toHex(), encrypted.asByteArray().toHex()) + assertThat(encrypted.asByteArray().toHex()).isEqualTo(encryptedMessage.toHex()) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt index 51a93579db..9df69de86d 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import app.aaps.core.utils.toHex +import com.google.common.truth.Truth.assertThat import com.google.crypto.tink.subtle.Hex import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MessagePacketTest { @@ -16,19 +16,19 @@ class MessagePacketTest { @Test fun testParseMessagePacket() { val msg = MessagePacket.parse(Hex.decode(payload)) - Assertions.assertEquals(msg.type, MessageType.ENCRYPTED) - Assertions.assertEquals(msg.source, Id.fromLong(136326824)) - Assertions.assertEquals(msg.destination, Id.fromLong(136326825)) - Assertions.assertEquals(msg.sequenceNumber, 7.toByte()) - Assertions.assertEquals(msg.ackNumber, 0.toByte()) - Assertions.assertEquals(msg.eqos, 1.toShort()) - Assertions.assertEquals(msg.priority, false) - Assertions.assertEquals(msg.lastMessage, false) - Assertions.assertEquals(msg.gateway, false) - Assertions.assertEquals(msg.sas, true) - Assertions.assertEquals(msg.tfs, false) - Assertions.assertEquals(msg.version, 0.toShort()) - Assertions.assertEquals(msg.payload.toHex(), payload.substring(32, payload.length)) + assertThat(msg.type).isEqualTo(MessageType.ENCRYPTED) + assertThat(msg.source).isEqualTo(Id.fromLong(136326824)) + assertThat(msg.destination).isEqualTo(Id.fromLong(136326825)) + assertThat(msg.sequenceNumber).isEqualTo(7.toByte()) + assertThat(msg.ackNumber).isEqualTo(0.toByte()) + assertThat(msg.eqos).isEqualTo(1.toShort()) + assertThat(msg.priority).isFalse() + assertThat(msg.lastMessage).isFalse() + assertThat(msg.gateway).isFalse() + assertThat(msg.sas).isTrue() + assertThat(msg.tfs).isFalse() + assertThat(msg.version).isEqualTo(0.toShort()) + assertThat(payload.substring(32, payload.length)).isEqualTo(msg.payload.toHex()) } @Test fun testSerializeMessagePacket() { @@ -46,6 +46,6 @@ class MessagePacketTest { tfs = false, payload = Hex.decode(payload.substring(32, payload.length)) ) - Assertions.assertEquals(msg.asByteArray().toHex(), payload) + assertThat(msg.asByteArray().toHex()).isEqualTo(payload) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadJoinerTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadJoinerTest.kt index 983cfdb72f..c534618a2c 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadJoinerTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadJoinerTest.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import app.aaps.core.utils.toHex +import com.google.common.truth.Truth.assertThat import com.google.crypto.tink.subtle.Hex import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadJoiner -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class PayloadJoinerTest { @@ -14,7 +14,7 @@ class PayloadJoinerTest { val payload = "54,57,10,23,03,00,00,c0,ff,ff,ff,fe,08,20,2e,a8,50,30,3d,00,01,a5".replace(",", "") val joiner = PayloadJoiner(f1) joiner.accumulate(f2) - val actual = joiner.finalize() - Assertions.assertEquals(payload, actual.toHex()) + val result = joiner.finalize() + assertThat(result.toHex()).isEqualTo(payload) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt index e37800a571..90b676a649 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import app.aaps.core.utils.toHex +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadJoiner import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import java.util.Random @@ -22,7 +22,7 @@ class PayloadSplitJoinTest { joiner.accumulate(p.toByteArray()) } val got = joiner.finalize() - Assertions.assertEquals(got.toHex(), payload.toHex()) + assertThat(got.toHex()).isEqualTo(payload.toHex()) } } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt index 6379eaa702..005c0337d2 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt @@ -1,8 +1,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import app.aaps.core.utils.toHex +import com.google.common.truth.Truth.assertThat import com.google.crypto.tink.subtle.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class StringLengthPrefixEncodingTest { @@ -12,12 +12,12 @@ class StringLengthPrefixEncodingTest { @Test fun testFormatKeysP0() { val payload = StringLengthPrefixEncoding.formatKeys(arrayOf("P0="), arrayOf(p0Content)) - Assertions.assertEquals(p0Payload.toHex(), payload.toHex()) + assertThat(p0Payload.toHex()).isEqualTo(payload.toHex()) } @Test fun testParseKeysP0() { val parsed = StringLengthPrefixEncoding.parseKeys(arrayOf("P0="), p0Payload) - Assertions.assertEquals(parsed.size, 1) - Assertions.assertEquals(parsed[0].toHex(), p0Content.toHex()) + assertThat(parsed).hasLength(1) + assertThat(parsed[0].toHex()).isEqualTo(p0Content.toHex()) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt index e8a36c089c..0d73b2ce5c 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt @@ -4,9 +4,9 @@ import app.aaps.core.interfaces.configuration.Config import app.aaps.core.utils.toHex import app.aaps.shared.tests.AAPSLoggerTest import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mock @@ -20,7 +20,7 @@ class KeyExchangeTest : TestBase() { private val keyGenerator = X25519KeyGenerator() private val keyGeneratorSpy: X25519KeyGenerator = spy(keyGenerator) - private var randomByteGenerator: RandomByteGenerator = mock(RandomByteGenerator::class.java) + private var randomByteGenerator = mock() @Mock lateinit var config: Config @@ -43,9 +43,9 @@ class KeyExchangeTest : TestBase() { val podPublicKey = Hex.decode("2fe57da347cd62431528daac5fbb290730fff684afc4cfc2ed90995f58cb3b74") val podNonce = Hex.decode("00000000000000000000000000000000") ke.updatePodPublicData(podPublicKey + podNonce) - Assertions.assertEquals(ke.pdmPublic.toHex(), "f2b6940243aba536a66e19fb9a39e37f1e76a1cd50ab59b3e05313b4fc93975e") - Assertions.assertEquals(ke.pdmConf.toHex(), "5fc3b4da865e838ceaf1e9e8bb85d1ac") + assertThat("f2b6940243aba536a66e19fb9a39e37f1e76a1cd50ab59b3e05313b4fc93975e").isEqualTo(ke.pdmPublic.toHex()) + assertThat("5fc3b4da865e838ceaf1e9e8bb85d1ac").isEqualTo(ke.pdmConf.toHex()) ke.validatePodConf(Hex.decode("af4f10db5f96e5d9cd6cfc1f54f4a92f")) - Assertions.assertEquals(ke.ltk.toHex(), "341e16d13f1cbf73b19d1c2964fee02b") + assertThat("341e16d13f1cbf73b19d1c2964fee02b").isEqualTo(ke.ltk.toHex()) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessageTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessageTest.kt index a17c03a276..92cd2282b3 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessageTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessageTest.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session import app.aaps.core.utils.toHex import app.aaps.shared.tests.AAPSLoggerTest -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test import org.spongycastle.util.encoders.Hex @@ -14,6 +14,6 @@ class EapMessageTest { Hex.decode("01bd0038170100000205000000c55c78e8d3b9b9e935860a7259f6c001050000c2cd1248451103bd77a6c7ef88c441ba7e0200006cff5d18") val eapMsg = EapMessage.parse(aapsLogger, payload) val back = eapMsg.toByteArray() - Assertions.assertEquals(back.toHex(), payload.toHex()) + assertThat(payload.toHex()).isEqualTo(back.toHex()) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/MilenageTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/MilenageTest.kt index 65152a5f36..847ce37927 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/MilenageTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/MilenageTest.kt @@ -4,7 +4,7 @@ import app.aaps.core.interfaces.configuration.Config import app.aaps.core.utils.toHex import app.aaps.shared.tests.AAPSLoggerTest import app.aaps.shared.tests.TestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test import org.mockito.Mock import org.spongycastle.util.encoders.Hex @@ -22,9 +22,9 @@ class MilenageTest : TestBase() { sqn = byteArrayOf(0, 0, 0, 0, 0, 2), randParam = Hex.decode("c2cd1248451103bd77a6c7ef88c441ba") ) - Assertions.assertEquals(m.res.toHex(), "a40bc6d13861447e") - Assertions.assertEquals(m.ck.toHex(), "55799fd26664cbf6e476525e2dee52c6") - Assertions.assertEquals(m.autn.toHex(), "00c55c78e8d3b9b9e935860a7259f6c0") + assertThat(m.res.toHex()).isEqualTo("a40bc6d13861447e") + assertThat(m.ck.toHex()).isEqualTo("55799fd26664cbf6e476525e2dee52c6") + assertThat(m.autn.toHex()).isEqualTo("00c55c78e8d3b9b9e935860a7259f6c0") } @Test fun testMilenage2() { @@ -36,9 +36,9 @@ class MilenageTest : TestBase() { sqn = byteArrayOf(0, 0, 0, 0, 0, 2), // 1 + 1 randParam = Hex.decode("4fc01ac1a94376ae3e052339c07d9e1f") ) - Assertions.assertEquals(m.res.toHex(), "ec549e00fa668a19") - Assertions.assertEquals(m.ck.toHex(), "ee3dac761fe358a9f476cc5ee81aa3e9") - Assertions.assertEquals(m.autn.toHex(), "a3e7a71430c8b9b95245b33b3bd679c4") + assertThat(m.res.toHex()).isEqualTo("ec549e00fa668a19") + assertThat(m.ck.toHex()).isEqualTo("ee3dac761fe358a9f476cc5ee81aa3e9") + assertThat(m.autn.toHex()).isEqualTo("a3e7a71430c8b9b95245b33b3bd679c4") } @Test fun testMilenageIncrementedSQN() { @@ -51,9 +51,9 @@ class MilenageTest : TestBase() { sqn = byteArrayOf(0, 0, 0, 0, 0x01, 0x5e), randParam = Hex.decode("d71cc44820e5419f42c62ae97c035988") ) - Assertions.assertEquals(m.res.toHex(), "5f807a379a5c5d30") - Assertions.assertEquals(m.ck.toHex(), "8dd4b3ceb849a01766e37f9d86045c39") - Assertions.assertEquals(m.autn.toHex(), "0e0264d056fcb9b9752227365a090955") + assertThat(m.res.toHex()).isEqualTo("5f807a379a5c5d30") + assertThat(m.ck.toHex()).isEqualTo("8dd4b3ceb849a01766e37f9d86045c39") + assertThat(m.autn.toHex()).isEqualTo("0e0264d056fcb9b9752227365a090955") } @Test fun testMileageSynchronization() { @@ -67,7 +67,7 @@ class MilenageTest : TestBase() { randParam = Hex.decode("396707041ca3a5931fc0e52d2d7b9ecf"), amf = byteArrayOf(0, 0), ) - Assertions.assertEquals(m.receivedMacS.toHex(), m.macS.toHex()) - Assertions.assertEquals(m.sqn.toHex(), m.synchronizationSqn.toHex()) + assertThat(m.receivedMacS.toHex()).isEqualTo(m.macS.toHex()) + assertThat(m.sqn.toHex()).isEqualTo(m.synchronizationSqn.toHex()) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt index 1c74df813f..db10dc0d41 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt @@ -1,13 +1,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command -import org.apache.commons.codec.DecoderException +import com.google.common.truth.Truth.assertThat import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class DeactivateCommandTest { - @Test @Throws(DecoderException::class) fun testEncoding() { + @Test fun testEncoding() { val encoded = DeactivateCommand.Builder() .setUniqueId(37879809) .setSequenceNumber(5.toShort()) @@ -15,6 +14,6 @@ class DeactivateCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000114061C04494E532E001C"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000114061C04494E532E001C").asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt index d149f51161..33195bfa8b 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class GetStatusCommandTest { - @Test @Throws(DecoderException::class) fun testGetDefaultStatusResponse() { + @Test fun testGetDefaultStatusResponse() { val encoded = GetStatusCommand.Builder() .setUniqueId(37879810) .setSequenceNumber(15.toShort()) @@ -16,6 +15,6 @@ class GetStatusCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("024200023C030E0100024C"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200023C030E0100024C").asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt index d3f66e68c0..dd7ab87763 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt @@ -1,19 +1,18 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command -import org.apache.commons.codec.DecoderException +import com.google.common.truth.Truth.assertThat import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class GetVersionCommandTest { - @Test @Throws(DecoderException::class) fun testEncoding() { + @Test fun testEncoding() { val encoded = GetVersionCommand.Builder() .setSequenceNumber(0.toShort()) .setUniqueId(GetVersionCommand.DEFAULT_UNIQUE_ID) .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2").asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt index 2497e8c74b..c77469c636 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt @@ -1,18 +1,17 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTrigger import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ProgramAlertsCommandTest { - @Test @Throws(DecoderException::class) fun testExpirationAlerts() { + @Test fun testExpirationAlerts() { val configurations: MutableList = ArrayList() configurations.add( AlertConfiguration( @@ -46,10 +45,10 @@ class ProgramAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testLowReservoirAlert() { + @Test fun testLowReservoirAlert() { val configurations: MutableList = ArrayList() configurations.add( AlertConfiguration( @@ -71,10 +70,10 @@ class ProgramAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testUserExpirationAlert() { + @Test fun testUserExpirationAlert() { val configurations: MutableList = ArrayList() configurations.add( AlertConfiguration( @@ -96,10 +95,10 @@ class ProgramAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testLumpOfCoalAlert() { + @Test fun testLumpOfCoalAlert() { val configurations: MutableList = ArrayList() configurations.add( AlertConfiguration( @@ -122,6 +121,6 @@ class ProgramAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("02420003280C190A494E532E7837000508020356"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("02420003280C190A494E532E7837000508020356").asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt index b988e45e4f..09c6feaade 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt @@ -1,17 +1,16 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import java.util.Date @Suppress("DEPRECATION") class ProgramBasalCommandTest { - @Test @Throws(DecoderException::class) fun testProgramBasalCommand() { + @Test fun testProgramBasalCommand() { val segments = listOf( BasalProgram.Segment(0.toShort(), 48.toShort(), 300) ) @@ -28,13 +27,10 @@ class ProgramBasalCommandTest { .build() .encoded - Assertions.assertArrayEquals( - Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C"), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testProgramBasalCommandWithExtraAlternateSegmentPulse() { + @Test fun testProgramBasalCommandWithExtraAlternateSegmentPulse() { val segments = listOf( BasalProgram.Segment(0.toShort(), 48.toShort(), 5) ) @@ -51,13 +47,10 @@ class ProgramBasalCommandTest { .build() .encoded - Assertions.assertArrayEquals( - Hex.decodeHex("0000109130241a12494e532e0000c52e0f700000f800f800f800130e0000000707fcad8000f015752a00033b"), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0000109130241a12494e532e0000c52e0f700000f800f800f800130e0000000707fcad8000f015752a00033b").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testProgramBasalCommandAllSegments() { + @Test fun testProgramBasalCommandAllSegments() { val segments = mutableListOf() for (segment in 0..23) { val rate = when (segment) { @@ -95,15 +88,10 @@ class ProgramBasalCommandTest { val expected = "0000000508C41A28494E532E00018B16273000032000300130023003300430053006300730083009200A100B100C180D1398400B005E009E22E80002EB49D200000A15752A0000140ABA9500001E07270E000028055D4A800032044AA200003C0393870000460310BCDB005002AEA540005A02625A00006402255100006E01F360E8007801C9C380008201A68D13008C01885E6D0096016E360000A0015752A000AA0143209600B401312D0000BE01211D2800C80112A88000DC00F9B07400F000E4E1C0010E00CB73558158".lowercase() - Assertions.assertArrayEquals( - Hex.decodeHex( - expected - ), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex(expected).asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testProgramBasalCommandHighRates() { + @Test fun testProgramBasalCommandHighRates() { val segments = listOf( BasalProgram.Segment(0.toShort(), 2.toShort(), 300), BasalProgram.Segment(2.toShort(), 4.toShort(), 290), @@ -140,15 +128,10 @@ class ProgramBasalCommandTest { val expected = "000000051C981A2C494E532E00046D162178000B101E101D101C101B101A301938173816101458123810380E300D180B100A180613684008013F008954400258005B8D800244005EB5B002300062179B021C0065B9AA02080069A34403E8006DDD0003AC0074E0360384007A12000190008954400456009476C1029400A675A2024400BD6B61020800D3468900E600EED54D00C80112A880008201A68D13809b" - Assertions.assertArrayEquals( - Hex.decodeHex( - expected - ), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex(expected).asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testProgramBasalCommandDifferentInterval() { + @Test fun testProgramBasalCommandDifferentInterval() { val segments = listOf( BasalProgram.Segment(0.toShort(), 2.toShort(), 50), BasalProgram.Segment(2.toShort(), 6.toShort(), 75), @@ -177,11 +160,6 @@ class ProgramBasalCommandTest { val expected = "0000000528581A1C494E532E00038E161E50000E100538075000780DB01B701D58091801133840040A100032DC82006402255100012C016E36000006EB49D200043800CB73550CA80065B9AA0910005EB5B0023A01211D28001E07270E000065" - Assertions.assertArrayEquals( - Hex.decodeHex( - expected - ), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex(expected).asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt index 6695c10155..9bc59e20bc 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt @@ -1,15 +1,14 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ProgramBeepsCommandTest { - @Test @Throws(DecoderException::class) fun testPlayTestBeep() { + @Test fun testPlayTestBeep() { val encoded = ProgramBeepsCommand.Builder() .setUniqueId(37879810) .setSequenceNumber(11.toShort()) @@ -20,6 +19,6 @@ class ProgramBeepsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("024200022C061E0402000000800F"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200022C061E0402000000800F").asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt index 2bca8a864b..16d1268792 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ProgramBolusCommandTest { - @Test @Throws(DecoderException::class) fun testProgramBolusCommand() { + @Test fun testProgramBolusCommand() { val encoded = ProgramBolusCommand.Builder() .setNumberOfUnits(5.0) .setProgramReminder(ProgramReminder(false, true, 0.toByte())) @@ -19,9 +18,6 @@ class ProgramBolusCommandTest { .build() .encoded - Assertions.assertArrayEquals( - Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6"), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6").asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt index a5222f611f..c0e9593c1a 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt @@ -1,14 +1,14 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ProgramTempBasalCommandTest { - @Test @Throws(DecoderException::class) fun testExtraAlternateSegmentPulseTempBasal() { + @Test fun testExtraAlternateSegmentPulseTempBasal() { val command = ProgramTempBasalCommand.Builder() .setUniqueId(37879809) .setNonce(1229869870) @@ -18,13 +18,10 @@ class ProgramTempBasalCommandTest { .setProgramReminder(ProgramReminder(atStart = false, atEnd = true, atInterval = 0.toByte())) .build() - Assertions.assertArrayEquals( - Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6"), - command.encoded - ) + assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testZeroTempBasal() { + @Test fun testZeroTempBasal() { val command = ProgramTempBasalCommand.Builder() .setUniqueId(37879809) .setNonce(1229869870) @@ -34,13 +31,10 @@ class ProgramTempBasalCommandTest { .setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte())) .build() - Assertions.assertArrayEquals( - Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000A6B49D20001E3"), - command.encoded - ) + assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000A6B49D20001E3").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testZeroTempBasalShort() { + @Test fun testZeroTempBasalShort() { val command = ProgramTempBasalCommand.Builder() .setUniqueId(37879809) .setNonce(1229869870) @@ -50,13 +44,10 @@ class ProgramTempBasalCommandTest { .setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte())) .build() - Assertions.assertArrayEquals( - Hex.decodeHex("024200011C201A0E494E532E01007901384000000000160EC00000016B49D2000001EB49D200815B"), - command.encoded - ) + assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200011C201A0E494E532E01007901384000000000160EC00000016B49D2000001EB49D200815B").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testZeroTempBasalVeryLong() { + @Test fun testZeroTempBasalVeryLong() { val command = ProgramTempBasalCommand.Builder() .setUniqueId(37879809) .setNonce(1229869870) @@ -66,9 +57,6 @@ class ProgramTempBasalCommandTest { .setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte())) .build() - Assertions.assertArrayEquals( - Hex.decodeHex("024200011C221A10494E532E0100901838400000F0007000160EC00000186B49D20000186B49D2000132"), - command.encoded - ) + assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200011C221A10494E532E0100901838400000F0007000160EC00000186B49D20000186B49D2000132").asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt index b47b52aa41..1dbdfbc75d 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command -import org.apache.commons.codec.DecoderException +import com.google.common.truth.Truth.assertThat import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import java.util.Date class SetUniqueIdCommandTest { - @Test @Throws(DecoderException::class) fun testEncoding() { + @Test fun testEncoding() { @Suppress("DEPRECATION") val encoded = SetUniqueIdCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(6.toShort()) @@ -18,6 +17,6 @@ class SetUniqueIdCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344").asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt index 64884e99dc..8360adddba 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt @@ -1,15 +1,14 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import java.util.EnumSet class SilenceAlertsCommandTest { - @Test @Throws(DecoderException::class) fun testSilenceLowReservoirAlert() { + @Test fun testSilenceLowReservoirAlert() { val encoded = SilenceAlertsCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(1.toShort()) @@ -18,7 +17,7 @@ class SilenceAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000304071105494E532E1081CE"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000304071105494E532E1081CE").asList()).inOrder() } // TODO capture more silence alerts commands diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt index e0dac98b34..01ce8b0000 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class StopDeliveryCommandTest { - @Test @Throws(DecoderException::class) fun testStopTempBasal() { + @Test fun testStopTempBasal() { val encoded = StopDeliveryCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(0.toShort()) @@ -18,10 +17,10 @@ class StopDeliveryCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000300071F05494E532E6201B1"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000300071F05494E532E6201B1").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testSuspendDelivery() { + @Test fun testSuspendDelivery() { val encoded = StopDeliveryCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(2.toShort()) @@ -31,7 +30,7 @@ class StopDeliveryCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000308071F05494E532E078287"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000308071F05494E532E078287").asList()).inOrder() } // TODO test cancel bolus diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommandTest.kt index ba53dc84b2..8787f2a0f1 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class SuspendDeliveryCommandTest { - @Test @Throws(DecoderException::class) fun testSuspendDelivery() { + @Test fun testSuspendDelivery() { val encoded = SuspendDeliveryCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(0.toShort()) @@ -16,6 +15,6 @@ class SuspendDeliveryCommandTest { .setBeepType(BeepType.LONG_SINGLE_BEEP) .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000300131f05494e532e67190a494e532e680000140302811f"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000300131f05494e532e67190a494e532e680000140302811f").asList()).inOrder() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt index 605d7043e9..9428a081f2 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt @@ -1,44 +1,44 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class AlarmStatusResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("021602080100000501BD00000003FF01950000000000670A") val response = AlarmStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(ResponseType.StatusResponseType.ALARM_STATUS, response.statusResponseType) - Assertions.assertEquals(ResponseType.StatusResponseType.ALARM_STATUS.value, response.additionalStatusResponseType) - Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus) - Assertions.assertEquals(0.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(5.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(445.toShort(), response.totalPulsesDelivered) - Assertions.assertEquals(AlarmType.NONE, response.alarmType) - Assertions.assertEquals(0.toShort(), response.alarmTime) - Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(405.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertFalse(response.occlusionAlarm) - Assertions.assertFalse(response.pulseInfoInvalid) - Assertions.assertEquals(PodStatus.UNINITIALIZED, response.podStatusWhenAlarmOccurred) - Assertions.assertFalse(response.immediateBolusWhenAlarmOccurred) - Assertions.assertEquals(0x00.toByte(), response.occlusionType) - Assertions.assertFalse(response.occurredWhenFetchingImmediateBolusActiveInformation) - Assertions.assertEquals(0.toShort(), response.rssi) - Assertions.assertEquals(0.toShort(), response.receiverLowerGain) - Assertions.assertEquals(PodStatus.UNINITIALIZED, response.podStatusWhenAlarmOccurred2) - Assertions.assertEquals(26378.toShort(), response.returnAddressOfPodAlarmHandlerCaller) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.ADDITIONAL_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.ADDITIONAL_STATUS_RESPONSE.value) + assertThat(response.statusResponseType).isEqualTo(ResponseType.StatusResponseType.ALARM_STATUS) + assertThat(response.additionalStatusResponseType).isEqualTo(ResponseType.StatusResponseType.ALARM_STATUS.value) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE) + assertThat(response.bolusPulsesRemaining).isEqualTo(0.toShort()) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(5.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(445.toShort()) + assertThat(response.alarmType).isEqualTo(AlarmType.NONE) + assertThat(response.alarmTime).isEqualTo(0.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort()) + assertThat(response.minutesSinceActivation).isEqualTo(405.toShort()) + assertThat(response.activeAlerts.size).isEqualTo(0) + assertThat(response.occlusionAlarm).isFalse() + assertThat(response.pulseInfoInvalid).isFalse() + assertThat(response.podStatusWhenAlarmOccurred).isEqualTo(PodStatus.UNINITIALIZED) + assertThat(response.immediateBolusWhenAlarmOccurred).isFalse() + assertThat(response.occlusionType).isEqualTo(0x00.toByte()) + assertThat(response.occurredWhenFetchingImmediateBolusActiveInformation).isFalse() + assertThat(response.rssi).isEqualTo(0.toShort()) + assertThat(response.receiverLowerGain).isEqualTo(0.toShort()) + assertThat(response.podStatusWhenAlarmOccurred2).isEqualTo(PodStatus.UNINITIALIZED) + assertThat(response.returnAddressOfPodAlarmHandlerCaller).isEqualTo(26378.toShort()) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt index 9d847eefe6..200567566c 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt @@ -1,30 +1,30 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class DefaultStatusResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("1D1800A02800000463FF") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus) - Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(320.toShort(), response.totalPulsesDelivered) - Assertions.assertEquals(5.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(0.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertEquals(280.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()) + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME) + assertThat(response.totalPulsesDelivered).isEqualTo(320.toShort()) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(5.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(0.toShort()) + assertThat(response.activeAlerts).isEmpty() + assertThat(response.minutesSinceActivation).isEqualTo(280.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort()) } /** @@ -49,21 +49,21 @@ class DefaultStatusResponseTest { Alert 7 is InActive Occlusion alert active false */ - @Test @Throws(DecoderException::class) fun testValidResponseBelowMin() { + @Test fun testValidResponseBelowMin() { val encoded = Hex.decodeHex("1D1905281000004387D3039A") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus) - Assertions.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(2.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(0.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertEquals(4321.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(979.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(2640.toShort(), response.totalPulsesDelivered) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_BELOW_MIN_VOLUME) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(2.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(0.toShort()) + assertThat(response.activeAlerts).isEmpty() + assertThat(response.minutesSinceActivation).isEqualTo(4321.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(979.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(2640.toShort()) } /** @@ -88,21 +88,21 @@ class DefaultStatusResponseTest { Alert 7 is InActive Occlusion alert active false */ - @Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining() { + @Test fun testValidResponseBolusPulsesRemaining() { val encoded = Hex.decodeHex("1D180519C00E0039A7FF8085") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus) - Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(8.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(14.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertEquals(3689.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(2611.toShort(), response.totalPulsesDelivered) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(8.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(14.toShort()) + assertThat(response.activeAlerts).isEmpty() + assertThat(response.minutesSinceActivation).isEqualTo(3689.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(2611.toShort()) } /** response (hex) 1D990714201F0042ED8801DE @@ -118,21 +118,21 @@ class DefaultStatusResponseTest { Full reservoir pulses remaining: 392 Time since activation: 4283 */ - @Test @Throws(DecoderException::class) fun testValidResponseReservoirPulsesRemaining() { + @Test fun testValidResponseReservoirPulsesRemaining() { val encoded = Hex.decodeHex("1D990714201F0042ED8801DE") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.UNKNOWN, response.deliveryStatus) // Extended bolus active - Assertions.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(4.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(31.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertEquals(4283.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(392.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(3624.toShort(), response.totalPulsesDelivered) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.UNKNOWN) // Extended bolus active + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_BELOW_MIN_VOLUME) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(4.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(31.toShort()) + assertThat(response.activeAlerts).isEmpty() + assertThat(response.minutesSinceActivation).isEqualTo(4283.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(392.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(3624.toShort()) } /** response (hex) 1d68002601f400002bff0368 @@ -148,13 +148,13 @@ class DefaultStatusResponseTest { Full reservoir pulses remaining: 392 Time since activation: 4283 */ - @Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining3() { + @Test fun testValidResponseBolusPulsesRemaining3() { val encoded = Hex.decodeHex("1d68002601f400002bff0368") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(500.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.bolusPulsesRemaining).isEqualTo(500.toShort()) + assertThat(response.activeAlerts).isEmpty() } /** response (hex) 1d28002e91e400002fff8256 @@ -170,13 +170,13 @@ class DefaultStatusResponseTest { Full reservoir pulses remaining: 392 Time since activation: 4283 */ - @Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining4() { + @Test fun testValidResponseBolusPulsesRemaining4() { val encoded = Hex.decodeHex("1d28002e91e400002fff8256") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(484.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.bolusPulsesRemaining).isEqualTo(484.toShort()) + assertThat(response.activeAlerts).isEmpty() } /* @@ -200,21 +200,21 @@ class DefaultStatusResponseTest { Alert 7 is Active Occlusion alert active false */ - @Test @Throws(DecoderException::class) fun testValidResponseActiveAlert1() { + @Test fun testValidResponseActiveAlert1() { val encoded = Hex.decodeHex("1D980559C820404393FF83AA") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.UNKNOWN, response.deliveryStatus) - Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(9.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(32.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(1, response.activeAlerts.size) - Assertions.assertEquals(4324.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(2739.toShort(), response.totalPulsesDelivered) - Assertions.assertEquals(true, response.activeAlerts.contains(AlertType.EXPIRATION)) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.UNKNOWN) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(9.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(32.toShort()) + assertThat(response.activeAlerts).hasSize(1) + assertThat(response.minutesSinceActivation).isEqualTo(4324.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(2739.toShort()) + assertThat(response.activeAlerts.contains(AlertType.EXPIRATION)).isTrue() } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt index 86e2d7e28e..53c19b63fa 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt @@ -1,26 +1,26 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.NakErrorType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class NakResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("0603070009") val response = NakResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.NAK_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.NAK_RESPONSE.value, response.messageType) - Assertions.assertEquals(NakErrorType.ILLEGAL_PARAM, response.nakErrorType) - Assertions.assertEquals(AlarmType.NONE, response.alarmType) - Assertions.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(0x00.toShort(), response.securityNakSyncCount) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.NAK_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.NAK_RESPONSE.value) + assertThat(response.nakErrorType).isEqualTo(NakErrorType.ILLEGAL_PARAM) + assertThat(response.alarmType).isEqualTo(AlarmType.NONE) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_BELOW_MIN_VOLUME) + assertThat(response.securityNakSyncCount).isEqualTo(0x00.toShort()) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt index 10460252df..99015de4f7 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt @@ -1,39 +1,39 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class SetUniqueIdResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("011B13881008340A50040A00010300040308146CC1000954D402420001") val response = SetUniqueIdResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, response.activationResponseType) - Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.messageType) - Assertions.assertEquals(27.toShort(), response.messageLength) - Assertions.assertEquals(5000.toShort(), response.pulseVolumeInTenThousandthMicroLiter) - Assertions.assertEquals(16.toShort(), response.pumpRate) - Assertions.assertEquals(8.toShort(), response.primePumpRate) - Assertions.assertEquals(52.toShort(), response.numberOfEngagingClutchDrivePulses) - Assertions.assertEquals(10.toShort(), response.numberOfPrimePulses) - Assertions.assertEquals(80.toShort(), response.podExpirationTimeInHours) - Assertions.assertEquals(4.toShort(), response.firmwareVersionMajor) - Assertions.assertEquals(10.toShort(), response.firmwareVersionMinor) - Assertions.assertEquals(0.toShort(), response.firmwareVersionInterim) - Assertions.assertEquals(1.toShort(), response.bleVersionMajor) - Assertions.assertEquals(3.toShort(), response.bleVersionMinor) - Assertions.assertEquals(0.toShort(), response.bleVersionInterim) - Assertions.assertEquals(4.toShort(), response.productId) - Assertions.assertEquals(PodStatus.UID_SET, response.podStatus) - Assertions.assertEquals(135556289L, response.lotNumber) - Assertions.assertEquals(611540L, response.podSequenceNumber) - Assertions.assertEquals(37879809L, response.uniqueIdReceivedInCommand) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.ACTIVATION_RESPONSE) + assertThat(response.activationResponseType).isEqualTo(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.ACTIVATION_RESPONSE.value) + assertThat(response.messageLength).isEqualTo(27.toShort()) + assertThat(response.pulseVolumeInTenThousandthMicroLiter).isEqualTo(5000.toShort()) + assertThat(response.pumpRate).isEqualTo(16.toShort()) + assertThat(response.primePumpRate).isEqualTo(8.toShort()) + assertThat(response.numberOfEngagingClutchDrivePulses).isEqualTo(52.toShort()) + assertThat(response.numberOfPrimePulses).isEqualTo(10.toShort()) + assertThat(response.podExpirationTimeInHours).isEqualTo(80.toShort()) + assertThat(response.firmwareVersionMajor).isEqualTo(4.toShort()) + assertThat(response.firmwareVersionMinor).isEqualTo(10.toShort()) + assertThat(response.firmwareVersionInterim).isEqualTo(0.toShort()) + assertThat(response.bleVersionMajor).isEqualTo(1.toShort()) + assertThat(response.bleVersionMinor).isEqualTo(3.toShort()) + assertThat(response.bleVersionInterim).isEqualTo(0.toShort()) + assertThat(response.productId).isEqualTo(4.toShort()) + assertThat(response.podStatus).isEqualTo(PodStatus.UID_SET) + assertThat(response.lotNumber).isEqualTo(135556289L) + assertThat(response.podSequenceNumber).isEqualTo(611540L) + assertThat(response.uniqueIdReceivedInCommand).isEqualTo(37879809L) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt index 7cc313a5bc..aa79c8afd9 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt @@ -1,35 +1,35 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class VersionResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("0115040A00010300040208146CC1000954D400FFFFFFFF") val response = VersionResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE, response.activationResponseType) - Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.messageType) - Assertions.assertEquals(21.toShort(), response.messageLength) - Assertions.assertEquals(4.toShort(), response.firmwareVersionMajor) - Assertions.assertEquals(10.toShort(), response.firmwareVersionMinor) - Assertions.assertEquals(0.toShort(), response.firmwareVersionInterim) - Assertions.assertEquals(1.toShort(), response.bleVersionMajor) - Assertions.assertEquals(3.toShort(), response.bleVersionMinor) - Assertions.assertEquals(0.toShort(), response.bleVersionInterim) - Assertions.assertEquals(4.toShort(), response.productId) - Assertions.assertEquals(PodStatus.FILLED, response.podStatus) - Assertions.assertEquals(135556289L, response.lotNumber) - Assertions.assertEquals(611540L, response.podSequenceNumber) - Assertions.assertEquals(0.toByte(), response.rssi) - Assertions.assertEquals(0.toByte(), response.receiverLowerGain) - Assertions.assertEquals(4294967295L, response.uniqueIdReceivedInCommand) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.ACTIVATION_RESPONSE) + assertThat(response.activationResponseType).isEqualTo(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.ACTIVATION_RESPONSE.value) + assertThat(response.messageLength).isEqualTo(21.toShort()) + assertThat(response.firmwareVersionMajor).isEqualTo(4.toShort()) + assertThat(response.firmwareVersionMinor).isEqualTo(10.toShort()) + assertThat(response.firmwareVersionInterim).isEqualTo(0.toShort()) + assertThat(response.bleVersionMajor).isEqualTo(1.toShort()) + assertThat(response.bleVersionMinor).isEqualTo(3.toShort()) + assertThat(response.bleVersionInterim).isEqualTo(0.toShort()) + assertThat(response.productId).isEqualTo(4.toShort()) + assertThat(response.podStatus).isEqualTo(PodStatus.FILLED) + assertThat(response.lotNumber).isEqualTo(135556289L) + assertThat(response.podSequenceNumber).isEqualTo(611540L) + assertThat(response.rssi).isEqualTo(0.toByte()) + assertThat(response.receiverLowerGain).isEqualTo(0.toByte()) + assertThat(response.uniqueIdReceivedInCommand).isEqualTo(4294967295L) } } diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt index 52ebcf240b..f6bb6ceb46 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt @@ -1,10 +1,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.util import app.aaps.core.interfaces.profile.Profile +import com.google.common.truth.Truth.assertThat import app.aaps.core.interfaces.profile.Profile.ProfileValue import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito import org.mockito.Mockito.`when` @@ -25,19 +25,19 @@ class FunctionsTest { val basalProgram: BasalProgram = mapProfileToBasalProgram(profile) val entries: List = basalProgram.segments - Assertions.assertEquals(3, entries.size) + assertThat(entries).hasSize(3) val entry1: BasalProgram.Segment = entries[0] - Assertions.assertEquals(0.toShort(), entry1.startSlotIndex) - Assertions.assertEquals(50, entry1.basalRateInHundredthUnitsPerHour) - Assertions.assertEquals(10.toShort(), entry1.endSlotIndex) + assertThat(entry1.startSlotIndex).isEqualTo(0.toShort()) + assertThat(entry1.basalRateInHundredthUnitsPerHour).isEqualTo(50) + assertThat(entry1.endSlotIndex).isEqualTo(10.toShort()) val entry2: BasalProgram.Segment = entries[1] - Assertions.assertEquals(10.toShort(), entry2.startSlotIndex) - Assertions.assertEquals(100, entry2.basalRateInHundredthUnitsPerHour) - Assertions.assertEquals(28.toShort(), entry2.endSlotIndex) + assertThat(entry2.startSlotIndex).isEqualTo(10.toShort()) + assertThat(entry2.basalRateInHundredthUnitsPerHour).isEqualTo(100) + assertThat(entry2.endSlotIndex).isEqualTo(28.toShort()) val entry3: BasalProgram.Segment = entries[2] - Assertions.assertEquals(28.toShort(), entry3.startSlotIndex) - Assertions.assertEquals(305, entry3.basalRateInHundredthUnitsPerHour) - Assertions.assertEquals(48.toShort(), entry3.endSlotIndex) + assertThat(entry3.startSlotIndex).isEqualTo(28.toShort()) + assertThat(entry3.basalRateInHundredthUnitsPerHour).isEqualTo(305) + assertThat(entry3.endSlotIndex).isEqualTo(48.toShort()) } @Test fun invalidProfileZeroEntries() { @@ -104,6 +104,6 @@ class FunctionsTest { val basalProgram: BasalProgram = mapProfileToBasalProgram(profile) val basalProgramElement: BasalProgram.Segment = basalProgram.segments[0] - Assertions.assertEquals(5, basalProgramElement.basalRateInHundredthUnitsPerHour) + assertThat(basalProgramElement.basalRateInHundredthUnitsPerHour).isEqualTo(5) } }