From d24d97cc4b4a4559f3fa520f9dcf186fb80f84f9 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:22:05 -0700 Subject: [PATCH] Rewrites StopPatchPacketTest with matchers Issue #2745 --- .../medtrum/comm/packets/StopPatchPacketTest.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/StopPatchPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/StopPatchPacketTest.kt index be58797655..138a0e887c 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/StopPatchPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/StopPatchPacketTest.kt @@ -1,9 +1,9 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class StopPatchPacketTest : MedtrumTestBase() { @@ -28,8 +28,7 @@ class StopPatchPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(1, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) + assertThat(result).asList().containsExactly(opCode.toByte()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -43,9 +42,9 @@ class StopPatchPacketTest : MedtrumTestBase() { // Expected values val expectedPatchId = 146L val expectedStopSequence = 23 - Assertions.assertTrue(result) - Assertions.assertEquals(expectedPatchId, medtrumPump.lastStopPatchId) - Assertions.assertEquals(expectedStopSequence, medtrumPump.lastStopSequence) + assertThat(result).isTrue() + assertThat(medtrumPump.lastStopPatchId).isEqualTo(expectedPatchId) + assertThat(medtrumPump.lastStopSequence).isEqualTo(expectedStopSequence) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -57,7 +56,7 @@ class StopPatchPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertFalse(result) - Assertions.assertTrue(packet.failed) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } }