parent
8af75ade2a
commit
6785f1a11d
1 changed files with 77 additions and 77 deletions
|
@ -1,30 +1,30 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
|
||||
import org.apache.commons.codec.DecoderException
|
||||
import org.apache.commons.codec.binary.Hex
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class DefaultStatusResponseTest {
|
||||
|
||||
@Test @Throws(DecoderException::class) fun testValidResponse() {
|
||||
@Test fun testValidResponse() {
|
||||
val encoded = Hex.decodeHex("1D1800A02800000463FF")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assertions.assertArrayEquals(encoded, response.encoded)
|
||||
Assertions.assertNotSame(encoded, response.encoded)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus)
|
||||
Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus)
|
||||
Assertions.assertEquals(320.toShort(), response.totalPulsesDelivered)
|
||||
Assertions.assertEquals(5.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assertions.assertEquals(0.toShort(), response.bolusPulsesRemaining)
|
||||
Assertions.assertEquals(0, response.activeAlerts.size)
|
||||
Assertions.assertEquals(280.toShort(), response.minutesSinceActivation)
|
||||
Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining)
|
||||
assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList())
|
||||
assertThat(response.encoded).isNotSameInstanceAs(encoded)
|
||||
assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE)
|
||||
assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value)
|
||||
assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE)
|
||||
assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME)
|
||||
assertThat(response.totalPulsesDelivered).isEqualTo(320.toShort())
|
||||
assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(5.toShort())
|
||||
assertThat(response.bolusPulsesRemaining).isEqualTo(0.toShort())
|
||||
assertThat(response.activeAlerts).isEmpty()
|
||||
assertThat(response.minutesSinceActivation).isEqualTo(280.toShort())
|
||||
assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,21 +49,21 @@ class DefaultStatusResponseTest {
|
|||
Alert 7 is InActive
|
||||
Occlusion alert active false
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseBelowMin() {
|
||||
@Test fun testValidResponseBelowMin() {
|
||||
val encoded = Hex.decodeHex("1D1905281000004387D3039A")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assertions.assertArrayEquals(encoded, response.encoded)
|
||||
Assertions.assertNotSame(encoded, response.encoded)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus)
|
||||
Assertions.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus)
|
||||
Assertions.assertEquals(2.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assertions.assertEquals(0.toShort(), response.bolusPulsesRemaining)
|
||||
Assertions.assertEquals(0, response.activeAlerts.size)
|
||||
Assertions.assertEquals(4321.toShort(), response.minutesSinceActivation)
|
||||
Assertions.assertEquals(979.toShort(), response.reservoirPulsesRemaining)
|
||||
Assertions.assertEquals(2640.toShort(), response.totalPulsesDelivered)
|
||||
assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder()
|
||||
assertThat(response.encoded).isNotSameInstanceAs(encoded)
|
||||
assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE)
|
||||
assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value)
|
||||
assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE)
|
||||
assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_BELOW_MIN_VOLUME)
|
||||
assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(2.toShort())
|
||||
assertThat(response.bolusPulsesRemaining).isEqualTo(0.toShort())
|
||||
assertThat(response.activeAlerts).isEmpty()
|
||||
assertThat(response.minutesSinceActivation).isEqualTo(4321.toShort())
|
||||
assertThat(response.reservoirPulsesRemaining).isEqualTo(979.toShort())
|
||||
assertThat(response.totalPulsesDelivered).isEqualTo(2640.toShort())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,21 +88,21 @@ class DefaultStatusResponseTest {
|
|||
Alert 7 is InActive
|
||||
Occlusion alert active false
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining() {
|
||||
@Test fun testValidResponseBolusPulsesRemaining() {
|
||||
val encoded = Hex.decodeHex("1D180519C00E0039A7FF8085")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assertions.assertArrayEquals(encoded, response.encoded)
|
||||
Assertions.assertNotSame(encoded, response.encoded)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus)
|
||||
Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus)
|
||||
Assertions.assertEquals(8.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assertions.assertEquals(14.toShort(), response.bolusPulsesRemaining)
|
||||
Assertions.assertEquals(0, response.activeAlerts.size)
|
||||
Assertions.assertEquals(3689.toShort(), response.minutesSinceActivation)
|
||||
Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining)
|
||||
Assertions.assertEquals(2611.toShort(), response.totalPulsesDelivered)
|
||||
assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder()
|
||||
assertThat(response.encoded).isNotSameInstanceAs(encoded)
|
||||
assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE)
|
||||
assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value)
|
||||
assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE)
|
||||
assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME)
|
||||
assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(8.toShort())
|
||||
assertThat(response.bolusPulsesRemaining).isEqualTo(14.toShort())
|
||||
assertThat(response.activeAlerts).isEmpty()
|
||||
assertThat(response.minutesSinceActivation).isEqualTo(3689.toShort())
|
||||
assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort())
|
||||
assertThat(response.totalPulsesDelivered).isEqualTo(2611.toShort())
|
||||
}
|
||||
|
||||
/** response (hex) 1D990714201F0042ED8801DE
|
||||
|
@ -118,21 +118,21 @@ class DefaultStatusResponseTest {
|
|||
Full reservoir pulses remaining: 392
|
||||
Time since activation: 4283
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseReservoirPulsesRemaining() {
|
||||
@Test fun testValidResponseReservoirPulsesRemaining() {
|
||||
val encoded = Hex.decodeHex("1D990714201F0042ED8801DE")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assertions.assertArrayEquals(encoded, response.encoded)
|
||||
Assertions.assertNotSame(encoded, response.encoded)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assertions.assertEquals(DeliveryStatus.UNKNOWN, response.deliveryStatus) // Extended bolus active
|
||||
Assertions.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus)
|
||||
Assertions.assertEquals(4.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assertions.assertEquals(31.toShort(), response.bolusPulsesRemaining)
|
||||
Assertions.assertEquals(0, response.activeAlerts.size)
|
||||
Assertions.assertEquals(4283.toShort(), response.minutesSinceActivation)
|
||||
Assertions.assertEquals(392.toShort(), response.reservoirPulsesRemaining)
|
||||
Assertions.assertEquals(3624.toShort(), response.totalPulsesDelivered)
|
||||
assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder()
|
||||
assertThat(response.encoded).isNotSameInstanceAs(encoded)
|
||||
assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE)
|
||||
assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value)
|
||||
assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.UNKNOWN) // Extended bolus active
|
||||
assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_BELOW_MIN_VOLUME)
|
||||
assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(4.toShort())
|
||||
assertThat(response.bolusPulsesRemaining).isEqualTo(31.toShort())
|
||||
assertThat(response.activeAlerts).isEmpty()
|
||||
assertThat(response.minutesSinceActivation).isEqualTo(4283.toShort())
|
||||
assertThat(response.reservoirPulsesRemaining).isEqualTo(392.toShort())
|
||||
assertThat(response.totalPulsesDelivered).isEqualTo(3624.toShort())
|
||||
}
|
||||
|
||||
/** response (hex) 1d68002601f400002bff0368
|
||||
|
@ -148,13 +148,13 @@ class DefaultStatusResponseTest {
|
|||
Full reservoir pulses remaining: 392
|
||||
Time since activation: 4283
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining3() {
|
||||
@Test fun testValidResponseBolusPulsesRemaining3() {
|
||||
val encoded = Hex.decodeHex("1d68002601f400002bff0368")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assertions.assertArrayEquals(encoded, response.encoded)
|
||||
Assertions.assertNotSame(encoded, response.encoded)
|
||||
Assertions.assertEquals(500.toShort(), response.bolusPulsesRemaining)
|
||||
Assertions.assertEquals(0, response.activeAlerts.size)
|
||||
assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder()
|
||||
assertThat(response.encoded).isNotSameInstanceAs(encoded)
|
||||
assertThat(response.bolusPulsesRemaining).isEqualTo(500.toShort())
|
||||
assertThat(response.activeAlerts).isEmpty()
|
||||
}
|
||||
|
||||
/** response (hex) 1d28002e91e400002fff8256
|
||||
|
@ -170,13 +170,13 @@ class DefaultStatusResponseTest {
|
|||
Full reservoir pulses remaining: 392
|
||||
Time since activation: 4283
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining4() {
|
||||
@Test fun testValidResponseBolusPulsesRemaining4() {
|
||||
val encoded = Hex.decodeHex("1d28002e91e400002fff8256")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assertions.assertArrayEquals(encoded, response.encoded)
|
||||
Assertions.assertNotSame(encoded, response.encoded)
|
||||
Assertions.assertEquals(484.toShort(), response.bolusPulsesRemaining)
|
||||
Assertions.assertEquals(0, response.activeAlerts.size)
|
||||
assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder()
|
||||
assertThat(response.encoded).isNotSameInstanceAs(encoded)
|
||||
assertThat(response.bolusPulsesRemaining).isEqualTo(484.toShort())
|
||||
assertThat(response.activeAlerts).isEmpty()
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -200,21 +200,21 @@ class DefaultStatusResponseTest {
|
|||
Alert 7 is Active
|
||||
Occlusion alert active false
|
||||
*/
|
||||
@Test @Throws(DecoderException::class) fun testValidResponseActiveAlert1() {
|
||||
@Test fun testValidResponseActiveAlert1() {
|
||||
val encoded = Hex.decodeHex("1D980559C820404393FF83AA")
|
||||
val response = DefaultStatusResponse(encoded)
|
||||
Assertions.assertArrayEquals(encoded, response.encoded)
|
||||
Assertions.assertNotSame(encoded, response.encoded)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
|
||||
Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType)
|
||||
Assertions.assertEquals(DeliveryStatus.UNKNOWN, response.deliveryStatus)
|
||||
Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus)
|
||||
Assertions.assertEquals(9.toShort(), response.sequenceNumberOfLastProgrammingCommand)
|
||||
Assertions.assertEquals(32.toShort(), response.bolusPulsesRemaining)
|
||||
Assertions.assertEquals(1, response.activeAlerts.size)
|
||||
Assertions.assertEquals(4324.toShort(), response.minutesSinceActivation)
|
||||
Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining)
|
||||
Assertions.assertEquals(2739.toShort(), response.totalPulsesDelivered)
|
||||
Assertions.assertEquals(true, response.activeAlerts.contains(AlertType.EXPIRATION))
|
||||
assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder()
|
||||
assertThat(response.encoded).isNotSameInstanceAs(encoded)
|
||||
assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE)
|
||||
assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value)
|
||||
assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.UNKNOWN)
|
||||
assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME)
|
||||
assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(9.toShort())
|
||||
assertThat(response.bolusPulsesRemaining).isEqualTo(32.toShort())
|
||||
assertThat(response.activeAlerts).hasSize(1)
|
||||
assertThat(response.minutesSinceActivation).isEqualTo(4324.toShort())
|
||||
assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort())
|
||||
assertThat(response.totalPulsesDelivered).isEqualTo(2739.toShort())
|
||||
assertThat(response.activeAlerts.contains(AlertType.EXPIRATION)).isTrue()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue