Rewrites VersionResponseTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-08 20:32:56 -07:00
parent 18cf56e267
commit f85953694b

View file

@ -1,35 +1,35 @@
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 VersionResponseTest { class VersionResponseTest {
@Test @Throws(DecoderException::class) fun testValidResponse() { @Test fun testValidResponse() {
val encoded = Hex.decodeHex("0115040A00010300040208146CC1000954D400FFFFFFFF") val encoded = Hex.decodeHex("0115040A00010300040208146CC1000954D400FFFFFFFF")
val response = VersionResponse(encoded) val response = VersionResponse(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.GET_VERSION_RESPONSE, response.activationResponseType) assertThat(response.activationResponseType).isEqualTo(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE)
Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.messageType) assertThat(response.messageType).isEqualTo(ResponseType.ACTIVATION_RESPONSE.value)
Assertions.assertEquals(21.toShort(), response.messageLength) assertThat(response.messageLength).isEqualTo(21.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.FILLED, response.podStatus) assertThat(response.podStatus).isEqualTo(PodStatus.FILLED)
Assertions.assertEquals(135556289L, response.lotNumber) assertThat(response.lotNumber).isEqualTo(135556289L)
Assertions.assertEquals(611540L, response.podSequenceNumber) assertThat(response.podSequenceNumber).isEqualTo(611540L)
Assertions.assertEquals(0.toByte(), response.rssi) assertThat(response.rssi).isEqualTo(0.toByte())
Assertions.assertEquals(0.toByte(), response.receiverLowerGain) assertThat(response.receiverLowerGain).isEqualTo(0.toByte())
Assertions.assertEquals(4294967295L, response.uniqueIdReceivedInCommand) assertThat(response.uniqueIdReceivedInCommand).isEqualTo(4294967295L)
} }
} }