Replaces isInstanceOf with assertIs in LoadBgWorkerTest

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-24 22:23:06 -07:00
parent de8c8a3621
commit 6421497cd2

View file

@ -6,7 +6,6 @@ import androidx.work.OneTimeWorkRequest
import androidx.work.WorkContinuation
import androidx.work.WorkManager
import androidx.work.testing.TestListenableWorkerBuilder
import app.aaps.core.main.utils.fabric.FabricPrivacy
import app.aaps.core.interfaces.configuration.Config
import app.aaps.core.interfaces.nsclient.StoreDataForDb
import app.aaps.core.interfaces.receivers.ReceiverStatusStore
@ -16,6 +15,9 @@ import app.aaps.core.interfaces.source.NSClientSource
import app.aaps.core.interfaces.ui.UiInteraction
import app.aaps.core.interfaces.utils.DateUtil
import app.aaps.core.interfaces.utils.DecimalFormatter
import app.aaps.core.main.utils.fabric.FabricPrivacy
import app.aaps.core.nssdk.interfaces.NSAndroidClient
import app.aaps.core.nssdk.remotemodel.LastModified
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector
@ -31,8 +33,7 @@ import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler
import info.nightscout.plugins.sync.nsclientV3.DataSyncSelectorV3
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.plugins.sync.nsclientV3.extensions.toNSSvgV3
import app.aaps.core.nssdk.interfaces.NSAndroidClient
import app.aaps.core.nssdk.remotemodel.LastModified
import kotlin.test.assertIs
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
@ -111,7 +112,7 @@ internal class LoadBgWorkerTest : TestBase() {
sut = TestListenableWorkerBuilder<LoadBgWorker>(context).build()
val result = sut.doWorkAndLog()
assertThat(result).isInstanceOf(ListenableWorker.Result.Failure::class.java)
assertIs<ListenableWorker.Result.Failure>(result)
}
@Test
@ -121,7 +122,7 @@ 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()
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
assertIs<ListenableWorker.Result.Success>(result)
assertThat(result.outputData.getString("Result")).isEqualTo("Load not enabled")
}
@ -137,7 +138,7 @@ internal class LoadBgWorkerTest : TestBase() {
val result = sut.doWorkAndLog()
assertThat(nsClientV3Plugin.lastLoadedSrvModified.collections.entries).isEqualTo(now - 1000)
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
assertIs<ListenableWorker.Result.Success>(result)
}
@Test
@ -165,7 +166,7 @@ internal class LoadBgWorkerTest : TestBase() {
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, listOf(glucoseValue.toNSSvgV3())))
val result = sut.doWorkAndLog()
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
assertIs<ListenableWorker.Result.Success>(result)
}
@Test
@ -180,6 +181,6 @@ internal class LoadBgWorkerTest : TestBase() {
val result = sut.doWorkAndLog()
assertThat(nsClientV3Plugin.lastLoadedSrvModified.collections.entries).isEqualTo(now - 1000)
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
assertIs<ListenableWorker.Result.Success>(result)
}
}