DanaR tests migration
This commit is contained in:
parent
d7ad8eeefc
commit
f20a1efe74
40
danar/src/test/java/info/nightscout/androidaps/TestBase.kt
Normal file
40
danar/src/test/java/info/nightscout/androidaps/TestBase.kt
Normal file
|
@ -0,0 +1,40 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import info.nightscout.androidaps.logging.AAPSLoggerTest
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.junit.MockitoRule
|
||||
import java.util.*
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
open class TestBase {
|
||||
|
||||
val aapsLogger = AAPSLoggerTest()
|
||||
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
||||
|
||||
// Add a JUnit rule that will setup the @Mock annotated vars and log.
|
||||
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
|
||||
@get:Rule
|
||||
val mockitoRule: MockitoRule = MockitoJUnit.rule()
|
||||
|
||||
@Before
|
||||
fun setupLocale() {
|
||||
Locale.setDefault(Locale.ENGLISH)
|
||||
System.setProperty("disableFirebase", "true")
|
||||
}
|
||||
|
||||
// Workaround for Kotlin nullability.
|
||||
// https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791
|
||||
// https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin
|
||||
fun <T> anyObject(): T {
|
||||
Mockito.any<T>()
|
||||
return uninitialized()
|
||||
}
|
||||
|
||||
@Suppress("Unchecked_Cast")
|
||||
fun <T> uninitialized(): T = null as T
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.db.ProfileSwitch
|
||||
import info.nightscout.androidaps.db.Treatment
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.ConfigInterface
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.interfaces.ProfileStore
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.json.JSONObject
|
||||
import org.junit.Before
|
||||
import org.mockito.Mock
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@PrepareForTest(FabricPrivacy::class)
|
||||
open class TestBaseWithProfile : TestBase() {
|
||||
|
||||
@Mock lateinit var activePluginProvider: ActivePluginProvider
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var treatmentsInterface: TreatmentsInterface
|
||||
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Mock lateinit var dateUtil: DateUtil
|
||||
@Mock lateinit var configInterface: ConfigInterface
|
||||
|
||||
val rxBus = RxBusWrapper(aapsSchedulers)
|
||||
|
||||
val profileInjector = HasAndroidInjector {
|
||||
AndroidInjector {
|
||||
if (it is Profile) {
|
||||
it.aapsLogger = aapsLogger
|
||||
it.activePlugin = activePluginProvider
|
||||
it.resourceHelper = resourceHelper
|
||||
it.rxBus = rxBus
|
||||
it.fabricPrivacy = fabricPrivacy
|
||||
it.configInterface = configInterface
|
||||
}
|
||||
if (it is ProfileSwitch) {
|
||||
it.treatmentsPlugin = treatmentsInterface
|
||||
it.aapsLogger = aapsLogger
|
||||
it.rxBus = rxBus
|
||||
it.resourceHelper = resourceHelper
|
||||
it.dateUtil = dateUtil
|
||||
}
|
||||
if (it is Treatment) {
|
||||
it.activePlugin = activePluginProvider
|
||||
it.profileFunction = profileFunction
|
||||
it.defaultValueHelper = defaultValueHelper
|
||||
it.resourceHelper = resourceHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var validProfileJSON: String
|
||||
lateinit var validProfile: Profile
|
||||
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
|
||||
|
||||
@Before
|
||||
fun prepareMock() {
|
||||
validProfileJSON = "{\"dia\":\"3\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"100\"},{\"time\":\"2:00\",\"value\":\"110\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4\"}],\"target_high\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
||||
validProfile = Profile(profileInjector, JSONObject(validProfileJSON), Constants.MGDL)
|
||||
}
|
||||
|
||||
fun getValidProfileStore(): ProfileStore {
|
||||
val json = JSONObject()
|
||||
val store = JSONObject()
|
||||
store.put(TESTPROFILENAME, JSONObject(validProfileJSON))
|
||||
json.put("defaultProfile", TESTPROFILENAME)
|
||||
json.put("store", store)
|
||||
return ProfileStore(profileInjector, json)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.data.PumpEnactResult
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface
|
||||
import info.nightscout.androidaps.plugins.common.ManufacturerType
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
import info.nightscout.androidaps.utils.TimeChangeType
|
||||
import org.json.JSONObject
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
class TestPumpPlugin(val injector: HasAndroidInjector) : PumpInterface {
|
||||
|
||||
var connected = false
|
||||
var isProfileSet = true
|
||||
|
||||
override fun isConnected() = connected
|
||||
override fun isConnecting() = false
|
||||
override fun isHandshakeInProgress() = false
|
||||
val lastData = 0L
|
||||
|
||||
val baseBasal = 0.0
|
||||
override val pumpDescription = PumpDescription()
|
||||
|
||||
override fun isInitialized(): Boolean = true
|
||||
override fun isSuspended(): Boolean = false
|
||||
override fun isBusy(): Boolean = false
|
||||
override fun connect(reason: String) {
|
||||
connected = true
|
||||
}
|
||||
|
||||
override fun disconnect(reason: String) {
|
||||
connected = false
|
||||
}
|
||||
|
||||
override fun stopConnecting() {
|
||||
connected = false
|
||||
}
|
||||
|
||||
override fun waitForDisconnectionInSeconds(): Int = 0
|
||||
override fun getPumpStatus(reason: String) {}
|
||||
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
|
||||
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
|
||||
override fun lastDataTime(): Long = lastData
|
||||
override val baseBasalRate: Double = baseBasal
|
||||
override val reservoirLevel: Double = 0.0
|
||||
override val batteryLevel: Int = 0
|
||||
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true)
|
||||
override fun stopBolusDelivering() {}
|
||||
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
|
||||
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
|
||||
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
|
||||
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
|
||||
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
|
||||
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
|
||||
override fun manufacturer(): ManufacturerType = ManufacturerType.AndroidAPS
|
||||
override fun model(): PumpType = PumpType.GenericAAPS
|
||||
override fun serialNumber(): String = "1"
|
||||
override fun shortStatus(veryShort: Boolean): String = ""
|
||||
override val isFakingTempsByExtendedBoluses: Boolean = false
|
||||
override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true)
|
||||
override fun canHandleDST(): Boolean = true
|
||||
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
|
||||
}
|
|
@ -4,10 +4,10 @@ import android.content.Context
|
|||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
|
@ -45,7 +45,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
|
|||
`when`(resourceHelper.gs(R.string.pumplimit)).thenReturn("pump limit")
|
||||
`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 = info.nightscout.androidaps.dana.DanaPump(aapsLogger, sp, injector)
|
||||
danaPump = DanaPump(aapsLogger, sp, injector)
|
||||
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy)
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
|
|||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.TestPumpPlugin
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||
|
@ -20,9 +21,11 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
|
|||
import org.junit.Before
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.anyBoolean
|
||||
import org.mockito.Mockito.doNothing
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
|
||||
@PrepareForTest(DetailedBolusInfoStorage::class, ConstraintChecker::class)
|
||||
@PrepareForTest(DetailedBolusInfoStorage::class, ConstraintChecker::class, DanaRKoreanPlugin::class, DanaRPlugin::class)
|
||||
open class DanaRTestBase : TestBase() {
|
||||
|
||||
@Mock lateinit var sp: SP
|
||||
|
@ -41,9 +44,16 @@ open class DanaRTestBase : TestBase() {
|
|||
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||
@Mock lateinit var nsUpload: NSUpload
|
||||
|
||||
lateinit var testPumpPlugin: TestPumpPlugin
|
||||
|
||||
@Before
|
||||
fun prepareMock() {
|
||||
fun setup() {
|
||||
danaPump = DanaPump(aapsLogger, sp, 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())
|
||||
}
|
||||
|
||||
val injector = HasAndroidInjector {
|
||||
|
@ -102,9 +112,4 @@ open class DanaRTestBase : TestBase() {
|
|||
array[6 + position] = value
|
||||
return array
|
||||
}
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
danaPump = info.nightscout.androidaps.dana.DanaPump(aapsLogger, sp, injector)
|
||||
}
|
||||
}
|
|
@ -2,21 +2,15 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
|
|||
|
||||
import info.nightscout.androidaps.danar.comm.MessageHashTableR
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, ConfigBuilderPlugin::class)
|
||||
class MessageHashTableRTest : DanaRTestBase() {
|
||||
|
||||
|
||||
@Test fun runTest() {
|
||||
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||
val messageHashTable = MessageHashTableR(injector)
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.androidaps.danar.comm.MsgBolusProgress
|
||||
import info.nightscout.androidaps.db.Treatment
|
||||
import org.junit.Assert
|
||||
|
@ -15,7 +15,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@RunWith(PowerMockRunner::class)
|
||||
class MsgBolusProgressTest : DanaRTestBase() {
|
||||
|
||||
|
||||
@Test fun runTest() {
|
||||
`when`(resourceHelper.gs(ArgumentMatchers.eq(R.string.bolusdelivering), ArgumentMatchers.anyDouble())).thenReturn("Delivering %1\$.2fU")
|
||||
danaPump.bolusingTreatment = Treatment(HasAndroidInjector { AndroidInjector { } })
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.androidaps.danar.comm.MsgBolusStop
|
||||
import info.nightscout.androidaps.db.Treatment
|
||||
import org.junit.Assert
|
|
@ -1,20 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.danar.comm.MsgError
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(NSUpload::class)
|
||||
class MsgErrorTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
PowerMockito.mockStatic(NSUpload::class.java)
|
||||
val packet = MsgError(injector)
|
||||
|
||||
// test message decoding
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryAlarmTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryAlarm(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -1,14 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.danar.comm.MsgHistoryAll
|
||||
import info.nightscout.androidaps.db.DatabaseHelper
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryBasalHourTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryBasalHour(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryBolusTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryBolus(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryCarboTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryCarbo(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryDailyInsulinTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryDailyInsulin(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryDoneTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryDone(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryErrorTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryError(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryGlucoseTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryGlucose(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryNewDoneTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryNewDone(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryNewTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryNew(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistoryRefillTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistoryRefill(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class MsgHistorySuspendTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val packet = MsgHistorySuspend(injector)
|
||||
// nothing left to test
|
||||
}
|
|
@ -1,21 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusOption
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(VirtualPumpPlugin::class)
|
||||
class MsgInitConnStatusOptionTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
`when`(activePluginProvider.activePump).thenReturn(PowerMockito.mock(VirtualPumpPlugin::class.java))
|
||||
val packet = MsgInitConnStatusOption(injector)
|
||||
|
||||
// test message decoding
|
|
@ -1,18 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusTime
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(DanaRKoreanPlugin::class, DanaRPlugin::class, ConfigBuilderPlugin::class, CommandQueueProvider::class)
|
||||
class MsgInitConnStatusTimeTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
|
@ -16,7 +16,7 @@ class MsgSettingPumpTimeTest : DanaRTestBase() {
|
|||
danaPump.units = DanaPump.UNITS_MGDL
|
||||
// test message decoding
|
||||
val bytes = createArray(34, 7.toByte())
|
||||
val time = Date(
|
||||
val time = GregorianCalendar(
|
||||
100 + packet.intFromBuff(bytes, 5, 1),
|
||||
packet.intFromBuff(bytes, 4, 1) - 1,
|
||||
packet.intFromBuff(bytes, 3, 1),
|
|
@ -1,20 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConfigBuilderPlugin::class)
|
||||
class MsgStatusTempBasalTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
`when`(activePluginProvider.activeTreatments).thenReturn(treatmentsInterface)
|
||||
val packet = MsgStatusTempBasal(injector)
|
||||
// test message decoding
|
||||
// test message decoding
|
|
@ -4,10 +4,10 @@ import android.content.Context
|
|||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
|
@ -2,22 +2,16 @@ package info.nightscout.androidaps.plugins.pump.danaRKorean.comm
|
|||
|
||||
import info.nightscout.androidaps.danaRKorean.comm.MessageHashTableRKorean
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, ConfigBuilderPlugin::class)
|
||||
class MessageHashTableRKoreanTest : DanaRTestBase() {
|
||||
|
||||
|
||||
@Test fun runTest() {
|
||||
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||
val messageHashTable = MessageHashTableRKorean(injector)
|
|
@ -4,10 +4,10 @@ import android.content.Context
|
|||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
|
@ -4,20 +4,15 @@ import info.nightscout.androidaps.danaRv2.comm.MessageHashTableRv2
|
|||
import info.nightscout.androidaps.danaRv2.comm.MsgStatusAPS_v2
|
||||
import info.nightscout.androidaps.danar.comm.MessageBase
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, ConfigBuilderPlugin::class)
|
||||
class MessageHashTable_rv2Test : DanaRTestBase() {
|
||||
class MessageHashTableRv2Test : DanaRTestBase() {
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
|
@ -1,21 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||
import info.nightscout.androidaps.danaRv2.comm.MsgCheckValue_v2
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(DanaRKoreanPlugin::class, DanaRPlugin::class, DanaRv2Plugin::class, ConfigBuilderPlugin::class)
|
||||
class MsgCheckValue_v2Test : DanaRTestBase() {
|
||||
class MsgCheckValueRv2Test : DanaRTestBase() {
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
|
@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(DetailedBolusInfoStorage::class)
|
||||
class MsgHistoryEvents_v2Test : DanaRTestBase() {
|
||||
class MsgHistoryEventsRv2Test : DanaRTestBase() {
|
||||
|
||||
@Test @Throws(Exception::class) fun runTest() {
|
||||
val packet = MsgHistoryEvents_v2(injector, 0)
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||
|
||||
import info.nightscout.androidaps.danars.comm.DanaRS_Packet_APS_Basal_Set_Temporary_Basal.Companion.PARAM30MIN
|
||||
import info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
@ -8,36 +8,36 @@ import org.junit.runner.RunWith
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetAPSTempBasalStart_v2Test : DanaRTestBase() {
|
||||
class MsgSetAPSTempBasalStartRv2Test : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
|
||||
// test low hard limit
|
||||
var packet = info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2(injector, -1, true, false)
|
||||
var packet = MsgSetAPSTempBasalStart_v2(injector, -1, true, false)
|
||||
Assert.assertEquals(0, packet.intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||
// test high hard limit
|
||||
packet = info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2(injector, 550, true, false)
|
||||
packet = MsgSetAPSTempBasalStart_v2(injector, 550, true, false)
|
||||
Assert.assertEquals(500, packet.intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||
// test setting 15 min
|
||||
packet = info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2(injector, 50, true, false)
|
||||
packet = MsgSetAPSTempBasalStart_v2(injector, 50, true, false)
|
||||
Assert.assertEquals(50, packet.intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||
// test setting 30 min
|
||||
packet = info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2(injector, 50, false, true)
|
||||
packet = MsgSetAPSTempBasalStart_v2(injector, 50, false, true)
|
||||
Assert.assertEquals(50, packet.intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||
Assert.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||
// over 200% set always 15 min
|
||||
packet = info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2(injector, 250, false, true)
|
||||
packet = MsgSetAPSTempBasalStart_v2(injector, 250, false, true)
|
||||
Assert.assertEquals(250, packet.intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||
// test low hard limit
|
||||
packet = info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2(injector, -1, false, true)
|
||||
packet = MsgSetAPSTempBasalStart_v2(injector, -1, false, true)
|
||||
Assert.assertEquals(0, packet.intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||
Assert.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||
// test high hard limit
|
||||
packet = info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2(injector, 550, false, true)
|
||||
packet = MsgSetAPSTempBasalStart_v2(injector, 550, false, true)
|
||||
Assert.assertEquals(500, packet.intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||
|
|
@ -8,7 +8,7 @@ import org.junit.runner.RunWith
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetHistoryEntry_v2Test : DanaRTestBase() {
|
||||
class MsgSetHistoryEntryRv2Test : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSetHistoryEntry_v2(injector, 1, System.currentTimeMillis(), 1, 0)
|
|
@ -8,7 +8,7 @@ import org.junit.runner.RunWith
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusAPS_v2Test : DanaRTestBase() {
|
||||
class MsgStatusAPSRv2Test : DanaRTestBase() {
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
|
@ -8,7 +8,7 @@ import org.junit.runner.RunWith
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusBolusExtended_v2Test : DanaRTestBase() {
|
||||
class MsgStatusBolusExtendedRv2Test : DanaRTestBase() {
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
|
@ -8,7 +8,7 @@ import org.junit.runner.RunWith
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusTempBasal_v2Test : DanaRTestBase() {
|
||||
class MsgStatusTempBasalRv2Test : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgStatusTempBasal_v2(injector)
|
Loading…
Reference in a new issue