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