shared-tests #12
This commit is contained in:
parent
8032cd8f42
commit
a2fb04c5fe
29 changed files with 340 additions and 372 deletions
|
@ -41,6 +41,8 @@ dependencies {
|
|||
api "androidx.room:room-rxjava3:$room_version"
|
||||
kapt "androidx.room:room-compiler:$room_version"
|
||||
|
||||
testImplementation project(':app-wear-shared:shared-tests')
|
||||
testImplementation "commons-codec:commons-codec:$commonscodec_version"
|
||||
|
||||
api 'com.github.guepardoapps:kulid:2.0.0.0'
|
||||
}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.TestAapsSchedulers
|
||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.junit.jupiter.MockitoExtension
|
||||
import org.mockito.junit.jupiter.MockitoSettings
|
||||
import org.mockito.quality.Strictness
|
||||
import java.util.Locale
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@ExtendWith(MockitoExtension::class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
open class TestBase {
|
||||
|
||||
val aapsLogger = AAPSLoggerTest()
|
||||
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
||||
|
||||
@BeforeEach
|
||||
fun setupLocale() {
|
||||
Locale.setDefault(Locale.ENGLISH)
|
||||
System.setProperty("disableFirebase", "true")
|
||||
}
|
||||
|
||||
// Workaround for Kotlin nullability.
|
||||
// https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791
|
||||
// https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin
|
||||
fun <T> anyObject(): T {
|
||||
Mockito.any<T>()
|
||||
return uninitialized()
|
||||
}
|
||||
|
||||
@Suppress("Unchecked_Cast")
|
||||
fun <T> uninitialized(): T = null as T
|
||||
}
|
|
@ -3,11 +3,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecry
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket
|
||||
import info.nightscout.core.utils.toHex
|
||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
||||
import org.junit.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.spongycastle.util.encoders.Hex
|
||||
|
||||
class EnDecryptTest {
|
||||
@Suppress("SpellCheckingInspection") class EnDecryptTest {
|
||||
|
||||
@Test
|
||||
fun decrypt() {
|
||||
|
@ -32,7 +32,7 @@ class EnDecryptTest {
|
|||
val msg = MessagePacket.parse(encryptedMessage)
|
||||
val decryptedMsg = enDecrypt.decrypt(msg)
|
||||
|
||||
Assert.assertEquals(decrypted.toHex(), decryptedMsg.payload.toHex())
|
||||
Assertions.assertEquals(decrypted.toHex(), decryptedMsg.payload.toHex())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,6 +56,6 @@ class EnDecryptTest {
|
|||
|
||||
val encrypted = enDecrypt.encrypt(msg)
|
||||
|
||||
Assert.assertEquals(encryptedMessage.toHex(), encrypted.asByteArray().toHex())
|
||||
Assertions.assertEquals(encryptedMessage.toHex(), encrypted.asByteArray().toHex())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
|
|||
import com.google.crypto.tink.subtle.Hex
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
|
||||
import info.nightscout.core.utils.toHex
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MessagePacketTest {
|
||||
|
||||
val payload =
|
||||
private val payload =
|
||||
"54,57,11,01,07,00,03,40,08,20,2e,a8,08,20,2e,a9,ab,35,d8,31,60,9b,b8,fe,3a,3b,de,5b,18,37,24,9a,16,db,f8,e4,d3,05,e9,75,dc,81,7c,37,07,cc,41,5f,af,8a".replace(
|
||||
",",
|
||||
""
|
||||
|
@ -16,19 +16,19 @@ class MessagePacketTest {
|
|||
|
||||
@Test fun testParseMessagePacket() {
|
||||
val msg = MessagePacket.parse(Hex.decode(payload))
|
||||
assertEquals(msg.type, MessageType.ENCRYPTED)
|
||||
assertEquals(msg.source, Id.fromLong(136326824))
|
||||
assertEquals(msg.destination, Id.fromLong(136326825))
|
||||
assertEquals(msg.sequenceNumber, 7.toByte())
|
||||
assertEquals(msg.ackNumber, 0.toByte())
|
||||
assertEquals(msg.eqos, 1.toShort())
|
||||
assertEquals(msg.priority, false)
|
||||
assertEquals(msg.lastMessage, false)
|
||||
assertEquals(msg.gateway, false)
|
||||
assertEquals(msg.sas, true)
|
||||
assertEquals(msg.tfs, false)
|
||||
assertEquals(msg.version, 0.toShort())
|
||||
assertEquals(msg.payload.toHex(), payload.substring(32, payload.length))
|
||||
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))
|
||||
}
|
||||
|
||||
@Test fun testSerializeMessagePacket() {
|
||||
|
@ -46,6 +46,6 @@ class MessagePacketTest {
|
|||
tfs = false,
|
||||
payload = Hex.decode(payload.substring(32, payload.length))
|
||||
)
|
||||
assertEquals(msg.asByteArray().toHex(), payload)
|
||||
Assertions.assertEquals(msg.asByteArray().toHex(), payload)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
|
|||
import com.google.crypto.tink.subtle.Hex
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadJoiner
|
||||
import info.nightscout.core.utils.toHex
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class PayloadJoinerTest {
|
||||
|
@ -15,6 +15,6 @@ class PayloadJoinerTest {
|
|||
val joiner = PayloadJoiner(f1)
|
||||
joiner.accumulate(f2)
|
||||
val actual = joiner.finalize()
|
||||
assertEquals(payload, actual.toHex())
|
||||
Assertions.assertEquals(payload, actual.toHex())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
|
|||
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.core.utils.toHex
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.Random
|
||||
|
||||
|
@ -17,12 +17,12 @@ class PayloadSplitJoinTest {
|
|||
random.nextBytes(payload)
|
||||
val splitter = PayloadSplitter(payload)
|
||||
val packets = splitter.splitInPackets()
|
||||
val joiner = PayloadJoiner(packets.get(0).toByteArray())
|
||||
val joiner = PayloadJoiner(packets[0].toByteArray())
|
||||
for (p in packets.subList(1, packets.size)) {
|
||||
joiner.accumulate(p.toByteArray())
|
||||
}
|
||||
val got = joiner.finalize()
|
||||
assertEquals(got.toHex(), payload.toHex())
|
||||
Assertions.assertEquals(got.toHex(), payload.toHex())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
|
|||
import com.google.crypto.tink.subtle.Hex
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter
|
||||
import info.nightscout.core.utils.toHex
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class PayloadSplitterTest {
|
||||
|
@ -17,10 +16,10 @@ class PayloadSplitterTest {
|
|||
val splitter = PayloadSplitter(payload)
|
||||
val packets = splitter.splitInPackets()
|
||||
|
||||
assertEquals(packets.size, 2)
|
||||
assertEquals(f1, packets.get(0).toByteArray().toHex())
|
||||
val p2 = packets.get(1).toByteArray()
|
||||
assertTrue(p2.size >= 10)
|
||||
assertEquals(f2.subSequence(0, 20), p2.copyOfRange(0, 10).toHex())
|
||||
Assertions.assertEquals(packets.size, 2)
|
||||
Assertions.assertEquals(f1, packets[0].toByteArray().toHex())
|
||||
val p2 = packets[1].toByteArray()
|
||||
Assertions.assertTrue(p2.size >= 10)
|
||||
Assertions.assertEquals(f2.subSequence(0, 20), p2.copyOfRange(0, 10).toHex())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
|
|||
|
||||
import com.google.crypto.tink.subtle.Hex
|
||||
import info.nightscout.core.utils.toHex
|
||||
import org.junit.Assert.assertEquals
|
||||
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))
|
||||
assertEquals(p0Payload.toHex(), payload.toHex())
|
||||
Assertions.assertEquals(p0Payload.toHex(), payload.toHex())
|
||||
}
|
||||
|
||||
@Test fun testParseKeysP0() {
|
||||
val parsed = StringLengthPrefixEncoding.parseKeys(arrayOf("P0="), p0Payload)
|
||||
assertEquals(parsed.size, 1)
|
||||
assertEquals(parsed[0].toHex(), p0Content.toHex())
|
||||
Assertions.assertEquals(parsed.size, 1)
|
||||
Assertions.assertEquals(parsed[0].toHex(), p0Content.toHex())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair
|
||||
|
||||
import info.nightscout.androidaps.TestBase
|
||||
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.core.utils.toHex
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
||||
import org.junit.Assert.assertEquals
|
||||
import info.nightscout.sharedtests.TestBase
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.Mock
|
||||
|
@ -17,10 +17,10 @@ import org.spongycastle.util.encoders.Hex
|
|||
|
||||
class KeyExchangeTest : TestBase() {
|
||||
|
||||
val keyGenerator = X25519KeyGenerator()
|
||||
val keyGeneratorSpy = spy(keyGenerator)
|
||||
private val keyGenerator = X25519KeyGenerator()
|
||||
private val keyGeneratorSpy: X25519KeyGenerator = spy(keyGenerator)
|
||||
|
||||
var randomByteGenerator: RandomByteGenerator = mock(RandomByteGenerator::class.java)
|
||||
private var randomByteGenerator: RandomByteGenerator = mock(RandomByteGenerator::class.java)
|
||||
|
||||
@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)
|
||||
assertEquals(ke.pdmPublic.toHex(), "f2b6940243aba536a66e19fb9a39e37f1e76a1cd50ab59b3e05313b4fc93975e")
|
||||
assertEquals(ke.pdmConf.toHex(), "5fc3b4da865e838ceaf1e9e8bb85d1ac")
|
||||
Assertions.assertEquals(ke.pdmPublic.toHex(), "f2b6940243aba536a66e19fb9a39e37f1e76a1cd50ab59b3e05313b4fc93975e")
|
||||
Assertions.assertEquals(ke.pdmConf.toHex(), "5fc3b4da865e838ceaf1e9e8bb85d1ac")
|
||||
ke.validatePodConf(Hex.decode("af4f10db5f96e5d9cd6cfc1f54f4a92f"))
|
||||
assertEquals(ke.ltk.toHex(), "341e16d13f1cbf73b19d1c2964fee02b")
|
||||
Assertions.assertEquals(ke.ltk.toHex(), "341e16d13f1cbf73b19d1c2964fee02b")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
|
|||
|
||||
import info.nightscout.core.utils.toHex
|
||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
||||
import org.junit.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
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()
|
||||
Assert.assertEquals(back.toHex(), payload.toHex())
|
||||
Assertions.assertEquals(back.toHex(), payload.toHex())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
|
||||
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.core.utils.toHex
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
||||
import org.junit.Assert
|
||||
import info.nightscout.sharedtests.TestBase
|
||||
import org.junit.jupiter.api.Assertions
|
||||
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")
|
||||
)
|
||||
Assert.assertEquals(m.res.toHex(), "a40bc6d13861447e")
|
||||
Assert.assertEquals(m.ck.toHex(), "55799fd26664cbf6e476525e2dee52c6")
|
||||
Assert.assertEquals(m.autn.toHex(), "00c55c78e8d3b9b9e935860a7259f6c0")
|
||||
Assertions.assertEquals(m.res.toHex(), "a40bc6d13861447e")
|
||||
Assertions.assertEquals(m.ck.toHex(), "55799fd26664cbf6e476525e2dee52c6")
|
||||
Assertions.assertEquals(m.autn.toHex(), "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")
|
||||
)
|
||||
Assert.assertEquals(m.res.toHex(), "ec549e00fa668a19")
|
||||
Assert.assertEquals(m.ck.toHex(), "ee3dac761fe358a9f476cc5ee81aa3e9")
|
||||
Assert.assertEquals(m.autn.toHex(), "a3e7a71430c8b9b95245b33b3bd679c4")
|
||||
Assertions.assertEquals(m.res.toHex(), "ec549e00fa668a19")
|
||||
Assertions.assertEquals(m.ck.toHex(), "ee3dac761fe358a9f476cc5ee81aa3e9")
|
||||
Assertions.assertEquals(m.autn.toHex(), "a3e7a71430c8b9b95245b33b3bd679c4")
|
||||
}
|
||||
|
||||
@Test fun testMilenageIncrementedSQN() {
|
||||
|
@ -51,9 +51,9 @@ class MilenageTest : TestBase() {
|
|||
sqn = byteArrayOf(0, 0, 0, 0, 0x01, 0x5e),
|
||||
randParam = Hex.decode("d71cc44820e5419f42c62ae97c035988")
|
||||
)
|
||||
Assert.assertEquals(m.res.toHex(), "5f807a379a5c5d30")
|
||||
Assert.assertEquals(m.ck.toHex(), "8dd4b3ceb849a01766e37f9d86045c39")
|
||||
Assert.assertEquals(m.autn.toHex(), "0e0264d056fcb9b9752227365a090955")
|
||||
Assertions.assertEquals(m.res.toHex(), "5f807a379a5c5d30")
|
||||
Assertions.assertEquals(m.ck.toHex(), "8dd4b3ceb849a01766e37f9d86045c39")
|
||||
Assertions.assertEquals(m.autn.toHex(), "0e0264d056fcb9b9752227365a090955")
|
||||
}
|
||||
|
||||
@Test fun testMileageSynchronization() {
|
||||
|
@ -67,7 +67,7 @@ class MilenageTest : TestBase() {
|
|||
randParam = Hex.decode("396707041ca3a5931fc0e52d2d7b9ecf"),
|
||||
amf = byteArrayOf(0, 0),
|
||||
)
|
||||
Assert.assertEquals(m.receivedMacS.toHex(), m.macS.toHex())
|
||||
Assert.assertEquals(m.sqn.toHex(), m.synchronizationSqn.toHex())
|
||||
Assertions.assertEquals(m.receivedMacS.toHex(), m.macS.toHex())
|
||||
Assertions.assertEquals(m.sqn.toHex(), m.synchronizationSqn.toHex())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
|
|||
|
||||
import org.apache.commons.codec.DecoderException
|
||||
import org.apache.commons.codec.binary.Hex
|
||||
import org.junit.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class DeactivateCommandTest {
|
||||
|
@ -15,6 +15,6 @@ class DeactivateCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("0242000114061C04494E532E001C"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("0242000114061C04494E532E001C"), encoded)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class GetStatusCommandTest {
|
||||
|
@ -16,6 +16,6 @@ class GetStatusCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("024200023C030E0100024C"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("024200023C030E0100024C"), encoded)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
|
|||
|
||||
import org.apache.commons.codec.DecoderException
|
||||
import org.apache.commons.codec.binary.Hex
|
||||
import org.junit.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class GetVersionCommandTest {
|
||||
|
@ -14,6 +14,6 @@ class GetVersionCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2"), encoded)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ProgramAlertsCommandTest {
|
||||
|
@ -46,7 +46,7 @@ class ProgramAlertsCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5"), encoded)
|
||||
}
|
||||
|
||||
@Test @Throws(DecoderException::class) fun testLowReservoirAlert() {
|
||||
|
@ -71,7 +71,7 @@ class ProgramAlertsCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149"), encoded)
|
||||
}
|
||||
|
||||
@Test @Throws(DecoderException::class) fun testUserExpirationAlert() {
|
||||
|
@ -96,7 +96,7 @@ class ProgramAlertsCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2"), encoded)
|
||||
}
|
||||
|
||||
@Test @Throws(DecoderException::class) fun testLumpOfCoalAlert() {
|
||||
|
@ -122,6 +122,6 @@ class ProgramAlertsCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("02420003280C190A494E532E7837000508020356"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("02420003280C190A494E532E7837000508020356"), encoded)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.Date
|
||||
|
||||
|
@ -28,7 +28,7 @@ class ProgramBasalCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C"),
|
||||
encoded
|
||||
)
|
||||
|
@ -51,7 +51,7 @@ class ProgramBasalCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex("0000109130241a12494e532e0000c52e0f700000f800f800f800130e0000000707fcad8000f015752a00033b"),
|
||||
encoded
|
||||
)
|
||||
|
@ -61,12 +61,15 @@ class ProgramBasalCommandTest {
|
|||
val segments = mutableListOf<BasalProgram.Segment>()
|
||||
for (segment in 0..23) {
|
||||
val rate = when (segment) {
|
||||
21 ->
|
||||
21 ->
|
||||
110
|
||||
22 ->
|
||||
|
||||
22 ->
|
||||
120
|
||||
23 ->
|
||||
|
||||
23 ->
|
||||
135
|
||||
|
||||
else ->
|
||||
segment * 5
|
||||
}
|
||||
|
@ -92,7 +95,7 @@ class ProgramBasalCommandTest {
|
|||
val expected =
|
||||
"0000000508C41A28494E532E00018B16273000032000300130023003300430053006300730083009200A100B100C180D1398400B005E009E22E80002EB49D200000A15752A0000140ABA9500001E07270E000028055D4A800032044AA200003C0393870000460310BCDB005002AEA540005A02625A00006402255100006E01F360E8007801C9C380008201A68D13008C01885E6D0096016E360000A0015752A000AA0143209600B401312D0000BE01211D2800C80112A88000DC00F9B07400F000E4E1C0010E00CB73558158".lowercase()
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex(
|
||||
expected
|
||||
),
|
||||
|
@ -137,7 +140,7 @@ class ProgramBasalCommandTest {
|
|||
val expected =
|
||||
"000000051C981A2C494E532E00046D162178000B101E101D101C101B101A301938173816101458123810380E300D180B100A180613684008013F008954400258005B8D800244005EB5B002300062179B021C0065B9AA02080069A34403E8006DDD0003AC0074E0360384007A12000190008954400456009476C1029400A675A2024400BD6B61020800D3468900E600EED54D00C80112A880008201A68D13809b"
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex(
|
||||
expected
|
||||
),
|
||||
|
@ -174,7 +177,7 @@ class ProgramBasalCommandTest {
|
|||
val expected =
|
||||
"0000000528581A1C494E532E00038E161E50000E100538075000780DB01B701D58091801133840040A100032DC82006402255100012C016E36000006EB49D200043800CB73550CA80065B9AA0910005EB5B0023A01211D28001E07270E000065"
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex(
|
||||
expected
|
||||
),
|
||||
|
|
|
@ -4,7 +4,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ProgramBeepsCommandTest {
|
||||
|
@ -20,6 +20,6 @@ class ProgramBeepsCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("024200022C061E0402000000800F"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("024200022C061E0402000000800F"), encoded)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ProgramBolusCommandTest {
|
||||
|
@ -19,7 +19,7 @@ class ProgramBolusCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6"),
|
||||
encoded
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ProgramTempBasalCommandTest {
|
||||
|
@ -15,10 +15,10 @@ class ProgramTempBasalCommandTest {
|
|||
.setSequenceNumber(15.toShort())
|
||||
.setRateInUnitsPerHour(5.05)
|
||||
.setDurationInMinutes(60.toShort())
|
||||
.setProgramReminder(ProgramReminder(false, true, 0.toByte()))
|
||||
.setProgramReminder(ProgramReminder(atStart = false, atEnd = true, atInterval = 0.toByte()))
|
||||
.build()
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6"),
|
||||
command.encoded
|
||||
)
|
||||
|
@ -31,10 +31,10 @@ class ProgramTempBasalCommandTest {
|
|||
.setSequenceNumber(7.toShort())
|
||||
.setRateInUnitsPerHour(0.0)
|
||||
.setDurationInMinutes(300.toShort())
|
||||
.setProgramReminder(ProgramReminder(true, true, 0.toByte()))
|
||||
.setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte()))
|
||||
.build()
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000A6B49D20001E3"),
|
||||
command.encoded
|
||||
)
|
||||
|
@ -47,10 +47,10 @@ class ProgramTempBasalCommandTest {
|
|||
.setSequenceNumber(7.toShort())
|
||||
.setRateInUnitsPerHour(0.0)
|
||||
.setDurationInMinutes(30.toShort())
|
||||
.setProgramReminder(ProgramReminder(true, true, 0.toByte()))
|
||||
.setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte()))
|
||||
.build()
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex("024200011C201A0E494E532E01007901384000000000160EC00000016B49D2000001EB49D200815B"),
|
||||
command.encoded
|
||||
)
|
||||
|
@ -63,10 +63,10 @@ class ProgramTempBasalCommandTest {
|
|||
.setSequenceNumber(7.toShort())
|
||||
.setRateInUnitsPerHour(0.0)
|
||||
.setDurationInMinutes(720.toShort())
|
||||
.setProgramReminder(ProgramReminder(true, true, 0.toByte()))
|
||||
.setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte()))
|
||||
.build()
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
Assertions.assertArrayEquals(
|
||||
Hex.decodeHex("024200011C221A10494E532E0100901838400000F0007000160EC00000186B49D20000186B49D2000132"),
|
||||
command.encoded
|
||||
)
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
|
|||
|
||||
import org.apache.commons.codec.DecoderException
|
||||
import org.apache.commons.codec.binary.Hex
|
||||
import org.junit.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.Date
|
||||
|
||||
|
@ -18,6 +18,6 @@ class SetUniqueIdCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344"), encoded)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.EnumSet
|
||||
|
||||
|
@ -18,7 +18,7 @@ class SilenceAlertsCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("0242000304071105494E532E1081CE"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("0242000304071105494E532E1081CE"), encoded)
|
||||
}
|
||||
|
||||
// TODO capture more silence alerts commands
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class StopDeliveryCommandTest {
|
||||
|
@ -18,7 +18,7 @@ class StopDeliveryCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("0242000300071F05494E532E6201B1"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("0242000300071F05494E532E6201B1"), encoded)
|
||||
}
|
||||
|
||||
@Test @Throws(DecoderException::class) fun testSuspendDelivery() {
|
||||
|
@ -31,7 +31,7 @@ class StopDeliveryCommandTest {
|
|||
.build()
|
||||
.encoded
|
||||
|
||||
Assert.assertArrayEquals(Hex.decodeHex("0242000308071F05494E532E078287"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("0242000308071F05494E532E078287"), encoded)
|
||||
}
|
||||
|
||||
// TODO test cancel bolus
|
||||
|
|
|
@ -3,10 +3,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class SuspendDeliveryCommandTest {
|
||||
|
||||
@Test @Throws(DecoderException::class) fun testSuspendDelivery() {
|
||||
val encoded = SuspendDeliveryCommand.Builder()
|
||||
.setUniqueId(37879811)
|
||||
|
@ -15,6 +16,6 @@ class SuspendDeliveryCommandTest {
|
|||
.setBeepType(BeepType.LONG_SINGLE_BEEP)
|
||||
.build()
|
||||
.encoded
|
||||
Assert.assertArrayEquals(Hex.decodeHex("0242000300131f05494e532e67190a494e532e680000140302811f"), encoded)
|
||||
Assertions.assertArrayEquals(Hex.decodeHex("0242000300131f05494e532e67190a494e532e680000140302811f"), encoded)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class AlarmStatusResponseTest {
|
||||
|
@ -14,31 +14,31 @@ class AlarmStatusResponseTest {
|
|||
val encoded = Hex.decodeHex("021602080100000501BD00000003FF01950000000000670A")
|
||||
val response = AlarmStatusResponse(encoded)
|
||||
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE, response.responseType)
|
||||
Assert.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE.value, response.messageType)
|
||||
Assert.assertEquals(ResponseType.StatusResponseType.ALARM_STATUS, response.statusResponseType)
|
||||
Assert.assertEquals(ResponseType.StatusResponseType.ALARM_STATUS.value, response.additionalStatusResponseType)
|
||||
Assert.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus)
|
||||
Assert.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus)
|
||||
Assert.assertEquals(0.toShort(), response.bolusPulsesRemaining)
|
||||
Assert.assertEquals(5.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assert.assertEquals(445.toShort(), response.totalPulsesDelivered)
|
||||
Assert.assertEquals(AlarmType.NONE, response.alarmType)
|
||||
Assert.assertEquals(0.toShort(), response.alarmTime)
|
||||
Assert.assertEquals(1023.toShort(), response.reservoirPulsesRemaining)
|
||||
Assert.assertEquals(405.toShort(), response.minutesSinceActivation)
|
||||
Assert.assertEquals(0, response.activeAlerts.size)
|
||||
Assert.assertFalse(response.occlusionAlarm)
|
||||
Assert.assertFalse(response.pulseInfoInvalid)
|
||||
Assert.assertEquals(PodStatus.UNINITIALIZED, response.podStatusWhenAlarmOccurred)
|
||||
Assert.assertFalse(response.immediateBolusWhenAlarmOccurred)
|
||||
Assert.assertEquals(0x00.toByte(), response.occlusionType)
|
||||
Assert.assertFalse(response.occurredWhenFetchingImmediateBolusActiveInformation)
|
||||
Assert.assertEquals(0.toShort(), response.rssi)
|
||||
Assert.assertEquals(0.toShort(), response.receiverLowerGain)
|
||||
Assert.assertEquals(PodStatus.UNINITIALIZED, response.podStatusWhenAlarmOccurred2)
|
||||
Assert.assertEquals(26378.toShort(), response.returnAddressOfPodAlarmHandlerCaller)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class DefaultStatusResponseTest {
|
||||
|
@ -13,169 +13,170 @@ class DefaultStatusResponseTest {
|
|||
@Test @Throws(DecoderException::class) fun testValidResponse() {
|
||||
val encoded = Hex.decodeHex("1D1800A02800000463FF")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assert.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus)
|
||||
Assert.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus)
|
||||
Assert.assertEquals(320.toShort(), response.totalPulsesDelivered)
|
||||
Assert.assertEquals(5.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assert.assertEquals(0.toShort(), response.bolusPulsesRemaining)
|
||||
Assert.assertEquals(0, response.activeAlerts.size)
|
||||
Assert.assertEquals(280.toShort(), response.minutesSinceActivation)
|
||||
Assert.assertEquals(1023.toShort(), response.reservoirPulsesRemaining)
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
* response (hex) 1D1905281000004387D3039A
|
||||
Status response: 29
|
||||
Pod status: RUNNING_BELOW_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: false
|
||||
Bolus pulses remaining: 0
|
||||
sequence number of last programing command: 2
|
||||
Total full pulses delivered: 2640
|
||||
Full reservoir pulses remaining: 979
|
||||
Time since activation: 4321
|
||||
Alert 1 is InActive
|
||||
Alert 2 is InActive
|
||||
Alert 3 is InActive
|
||||
Alert 4 is InActive
|
||||
Alert 5 is InActive
|
||||
Alert 6 is InActive
|
||||
Alert 7 is InActive
|
||||
Occlusion alert active false
|
||||
Status response: 29
|
||||
Pod status: RUNNING_BELOW_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: false
|
||||
Bolus pulses remaining: 0
|
||||
sequence number of last programing command: 2
|
||||
Total full pulses delivered: 2640
|
||||
Full reservoir pulses remaining: 979
|
||||
Time since activation: 4321
|
||||
Alert 1 is InActive
|
||||
Alert 2 is InActive
|
||||
Alert 3 is InActive
|
||||
Alert 4 is InActive
|
||||
Alert 5 is InActive
|
||||
Alert 6 is InActive
|
||||
Alert 7 is InActive
|
||||
Occlusion alert active false
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseBelowMin() {
|
||||
val encoded = Hex.decodeHex("1D1905281000004387D3039A")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assert.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus)
|
||||
Assert.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus)
|
||||
Assert.assertEquals(2.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assert.assertEquals(0.toShort(), response.bolusPulsesRemaining)
|
||||
Assert.assertEquals(0, response.activeAlerts.size)
|
||||
Assert.assertEquals(4321.toShort(), response.minutesSinceActivation)
|
||||
Assert.assertEquals(979.toShort(), response.reservoirPulsesRemaining)
|
||||
Assert.assertEquals(2640.toShort(), response.totalPulsesDelivered)
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
* response (hex) 1D180519C00E0039A7FF8085
|
||||
Status response: 29
|
||||
Pod status: RUNNING_ABOVE_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: false
|
||||
Bolus pulses remaining: 14
|
||||
sequence number of last programing command: 8
|
||||
Total full pulses delivered: 2611
|
||||
Full reservoir pulses remaining: 1023
|
||||
Time since activation: 3689
|
||||
Alert 1 is InActive
|
||||
Alert 2 is InActive
|
||||
Alert 3 is InActive
|
||||
Alert 4 is InActive
|
||||
Alert 5 is InActive
|
||||
Alert 6 is InActive
|
||||
Alert 7 is InActive
|
||||
Occlusion alert active false
|
||||
Status response: 29
|
||||
Pod status: RUNNING_ABOVE_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: false
|
||||
Bolus pulses remaining: 14
|
||||
sequence number of last programing command: 8
|
||||
Total full pulses delivered: 2611
|
||||
Full reservoir pulses remaining: 1023
|
||||
Time since activation: 3689
|
||||
Alert 1 is InActive
|
||||
Alert 2 is InActive
|
||||
Alert 3 is InActive
|
||||
Alert 4 is InActive
|
||||
Alert 5 is InActive
|
||||
Alert 6 is InActive
|
||||
Alert 7 is InActive
|
||||
Occlusion alert active false
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining() {
|
||||
val encoded = Hex.decodeHex("1D180519C00E0039A7FF8085")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assert.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus)
|
||||
Assert.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus)
|
||||
Assert.assertEquals(8.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assert.assertEquals(14.toShort(), response.bolusPulsesRemaining)
|
||||
Assert.assertEquals(0, response.activeAlerts.size)
|
||||
Assert.assertEquals(3689.toShort(), response.minutesSinceActivation)
|
||||
Assert.assertEquals(1023.toShort(), response.reservoirPulsesRemaining)
|
||||
Assert.assertEquals(2611.toShort(), response.totalPulsesDelivered)
|
||||
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)
|
||||
}
|
||||
|
||||
/** response (hex) 1D990714201F0042ED8801DE
|
||||
Status response: 29
|
||||
Pod status: RUNNING_BELOW_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: true
|
||||
Bolus pulses remaining: 31
|
||||
sequence number of last programing command: 4
|
||||
Total full pulses delivered: 3624
|
||||
Full reservoir pulses remaining: 392
|
||||
Time since activation: 4283
|
||||
Status response: 29
|
||||
Pod status: RUNNING_BELOW_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: true
|
||||
Bolus pulses remaining: 31
|
||||
sequence number of last programing command: 4
|
||||
Total full pulses delivered: 3624
|
||||
Full reservoir pulses remaining: 392
|
||||
Time since activation: 4283
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseReservoirPulsesRemaining() {
|
||||
val encoded = Hex.decodeHex("1D990714201F0042ED8801DE")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assert.assertEquals(DeliveryStatus.UNKNOWN, response.deliveryStatus) // Extended bolus active
|
||||
Assert.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus)
|
||||
Assert.assertEquals(4.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assert.assertEquals(31.toShort(), response.bolusPulsesRemaining)
|
||||
Assert.assertEquals(0, response.activeAlerts.size)
|
||||
Assert.assertEquals(4283.toShort(), response.minutesSinceActivation)
|
||||
Assert.assertEquals(392.toShort(), response.reservoirPulsesRemaining)
|
||||
Assert.assertEquals(3624.toShort(), response.totalPulsesDelivered)
|
||||
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)
|
||||
}
|
||||
|
||||
/** response (hex) 1d68002601f400002bff0368
|
||||
Status response: 29
|
||||
Pod status: RUNNING_BELOW_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: true
|
||||
Bolus pulses remaining: 31
|
||||
sequence number of last programing command: 4
|
||||
Total full pulses delivered: 3624
|
||||
Full reservoir pulses remaining: 392
|
||||
Time since activation: 4283
|
||||
Status response: 29
|
||||
Pod status: RUNNING_BELOW_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: true
|
||||
Bolus pulses remaining: 31
|
||||
sequence number of last programing command: 4
|
||||
Total full pulses delivered: 3624
|
||||
Full reservoir pulses remaining: 392
|
||||
Time since activation: 4283
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining3() {
|
||||
val encoded = Hex.decodeHex("1d68002601f400002bff0368")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(500.toShort(), response.bolusPulsesRemaining)
|
||||
Assert.assertEquals(0, response.activeAlerts.size)
|
||||
Assertions.assertArrayEquals(encoded, response.encoded)
|
||||
Assertions.assertNotSame(encoded, response.encoded)
|
||||
Assertions.assertEquals(500.toShort(), response.bolusPulsesRemaining)
|
||||
Assertions.assertEquals(0, response.activeAlerts.size)
|
||||
}
|
||||
|
||||
/** response (hex) 1d28002e91e400002fff8256
|
||||
Status response: 29
|
||||
Pod status: RUNNING_BELOW_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: true
|
||||
Bolus pulses remaining: 31
|
||||
sequence number of last programing command: 4
|
||||
Total full pulses delivered: 3624
|
||||
Full reservoir pulses remaining: 392
|
||||
Time since activation: 4283
|
||||
Status response: 29
|
||||
Pod status: RUNNING_BELOW_MIN_VOLUME
|
||||
Basal active: true
|
||||
Temp Basal active: false
|
||||
Immediate bolus active: false
|
||||
Extended bolus active: true
|
||||
Bolus pulses remaining: 31
|
||||
sequence number of last programing command: 4
|
||||
Total full pulses delivered: 3624
|
||||
Full reservoir pulses remaining: 392
|
||||
Time since activation: 4283
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining4() {
|
||||
val encoded = Hex.decodeHex("1d28002e91e400002fff8256")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(484.toShort(), response.bolusPulsesRemaining)
|
||||
Assert.assertEquals(0, response.activeAlerts.size)
|
||||
Assertions.assertArrayEquals(encoded, response.encoded)
|
||||
Assertions.assertNotSame(encoded, response.encoded)
|
||||
Assertions.assertEquals(484.toShort(), response.bolusPulsesRemaining)
|
||||
Assertions.assertEquals(0, response.activeAlerts.size)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -202,18 +203,18 @@ class DefaultStatusResponseTest {
|
|||
@Test @Throws(DecoderException::class) fun testValidResponseActiveAlert1() {
|
||||
val encoded = Hex.decodeHex("1D980559C820404393FF83AA")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assert.assertEquals(DeliveryStatus.UNKNOWN, response.deliveryStatus)
|
||||
Assert.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus)
|
||||
Assert.assertEquals(9.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assert.assertEquals(32.toShort(), response.bolusPulsesRemaining)
|
||||
Assert.assertEquals(1, response.activeAlerts.size)
|
||||
Assert.assertEquals(4324.toShort(), response.minutesSinceActivation)
|
||||
Assert.assertEquals(1023.toShort(), response.reservoirPulsesRemaining)
|
||||
Assert.assertEquals(2739.toShort(), response.totalPulsesDelivered)
|
||||
Assert.assertEquals(true, response.activeAlerts.contains(AlertType.EXPIRATION))
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class NakResponseTest {
|
||||
|
@ -14,13 +14,13 @@ class NakResponseTest {
|
|||
val encoded = Hex.decodeHex("0603070009")
|
||||
val response = NakResponse(encoded)
|
||||
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(ResponseType.NAK_RESPONSE, response.responseType)
|
||||
Assert.assertEquals(ResponseType.NAK_RESPONSE.value, response.messageType)
|
||||
Assert.assertEquals(NakErrorType.ILLEGAL_PARAM, response.nakErrorType)
|
||||
Assert.assertEquals(AlarmType.NONE, response.alarmType)
|
||||
Assert.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus)
|
||||
Assert.assertEquals(0x00.toShort(), response.securityNakSyncCount)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class SetUniqueIdResponseTest {
|
||||
|
@ -12,28 +12,28 @@ class SetUniqueIdResponseTest {
|
|||
val encoded = Hex.decodeHex("011B13881008340A50040A00010300040308146CC1000954D402420001")
|
||||
val response = SetUniqueIdResponse(encoded)
|
||||
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType)
|
||||
Assert.assertEquals(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, response.activationResponseType)
|
||||
Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.messageType)
|
||||
Assert.assertEquals(27.toShort(), response.messageLength)
|
||||
Assert.assertEquals(5000.toShort(), response.pulseVolumeInTenThousandthMicroLiter)
|
||||
Assert.assertEquals(16.toShort(), response.pumpRate)
|
||||
Assert.assertEquals(8.toShort(), response.primePumpRate)
|
||||
Assert.assertEquals(52.toShort(), response.numberOfEngagingClutchDrivePulses)
|
||||
Assert.assertEquals(10.toShort(), response.numberOfPrimePulses)
|
||||
Assert.assertEquals(80.toShort(), response.podExpirationTimeInHours)
|
||||
Assert.assertEquals(4.toShort(), response.firmwareVersionMajor)
|
||||
Assert.assertEquals(10.toShort(), response.firmwareVersionMinor)
|
||||
Assert.assertEquals(0.toShort(), response.firmwareVersionInterim)
|
||||
Assert.assertEquals(1.toShort(), response.bleVersionMajor)
|
||||
Assert.assertEquals(3.toShort(), response.bleVersionMinor)
|
||||
Assert.assertEquals(0.toShort(), response.bleVersionInterim)
|
||||
Assert.assertEquals(4.toShort(), response.productId)
|
||||
Assert.assertEquals(PodStatus.UID_SET, response.podStatus)
|
||||
Assert.assertEquals(135556289L, response.lotNumber)
|
||||
Assert.assertEquals(611540L, response.podSequenceNumber)
|
||||
Assert.assertEquals(37879809L, response.uniqueIdReceivedInCommand)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
|
|||
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.Assert
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class VersionResponseTest {
|
||||
|
@ -12,24 +12,24 @@ class VersionResponseTest {
|
|||
val encoded = Hex.decodeHex("0115040A00010300040208146CC1000954D400FFFFFFFF")
|
||||
val response = VersionResponse(encoded)
|
||||
|
||||
Assert.assertArrayEquals(encoded, response.encoded)
|
||||
Assert.assertNotSame(encoded, response.encoded)
|
||||
Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType)
|
||||
Assert.assertEquals(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE, response.activationResponseType)
|
||||
Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.messageType)
|
||||
Assert.assertEquals(21.toShort(), response.messageLength)
|
||||
Assert.assertEquals(4.toShort(), response.firmwareVersionMajor)
|
||||
Assert.assertEquals(10.toShort(), response.firmwareVersionMinor)
|
||||
Assert.assertEquals(0.toShort(), response.firmwareVersionInterim)
|
||||
Assert.assertEquals(1.toShort(), response.bleVersionMajor)
|
||||
Assert.assertEquals(3.toShort(), response.bleVersionMinor)
|
||||
Assert.assertEquals(0.toShort(), response.bleVersionInterim)
|
||||
Assert.assertEquals(4.toShort(), response.productId)
|
||||
Assert.assertEquals(PodStatus.FILLED, response.podStatus)
|
||||
Assert.assertEquals(135556289L, response.lotNumber)
|
||||
Assert.assertEquals(611540L, response.podSequenceNumber)
|
||||
Assert.assertEquals(0.toByte(), response.rssi)
|
||||
Assert.assertEquals(0.toByte(), response.receiverLowerGain)
|
||||
Assert.assertEquals(4294967295L, response.uniqueIdReceivedInCommand)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
import info.nightscout.interfaces.profile.Profile
|
||||
import info.nightscout.interfaces.profile.Profile.ProfileValue
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.`when`
|
||||
|
@ -24,19 +24,19 @@ class FunctionsTest {
|
|||
|
||||
val basalProgram: BasalProgram = mapProfileToBasalProgram(profile)
|
||||
val entries: List<BasalProgram.Segment> = basalProgram.segments
|
||||
assertEquals(3, entries.size)
|
||||
Assertions.assertEquals(3, entries.size)
|
||||
val entry1: BasalProgram.Segment = entries[0]
|
||||
assertEquals(0.toShort(), entry1.startSlotIndex)
|
||||
assertEquals(50, entry1.basalRateInHundredthUnitsPerHour)
|
||||
assertEquals(10.toShort(), entry1.endSlotIndex)
|
||||
Assertions.assertEquals(0.toShort(), entry1.startSlotIndex)
|
||||
Assertions.assertEquals(50, entry1.basalRateInHundredthUnitsPerHour)
|
||||
Assertions.assertEquals(10.toShort(), entry1.endSlotIndex)
|
||||
val entry2: BasalProgram.Segment = entries[1]
|
||||
assertEquals(10.toShort(), entry2.startSlotIndex)
|
||||
assertEquals(100, entry2.basalRateInHundredthUnitsPerHour)
|
||||
assertEquals(28.toShort(), entry2.endSlotIndex)
|
||||
Assertions.assertEquals(10.toShort(), entry2.startSlotIndex)
|
||||
Assertions.assertEquals(100, entry2.basalRateInHundredthUnitsPerHour)
|
||||
Assertions.assertEquals(28.toShort(), entry2.endSlotIndex)
|
||||
val entry3: BasalProgram.Segment = entries[2]
|
||||
assertEquals(28.toShort(), entry3.startSlotIndex)
|
||||
assertEquals(305, entry3.basalRateInHundredthUnitsPerHour)
|
||||
assertEquals(48.toShort(), entry3.endSlotIndex)
|
||||
Assertions.assertEquals(28.toShort(), entry3.startSlotIndex)
|
||||
Assertions.assertEquals(305, entry3.basalRateInHundredthUnitsPerHour)
|
||||
Assertions.assertEquals(48.toShort(), entry3.endSlotIndex)
|
||||
}
|
||||
|
||||
@Test fun invalidProfileZeroEntries() {
|
||||
|
@ -108,6 +108,6 @@ class FunctionsTest {
|
|||
|
||||
val basalProgram: BasalProgram = mapProfileToBasalProgram(profile)
|
||||
val basalProgramElement: BasalProgram.Segment = basalProgram.segments[0]
|
||||
assertEquals(5, basalProgramElement.basalRateInHundredthUnitsPerHour)
|
||||
Assertions.assertEquals(5, basalProgramElement.basalRateInHundredthUnitsPerHour)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue