Rewrites AlarmStatusResponseTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-08 20:16:21 -07:00
parent 5d4c0f7243
commit 8af75ade2a

View file

@ -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())
} }
} }