Merge pull request #2835 from ryanhaining/assertis
Replaces isInstanceOf with assertIs
This commit is contained in:
commit
ad662fbac2
|
@ -3,6 +3,7 @@ package info.nightscout.implementation.profile
|
|||
import app.aaps.core.interfaces.profile.PureProfile
|
||||
import app.aaps.shared.tests.TestBaseWithProfile
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlin.test.assertIs
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class ProfileStoreTest : TestBaseWithProfile() {
|
||||
|
@ -14,7 +15,7 @@ internal class ProfileStoreTest : TestBaseWithProfile() {
|
|||
|
||||
@Test
|
||||
fun getDefaultProfileTest() {
|
||||
assertThat(getValidProfileStore().getDefaultProfile()).isInstanceOf(PureProfile::class.java)
|
||||
assertIs<PureProfile>(getValidProfileStore().getDefaultProfile())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -35,7 +36,7 @@ internal class ProfileStoreTest : TestBaseWithProfile() {
|
|||
|
||||
@Test
|
||||
fun getSpecificProfileTest() {
|
||||
assertThat(getValidProfileStore().getSpecificProfile(TESTPROFILENAME)).isInstanceOf(PureProfile::class.java)
|
||||
assertIs<PureProfile>(getValidProfileStore().getSpecificProfile(TESTPROFILENAME))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.automation.triggers
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlin.test.assertIs
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import org.junit.jupiter.api.Test
|
||||
|
@ -73,7 +74,7 @@ class TriggerConnectorTest : TriggerTestBase() {
|
|||
t.list.add(TriggerConnector(injector))
|
||||
val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerConnector
|
||||
assertThat(t2.size()).isEqualTo(1)
|
||||
assertThat(t2.list[0]).isInstanceOf(TriggerConnector::class.java)
|
||||
assertIs<TriggerConnector>(t2.list[0])
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||
|
||||
import app.aaps.core.nssdk.localmodel.treatment.NSExtendedBolus
|
||||
import app.aaps.core.nssdk.localmodel.treatment.NSTemporaryBasal
|
||||
import app.aaps.core.nssdk.mapper.convertToRemoteAndBack
|
||||
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 app.aaps.core.nssdk.localmodel.treatment.NSExtendedBolus
|
||||
import app.aaps.core.nssdk.localmodel.treatment.NSTemporaryBasal
|
||||
import app.aaps.core.nssdk.mapper.convertToRemoteAndBack
|
||||
import kotlin.test.assertIs
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
|
@ -47,10 +48,10 @@ internal class ExtendedBolusExtensionKtTest : TestBaseWithProfile() {
|
|||
)
|
||||
|
||||
val converted = extendedBolus.toNSExtendedBolus(validProfile)
|
||||
assertThat(converted).isInstanceOf(NSTemporaryBasal::class.java)
|
||||
assertIs<NSTemporaryBasal>(converted)
|
||||
assertThat((converted as NSTemporaryBasal).extendedEmulated).isNotNull()
|
||||
val convertedBack = converted.convertToRemoteAndBack()
|
||||
assertThat(convertedBack).isInstanceOf(NSExtendedBolus::class.java)
|
||||
assertIs<NSExtendedBolus>(convertedBack)
|
||||
|
||||
extendedBolus2 = (extendedBolus.toNSExtendedBolus(validProfile).convertToRemoteAndBack() as NSExtendedBolus).toExtendedBolus()
|
||||
assertThat(extendedBolus.contentEqualsTo(extendedBolus2)).isTrue()
|
||||
|
|
|
@ -12,6 +12,7 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.plugins.sync.nsclientV3.DataSyncSelectorV3
|
||||
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
||||
import kotlin.test.assertIs
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
|
@ -64,6 +65,6 @@ internal class DataSyncWorkerTest : TestBase() {
|
|||
`when`(nsClient.hasWritePermission).thenReturn(true)
|
||||
val result = sut.doWorkAndLog()
|
||||
Mockito.verify(dataSyncSelectorV3, Mockito.times(1)).doUpload()
|
||||
assertThat(result).isInstanceOf(Success::class.java)
|
||||
assertIs<Success>(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue