Rewrites ProgramTempBasalCommandTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-08 21:00:39 -07:00
parent 249106cf6a
commit a4fb17e53c

View file

@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import com.google.common.truth.Truth.assertThat
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
class ProgramTempBasalCommandTest {
@Test @Throws(DecoderException::class) fun testExtraAlternateSegmentPulseTempBasal() {
@Test fun testExtraAlternateSegmentPulseTempBasal() {
val command = ProgramTempBasalCommand.Builder()
.setUniqueId(37879809)
.setNonce(1229869870)
@ -18,13 +18,10 @@ class ProgramTempBasalCommandTest {
.setProgramReminder(ProgramReminder(atStart = false, atEnd = true, atInterval = 0.toByte()))
.build()
Assertions.assertArrayEquals(
Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6"),
command.encoded
)
assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6").asList()).inOrder()
}
@Test @Throws(DecoderException::class) fun testZeroTempBasal() {
@Test fun testZeroTempBasal() {
val command = ProgramTempBasalCommand.Builder()
.setUniqueId(37879809)
.setNonce(1229869870)
@ -34,13 +31,10 @@ class ProgramTempBasalCommandTest {
.setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte()))
.build()
Assertions.assertArrayEquals(
Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000A6B49D20001E3"),
command.encoded
)
assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000A6B49D20001E3").asList()).inOrder()
}
@Test @Throws(DecoderException::class) fun testZeroTempBasalShort() {
@Test fun testZeroTempBasalShort() {
val command = ProgramTempBasalCommand.Builder()
.setUniqueId(37879809)
.setNonce(1229869870)
@ -50,13 +44,10 @@ class ProgramTempBasalCommandTest {
.setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte()))
.build()
Assertions.assertArrayEquals(
Hex.decodeHex("024200011C201A0E494E532E01007901384000000000160EC00000016B49D2000001EB49D200815B"),
command.encoded
)
assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200011C201A0E494E532E01007901384000000000160EC00000016B49D2000001EB49D200815B").asList()).inOrder()
}
@Test @Throws(DecoderException::class) fun testZeroTempBasalVeryLong() {
@Test fun testZeroTempBasalVeryLong() {
val command = ProgramTempBasalCommand.Builder()
.setUniqueId(37879809)
.setNonce(1229869870)
@ -66,9 +57,6 @@ class ProgramTempBasalCommandTest {
.setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte()))
.build()
Assertions.assertArrayEquals(
Hex.decodeHex("024200011C221A10494E532E0100901838400000F0007000160EC00000186B49D20000186B49D2000132"),
command.encoded
)
assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200011C221A10494E532E0100901838400000F0007000160EC00000186B49D20000186B49D2000132").asList()).inOrder()
}
}