From f388285ff59ae56ce6544995061a0089cad6b208 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 23:10:32 -0700 Subject: [PATCH] Rewrites PodInfoResponseTest with matchers Issue #2745 --- .../response/podinfo/PodInfoResponseTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/message/response/podinfo/PodInfoResponseTest.kt b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/message/response/podinfo/PodInfoResponseTest.kt index bf97fff625..f989ffe4d8 100644 --- a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/message/response/podinfo/PodInfoResponseTest.kt +++ b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/message/response/podinfo/PodInfoResponseTest.kt @@ -3,35 +3,35 @@ package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communicatio import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodInfoType import info.nightscout.pump.common.utils.ByteUtil -import org.junit.jupiter.api.Assertions +import kotlin.test.assertIsNot import org.junit.jupiter.api.Test internal class PodInfoResponseTest { @Test fun testRawData() { - val encodedData = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d") + val encodedData = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d")!! val podInfoResponse = PodInfoResponse(encodedData) - Assertions.assertArrayEquals(encodedData, podInfoResponse.rawData) + assertThat(podInfoResponse.rawData.asList()).containsExactlyElementsIn(encodedData.asIterable()).inOrder() } @Test fun testRawDataWithLongerMessage() { - val encodedData = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d01") - val expected = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d") + val encodedData = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d01")!! + val expected = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d")!! val podInfoResponse = PodInfoResponse(encodedData) - Assertions.assertArrayEquals(expected, podInfoResponse.rawData) + assertThat(podInfoResponse.rawData.asList()).containsExactlyElementsIn(expected.asIterable()).inOrder() } @Test fun testMessageDecoding() { val podInfoResponse = PodInfoResponse(ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d")) - Assertions.assertEquals(PodInfoType.DETAILED_STATUS, podInfoResponse.subType) + assertThat(podInfoResponse.subType).isEqualTo(PodInfoType.DETAILED_STATUS) val podInfo = podInfoResponse.podInfo as PodInfoDetailedStatus - Assertions.assertFalse(podInfo.isFaultAccessingTables) - Assertions.assertEquals(0x01, podInfo.errorEventInfo.internalVariable.toInt()) + assertThat(podInfo.isFaultAccessingTables).isFalse() + assertThat(podInfo.errorEventInfo.internalVariable.toInt()).isEqualTo(0x01) } @Test fun testInvalidPodInfoTypeMessageDecoding() { val podInfoResponse = PodInfoResponse(ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d")) - Assertions.assertEquals(PodInfoType.DETAILED_STATUS, podInfoResponse.subType) - assertThat(podInfoResponse.podInfo).isNotInstanceOf(PodInfoActiveAlerts::class.java) + assertThat(podInfoResponse.subType).isEqualTo(PodInfoType.DETAILED_STATUS) + assertIsNot(podInfoResponse.podInfo) } }