From 8664bc71706da592827dd2f70f9b0d1ca992be3c Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Mon, 18 Sep 2023 23:50:16 -0700 Subject: [PATCH] Rewrites EventDataTest with matchers Issue #2745 --- .../nightscout/rx/weardata/EventDataTest.kt | 172 +++++++++--------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/app-wear-shared/shared/src/test/java/info/nightscout/rx/weardata/EventDataTest.kt b/app-wear-shared/shared/src/test/java/info/nightscout/rx/weardata/EventDataTest.kt index 0ff0c07f33..25198a8e2c 100644 --- a/app-wear-shared/shared/src/test/java/info/nightscout/rx/weardata/EventDataTest.kt +++ b/app-wear-shared/shared/src/test/java/info/nightscout/rx/weardata/EventDataTest.kt @@ -1,7 +1,7 @@ package info.nightscout.rx.weardata +import com.google.common.truth.Truth.assertThat import kotlinx.serialization.ExperimentalSerializationApi -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -21,132 +21,132 @@ class EventDataTest { @Test fun serializationTest() { EventData.ActionPong(1, 2).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.WearException(1, byteArrayOf(0xAA.toByte()), "board", "fingerprint", "sdk", "model", "manufacturer", "product").let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.Error(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.CancelBolus(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionResendData("data").let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionPumpStatus(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionLoopStatus(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionTddStatus(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionECarbsPreCheck(1, 2, 3).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionBolusPreCheck(1.0, 2).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionFillPreCheck(1.0).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionFillPresetPreCheck(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionProfileSwitchSendInitialData(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionProfileSwitchPreCheck(1, 2).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionWizardPreCheck(1, 2).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionQuickWizardPreCheck("guid").let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionHeartRate(1, 2, 3.0, "device").let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionTempTargetPreCheck(EventData.ActionTempTargetPreCheck.TempTargetCommand.CANCEL).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionWizardConfirmed(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionTempTargetConfirmed(false).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionBolusConfirmed(1.0, 2).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionECarbsConfirmed(1, 2, 3).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionFillConfirmed(1.0).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionProfileSwitchConfirmed(1, 2).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.OpenLoopRequestConfirmed(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.CancelNotification(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } // EventData.ActionGetCustomWatchface(EventData.ActionSetCustomWatchface(CwfData())).let { - // Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - // Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + // assertThat( EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + // assertThat( EventData.deserialize(it.serialize())).isEqualTo(it) // } EventData.ActionPing(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.OpenSettings(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.BolusProgress(1, "status").let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.SingleBg(1, sgv = 2.0, high = 3.0, low = 4.0).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.GraphData(arrayListOf(EventData.SingleBg(1, sgv = 2.0, high = 3.0, low = 4.0))).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.TreatmentData( arrayListOf(EventData.TreatmentData.TempBasal(1, 2.0, 3, 4.0, 5.0)), @@ -154,44 +154,44 @@ class EventDataTest { arrayListOf(EventData.TreatmentData.Treatment(1, 2.0, 3.0, true, isValid = true)), arrayListOf(EventData.SingleBg(1, sgv = 2.0, high = 3.0, low = 4.0)) ).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.Preferences(1, wearControl = true, true, 2, 3, 4.0, 5.0, 6.0, 7, 8).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.QuickWizard(arrayListOf(EventData.QuickWizard.QuickWizardEntry("1", "2", 3, 4, 5))).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } // EventData.ActionSetCustomWatchface().let { - // Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - // Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + // assertThat( EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + // assertThat( EventData.deserialize(it.serialize())).isEqualTo(it) // } EventData.ActionrequestCustomWatchface(true).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionrequestSetDefaultWatchface(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ActionProfileSwitchOpenActivity(1, 2).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.OpenLoopRequest("1", "2", null).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.ConfirmAction("1", "2", null).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } EventData.SnoozeAlert(1).let { - Assertions.assertEquals(it, EventData.deserializeByte(it.serializeByte())) - Assertions.assertEquals(it, EventData.deserialize(it.serialize())) + assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) + assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } } -} \ No newline at end of file +}