Rewrites SetUniqueIdResponseTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-08 20:31:11 -07:00
parent 25112828a2
commit 18cf56e267

View file

@ -1,39 +1,39 @@
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.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 SetUniqueIdResponseTest { class SetUniqueIdResponseTest {
@Test @Throws(DecoderException::class) fun testValidResponse() { @Test fun testValidResponse() {
val encoded = Hex.decodeHex("011B13881008340A50040A00010300040308146CC1000954D402420001") val encoded = Hex.decodeHex("011B13881008340A50040A00010300040308146CC1000954D402420001")
val response = SetUniqueIdResponse(encoded) val response = SetUniqueIdResponse(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.ACTIVATION_RESPONSE, response.responseType) assertThat(response.responseType).isEqualTo(ResponseType.ACTIVATION_RESPONSE)
Assertions.assertEquals(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, response.activationResponseType) assertThat(response.activationResponseType).isEqualTo(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE)
Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.messageType) assertThat(response.messageType).isEqualTo(ResponseType.ACTIVATION_RESPONSE.value)
Assertions.assertEquals(27.toShort(), response.messageLength) assertThat(response.messageLength).isEqualTo(27.toShort())
Assertions.assertEquals(5000.toShort(), response.pulseVolumeInTenThousandthMicroLiter) assertThat(response.pulseVolumeInTenThousandthMicroLiter).isEqualTo(5000.toShort())
Assertions.assertEquals(16.toShort(), response.pumpRate) assertThat(response.pumpRate).isEqualTo(16.toShort())
Assertions.assertEquals(8.toShort(), response.primePumpRate) assertThat(response.primePumpRate).isEqualTo(8.toShort())
Assertions.assertEquals(52.toShort(), response.numberOfEngagingClutchDrivePulses) assertThat(response.numberOfEngagingClutchDrivePulses).isEqualTo(52.toShort())
Assertions.assertEquals(10.toShort(), response.numberOfPrimePulses) assertThat(response.numberOfPrimePulses).isEqualTo(10.toShort())
Assertions.assertEquals(80.toShort(), response.podExpirationTimeInHours) assertThat(response.podExpirationTimeInHours).isEqualTo(80.toShort())
Assertions.assertEquals(4.toShort(), response.firmwareVersionMajor) assertThat(response.firmwareVersionMajor).isEqualTo(4.toShort())
Assertions.assertEquals(10.toShort(), response.firmwareVersionMinor) assertThat(response.firmwareVersionMinor).isEqualTo(10.toShort())
Assertions.assertEquals(0.toShort(), response.firmwareVersionInterim) assertThat(response.firmwareVersionInterim).isEqualTo(0.toShort())
Assertions.assertEquals(1.toShort(), response.bleVersionMajor) assertThat(response.bleVersionMajor).isEqualTo(1.toShort())
Assertions.assertEquals(3.toShort(), response.bleVersionMinor) assertThat(response.bleVersionMinor).isEqualTo(3.toShort())
Assertions.assertEquals(0.toShort(), response.bleVersionInterim) assertThat(response.bleVersionInterim).isEqualTo(0.toShort())
Assertions.assertEquals(4.toShort(), response.productId) assertThat(response.productId).isEqualTo(4.toShort())
Assertions.assertEquals(PodStatus.UID_SET, response.podStatus) assertThat(response.podStatus).isEqualTo(PodStatus.UID_SET)
Assertions.assertEquals(135556289L, response.lotNumber) assertThat(response.lotNumber).isEqualTo(135556289L)
Assertions.assertEquals(611540L, response.podSequenceNumber) assertThat(response.podSequenceNumber).isEqualTo(611540L)
Assertions.assertEquals(37879809L, response.uniqueIdReceivedInCommand) assertThat(response.uniqueIdReceivedInCommand).isEqualTo(37879809L)
} }
} }