fix tests
This commit is contained in:
parent
194cf305fd
commit
4eef2507fb
|
@ -79,7 +79,7 @@ open class AppModule {
|
|||
@Binds fun bindCommandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
|
||||
@Binds fun bindConfigInterface(config: Config): ConfigInterface
|
||||
@Binds fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilderInterface
|
||||
@Binds fun bindTreatmentInterface(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface
|
||||
@Binds fun bindTreatmentsInterface(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface
|
||||
@Binds fun bindDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface
|
||||
@Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolder): NotificationHolderInterface
|
||||
@Binds fun bindImportExportPrefsInterface(importExportPrefs: ImportExportPrefs): ImportExportPrefsInterface
|
||||
|
|
|
@ -8,6 +8,7 @@ import info.nightscout.androidaps.TestPumpPlugin
|
|||
import info.nightscout.androidaps.data.PumpEnactResult
|
||||
import info.nightscout.androidaps.interfaces.*
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
|
@ -17,7 +18,7 @@ import org.mockito.Mock
|
|||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
|
||||
@PrepareForTest(RxBusWrapper::class, ActionsTestBase.TestLoopPlugin::class)
|
||||
@PrepareForTest(RxBusWrapper::class, ActionsTestBase.TestLoopPlugin::class, UserEntryLogger::class)
|
||||
open class ActionsTestBase : TestBaseWithProfile() {
|
||||
|
||||
open class TestLoopPlugin(
|
||||
|
@ -29,7 +30,7 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
|||
pluginDescription, aapsLogger, resourceHelper, injector
|
||||
), LoopInterface {
|
||||
|
||||
var suspended = false
|
||||
private var suspended = false
|
||||
override var lastRun: LoopInterface.LastRun? = LoopInterface.LastRun()
|
||||
override val isSuspended: Boolean = suspended
|
||||
override fun suspendTo(endTime: Long) {}
|
||||
|
@ -44,6 +45,7 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
|||
@Mock lateinit var profilePlugin: ProfileInterface
|
||||
@Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorInterface
|
||||
@Mock lateinit var loopPlugin: TestLoopPlugin
|
||||
@Mock lateinit var uel: UserEntryLogger
|
||||
|
||||
private val pluginDescription = PluginDescription()
|
||||
lateinit var testPumpPlugin: TestPumpPlugin
|
||||
|
@ -55,6 +57,7 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
|||
it.resourceHelper = resourceHelper
|
||||
it.dateUtil = dateUtil
|
||||
it.repository = repository
|
||||
it.uel = uel
|
||||
}
|
||||
if (it is ActionStartTempTarget) {
|
||||
it.aapsLogger = aapsLogger
|
||||
|
@ -62,6 +65,7 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
|||
it.activePlugin = activePlugin
|
||||
it.repository = repository
|
||||
it.profileFunction = profileFunction
|
||||
it.uel = uel
|
||||
}
|
||||
if (it is ActionSendSMS) {
|
||||
it.aapsLogger = aapsLogger
|
||||
|
@ -73,10 +77,12 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
|||
it.resourceHelper = resourceHelper
|
||||
it.activePlugin = activePlugin
|
||||
it.profileFunction = profileFunction
|
||||
it.uel = uel
|
||||
}
|
||||
if (it is ActionProfileSwitchPercent) {
|
||||
it.resourceHelper = resourceHelper
|
||||
it.activePlugin = activePlugin
|
||||
it.uel = uel
|
||||
}
|
||||
if (it is ActionNotification) {
|
||||
it.resourceHelper = resourceHelper
|
||||
|
@ -86,18 +92,21 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
|||
it.loopPlugin = loopPlugin
|
||||
it.resourceHelper = resourceHelper
|
||||
it.rxBus = rxBus
|
||||
it.uel = uel
|
||||
}
|
||||
if (it is ActionLoopResume) {
|
||||
it.loopPlugin = loopPlugin
|
||||
it.resourceHelper = resourceHelper
|
||||
it.configBuilderPlugin = configBuilderPlugin
|
||||
it.rxBus = rxBus
|
||||
it.uel = uel
|
||||
}
|
||||
if (it is ActionLoopEnable) {
|
||||
it.loopPlugin = loopPlugin
|
||||
it.resourceHelper = resourceHelper
|
||||
it.configBuilderPlugin = configBuilderPlugin
|
||||
it.rxBus = rxBus
|
||||
it.uel = uel
|
||||
}
|
||||
if (it is ActionLoopDisable) {
|
||||
it.loopPlugin = loopPlugin
|
||||
|
@ -105,6 +114,7 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
|||
it.configBuilderPlugin = configBuilderPlugin
|
||||
it.commandQueue = commandQueue
|
||||
it.rxBus = rxBus
|
||||
it.uel = uel
|
||||
}
|
||||
if (it is PumpEnactResult) {
|
||||
it.resourceHelper = resourceHelper
|
||||
|
|
|
@ -30,7 +30,7 @@ class TriggerIobTest : TriggerTestBase() {
|
|||
}
|
||||
|
||||
@Test fun shouldRunTest() {
|
||||
`when`(iobCobCalculatorPlugin.calculateFromTreatmentsAndTempsSynchronized(ArgumentMatchers.anyLong(), ArgumentMatchers.any(Profile::class.java))).thenReturn(generateIobRecordData())
|
||||
`when`(iobCobCalculatorPlugin.calculateFromTreatmentsAndTempsSynchronized(ArgumentMatchers.anyLong(), anyObject())).thenReturn(generateIobRecordData())
|
||||
var t: TriggerIob = TriggerIob(injector).setValue(1.1).comparator(Comparator.Compare.IS_EQUAL)
|
||||
Assert.assertFalse(t.shouldRun())
|
||||
t = TriggerIob(injector).setValue(1.0).comparator(Comparator.Compare.IS_EQUAL)
|
||||
|
|
|
@ -33,6 +33,7 @@ object SealedClassHelper {
|
|||
val x = gson.fromJson<T>(jsonReader, innerClass.javaObjectType)
|
||||
jsonReader.endObject()
|
||||
// if there a static object, actually return that
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return innerClass.objectInstance as T? ?: x
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import info.nightscout.androidaps.danar.R;
|
|||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||
|
|
|
@ -25,7 +25,7 @@ class MsgInitConnStatusBasic(
|
|||
danaPump.currentBasal = intFromBuff(bytes, 11, 2) / 100.0
|
||||
val tempBasalPercent = intFromBuff(bytes, 13, 1)
|
||||
val isExtendedInProgress = intFromBuff(bytes, 14, 1) == 1
|
||||
val isTempBasalInProgress = intFromBuff(bytes, 15, 1) == 1
|
||||
//val isTempBasalInProgress = intFromBuff(bytes, 15, 1) == 1
|
||||
val statusBasalUDOption = intFromBuff(bytes, 16, 1)
|
||||
danaPump.isDualBolusInProgress = intFromBuff(bytes, 17, 1) == 1
|
||||
val extendedBolusRate = intFromBuff(bytes, 18, 2) / 100.0
|
||||
|
@ -46,8 +46,8 @@ class MsgInitConnStatusBasic(
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "Reservoir remaining units: " + danaPump.reservoirRemainingUnits)
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Bolus blocked: " + danaPump.bolusBlocked)
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Current basal: " + danaPump.currentBasal)
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal percent: " + tempBasalPercent)
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Is extended bolus running: " + isExtendedInProgress)
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal percent: $tempBasalPercent")
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Is extended bolus running: $isExtendedInProgress")
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "statusBasalUDOption: $statusBasalUDOption")
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Is dual bolus running: " + danaPump.isDualBolusInProgress)
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus rate: $extendedBolusRate")
|
||||
|
|
|
@ -16,8 +16,10 @@ class MsgStatusTempBasal(
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||
}
|
||||
|
||||
var isTempBasalInProgress = false
|
||||
|
||||
override fun handleMessage(bytes: ByteArray) {
|
||||
val isTempBasalInProgress = intFromBuff(bytes, 0, 1) and 0x01 == 0x01
|
||||
isTempBasalInProgress = intFromBuff(bytes, 0, 1) and 0x01 == 0x01
|
||||
val isAPSTempBasalInProgress = intFromBuff(bytes, 0, 1) and 0x02 == 0x02
|
||||
var tempBasalPercent = intFromBuff(bytes, 1, 1)
|
||||
if (tempBasalPercent > 200) tempBasalPercent = (tempBasalPercent - 200) * 10
|
||||
|
@ -47,7 +49,7 @@ class MsgStatusTempBasal(
|
|||
}
|
||||
|
||||
private fun getDateFromSecAgo(tempBasalAgoSecs: Int): Long {
|
||||
return (floor(System.currentTimeMillis() / 1000.0) - tempBasalAgoSecs).toLong() * 1000
|
||||
return (floor(dateUtil._now() / 1000.0) - tempBasalAgoSecs).toLong() * 1000
|
||||
}
|
||||
|
||||
// because there is no fixed timestamp of start allow update of tbr only if tbr start differs more
|
||||
|
|
|
@ -32,7 +32,6 @@ open class DanaRTestBase : TestBase() {
|
|||
@Mock lateinit var activePluginProvider: ActivePluginProvider
|
||||
@Mock lateinit var dateUtil: DateUtil
|
||||
@Mock lateinit var databaseHelper: DatabaseHelperInterface
|
||||
@Mock lateinit var treatmentsInterface: TreatmentsInterface
|
||||
@Mock lateinit var danaRPlugin: DanaRPlugin
|
||||
@Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||
@Mock lateinit var danaRv2Plugin: DanaRv2Plugin
|
||||
|
@ -49,7 +48,6 @@ open class DanaRTestBase : TestBase() {
|
|||
fun setup() {
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
|
||||
testPumpPlugin = TestPumpPlugin(injector)
|
||||
`when`(activePluginProvider.activeTreatments).thenReturn(treatmentsInterface)
|
||||
`when`(activePluginProvider.activePump).thenReturn(testPumpPlugin)
|
||||
doNothing().`when`(danaRKoreanPlugin).setPluginEnabled(anyObject(), anyBoolean())
|
||||
doNothing().`when`(danaRPlugin).setPluginEnabled(anyObject(), anyBoolean())
|
||||
|
|
|
@ -5,7 +5,6 @@ import info.nightscout.androidaps.utils.T
|
|||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
|
@ -13,12 +12,12 @@ class MsgStatusBolusExtendedTest : DanaRTestBase() {
|
|||
|
||||
@Test
|
||||
fun runTest() {
|
||||
`when`(activePluginProvider.activeTreatments).thenReturn(treatmentsInterface)
|
||||
val packet = MsgStatusBolusExtended(injector)
|
||||
// test message decoding
|
||||
val array = ByteArray(100)
|
||||
putByteToArray(array, 0, 1)
|
||||
putByteToArray(array, 1, 1)
|
||||
packet.handleMessage(array)
|
||||
Assert.assertEquals(T.mins(30).msecs() , danaPump.extendedBolusDuration)
|
||||
Assert.assertEquals(T.mins(30).msecs(), danaPump.extendedBolusDuration)
|
||||
}
|
||||
}
|
|
@ -12,11 +12,10 @@ class MsgStatusTempBasalTest : DanaRTestBase() {
|
|||
@Test fun runTest() {
|
||||
val packet = MsgStatusTempBasal(injector)
|
||||
// test message decoding
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
Assert.assertEquals(true, danaPump.isTempBasalInProgress)
|
||||
Assert.assertEquals(true, packet.isTempBasalInProgress)
|
||||
// passing an bigger number
|
||||
packet.handleMessage(createArray(34, 2.toByte()))
|
||||
Assert.assertEquals(false, danaPump.isTempBasalInProgress)
|
||||
Assert.assertEquals(false, packet.isTempBasalInProgress)
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
|||
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
|
||||
danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, danaPump, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, dateUtil, pumpSync, fabricPrivacy)
|
||||
danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync)
|
||||
}
|
||||
|
||||
@Test @Throws(Exception::class)
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class)
|
||||
class DanaRv2PluginTest : TestBaseWithProfile() {
|
||||
|
||||
@Mock lateinit var context: Context
|
||||
|
@ -51,7 +51,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
|
|||
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
|
||||
danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, danaPump, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, detailedBolusInfoStorage, temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync)
|
||||
danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, danaPump,detailedBolusInfoStorage, temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -19,12 +19,12 @@ class MsgHistoryEventsRv2Test : DanaRTestBase() {
|
|||
// test message decoding
|
||||
val array = createArray(100, 2)
|
||||
|
||||
putByteToArray(array, 0, 0xFF.toByte())
|
||||
packet.handleMessage(array)
|
||||
Assert.assertEquals(true, danaPump.historyDoneReceived)
|
||||
// passing an bigger number
|
||||
putByteToArray(array, 0, 0x01.toByte())
|
||||
packet.handleMessage(array)
|
||||
Assert.assertEquals(false, danaPump.historyDoneReceived)
|
||||
|
||||
putByteToArray(array, 0, 0xFF.toByte())
|
||||
packet.handleMessage(array)
|
||||
Assert.assertEquals(true, danaPump.historyDoneReceived)
|
||||
}
|
||||
}
|
|
@ -19,14 +19,18 @@ class DanaRS_Packet_Basal_Get_Temporary_Basal_State(
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "Requesting temporary basal status")
|
||||
}
|
||||
|
||||
var isTempBasalInProgress: Boolean = false
|
||||
var tempBasalTotalSec: Int = 0
|
||||
var tempBasalPercent: Int = 0
|
||||
|
||||
override fun handleMessage(data: ByteArray) {
|
||||
val error = byteArrayToInt(getBytes(data, DATA_START, 1))
|
||||
val isTempBasalInProgress = byteArrayToInt(getBytes(data, DATA_START + 1, 1)) == 0x01
|
||||
isTempBasalInProgress = byteArrayToInt(getBytes(data, DATA_START + 1, 1)) == 0x01
|
||||
val isAPSTempBasalInProgress = byteArrayToInt(getBytes(data, DATA_START + 1, 1)) == 0x02
|
||||
var tempBasalPercent = byteArrayToInt(getBytes(data, DATA_START + 2, 1))
|
||||
tempBasalPercent = byteArrayToInt(getBytes(data, DATA_START + 2, 1))
|
||||
if (tempBasalPercent > 200) tempBasalPercent = (tempBasalPercent - 200) * 10
|
||||
val durationHour = byteArrayToInt(getBytes(data, DATA_START + 3, 1))
|
||||
val tempBasalTotalSec: Int = if (durationHour == 150) 15 * 60 else if (durationHour == 160) 30 * 60 else durationHour * 60 * 60
|
||||
tempBasalTotalSec = if (durationHour == 150) 15 * 60 else if (durationHour == 160) 30 * 60 else durationHour * 60 * 60
|
||||
val runningMin = byteArrayToInt(getBytes(data, DATA_START + 4, 2))
|
||||
if (error != 0) failed = true
|
||||
val tempBasalRemainingMin = (danaPump.tempBasalTotalSec - runningMin * 60) / 60
|
||||
|
|
|
@ -18,13 +18,15 @@ class DanaRS_Packet_Bolus_Get_Extended_Bolus_State(
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||
}
|
||||
|
||||
var isExtendedInProgress: Boolean = false
|
||||
|
||||
override fun handleMessage(data: ByteArray) {
|
||||
var dataIndex = DATA_START
|
||||
var dataSize = 1
|
||||
val error = byteArrayToInt(getBytes(data, dataIndex, dataSize))
|
||||
dataIndex += dataSize
|
||||
dataSize = 1
|
||||
val isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01
|
||||
isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01
|
||||
dataIndex += dataSize
|
||||
dataSize = 1
|
||||
val extendedBolusDuration = T.mins(byteArrayToInt(getBytes(data, dataIndex, dataSize)) * 30L).msecs()
|
||||
|
|
|
@ -17,13 +17,15 @@ class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||
}
|
||||
|
||||
var isExtendedInProgress: Boolean = false
|
||||
|
||||
override fun handleMessage(data: ByteArray) {
|
||||
var dataIndex = DATA_START
|
||||
var dataSize = 1
|
||||
val extendedMenuOption = byteArrayToInt(getBytes(data, dataIndex, dataSize))
|
||||
dataIndex += dataSize
|
||||
dataSize = 1
|
||||
val isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01
|
||||
isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "extendedMenuOption: $extendedMenuOption")
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConstraintChecker::class, RxBusWrapper::class, DetailedBolusInfoStorage::class)
|
||||
@PrepareForTest(ConstraintChecker::class, RxBusWrapper::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class)
|
||||
class DanaRSPluginTest : DanaRSTestBase() {
|
||||
|
||||
@Mock lateinit var context: Context
|
||||
|
|
|
@ -5,7 +5,6 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danars.comm.DanaRS_Packet
|
||||
import info.nightscout.androidaps.db.TemporaryBasal
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.junit.Before
|
||||
import org.mockito.ArgumentMatchers
|
||||
|
@ -16,16 +15,7 @@ open class DanaRSTestBase : TestBaseWithProfile() {
|
|||
|
||||
@Mock lateinit var sp: SP
|
||||
|
||||
val injector = HasAndroidInjector {
|
||||
AndroidInjector {
|
||||
if (it is TemporaryBasal) {
|
||||
it.aapsLogger = aapsLogger
|
||||
it.activePlugin = activePluginProvider
|
||||
it.profileFunction = profileFunction
|
||||
it.sp = sp
|
||||
}
|
||||
}
|
||||
}
|
||||
val injector = HasAndroidInjector { AndroidInjector { } }
|
||||
|
||||
lateinit var danaPump: DanaPump
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
import java.util.*
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(RxBusWrapper::class, DetailedBolusInfoStorage::class, DanaRSPlugin::class)
|
||||
@PrepareForTest(RxBusWrapper::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class, DanaRSPlugin::class)
|
||||
class DanaRsPacketApsHistoryEventsTest : DanaRSTestBase() {
|
||||
|
||||
@Mock lateinit var context: Context
|
||||
|
|
|
@ -34,9 +34,9 @@ class DanaRsPacketBasalGetTemporaryBasalStateTest : DanaRSTestBase() {
|
|||
putIntToArray(array, 4, 1)
|
||||
packet.handleMessage(array)
|
||||
Assert.assertTrue(packet.failed)
|
||||
Assert.assertTrue(danaPump.isTempBasalInProgress)
|
||||
Assert.assertEquals(300, danaPump.tempBasalPercent)
|
||||
Assert.assertEquals(15 * 60, danaPump.tempBasalTotalSec)
|
||||
Assert.assertTrue(packet.isTempBasalInProgress)
|
||||
Assert.assertEquals(300, packet.tempBasalPercent)
|
||||
Assert.assertEquals(15 * 60, packet.tempBasalTotalSec)
|
||||
Assert.assertEquals("BASAL__TEMPORARY_BASAL_STATE", packet.friendlyName)
|
||||
}
|
||||
}
|
|
@ -33,7 +33,6 @@ class DanaRsPacketBolusGetDualBolusTest : DanaRSTestBase() {
|
|||
packet.handleMessage(array)
|
||||
Assert.assertTrue(packet.failed)
|
||||
Assert.assertEquals(1.0, danaPump.bolusStep, 0.0)
|
||||
Assert.assertEquals(0.55, danaPump.extendedBolusAbsoluteRate, 0.0)
|
||||
Assert.assertEquals(40.0, danaPump.maxBolus, 0.0)
|
||||
|
||||
Assert.assertEquals("BOLUS__GET_DUAL_BOLUS", packet.friendlyName)
|
||||
|
|
|
@ -31,7 +31,7 @@ class DanaRsPacketBolusGetExtendedBolusStateTest : DanaRSTestBase() {
|
|||
testValue = 1.0
|
||||
packet.handleMessage(createArray(11, testValue.toInt().toByte()))
|
||||
// is extended bolus in progress
|
||||
Assert.assertEquals(testValue == 1.0, danaPump.isExtendedInProgress)
|
||||
Assert.assertEquals(testValue == 1.0, packet.isExtendedInProgress)
|
||||
Assert.assertEquals(testValue != 0.0, packet.failed)
|
||||
Assert.assertEquals("BOLUS__GET_EXTENDED_BOLUS_STATE", packet.friendlyName)
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ class DanaRsPacketBolusGetExtendedMenuOptionStateTest : DanaRSTestBase() {
|
|||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 0.toByte()))
|
||||
// isExtendedInProgress should be false
|
||||
Assert.assertEquals(false, danaPump.isExtendedInProgress)
|
||||
Assert.assertEquals(false, packet.isExtendedInProgress)
|
||||
// assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
Assert.assertEquals(true, danaPump.isExtendedInProgress)
|
||||
Assert.assertEquals(true, packet.isExtendedInProgress)
|
||||
Assert.assertEquals("BOLUS__GET_EXTENDED_MENU_OPTION_STATE", packet.friendlyName)
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class)
|
||||
class DanaRsPacketBolusSetStepBolusStartTest : DanaRSTestBase() {
|
||||
|
||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||
|
|
|
@ -44,8 +44,6 @@ class DanaRsPacketGeneralGetMoreInformationTest : DanaRSTestBase() {
|
|||
Assert.assertFalse(packet.failed)
|
||||
Assert.assertEquals(6.0, danaPump.iob, 0.01)
|
||||
Assert.assertEquals(12.5, danaPump.dailyTotalUnits, 0.01)
|
||||
Assert.assertTrue(danaPump.isExtendedInProgress)
|
||||
Assert.assertEquals(150, danaPump.extendedBolusRemainingMinutes)
|
||||
val lastBolus = Calendar.getInstance()
|
||||
lastBolus.timeInMillis = danaPump.lastBolusTime
|
||||
Assert.assertEquals(15, lastBolus.get(Calendar.HOUR_OF_DAY))
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConstraintChecker::class, RxBusWrapper::class, DetailedBolusInfoStorage::class)
|
||||
@PrepareForTest(ConstraintChecker::class, RxBusWrapper::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class)
|
||||
class DanaRsPacketNotifyDeliveryRateDisplayTest : DanaRSTestBase() {
|
||||
|
||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||
|
|
|
@ -33,6 +33,7 @@ object SealedClassHelper {
|
|||
val x = gson.fromJson<T>(jsonReader, innerClass.javaObjectType)
|
||||
jsonReader.endObject()
|
||||
// if there a static object, actually return that
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return innerClass.objectInstance as T? ?: x
|
||||
}
|
||||
|
||||
|
|
|
@ -68,9 +68,10 @@ public class OmnipodErosPumpPluginTest {
|
|||
OmnipodErosPumpPlugin plugin = new OmnipodErosPumpPlugin(injector, aapsLogger, new TestAapsSchedulers(), rxBusWrapper, null,
|
||||
resourceHelper, activePluginProvider, null, null, aapsOmnipodErosManager, commandQueueProvider,
|
||||
null, null, null, null,
|
||||
rileyLinkUtil, null, null, null
|
||||
rileyLinkUtil, null, null, pumpSync
|
||||
);
|
||||
when(pumpSync.expectedPumpState().getTemporaryBasal()).thenReturn(null);
|
||||
PumpSync.PumpState pumpState = new PumpSync.PumpState(null, null, null, null);
|
||||
when(pumpSync.expectedPumpState()).thenReturn(pumpState);
|
||||
when(rileyLinkUtil.getRileyLinkHistory()).thenReturn(new ArrayList<>());
|
||||
when(injector.androidInjector()).thenReturn(instance -> {
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue