From 55b90e57f2b2df3f56e3e1bfc486b8ab659e2742 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 19:53:50 -0700 Subject: [PATCH 01/19] Rewrites DataBroadcastPluginTest with matchers Issue #2745 --- .../DataBroadcastPluginTest.kt | 128 +++++++++--------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/dataBroadcaster/DataBroadcastPluginTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/dataBroadcaster/DataBroadcastPluginTest.kt index e411feb219..45397902a6 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/dataBroadcaster/DataBroadcastPluginTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/dataBroadcaster/DataBroadcastPluginTest.kt @@ -2,6 +2,7 @@ package info.nightscout.plugins.sync.dataBroadcaster import app.aaps.shared.tests.BundleMock import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.database.entities.GlucoseValue @@ -20,7 +21,6 @@ import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.rx.events.EventOverviewBolusProgress import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyLong @@ -81,37 +81,37 @@ internal class DataBroadcastPluginTest : TestBaseWithProfile() { } val bundle = BundleMock.mock() sut.prepareData(event, bundle) - Assertions.assertTrue(bundle.containsKey("progressPercent")) - Assertions.assertTrue(bundle.containsKey("progressStatus")) - Assertions.assertTrue(bundle.containsKey("glucoseMgdl")) - Assertions.assertTrue(bundle.containsKey("glucoseTimeStamp")) - Assertions.assertTrue(bundle.containsKey("units")) - Assertions.assertTrue(bundle.containsKey("slopeArrow")) - Assertions.assertTrue(bundle.containsKey("deltaMgdl")) - Assertions.assertTrue(bundle.containsKey("avgDeltaMgdl")) - Assertions.assertTrue(bundle.containsKey("high")) - Assertions.assertTrue(bundle.containsKey("low")) - Assertions.assertTrue(bundle.containsKey("bolusIob")) - Assertions.assertTrue(bundle.containsKey("basalIob")) - Assertions.assertTrue(bundle.containsKey("iob")) - Assertions.assertTrue(bundle.containsKey("cob")) - Assertions.assertTrue(bundle.containsKey("futureCarbs")) - Assertions.assertTrue(bundle.containsKey("phoneBattery")) - Assertions.assertTrue(bundle.containsKey("rigBattery")) - Assertions.assertTrue(bundle.containsKey("suggestedTimeStamp")) - Assertions.assertTrue(bundle.containsKey("suggested")) - Assertions.assertTrue(bundle.containsKey("enactedTimeStamp")) - Assertions.assertTrue(bundle.containsKey("enacted")) - Assertions.assertTrue(bundle.containsKey("basalTimeStamp")) - Assertions.assertTrue(bundle.containsKey("baseBasal")) - Assertions.assertTrue(bundle.containsKey("profile")) - Assertions.assertTrue(bundle.containsKey("tempBasalStart")) - Assertions.assertTrue(bundle.containsKey("tempBasalDurationInMinutes")) - Assertions.assertTrue(bundle.containsKey("tempBasalString")) - Assertions.assertTrue(bundle.containsKey("pumpTimeStamp")) - Assertions.assertTrue(bundle.containsKey("pumpBattery")) - Assertions.assertTrue(bundle.containsKey("pumpReservoir")) - Assertions.assertTrue(bundle.containsKey("pumpStatus")) + assertThat(bundle.containsKey("progressPercent")).isTrue() + assertThat(bundle.containsKey("progressStatus")).isTrue() + assertThat(bundle.containsKey("glucoseMgdl")).isTrue() + assertThat(bundle.containsKey("glucoseTimeStamp")).isTrue() + assertThat(bundle.containsKey("units")).isTrue() + assertThat(bundle.containsKey("slopeArrow")).isTrue() + assertThat(bundle.containsKey("deltaMgdl")).isTrue() + assertThat(bundle.containsKey("avgDeltaMgdl")).isTrue() + assertThat(bundle.containsKey("high")).isTrue() + assertThat(bundle.containsKey("low")).isTrue() + assertThat(bundle.containsKey("bolusIob")).isTrue() + assertThat(bundle.containsKey("basalIob")).isTrue() + assertThat(bundle.containsKey("iob")).isTrue() + assertThat(bundle.containsKey("cob")).isTrue() + assertThat(bundle.containsKey("futureCarbs")).isTrue() + assertThat(bundle.containsKey("phoneBattery")).isTrue() + assertThat(bundle.containsKey("rigBattery")).isTrue() + assertThat(bundle.containsKey("suggestedTimeStamp")).isTrue() + assertThat(bundle.containsKey("suggested")).isTrue() + assertThat(bundle.containsKey("enactedTimeStamp")).isTrue() + assertThat(bundle.containsKey("enacted")).isTrue() + assertThat(bundle.containsKey("basalTimeStamp")).isTrue() + assertThat(bundle.containsKey("baseBasal")).isTrue() + assertThat(bundle.containsKey("profile")).isTrue() + assertThat(bundle.containsKey("tempBasalStart")).isTrue() + assertThat(bundle.containsKey("tempBasalDurationInMinutes")).isTrue() + assertThat(bundle.containsKey("tempBasalString")).isTrue() + assertThat(bundle.containsKey("pumpTimeStamp")).isTrue() + assertThat(bundle.containsKey("pumpBattery")).isTrue() + assertThat(bundle.containsKey("pumpReservoir")).isTrue() + assertThat(bundle.containsKey("pumpStatus")).isTrue() } @Test @@ -123,36 +123,36 @@ internal class DataBroadcastPluginTest : TestBaseWithProfile() { } val bundle = BundleMock.mock() sut.prepareData(event, bundle) - Assertions.assertTrue(bundle.containsKey("progressPercent")) - Assertions.assertTrue(bundle.containsKey("progressStatus")) - Assertions.assertTrue(bundle.containsKey("glucoseMgdl")) - Assertions.assertTrue(bundle.containsKey("glucoseTimeStamp")) - Assertions.assertTrue(bundle.containsKey("units")) - Assertions.assertTrue(bundle.containsKey("slopeArrow")) - Assertions.assertTrue(bundle.containsKey("deltaMgdl")) - Assertions.assertTrue(bundle.containsKey("avgDeltaMgdl")) - Assertions.assertTrue(bundle.containsKey("high")) - Assertions.assertTrue(bundle.containsKey("low")) - Assertions.assertTrue(bundle.containsKey("bolusIob")) - Assertions.assertTrue(bundle.containsKey("basalIob")) - Assertions.assertTrue(bundle.containsKey("iob")) - Assertions.assertTrue(bundle.containsKey("cob")) - Assertions.assertTrue(bundle.containsKey("futureCarbs")) - Assertions.assertTrue(bundle.containsKey("phoneBattery")) - Assertions.assertTrue(bundle.containsKey("rigBattery")) - Assertions.assertTrue(bundle.containsKey("suggestedTimeStamp")) - Assertions.assertTrue(bundle.containsKey("suggested")) - Assertions.assertTrue(bundle.containsKey("enactedTimeStamp")) - Assertions.assertTrue(bundle.containsKey("enacted")) - Assertions.assertTrue(bundle.containsKey("basalTimeStamp")) - Assertions.assertTrue(bundle.containsKey("baseBasal")) - Assertions.assertTrue(bundle.containsKey("profile")) - Assertions.assertTrue(bundle.containsKey("tempBasalStart")) - Assertions.assertTrue(bundle.containsKey("tempBasalDurationInMinutes")) - Assertions.assertTrue(bundle.containsKey("tempBasalString")) - Assertions.assertTrue(bundle.containsKey("pumpTimeStamp")) - Assertions.assertTrue(bundle.containsKey("pumpBattery")) - Assertions.assertTrue(bundle.containsKey("pumpReservoir")) - Assertions.assertTrue(bundle.containsKey("pumpStatus")) + assertThat(bundle.containsKey("progressPercent")).isTrue() + assertThat(bundle.containsKey("progressStatus")).isTrue() + assertThat(bundle.containsKey("glucoseMgdl")).isTrue() + assertThat(bundle.containsKey("glucoseTimeStamp")).isTrue() + assertThat(bundle.containsKey("units")).isTrue() + assertThat(bundle.containsKey("slopeArrow")).isTrue() + assertThat(bundle.containsKey("deltaMgdl")).isTrue() + assertThat(bundle.containsKey("avgDeltaMgdl")).isTrue() + assertThat(bundle.containsKey("high")).isTrue() + assertThat(bundle.containsKey("low")).isTrue() + assertThat(bundle.containsKey("bolusIob")).isTrue() + assertThat(bundle.containsKey("basalIob")).isTrue() + assertThat(bundle.containsKey("iob")).isTrue() + assertThat(bundle.containsKey("cob")).isTrue() + assertThat(bundle.containsKey("futureCarbs")).isTrue() + assertThat(bundle.containsKey("phoneBattery")).isTrue() + assertThat(bundle.containsKey("rigBattery")).isTrue() + assertThat(bundle.containsKey("suggestedTimeStamp")).isTrue() + assertThat(bundle.containsKey("suggested")).isTrue() + assertThat(bundle.containsKey("enactedTimeStamp")).isTrue() + assertThat(bundle.containsKey("enacted")).isTrue() + assertThat(bundle.containsKey("basalTimeStamp")).isTrue() + assertThat(bundle.containsKey("baseBasal")).isTrue() + assertThat(bundle.containsKey("profile")).isTrue() + assertThat(bundle.containsKey("tempBasalStart")).isTrue() + assertThat(bundle.containsKey("tempBasalDurationInMinutes")).isTrue() + assertThat(bundle.containsKey("tempBasalString")).isTrue() + assertThat(bundle.containsKey("pumpTimeStamp")).isTrue() + assertThat(bundle.containsKey("pumpBattery")).isTrue() + assertThat(bundle.containsKey("pumpReservoir")).isTrue() + assertThat(bundle.containsKey("pumpStatus")).isTrue() } -} \ No newline at end of file +} From 362a54b2c4fbfa0b1f1c91b57e596e227a242736 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:00:15 -0700 Subject: [PATCH 02/19] Rewrites ReceiverDelegateTest with matchers Issue #2745 --- .../sync/nsclient/ReceiverDelegateTest.kt | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclient/ReceiverDelegateTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclient/ReceiverDelegateTest.kt index fea76676e8..bb80421e03 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclient/ReceiverDelegateTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclient/ReceiverDelegateTest.kt @@ -1,6 +1,7 @@ package info.nightscout.plugins.sync.nsclient import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.plugins.sync.R @@ -8,7 +9,6 @@ import info.nightscout.rx.events.EventChargingState import info.nightscout.rx.events.EventNetworkChange import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -33,12 +33,12 @@ class ReceiverDelegateTest : TestBase() { fun testCalculateStatusChargingState() { `when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(true) `when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(false) - Assertions.assertTrue(sut.calculateStatus(EventChargingState(false, 0))) - Assertions.assertFalse(sut.calculateStatus(EventChargingState(true, 0))) + assertThat(sut.calculateStatus(EventChargingState(false, 0))).isTrue() + assertThat(sut.calculateStatus(EventChargingState(true, 0))).isFalse() `when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(false) `when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(true) - Assertions.assertTrue(sut.calculateStatus(EventChargingState(true, 0))) - Assertions.assertFalse(sut.calculateStatus(EventChargingState(false, 0))) + assertThat(sut.calculateStatus(EventChargingState(true, 0))).isTrue() + assertThat(sut.calculateStatus(EventChargingState(false, 0))).isFalse() } @Test @@ -47,41 +47,41 @@ class ReceiverDelegateTest : TestBase() { `when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true) `when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true) `when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("") - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))) - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))) - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "", mobileConnected = true, wifiConnected = true))) - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "", mobileConnected = false, wifiConnected = true))) - Assertions.assertFalse(sut.calculateStatus(EventNetworkChange())) + assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange(ssid = "", mobileConnected = true, wifiConnected = true))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange(ssid = "", mobileConnected = false, wifiConnected = true))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange())).isFalse() `when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("test 1") - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))) - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))) - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "", mobileConnected = true, wifiConnected = true))) - Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(ssid = "", mobileConnected = false, wifiConnected = true))) - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = true, wifiConnected = true))) - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = false, wifiConnected = true))) - Assertions.assertFalse(sut.calculateStatus(EventNetworkChange())) + assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange(ssid = "", mobileConnected = true, wifiConnected = true))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange(ssid = "", mobileConnected = false, wifiConnected = true))).isFalse() + assertThat(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = true, wifiConnected = true))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = false, wifiConnected = true))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange())).isFalse() `when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(false) `when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true) `when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true) `when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("") - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(wifiConnected = true))) - Assertions.assertFalse(sut.calculateStatus(EventNetworkChange())) - Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true))) + assertThat(sut.calculateStatus(EventNetworkChange(wifiConnected = true))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange())).isFalse() + assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true))).isFalse() `when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true) `when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true) `when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(false) `when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("") - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))) - Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true))) + assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true))).isFalse() `when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true) `when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true) `when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true) `when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("") - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))) - Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true))) + assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))).isTrue() + assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true))).isTrue() } -} \ No newline at end of file +} From af7f8e564d3e9e2b730100312657900ed3562bc3 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:11:06 -0700 Subject: [PATCH 03/19] Rewrites NSClientV3PluginTest with matchers Issue #2745 --- .../sync/nsclientV3/NSClientV3PluginTest.kt | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/NSClientV3PluginTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/NSClientV3PluginTest.kt index dbdcc3c91f..efac9ef115 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/NSClientV3PluginTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/NSClientV3PluginTest.kt @@ -1,6 +1,7 @@ package info.nightscout.plugins.sync.nsclientV3 import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.core.extensions.fromConstant @@ -36,7 +37,6 @@ import info.nightscout.plugins.sync.nsclient.extensions.fromConstant import info.nightscout.sdk.interfaces.NSAndroidClient import info.nightscout.sdk.localmodel.treatment.CreateUpdateResponse import kotlinx.coroutines.test.runTest -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -108,11 +108,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("devicestatus", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdDeviceStatuses.size) + assertThat(storeDataForDb.nsIdDeviceStatuses).hasSize(1) // update Mockito.`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsAdd("devicestatus", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdDeviceStatuses.size) // still only 1 + assertThat(storeDataForDb.nsIdDeviceStatuses).hasSize(2) // still only 1 } @Test @@ -134,11 +134,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createSgv(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("entries", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdGlucoseValues.size) + assertThat(storeDataForDb.nsIdGlucoseValues).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateSvg(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("entries", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdGlucoseValues.size) + assertThat(storeDataForDb.nsIdGlucoseValues).hasSize(2) } @Test @@ -164,11 +164,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createFood(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("food", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdFoods.size) + assertThat(storeDataForDb.nsIdFoods).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateFood(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("food", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdFoods.size) + assertThat(storeDataForDb.nsIdFoods).hasSize(2) } @Test @@ -192,11 +192,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdBoluses.size) + assertThat(storeDataForDb.nsIdBoluses).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdBoluses.size) + assertThat(storeDataForDb.nsIdBoluses).hasSize(2) } @Test @@ -219,11 +219,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdCarbs.size) + assertThat(storeDataForDb.nsIdCarbs).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdCarbs.size) + assertThat(storeDataForDb.nsIdCarbs).hasSize(2) } @Test @@ -272,11 +272,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdBolusCalculatorResults.size) + assertThat(storeDataForDb.nsIdBolusCalculatorResults).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdBolusCalculatorResults.size) + assertThat(storeDataForDb.nsIdBolusCalculatorResults).hasSize(2) } @Test @@ -310,11 +310,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdEffectiveProfileSwitches.size) + assertThat(storeDataForDb.nsIdEffectiveProfileSwitches).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdEffectiveProfileSwitches.size) + assertThat(storeDataForDb.nsIdEffectiveProfileSwitches).hasSize(2) } @Test @@ -346,11 +346,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdProfileSwitches.size) + assertThat(storeDataForDb.nsIdProfileSwitches).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdProfileSwitches.size) + assertThat(storeDataForDb.nsIdProfileSwitches).hasSize(2) } @Test @@ -373,11 +373,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3", validProfile) - Assertions.assertEquals(1, storeDataForDb.nsIdExtendedBoluses.size) + assertThat(storeDataForDb.nsIdExtendedBoluses).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3", validProfile) - Assertions.assertEquals(2, storeDataForDb.nsIdExtendedBoluses.size) + assertThat(storeDataForDb.nsIdExtendedBoluses).hasSize(2) } @Test @@ -399,11 +399,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdOfflineEvents.size) + assertThat(storeDataForDb.nsIdOfflineEvents).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdOfflineEvents.size) + assertThat(storeDataForDb.nsIdOfflineEvents).hasSize(2) } @Test @@ -427,11 +427,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3", validProfile) - Assertions.assertEquals(1, storeDataForDb.nsIdTemporaryBasals.size) + assertThat(storeDataForDb.nsIdTemporaryBasals).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3", validProfile) - Assertions.assertEquals(2, storeDataForDb.nsIdTemporaryBasals.size) + assertThat(storeDataForDb.nsIdTemporaryBasals).hasSize(2) } @Test @@ -455,11 +455,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdTemporaryTargets.size) + assertThat(storeDataForDb.nsIdTemporaryTargets).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdTemporaryTargets.size) + assertThat(storeDataForDb.nsIdTemporaryTargets).hasSize(2) } @Test @@ -486,11 +486,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // create Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) sut.nsAdd("treatments", dataPair, "1/3") - Assertions.assertEquals(1, storeDataForDb.nsIdTherapyEvents.size) + assertThat(storeDataForDb.nsIdTherapyEvents).hasSize(1) // update Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) sut.nsUpdate("treatments", dataPair, "1/3") - Assertions.assertEquals(2, storeDataForDb.nsIdTherapyEvents.size) + assertThat(storeDataForDb.nsIdTherapyEvents).hasSize(2) } @Test @@ -509,4 +509,4 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { // verify(dataSyncSelectorV3, Times(2)).confirmLastProfileStore(1000) // verify(dataSyncSelectorV3, Times(2)).processChangedProfileStore() } -} \ No newline at end of file +} From a62954c56c6af9ed5441bb2365d8cc4e81f87b5a Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:15:08 -0700 Subject: [PATCH 04/19] Rewrites DataSyncWorkerTest with matchers Issue #2745 --- .../plugins/sync/nsclientV3/workers/DataSyncWorkerTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorkerTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorkerTest.kt index 846bdcf2bd..bc30ccc49b 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorkerTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorkerTest.kt @@ -4,6 +4,7 @@ import android.content.Context import androidx.work.ListenableWorker.Result.Success import androidx.work.testing.TestListenableWorkerBuilder import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.core.utils.fabric.FabricPrivacy @@ -13,7 +14,6 @@ import info.nightscout.plugins.sync.nsclientV3.DataSyncSelectorV3 import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -64,6 +64,6 @@ internal class DataSyncWorkerTest : TestBase() { `when`(nsClient.hasWritePermission).thenReturn(true) val result = sut.doWorkAndLog() Mockito.verify(dataSyncSelectorV3, Mockito.times(1)).doUpload() - Assertions.assertTrue(result is Success) + assertThat(result).isInstanceOf(Success::class.java) } -} \ No newline at end of file +} From aac358088597698612422569d698e0081b7f1719 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:20:12 -0700 Subject: [PATCH 05/19] Rewrites LoadBgWorkerTest with matchers Issue #2745 --- .../nsclientV3/workers/LoadBgWorkerTest.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadBgWorkerTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadBgWorkerTest.kt index cd6d6cbed1..19d2f2c34c 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadBgWorkerTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadBgWorkerTest.kt @@ -7,6 +7,7 @@ import androidx.work.WorkContinuation import androidx.work.WorkManager import androidx.work.testing.TestListenableWorkerBuilder import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.core.utils.fabric.FabricPrivacy @@ -33,7 +34,6 @@ import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil import kotlinx.coroutines.test.runTest -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.any @@ -111,7 +111,7 @@ internal class LoadBgWorkerTest : TestBase() { sut = TestListenableWorkerBuilder(context).build() val result = sut.doWorkAndLog() - Assertions.assertTrue(result is ListenableWorker.Result.Failure) + assertThat(result).isInstanceOf(ListenableWorker.Result.Failure::class.java) } @Test @@ -121,8 +121,8 @@ internal class LoadBgWorkerTest : TestBase() { Mockito.`when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_cgm, false)).thenReturn(false) val result = sut.doWorkAndLog() - Assertions.assertTrue(result is ListenableWorker.Result.Success) - Assertions.assertTrue(result.outputData.getString("Result") == "Load not enabled") + assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java) + assertThat(result.outputData.getString("Result")).isEqualTo("Load not enabled") } @Test @@ -136,8 +136,8 @@ internal class LoadBgWorkerTest : TestBase() { Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, emptyList())) val result = sut.doWorkAndLog() - Assertions.assertEquals(now - 1000, nsClientV3Plugin.lastLoadedSrvModified.collections.entries) - Assertions.assertTrue(result is ListenableWorker.Result.Success) + assertThat(nsClientV3Plugin.lastLoadedSrvModified.collections.entries).isEqualTo(now - 1000) + assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java) } @Test @@ -165,7 +165,7 @@ internal class LoadBgWorkerTest : TestBase() { Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, listOf(glucoseValue.toNSSvgV3()))) val result = sut.doWorkAndLog() - Assertions.assertTrue(result is ListenableWorker.Result.Success) + assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java) } @Test @@ -179,7 +179,7 @@ internal class LoadBgWorkerTest : TestBase() { Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, emptyList())) val result = sut.doWorkAndLog() - Assertions.assertEquals(now - 1000, nsClientV3Plugin.lastLoadedSrvModified.collections.entries) - Assertions.assertTrue(result is ListenableWorker.Result.Success) + assertThat(nsClientV3Plugin.lastLoadedSrvModified.collections.entries).isEqualTo(now - 1000) + assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java) } -} \ No newline at end of file +} From cef8ba00dd83f219cfbac003e7de97f2c3700c99 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:46:45 -0700 Subject: [PATCH 06/19] Rewrites BolusCalculatorResultExtensionKtTest with matchers Issue #2745 --- .../extensions/BolusCalculatorResultExtensionKtTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusCalculatorResultExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusCalculatorResultExtensionKtTest.kt index dd24c3d6ce..be4415c765 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusCalculatorResultExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusCalculatorResultExtensionKtTest.kt @@ -1,10 +1,10 @@ package info.nightscout.plugins.sync.nsclientV3.extensions +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.BolusCalculatorResult import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.localmodel.treatment.NSBolusWizard import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @Suppress("SpellCheckingInspection") @@ -53,7 +53,7 @@ internal class BolusCalculatorResultExtensionKtTest { ) val bolus2 = (bolus.toNSBolusWizard().convertToRemoteAndBack() as NSBolusWizard).toBolusCalculatorResult()!! - Assertions.assertTrue(bolus.contentEqualsTo(bolus2)) - Assertions.assertTrue(bolus.interfaceIdsEqualsTo(bolus2)) + assertThat(bolus.contentEqualsTo(bolus2)).isTrue() + assertThat(bolus.interfaceIdsEqualsTo(bolus2)).isTrue() } -} \ No newline at end of file +} From 483077e6662b0246adfd2c836bd4d061d89e66bf Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:46:50 -0700 Subject: [PATCH 07/19] Rewrites BolusExtensionKtTest with matchers Issue #2745 --- .../nsclientV3/extensions/BolusExtensionKtTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusExtensionKtTest.kt index 3c8573bfc9..532aa1d7f7 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusExtensionKtTest.kt @@ -1,10 +1,10 @@ package info.nightscout.plugins.sync.nsclientV3.extensions +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.localmodel.treatment.NSBolus import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @@ -29,8 +29,8 @@ internal class BolusExtensionKtTest { ) var bolus2 = (bolus.toNSBolus().convertToRemoteAndBack() as NSBolus).toBolus() - Assertions.assertTrue(bolus.contentEqualsTo(bolus2)) - Assertions.assertTrue(bolus.interfaceIdsEqualsTo(bolus2)) + assertThat(bolus.contentEqualsTo(bolus2)).isTrue() + assertThat(bolus.interfaceIdsEqualsTo(bolus2)).isTrue() bolus = Bolus( timestamp = 10000, @@ -48,7 +48,7 @@ internal class BolusExtensionKtTest { ) bolus2 = (bolus.toNSBolus().convertToRemoteAndBack() as NSBolus).toBolus() - Assertions.assertTrue(bolus.contentEqualsTo(bolus2)) - Assertions.assertTrue(bolus.interfaceIdsEqualsTo(bolus2)) + assertThat(bolus.contentEqualsTo(bolus2)).isTrue() + assertThat(bolus.interfaceIdsEqualsTo(bolus2)).isTrue() } -} \ No newline at end of file +} From 4543988be9537e4d9704d818e3635badced092ec Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:46:55 -0700 Subject: [PATCH 08/19] Rewrites CarbsExtensionKtTest with matchers Issue #2745 --- .../nsclientV3/extensions/CarbsExtensionKtTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/CarbsExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/CarbsExtensionKtTest.kt index f071299570..5414a13989 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/CarbsExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/CarbsExtensionKtTest.kt @@ -1,10 +1,10 @@ package info.nightscout.plugins.sync.nsclientV3.extensions +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.Carbs import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.localmodel.treatment.NSCarbs import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @Suppress("SpellCheckingInspection") @@ -27,8 +27,8 @@ internal class CarbsExtensionKtTest { ) var carbs2 = (carbs.toNSCarbs().convertToRemoteAndBack() as NSCarbs).toCarbs() - Assertions.assertTrue(carbs.contentEqualsTo(carbs2)) - Assertions.assertTrue(carbs.interfaceIdsEqualsTo(carbs2)) + assertThat(carbs.contentEqualsTo(carbs2)).isTrue() + assertThat(carbs.interfaceIdsEqualsTo(carbs2)).isTrue() carbs = Carbs( timestamp = 10000, @@ -45,7 +45,7 @@ internal class CarbsExtensionKtTest { ) carbs2 = (carbs.toNSCarbs().convertToRemoteAndBack() as NSCarbs).toCarbs() - Assertions.assertTrue(carbs.contentEqualsTo(carbs2)) - Assertions.assertTrue(carbs.interfaceIdsEqualsTo(carbs2)) + assertThat(carbs.contentEqualsTo(carbs2)).isTrue() + assertThat(carbs.interfaceIdsEqualsTo(carbs2)).isTrue() } -} \ No newline at end of file +} From c69188475994c2553f131ebbdc411a51c2cebea2 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:47:02 -0700 Subject: [PATCH 09/19] Rewrites DeviceStatusExtensionKtTest with matchers Issue #2745 --- .../extensions/DeviceStatusExtensionKtTest.kt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/DeviceStatusExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/DeviceStatusExtensionKtTest.kt index e747af9ec7..f73dc176b5 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/DeviceStatusExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/DeviceStatusExtensionKtTest.kt @@ -1,6 +1,7 @@ package info.nightscout.plugins.sync.nsclientV3.extensions import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.DeviceStatus import info.nightscout.interfaces.Config import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData @@ -12,7 +13,6 @@ import info.nightscout.sdk.mapper.convertToRemoteAndBack import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -57,20 +57,20 @@ internal class DeviceStatusExtensionKtTest : TestBase() { val nsDeviceStatus = deviceStatus.toNSDeviceStatus() nsDeviceStatusHandler.handleNewData(arrayOf(nsDeviceStatus)) - Assertions.assertEquals(75, processedDeviceStatusData.pumpData?.percent) + assertThat(processedDeviceStatusData.pumpData!!.percent).isEqualTo(75) val nsDeviceStatus2 = nsDeviceStatus.convertToRemoteAndBack() - Assertions.assertTrue(nsDeviceStatus.device == nsDeviceStatus2.device) - Assertions.assertTrue(nsDeviceStatus.identifier == nsDeviceStatus2.identifier) - Assertions.assertTrue(nsDeviceStatus.srvCreated == nsDeviceStatus2.srvCreated) - Assertions.assertTrue(nsDeviceStatus.srvModified == nsDeviceStatus2.srvModified) - Assertions.assertTrue(nsDeviceStatus.createdAt == nsDeviceStatus2.createdAt) - Assertions.assertTrue(nsDeviceStatus.date == nsDeviceStatus2.date) - Assertions.assertTrue(nsDeviceStatus.uploaderBattery == nsDeviceStatus2.uploaderBattery) - Assertions.assertTrue(nsDeviceStatus.device == nsDeviceStatus2.device) - Assertions.assertTrue(nsDeviceStatus.uploader?.battery == nsDeviceStatus2.uploader?.battery) - Assertions.assertTrue(nsDeviceStatus.pump?.battery == nsDeviceStatus2.pump?.battery) - Assertions.assertTrue(nsDeviceStatus.openaps?.enacted?.toString() == nsDeviceStatus2.openaps?.enacted?.toString()) - Assertions.assertTrue(nsDeviceStatus.configuration?.toString() == nsDeviceStatus2.configuration?.toString()) + assertThat(nsDeviceStatus2.device).isEqualTo(nsDeviceStatus.device) + assertThat(nsDeviceStatus2.identifier).isEqualTo(nsDeviceStatus.identifier) + assertThat(nsDeviceStatus2.srvCreated).isEqualTo(nsDeviceStatus.srvCreated) + assertThat(nsDeviceStatus2.srvModified).isEqualTo(nsDeviceStatus.srvModified) + assertThat(nsDeviceStatus2.createdAt).isEqualTo(nsDeviceStatus.createdAt) + assertThat(nsDeviceStatus2.date).isEqualTo(nsDeviceStatus.date) + assertThat(nsDeviceStatus2.uploaderBattery).isEqualTo(nsDeviceStatus.uploaderBattery) + assertThat(nsDeviceStatus2.device).isEqualTo(nsDeviceStatus.device) + assertThat(nsDeviceStatus2.uploader?.battery).isEqualTo(nsDeviceStatus.uploader?.battery) + assertThat(nsDeviceStatus2.pump?.battery).isEqualTo(nsDeviceStatus.pump?.battery) + assertThat(nsDeviceStatus2.openaps?.enacted?.toString()).isEqualTo(nsDeviceStatus.openaps?.enacted?.toString()) + assertThat(nsDeviceStatus2.configuration?.toString()).isEqualTo(nsDeviceStatus.configuration?.toString()) } -} \ No newline at end of file +} From d8fe546c9fd114e06bc35e014442599aa3caaf2f Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:47:08 -0700 Subject: [PATCH 10/19] Rewrites EffectiveProfileSwitchExtensionKtTest with matchers Issue #2745 --- .../extensions/EffectiveProfileSwitchExtensionKtTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/EffectiveProfileSwitchExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/EffectiveProfileSwitchExtensionKtTest.kt index 96f0bd872e..de17af6cff 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/EffectiveProfileSwitchExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/EffectiveProfileSwitchExtensionKtTest.kt @@ -1,6 +1,7 @@ package info.nightscout.plugins.sync.nsclientV3.extensions import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.EffectiveProfileSwitch import info.nightscout.database.entities.embedments.InsulinConfiguration import info.nightscout.database.entities.embedments.InterfaceIDs @@ -8,7 +9,6 @@ import info.nightscout.interfaces.insulin.Insulin import info.nightscout.plugins.sync.nsclient.extensions.fromConstant import info.nightscout.sdk.localmodel.treatment.NSEffectiveProfileSwitch import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -55,7 +55,7 @@ internal class EffectiveProfileSwitchExtensionKtTest : TestBaseWithProfile() { ) val profileSwitch2 = (profileSwitch.toNSEffectiveProfileSwitch(dateUtil).convertToRemoteAndBack() as NSEffectiveProfileSwitch).toEffectiveProfileSwitch(dateUtil)!! - Assertions.assertTrue(profileSwitch.contentEqualsTo(profileSwitch2)) - Assertions.assertTrue(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)) + assertThat(profileSwitch.contentEqualsTo(profileSwitch2)).isTrue() + assertThat(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)).isTrue() } -} \ No newline at end of file +} From 0e3647616ecb2d80b5870fc1bdb1a13318de178d Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:47:17 -0700 Subject: [PATCH 11/19] Rewrites FoodExtensionKtTest with matchers Issue #2745 --- .../sync/nsclientV3/extensions/FoodExtensionKtTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/FoodExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/FoodExtensionKtTest.kt index db9ee6f1f1..cf26988f9f 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/FoodExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/FoodExtensionKtTest.kt @@ -1,10 +1,10 @@ package info.nightscout.plugins.sync.nsclientV3.extensions +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.Food import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.localmodel.food.NSFood import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @Suppress("SpellCheckingInspection") @@ -30,7 +30,7 @@ internal class FoodExtensionKtTest { ) val food2 = (food.toNSFood().convertToRemoteAndBack() as NSFood).toFood() - Assertions.assertTrue(food.contentEqualsTo(food2)) - Assertions.assertTrue(food.interfaceIdsEqualsTo(food2)) + assertThat(food.contentEqualsTo(food2)).isTrue() + assertThat(food.interfaceIdsEqualsTo(food2)).isTrue() } -} \ No newline at end of file +} From 4ae21a1c856c2b1214ce5d51a80b94783e0ac86a Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:47:24 -0700 Subject: [PATCH 12/19] Rewrites ExtendedBolusExtensionKtTest with matchers Issue #2745 --- .../extensions/ExtendedBolusExtensionKtTest.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/ExtendedBolusExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/ExtendedBolusExtensionKtTest.kt index 6a05e34943..49a7d4a019 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/ExtendedBolusExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/ExtendedBolusExtensionKtTest.kt @@ -1,12 +1,12 @@ package info.nightscout.plugins.sync.nsclientV3.extensions import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.localmodel.treatment.NSExtendedBolus import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @Suppress("SpellCheckingInspection") @@ -29,8 +29,8 @@ internal class ExtendedBolusExtensionKtTest : TestBaseWithProfile() { ) var extendedBolus2 = (extendedBolus.toNSExtendedBolus(validProfile).convertToRemoteAndBack() as NSExtendedBolus).toExtendedBolus() - Assertions.assertTrue(extendedBolus.contentEqualsTo(extendedBolus2)) - Assertions.assertTrue(extendedBolus.interfaceIdsEqualsTo(extendedBolus2)) + assertThat(extendedBolus.contentEqualsTo(extendedBolus2)).isTrue() + assertThat(extendedBolus.interfaceIdsEqualsTo(extendedBolus2)).isTrue() extendedBolus = ExtendedBolus( timestamp = 10000, @@ -47,13 +47,13 @@ internal class ExtendedBolusExtensionKtTest : TestBaseWithProfile() { ) val converted = extendedBolus.toNSExtendedBolus(validProfile) - Assertions.assertTrue(converted is NSTemporaryBasal) - Assertions.assertNotNull((converted as NSTemporaryBasal).extendedEmulated) + assertThat(converted).isInstanceOf(NSTemporaryBasal::class.java) + assertThat((converted as NSTemporaryBasal).extendedEmulated).isNotNull() val convertedBack = converted.convertToRemoteAndBack() - Assertions.assertTrue(convertedBack is NSExtendedBolus) + assertThat(convertedBack).isInstanceOf(NSExtendedBolus::class.java) extendedBolus2 = (extendedBolus.toNSExtendedBolus(validProfile).convertToRemoteAndBack() as NSExtendedBolus).toExtendedBolus() - Assertions.assertTrue(extendedBolus.contentEqualsTo(extendedBolus2)) - Assertions.assertTrue(extendedBolus.interfaceIdsEqualsTo(extendedBolus2)) + assertThat(extendedBolus.contentEqualsTo(extendedBolus2)).isTrue() + assertThat(extendedBolus.interfaceIdsEqualsTo(extendedBolus2)).isTrue() } -} \ No newline at end of file +} From 9facdf5c6c695a0b765dc552ece032306e547899 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:47:31 -0700 Subject: [PATCH 13/19] Rewrites GlucoseValueExtensionKtTest with matchers Issue #2745 --- .../nsclientV3/extensions/GlucoseValueExtensionKtTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/GlucoseValueExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/GlucoseValueExtensionKtTest.kt index 14e9e8fd6c..c611a0734d 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/GlucoseValueExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/GlucoseValueExtensionKtTest.kt @@ -1,10 +1,10 @@ package info.nightscout.plugins.sync.nsclientV3.extensions import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test internal class GlucoseValueExtensionKtTest : TestBaseWithProfile() { @@ -25,7 +25,7 @@ internal class GlucoseValueExtensionKtTest : TestBaseWithProfile() { ) val glucoseValue2 = glucoseValue.toNSSvgV3().convertToRemoteAndBack()?.toTransactionGlucoseValue()?.toGlucoseValue() - Assertions.assertTrue(glucoseValue.contentEqualsTo(glucoseValue2!!)) - Assertions.assertTrue(glucoseValue.interfaceIdsEqualsTo(glucoseValue2)) + assertThat(glucoseValue.contentEqualsTo(glucoseValue2!!)).isTrue() + assertThat(glucoseValue.interfaceIdsEqualsTo(glucoseValue2)).isTrue() } -} \ No newline at end of file +} From 980c8fff0b176c3b9f97281f4f52f0fe612b7273 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:47:38 -0700 Subject: [PATCH 14/19] Rewrites OfflineEventExtensionKtTest with matchers Issue #2745 --- .../extensions/OfflineEventExtensionKtTest.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/OfflineEventExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/OfflineEventExtensionKtTest.kt index 34137f047c..f7d8862c20 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/OfflineEventExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/OfflineEventExtensionKtTest.kt @@ -1,10 +1,10 @@ package info.nightscout.plugins.sync.nsclientV3.extensions +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.OfflineEvent import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.localmodel.treatment.NSOfflineEvent import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @Suppress("SpellCheckingInspection") @@ -26,8 +26,8 @@ internal class OfflineEventExtensionKtTest { ) var offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent() - Assertions.assertTrue(offlineEvent.contentEqualsTo(offlineEvent2)) - Assertions.assertTrue(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)) + assertThat(offlineEvent.contentEqualsTo(offlineEvent2)).isTrue() + assertThat(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)).isTrue() offlineEvent = OfflineEvent( timestamp = 10000, @@ -43,8 +43,8 @@ internal class OfflineEventExtensionKtTest { ) offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent() - Assertions.assertTrue(offlineEvent.contentEqualsTo(offlineEvent2)) - Assertions.assertTrue(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)) + assertThat(offlineEvent.contentEqualsTo(offlineEvent2)).isTrue() + assertThat(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)).isTrue() offlineEvent = OfflineEvent( timestamp = 10000, @@ -60,7 +60,7 @@ internal class OfflineEventExtensionKtTest { ) offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent() - Assertions.assertTrue(offlineEvent.contentEqualsTo(offlineEvent2)) - Assertions.assertTrue(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)) + assertThat(offlineEvent.contentEqualsTo(offlineEvent2)).isTrue() + assertThat(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)).isTrue() } -} \ No newline at end of file +} From 129031b2a77e56c50c2305b9ef79b592ef31e8cc Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:47:45 -0700 Subject: [PATCH 15/19] Rewrites ProfileSwitchExtensionKtTest with matchers Issue #2745 --- .../extensions/ProfileSwitchExtensionKtTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/ProfileSwitchExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/ProfileSwitchExtensionKtTest.kt index 7d682db78a..f7b4083ace 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/ProfileSwitchExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/ProfileSwitchExtensionKtTest.kt @@ -1,6 +1,7 @@ package info.nightscout.plugins.sync.nsclientV3.extensions import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.core.extensions.fromConstant import info.nightscout.database.entities.ProfileSwitch import info.nightscout.database.entities.embedments.InsulinConfiguration @@ -8,7 +9,6 @@ import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.interfaces.insulin.Insulin import info.nightscout.sdk.localmodel.treatment.NSProfileSwitch import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -53,8 +53,8 @@ internal class ProfileSwitchExtensionKtTest : TestBaseWithProfile() { ) var profileSwitch2 = (profileSwitch.toNSProfileSwitch(dateUtil, decimalFormatter).convertToRemoteAndBack() as NSProfileSwitch).toProfileSwitch(activePlugin, dateUtil)!! - Assertions.assertTrue(profileSwitch.contentEqualsTo(profileSwitch2)) - Assertions.assertTrue(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)) + assertThat(profileSwitch.contentEqualsTo(profileSwitch2)).isTrue() + assertThat(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)).isTrue() profileSwitch = ProfileSwitch( timestamp = 10000, @@ -80,7 +80,7 @@ internal class ProfileSwitchExtensionKtTest : TestBaseWithProfile() { ) profileSwitch2 = (profileSwitch.toNSProfileSwitch(dateUtil, decimalFormatter).convertToRemoteAndBack() as NSProfileSwitch).toProfileSwitch(activePlugin, dateUtil)!! - Assertions.assertTrue(profileSwitch.contentEqualsTo(profileSwitch2)) - Assertions.assertTrue(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)) + assertThat(profileSwitch.contentEqualsTo(profileSwitch2)).isTrue() + assertThat(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)).isTrue() } -} \ No newline at end of file +} From 869ce9588948572e97fb8fdd31378e104aea5d46 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:47:51 -0700 Subject: [PATCH 16/19] Rewrites TemporaryBasalExtensionKtTest with matchers Issue #2745 --- .../extensions/TemporaryBasalExtensionKtTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryBasalExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryBasalExtensionKtTest.kt index 2a4aa46388..fb72277b60 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryBasalExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryBasalExtensionKtTest.kt @@ -1,11 +1,11 @@ package info.nightscout.plugins.sync.nsclientV3.extensions import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @Suppress("SpellCheckingInspection") @@ -29,8 +29,8 @@ internal class TemporaryBasalExtensionKtTest : TestBaseWithProfile() { ) var temporaryBasal2 = (temporaryBasal.toNSTemporaryBasal(validProfile).convertToRemoteAndBack() as NSTemporaryBasal).toTemporaryBasal() - Assertions.assertTrue(temporaryBasal.contentEqualsTo(temporaryBasal2)) - Assertions.assertTrue(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2)) + assertThat(temporaryBasal.contentEqualsTo(temporaryBasal2)).isTrue() + assertThat(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2)).isTrue() temporaryBasal = TemporaryBasal( timestamp = 10000, @@ -48,7 +48,7 @@ internal class TemporaryBasalExtensionKtTest : TestBaseWithProfile() { ) temporaryBasal2 = (temporaryBasal.toNSTemporaryBasal(validProfile).convertToRemoteAndBack() as NSTemporaryBasal).toTemporaryBasal() - Assertions.assertTrue(temporaryBasal.contentEqualsTo(temporaryBasal2)) - Assertions.assertTrue(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2)) + assertThat(temporaryBasal.contentEqualsTo(temporaryBasal2)).isTrue() + assertThat(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2)).isTrue() } -} \ No newline at end of file +} From aa689d75c71bc14204d14894e8098f1970966cb7 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:47:56 -0700 Subject: [PATCH 17/19] Rewrites TemporaryTargetExtensionKtTest with matchers Issue #2745 --- .../extensions/TemporaryTargetExtensionKtTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryTargetExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryTargetExtensionKtTest.kt index 835e8dcb96..49aef9daba 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryTargetExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryTargetExtensionKtTest.kt @@ -1,11 +1,11 @@ package info.nightscout.plugins.sync.nsclientV3.extensions import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.TemporaryTarget import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.localmodel.treatment.NSTemporaryTarget import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @Suppress("SpellCheckingInspection") @@ -29,8 +29,8 @@ internal class TemporaryTargetExtensionKtTest : TestBaseWithProfile() { ) var temporaryTarget2 = (temporaryTarget.toNSTemporaryTarget().convertToRemoteAndBack() as NSTemporaryTarget).toTemporaryTarget() - Assertions.assertTrue(temporaryTarget.contentEqualsTo(temporaryTarget2)) - Assertions.assertTrue(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2)) + assertThat(temporaryTarget.contentEqualsTo(temporaryTarget2)).isTrue() + assertThat(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2)).isTrue() temporaryTarget = TemporaryTarget( timestamp = 10000, @@ -48,7 +48,7 @@ internal class TemporaryTargetExtensionKtTest : TestBaseWithProfile() { ) temporaryTarget2 = (temporaryTarget.toNSTemporaryTarget().convertToRemoteAndBack() as NSTemporaryTarget).toTemporaryTarget() - Assertions.assertTrue(temporaryTarget.contentEqualsTo(temporaryTarget2)) - Assertions.assertTrue(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2)) + assertThat(temporaryTarget.contentEqualsTo(temporaryTarget2)).isTrue() + assertThat(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2)).isTrue() } -} \ No newline at end of file +} From c95cdc1c9b341db85f48b9682b93bcb9734f5b00 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:48:03 -0700 Subject: [PATCH 18/19] Rewrites TherapyEventExtensionKtTest with matchers Issue #2745 --- .../extensions/TherapyEventExtensionKtTest.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TherapyEventExtensionKtTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TherapyEventExtensionKtTest.kt index 17423a6146..68ab4f36b9 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TherapyEventExtensionKtTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/extensions/TherapyEventExtensionKtTest.kt @@ -1,11 +1,11 @@ package info.nightscout.plugins.sync.nsclientV3.extensions import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.sdk.localmodel.treatment.NSTherapyEvent import info.nightscout.sdk.mapper.convertToRemoteAndBack -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @Suppress("SpellCheckingInspection") @@ -32,8 +32,8 @@ internal class TherapyEventExtensionKtTest : TestBaseWithProfile() { ) var therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent() - Assertions.assertTrue(therapyEvent.contentEqualsTo(therapyEvent2)) - Assertions.assertTrue(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)) + assertThat(therapyEvent.contentEqualsTo(therapyEvent2)).isTrue() + assertThat(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)).isTrue() therapyEvent = TherapyEvent( @@ -55,8 +55,8 @@ internal class TherapyEventExtensionKtTest : TestBaseWithProfile() { ) therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent() - Assertions.assertTrue(therapyEvent.contentEqualsTo(therapyEvent2)) - Assertions.assertTrue(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)) + assertThat(therapyEvent.contentEqualsTo(therapyEvent2)).isTrue() + assertThat(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)).isTrue() therapyEvent = TherapyEvent( timestamp = 10000, @@ -77,7 +77,7 @@ internal class TherapyEventExtensionKtTest : TestBaseWithProfile() { ) therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent() - Assertions.assertTrue(therapyEvent.contentEqualsTo(therapyEvent2)) - Assertions.assertTrue(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)) + assertThat(therapyEvent.contentEqualsTo(therapyEvent2)).isTrue() + assertThat(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)).isTrue() } -} \ No newline at end of file +} From 5668377307c1d1bdea32cacddd4446d9b5218027 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 20:56:06 -0700 Subject: [PATCH 19/19] Rewrites SessionTest with matchers Issue #2745 --- .../plugins/sync/tidepool/comm/SessionTest.kt | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/tidepool/comm/SessionTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/tidepool/comm/SessionTest.kt index 03c6a53e5b..26c10d2c90 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/tidepool/comm/SessionTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/tidepool/comm/SessionTest.kt @@ -1,32 +1,44 @@ package info.nightscout.plugins.sync.tidepool.comm +import com.google.common.truth.Truth.assertThat import info.nightscout.plugins.sync.tidepool.messages.AuthReplyMessage import info.nightscout.plugins.sync.tidepool.messages.DatasetReplyMessage -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class SessionTest { + private val session = Session("", "", null) + @Test - fun populateBody() { - val session = Session("", "", null) - Assertions.assertNull(session.authReply) - - // test authReply - val authReplyMessage = AuthReplyMessage() - session.populateBody(authReplyMessage) - Assertions.assertEquals(authReplyMessage, session.authReply) - - // test datasetReply - val datasetReplyMessage = DatasetReplyMessage() - Assertions.assertNull(session.datasetReply) - session.populateBody(datasetReplyMessage) - Assertions.assertEquals(datasetReplyMessage, session.datasetReply) - - // test datasetReply as array - val list: List = listOf(datasetReplyMessage) - session.datasetReply = null - session.populateBody(list) - Assertions.assertEquals(datasetReplyMessage, session.datasetReply) + fun emptySession() { + assertThat(session.authReply).isNull() + assertThat(session.datasetReply).isNull() } -} \ No newline at end of file + + @Test + fun authReply() { + val authReplyMessage = AuthReplyMessage() + + session.populateBody(authReplyMessage) + + assertThat(session.authReply).isEqualTo(authReplyMessage) + } + + @Test + fun datasetReply() { + val datasetReplyMessage = DatasetReplyMessage() + + session.populateBody(datasetReplyMessage) + + assertThat(session.datasetReply).isEqualTo(datasetReplyMessage) + } + + @Test + fun datasetReply_asList() { + val datasetReplyMessage = DatasetReplyMessage() + + session.populateBody(listOf(datasetReplyMessage)) + + assertThat(session.datasetReply).isEqualTo(datasetReplyMessage) + } +}