From de1694d1a326ec2e5f94c95d9dfc42bc9cddb793 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 22 Jul 2023 10:14:45 +0200 Subject: [PATCH] fix tests --- .../plugins/sync/nsclientV3/NSClientV3PluginTest.kt | 12 +++++------- .../sync/nsclientV3/workers/LoadBgWorkerTest.kt | 6 +----- 2 files changed, 6 insertions(+), 12 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 428cbafc8a..2dd14bbffa 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 @@ -38,9 +38,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock import org.mockito.Mockito.anyLong -import org.mockito.Mockito.verify import org.mockito.Mockito.`when` -import org.mockito.internal.verification.Times @Suppress("SpellCheckingInspection") internal class NSClientV3PluginTest : TestBaseWithProfile() { @@ -70,7 +68,7 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { sut = NSClientV3Plugin( injector, aapsLogger, aapsSchedulers, rxBus, rh, context, fabricPrivacy, - sp, receiverDelegate, config, dateUtil, uiInteraction, dataSyncSelectorV3, mockedProfileFunction, repository, + sp, receiverDelegate, config, dateUtil, uiInteraction, dataSyncSelectorV3, repository, nsDeviceStatusHandler, nsClientSource, nsIncomingDataProcessor, storeDataForDb ) sut.nsAndroidClient = nsAndroidClient @@ -361,11 +359,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { val dataPair = DataSyncSelector.PairExtendedBolus(extendedBolus, 1000) // create `when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) - sut.nsAdd("treatments", dataPair, "1/3") + sut.nsAdd("treatments", dataPair, "1/3", validProfile) Assertions.assertEquals(1, storeDataForDb.nsIdExtendedBoluses.size) // update `when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) - sut.nsUpdate("treatments", dataPair, "1/3") + sut.nsUpdate("treatments", dataPair, "1/3", validProfile) Assertions.assertEquals(2, storeDataForDb.nsIdExtendedBoluses.size) } @@ -415,11 +413,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() { val dataPair = DataSyncSelector.PairTemporaryBasal(temporaryBasal, 1000) // create `when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa")) - sut.nsAdd("treatments", dataPair, "1/3") + sut.nsAdd("treatments", dataPair, "1/3", validProfile) Assertions.assertEquals(1, storeDataForDb.nsIdTemporaryBasals.size) // update `when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa")) - sut.nsUpdate("treatments", dataPair, "1/3") + sut.nsUpdate("treatments", dataPair, "1/3", validProfile) Assertions.assertEquals(2, storeDataForDb.nsIdTemporaryBasals.size) } 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 be8f72305b..f2f3c4372c 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 @@ -15,7 +15,6 @@ import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.impl.AppRepository import info.nightscout.interfaces.Config import info.nightscout.interfaces.nsclient.StoreDataForDb -import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.interfaces.source.NSClientSource import info.nightscout.interfaces.sync.DataSyncSelectorV3 @@ -31,7 +30,6 @@ import info.nightscout.sdk.remotemodel.LastModified import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach @@ -43,7 +41,6 @@ import org.mockito.ArgumentMatchers.anyString import org.mockito.Mock import org.mockito.Mockito -@OptIn(ExperimentalCoroutinesApi::class) internal class LoadBgWorkerTest : TestBase() { @Mock lateinit var sp: SP @@ -51,7 +48,6 @@ internal class LoadBgWorkerTest : TestBase() { @Mock lateinit var dateUtil: DateUtil @Mock lateinit var nsAndroidClient: NSAndroidClient @Mock lateinit var rh: ResourceHelper - @Mock lateinit var profileFunction: ProfileFunction @Mock lateinit var config: Config @Mock lateinit var uiInteraction: UiInteraction @Mock lateinit var dataSyncSelectorV3: DataSyncSelectorV3 @@ -98,7 +94,7 @@ internal class LoadBgWorkerTest : TestBase() { receiverDelegate = ReceiverDelegate(rxBus, rh, sp, receiverStatusStore, aapsSchedulers, fabricPrivacy) nsClientV3Plugin = NSClientV3Plugin( injector, aapsLogger, aapsSchedulers, rxBus, rh, context, fabricPrivacy, - sp, receiverDelegate, config, dateUtil, uiInteraction, dataSyncSelectorV3, profileFunction, repository, + sp, receiverDelegate, config, dateUtil, uiInteraction, dataSyncSelectorV3, repository, nsDeviceStatusHandler, nsClientSource, nsIncomingDataProcessor, storeDataForDb ) nsClientV3Plugin.newestDataOnServer = LastModified(LastModified.Collections())