parent
77964df4ae
commit
9840cf81c8
1 changed files with 11 additions and 33 deletions
|
@ -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
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue