From ae65c8b6502863373db20fccb364b98b48e9ec47 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 17:11:37 -0700 Subject: [PATCH 1/4] Rewrites InsulinLyumjevPluginTest with matchers Issue #2745 --- .../nightscout/insulin/InsulinLyumjevPluginTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinLyumjevPluginTest.kt b/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinLyumjevPluginTest.kt index e03fce024a..1d3f02b7df 100644 --- a/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinLyumjevPluginTest.kt +++ b/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinLyumjevPluginTest.kt @@ -1,5 +1,6 @@ package info.nightscout.insulin +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.interfaces.Config @@ -10,7 +11,6 @@ import info.nightscout.interfaces.utils.HardLimits import info.nightscout.rx.bus.RxBus import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.interfaces.ResourceHelper -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 @@ -47,24 +47,24 @@ class InsulinLyumjevPluginTest { @Test fun `simple peak test`() { - Assertions.assertEquals(45, sut.peak) + assertThat(sut.peak).isEqualTo(45) } @Test fun getIdTest() { - Assertions.assertEquals(Insulin.InsulinType.OREF_LYUMJEV, sut.id) + assertThat(sut.id).isEqualTo(Insulin.InsulinType.OREF_LYUMJEV) } @Test fun commentStandardTextTest() { `when`(rh.gs(eq(R.string.lyumjev))).thenReturn("Lyumjev") - Assertions.assertEquals("Lyumjev", sut.commentStandardText()) + assertThat(sut.commentStandardText()).isEqualTo("Lyumjev") } @Test fun getFriendlyNameTest() { `when`(rh.gs(eq(R.string.lyumjev))).thenReturn("Lyumjev") - Assertions.assertEquals("Lyumjev", sut.friendlyName) + assertThat(sut.friendlyName).isEqualTo("Lyumjev") } -} \ No newline at end of file +} From 7a2479ef951f6a911bb093398ff26233441c50c9 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 17:12:03 -0700 Subject: [PATCH 2/4] Rewrites InsulinOrefFreePeakPluginTest with matchers Issue #2745 --- .../insulin/InsulinOrefFreePeakPluginTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefFreePeakPluginTest.kt b/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefFreePeakPluginTest.kt index d086c2146e..af2a707086 100644 --- a/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefFreePeakPluginTest.kt +++ b/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefFreePeakPluginTest.kt @@ -1,6 +1,7 @@ package info.nightscout.insulin import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.interfaces.Config @@ -10,7 +11,6 @@ import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.utils.HardLimits 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.ArgumentMatchers.anyInt @@ -46,24 +46,24 @@ class InsulinOrefFreePeakPluginTest : TestBase() { @Test fun `simple peak test`() { `when`(sp.getInt(eq(info.nightscout.core.utils.R.string.key_insulin_oref_peak), anyInt())).thenReturn(90) - Assertions.assertEquals(90, sut.peak) + assertThat(sut.peak).isEqualTo(90) } @Test fun getIdTest() { - Assertions.assertEquals(Insulin.InsulinType.OREF_FREE_PEAK, sut.id) + assertThat(sut.id).isEqualTo(Insulin.InsulinType.OREF_FREE_PEAK) } @Test fun commentStandardTextTest() { `when`(sp.getInt(eq(info.nightscout.core.utils.R.string.key_insulin_oref_peak), anyInt())).thenReturn(90) `when`(rh.gs(eq(R.string.insulin_peak_time))).thenReturn("Peak Time [min]") - Assertions.assertEquals("Peak Time [min]: 90", sut.commentStandardText()) + assertThat(sut.commentStandardText()).isEqualTo("Peak Time [min]: 90") } @Test fun getFriendlyNameTest() { `when`(rh.gs(eq(R.string.free_peak_oref))).thenReturn("Free-Peak Oref") - Assertions.assertEquals("Free-Peak Oref", sut.friendlyName) + assertThat(sut.friendlyName).isEqualTo("Free-Peak Oref") } -} \ No newline at end of file +} From 5acec0b363bdd52e85ffbedcf1e06500e03f2f1c Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 17:12:13 -0700 Subject: [PATCH 3/4] Rewrites InsulinOrefRapidActingPluginTest with matchers Issue #2745 --- .../insulin/InsulinOrefRapidActingPluginTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefRapidActingPluginTest.kt b/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefRapidActingPluginTest.kt index d8d7d2a697..cd56e05515 100644 --- a/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefRapidActingPluginTest.kt +++ b/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefRapidActingPluginTest.kt @@ -1,5 +1,6 @@ package info.nightscout.insulin +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.interfaces.Config @@ -10,7 +11,6 @@ import info.nightscout.interfaces.utils.HardLimits import info.nightscout.rx.bus.RxBus import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.interfaces.ResourceHelper -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 @@ -47,24 +47,24 @@ class InsulinOrefRapidActingPluginTest { @Test fun `simple peak test`() { - Assertions.assertEquals(75, sut.peak) + assertThat(sut.peak).isEqualTo(75) } @Test fun getIdTest() { - Assertions.assertEquals(Insulin.InsulinType.OREF_RAPID_ACTING, sut.id) + assertThat(sut.id).isEqualTo(Insulin.InsulinType.OREF_RAPID_ACTING) } @Test fun commentStandardTextTest() { `when`(rh.gs(eq(R.string.fast_acting_insulin_comment))).thenReturn("Novorapid, Novolog, Humalog") - Assertions.assertEquals("Novorapid, Novolog, Humalog", sut.commentStandardText()) + assertThat(sut.commentStandardText()).isEqualTo("Novorapid, Novolog, Humalog") } @Test fun getFriendlyNameTest() { `when`(rh.gs(eq(R.string.rapid_acting_oref))).thenReturn("Rapid-Acting Oref") - Assertions.assertEquals("Rapid-Acting Oref", sut.friendlyName) + assertThat(sut.friendlyName).isEqualTo("Rapid-Acting Oref") } -} \ No newline at end of file +} From 672aebb87cdbb0c1a6a11d34086f323c0d69899f Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 17:12:23 -0700 Subject: [PATCH 4/4] Rewrites InsulinOrefUltraRapidActingPluginTest with matchers Issue #2745 --- .../insulin/InsulinOrefUltraRapidActingPluginTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefUltraRapidActingPluginTest.kt b/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefUltraRapidActingPluginTest.kt index ec8dc09c5e..6082a7fe9b 100644 --- a/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefUltraRapidActingPluginTest.kt +++ b/plugins/insulin/src/test/java/info/nightscout/insulin/InsulinOrefUltraRapidActingPluginTest.kt @@ -1,5 +1,6 @@ package info.nightscout.insulin +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.interfaces.Config @@ -10,7 +11,6 @@ import info.nightscout.interfaces.utils.HardLimits import info.nightscout.rx.bus.RxBus import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.interfaces.ResourceHelper -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 @@ -47,24 +47,24 @@ class InsulinOrefUltraRapidActingPluginTest { @Test fun `simple peak test`() { - Assertions.assertEquals(55, sut.peak) + assertThat(sut.peak).isEqualTo(55) } @Test fun getIdTest() { - Assertions.assertEquals(Insulin.InsulinType.OREF_ULTRA_RAPID_ACTING, sut.id) + assertThat(sut.id).isEqualTo(Insulin.InsulinType.OREF_ULTRA_RAPID_ACTING) } @Test fun commentStandardTextTest() { `when`(rh.gs(eq(R.string.ultra_fast_acting_insulin_comment))).thenReturn("Fiasp") - Assertions.assertEquals("Fiasp", sut.commentStandardText()) + assertThat(sut.commentStandardText()).isEqualTo("Fiasp") } @Test fun getFriendlyNameTest() { `when`(rh.gs(eq(R.string.ultra_rapid_oref))).thenReturn("Ultra-Rapid Oref") - Assertions.assertEquals("Ultra-Rapid Oref", sut.friendlyName) + assertThat(sut.friendlyName).isEqualTo("Ultra-Rapid Oref") } -} \ No newline at end of file +}