NSCv3: use alarm socket only when needed
This commit is contained in:
parent
e7225ce602
commit
2b49778697
6 changed files with 66 additions and 43 deletions
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.plugins.sync.nsclient.data
|
package info.nightscout.plugins.sync.nsclient.data
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.annotations.OpenForTesting
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
||||||
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
|
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
|
||||||
|
@ -65,6 +66,7 @@ import javax.inject.Singleton
|
||||||
*/
|
*/
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@OpenForTesting
|
||||||
class NSDeviceStatusHandler @Inject constructor(
|
class NSDeviceStatusHandler @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val config: Config,
|
private val config: Config,
|
||||||
|
|
|
@ -202,7 +202,9 @@ class NSClientV3Plugin @Inject constructor(
|
||||||
if (ev.isChanged(rh.gs(R.string.key_ns_client_token)) ||
|
if (ev.isChanged(rh.gs(R.string.key_ns_client_token)) ||
|
||||||
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_nsclientinternal_url)) ||
|
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_nsclientinternal_url)) ||
|
||||||
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_ns_use_ws)) ||
|
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_ns_use_ws)) ||
|
||||||
ev.isChanged(rh.gs(R.string.key_ns_paused))
|
ev.isChanged(rh.gs(R.string.key_ns_paused)) ||
|
||||||
|
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_ns_alarms)) ||
|
||||||
|
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_ns_announcements))
|
||||||
)
|
)
|
||||||
setClient("SETTING CHANGE")
|
setClient("SETTING CHANGE")
|
||||||
if (ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_local_profile_last_change)))
|
if (ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_local_profile_last_change)))
|
||||||
|
@ -337,16 +339,19 @@ class NSClientV3Plugin @Inject constructor(
|
||||||
socket.on("update", onDataCreateUpdate)
|
socket.on("update", onDataCreateUpdate)
|
||||||
socket.on("delete", onDataDelete)
|
socket.on("delete", onDataDelete)
|
||||||
}
|
}
|
||||||
alarmSocket = IO.socket(urlAlarm).also { socket ->
|
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_announcements, config.NSCLIENT) ||
|
||||||
socket.on(Socket.EVENT_CONNECT, onConnectAlarms)
|
sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, config.NSCLIENT)
|
||||||
socket.on(Socket.EVENT_DISCONNECT, onDisconnectAlarm)
|
)
|
||||||
rxBus.send(EventNSClientNewLog("► WS", "do connect alarm $reason"))
|
alarmSocket = IO.socket(urlAlarm).also { socket ->
|
||||||
socket.connect()
|
socket.on(Socket.EVENT_CONNECT, onConnectAlarms)
|
||||||
socket.on("announcement", onAnnouncement)
|
socket.on(Socket.EVENT_DISCONNECT, onDisconnectAlarm)
|
||||||
socket.on("alarm", onAlarm)
|
rxBus.send(EventNSClientNewLog("► WS", "do connect alarm $reason"))
|
||||||
socket.on("urgent_alarm", onUrgentAlarm)
|
socket.connect()
|
||||||
socket.on("clear_alarm", onClearAlarm)
|
socket.on("announcement", onAnnouncement)
|
||||||
}
|
socket.on("alarm", onAlarm)
|
||||||
|
socket.on("urgent_alarm", onUrgentAlarm)
|
||||||
|
socket.on("clear_alarm", onClearAlarm)
|
||||||
|
}
|
||||||
} catch (e: URISyntaxException) {
|
} catch (e: URISyntaxException) {
|
||||||
rxBus.send(EventNSClientNewLog("● WS", "Wrong URL syntax"))
|
rxBus.send(EventNSClientNewLog("● WS", "Wrong URL syntax"))
|
||||||
} catch (e: RuntimeException) {
|
} catch (e: RuntimeException) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.sync.nsclient
|
package info.nightscout.plugins.sync.nsclient
|
||||||
|
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
||||||
import info.nightscout.plugins.sync.R
|
import info.nightscout.plugins.sync.R
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
|
@ -8,7 +9,7 @@ import info.nightscout.rx.events.EventChargingState
|
||||||
import info.nightscout.rx.events.EventNetworkChange
|
import info.nightscout.rx.events.EventNetworkChange
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -18,28 +19,28 @@ class NsClientReceiverDelegateTest : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var rh: ResourceHelper
|
@Mock lateinit var rh: ResourceHelper
|
||||||
val rxBus = RxBus(aapsSchedulers, aapsLogger)
|
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
private val rxBus = RxBus(aapsSchedulers, aapsLogger)
|
||||||
|
|
||||||
@Mock private lateinit var receiverStatusStore: ReceiverStatusStore
|
@Mock private lateinit var receiverStatusStore: ReceiverStatusStore
|
||||||
private lateinit var sut: NsClientReceiverDelegate
|
private lateinit var sut: NsClientReceiverDelegate
|
||||||
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun prepare() {
|
fun prepare() {
|
||||||
//receiverStatusStore = ReceiverStatusStore(context, rxBus)
|
//receiverStatusStore = ReceiverStatusStore(context, rxBus)
|
||||||
sut = NsClientReceiverDelegate(rxBus, rh, sp, receiverStatusStore)
|
sut = NsClientReceiverDelegate(rxBus, rh, sp, receiverStatusStore, aapsSchedulers, fabricPrivacy)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testCalculateStatusChargingState() {
|
fun testCalculateStatusChargingState() {
|
||||||
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(false)
|
||||||
Assert.assertTrue(sut.calculateStatus(EventChargingState(false, 0)))
|
Assertions.assertTrue(sut.calculateStatus(EventChargingState(false, 0)))
|
||||||
Assert.assertFalse(sut.calculateStatus(EventChargingState(true, 0)))
|
Assertions.assertFalse(sut.calculateStatus(EventChargingState(true, 0)))
|
||||||
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(false)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(true)
|
||||||
Assert.assertTrue(sut.calculateStatus(EventChargingState(true, 0)))
|
Assertions.assertTrue(sut.calculateStatus(EventChargingState(true, 0)))
|
||||||
Assert.assertFalse(sut.calculateStatus(EventChargingState(false, 0)))
|
Assertions.assertFalse(sut.calculateStatus(EventChargingState(false, 0)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -48,41 +49,41 @@ class NsClientReceiverDelegateTest : TestBase() {
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
`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.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
|
||||||
Assert.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
||||||
|
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("test")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("test")
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
|
||||||
Assert.assertFalse(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
|
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test", mobileConnected = true, wifiConnected = true)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test", mobileConnected = true, wifiConnected = true)))
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test", mobileConnected = false, wifiConnected = true)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test", mobileConnected = false, wifiConnected = true)))
|
||||||
Assert.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
||||||
|
|
||||||
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(false)
|
`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_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, 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("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(wifiConnected = true)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(wifiConnected = true)))
|
||||||
Assert.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
||||||
Assert.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true)))
|
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true)))
|
||||||
|
|
||||||
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
`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_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(false)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
|
||||||
Assert.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
|
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
|
||||||
|
|
||||||
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
`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_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, 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("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
|
||||||
Assert.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
|
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,11 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3
|
package info.nightscout.plugins.sync.nsclientV3
|
||||||
|
|
||||||
|
import androidx.work.WorkManager
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
import info.nightscout.core.extensions.fromConstant
|
import info.nightscout.core.extensions.fromConstant
|
||||||
|
import info.nightscout.core.utils.receivers.DataWorkerStorage
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.database.entities.BolusCalculatorResult
|
import info.nightscout.database.entities.BolusCalculatorResult
|
||||||
import info.nightscout.database.entities.Carbs
|
import info.nightscout.database.entities.Carbs
|
||||||
|
@ -26,8 +28,10 @@ import info.nightscout.interfaces.pump.VirtualPump
|
||||||
import info.nightscout.interfaces.source.NSClientSource
|
import info.nightscout.interfaces.source.NSClientSource
|
||||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
|
import info.nightscout.interfaces.workflow.WorkerClasses
|
||||||
import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
|
import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
|
||||||
import info.nightscout.plugins.sync.nsclient.NsClientReceiverDelegate
|
import info.nightscout.plugins.sync.nsclient.NsClientReceiverDelegate
|
||||||
|
import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler
|
||||||
import info.nightscout.plugins.sync.nsclient.extensions.fromConstant
|
import info.nightscout.plugins.sync.nsclient.extensions.fromConstant
|
||||||
import info.nightscout.sdk.interfaces.NSAndroidClient
|
import info.nightscout.sdk.interfaces.NSAndroidClient
|
||||||
import info.nightscout.sdk.localmodel.treatment.CreateUpdateResponse
|
import info.nightscout.sdk.localmodel.treatment.CreateUpdateResponse
|
||||||
|
@ -54,6 +58,10 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
@Mock lateinit var xDripBroadcast: XDripBroadcast
|
@Mock lateinit var xDripBroadcast: XDripBroadcast
|
||||||
@Mock lateinit var virtualPump: VirtualPump
|
@Mock lateinit var virtualPump: VirtualPump
|
||||||
@Mock lateinit var mockedProfileFunction: ProfileFunction
|
@Mock lateinit var mockedProfileFunction: ProfileFunction
|
||||||
|
@Mock lateinit var nsDeviceStatusHandler: NSDeviceStatusHandler
|
||||||
|
@Mock lateinit var workManager: WorkManager
|
||||||
|
@Mock lateinit var workerClasses: WorkerClasses
|
||||||
|
@Mock lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
|
||||||
private lateinit var storeDataForDb: StoreDataForDb
|
private lateinit var storeDataForDb: StoreDataForDb
|
||||||
private lateinit var sut: NSClientV3Plugin
|
private lateinit var sut: NSClientV3Plugin
|
||||||
|
@ -69,7 +77,8 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
sut =
|
sut =
|
||||||
NSClientV3Plugin(
|
NSClientV3Plugin(
|
||||||
injector, aapsLogger, aapsSchedulers, rxBus, rh, context, fabricPrivacy,
|
injector, aapsLogger, aapsSchedulers, rxBus, rh, context, fabricPrivacy,
|
||||||
sp, nsClientReceiverDelegate, config, dateUtil, uiInteraction, dataSyncSelector, mockedProfileFunction, repository
|
sp, nsClientReceiverDelegate, config, dateUtil, uiInteraction, dataSyncSelector, mockedProfileFunction, repository,
|
||||||
|
nsDeviceStatusHandler, workManager, workerClasses, dataWorkerStorage, nsClientSource
|
||||||
)
|
)
|
||||||
sut.nsAndroidClient = nsAndroidClient
|
sut.nsAndroidClient = nsAndroidClient
|
||||||
`when`(mockedProfileFunction.getProfile(anyLong())).thenReturn(validProfile)
|
`when`(mockedProfileFunction.getProfile(anyLong())).thenReturn(validProfile)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
import info.nightscout.interfaces.sync.NsClient
|
import info.nightscout.interfaces.sync.NsClient
|
||||||
|
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
@ -27,6 +28,7 @@ internal class DataSyncWorkerTest : TestBase() {
|
||||||
@Mock lateinit var activePlugin: ActivePlugin
|
@Mock lateinit var activePlugin: ActivePlugin
|
||||||
@Mock lateinit var nsClient: NsClient
|
@Mock lateinit var nsClient: NsClient
|
||||||
@Mock lateinit var rxBus: RxBus
|
@Mock lateinit var rxBus: RxBus
|
||||||
|
@Mock lateinit var nsClientV3Plugin: NSClientV3Plugin
|
||||||
|
|
||||||
private lateinit var sut: DataSyncWorker
|
private lateinit var sut: DataSyncWorker
|
||||||
|
|
||||||
|
@ -38,6 +40,7 @@ internal class DataSyncWorkerTest : TestBase() {
|
||||||
it.dataSyncSelector = dataSyncSelector
|
it.dataSyncSelector = dataSyncSelector
|
||||||
it.activePlugin = activePlugin
|
it.activePlugin = activePlugin
|
||||||
it.rxBus = rxBus
|
it.rxBus = rxBus
|
||||||
|
it.nsClientV3Plugin = nsClientV3Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.interfaces.workflow.WorkerClasses
|
import info.nightscout.interfaces.workflow.WorkerClasses
|
||||||
import info.nightscout.plugins.sync.nsclient.NsClientReceiverDelegate
|
import info.nightscout.plugins.sync.nsclient.NsClientReceiverDelegate
|
||||||
|
import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler
|
||||||
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
||||||
import info.nightscout.plugins.sync.nsclientV3.extensions.toNSSvgV3
|
import info.nightscout.plugins.sync.nsclientV3.extensions.toNSSvgV3
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
|
@ -49,7 +50,6 @@ internal class LoadBgWorkerTest : TestBase() {
|
||||||
@Mock lateinit var workerClasses: WorkerClasses
|
@Mock lateinit var workerClasses: WorkerClasses
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Mock lateinit var rxBus: RxBus
|
|
||||||
@Mock lateinit var dateUtil: DateUtil
|
@Mock lateinit var dateUtil: DateUtil
|
||||||
@Mock lateinit var nsAndroidClient: NSAndroidClient
|
@Mock lateinit var nsAndroidClient: NSAndroidClient
|
||||||
@Mock lateinit var rh: ResourceHelper
|
@Mock lateinit var rh: ResourceHelper
|
||||||
|
@ -62,7 +62,9 @@ internal class LoadBgWorkerTest : TestBase() {
|
||||||
@Mock lateinit var nsClientSource: NSClientSource
|
@Mock lateinit var nsClientSource: NSClientSource
|
||||||
@Mock lateinit var workManager: WorkManager
|
@Mock lateinit var workManager: WorkManager
|
||||||
@Mock lateinit var workContinuation: WorkContinuation
|
@Mock lateinit var workContinuation: WorkContinuation
|
||||||
|
@Mock lateinit var nsDeviceStatusHandler: NSDeviceStatusHandler
|
||||||
|
|
||||||
|
private val rxBus: RxBus = RxBus(aapsSchedulers, aapsLogger)
|
||||||
private lateinit var nsClientV3Plugin: NSClientV3Plugin
|
private lateinit var nsClientV3Plugin: NSClientV3Plugin
|
||||||
private lateinit var nsClientReceiverDelegate: NsClientReceiverDelegate
|
private lateinit var nsClientReceiverDelegate: NsClientReceiverDelegate
|
||||||
private lateinit var dataWorkerStorage: DataWorkerStorage
|
private lateinit var dataWorkerStorage: DataWorkerStorage
|
||||||
|
@ -95,10 +97,11 @@ internal class LoadBgWorkerTest : TestBase() {
|
||||||
Mockito.`when`(dateUtil.now()).thenReturn(now)
|
Mockito.`when`(dateUtil.now()).thenReturn(now)
|
||||||
Mockito.`when`(nsClientSource.isEnabled()).thenReturn(true)
|
Mockito.`when`(nsClientSource.isEnabled()).thenReturn(true)
|
||||||
dataWorkerStorage = DataWorkerStorage(context)
|
dataWorkerStorage = DataWorkerStorage(context)
|
||||||
nsClientReceiverDelegate = NsClientReceiverDelegate(rxBus, rh, sp, receiverStatusStore)
|
nsClientReceiverDelegate = NsClientReceiverDelegate(rxBus, rh, sp, receiverStatusStore, aapsSchedulers, fabricPrivacy)
|
||||||
nsClientV3Plugin = NSClientV3Plugin(
|
nsClientV3Plugin = NSClientV3Plugin(
|
||||||
injector, aapsLogger, aapsSchedulers, rxBus, rh, context, fabricPrivacy, sp, nsClientReceiverDelegate, config, dateUtil, uiInteraction, dataSyncSelector,
|
injector, aapsLogger, aapsSchedulers, rxBus, rh, context, fabricPrivacy,
|
||||||
profileFunction, repository
|
sp, nsClientReceiverDelegate, config, dateUtil, uiInteraction, dataSyncSelector, profileFunction, repository,
|
||||||
|
nsDeviceStatusHandler, workManager, workerClasses, dataWorkerStorage, nsClientSource
|
||||||
)
|
)
|
||||||
nsClientV3Plugin.newestDataOnServer = LastModified(LastModified.Collections())
|
nsClientV3Plugin.newestDataOnServer = LastModified(LastModified.Collections())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue