tests cleanup
This commit is contained in:
parent
7e9402b939
commit
46efb92d3d
|
@ -19,17 +19,17 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class VersionCheckerUtils @Inject constructor() {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var mainApp: MainApp
|
||||
class VersionCheckerUtils @Inject constructor(
|
||||
val aapsLogger: AAPSLogger,
|
||||
val sp: SP,
|
||||
val resourceHelper: ResourceHelper,
|
||||
val rxBus: RxBusWrapper,
|
||||
val context: Context
|
||||
) {
|
||||
|
||||
// check network connection
|
||||
fun isConnected(): Boolean {
|
||||
val connMgr = mainApp.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val connMgr = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
return connMgr.activeNetworkInfo?.isConnected ?: false
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,6 @@ class VersionCheckerUtils @Inject constructor() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun String?.toNumberList() =
|
||||
this?.numericVersionPart().takeIf { !it.isNullOrBlank() }?.split(".")?.map { it.toInt() }
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package info
|
||||
package info.nightscout.androidaps
|
||||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.data.ProfileStore
|
||||
import org.json.JSONObject
|
|
@ -1,24 +1,29 @@
|
|||
package info.nightscout.androidaps.data.defaultProfile
|
||||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.Constants
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class DefaultProfileTest {
|
||||
class DefaultProfileTest : TestBase() {
|
||||
|
||||
val injector = HasAndroidInjector { AndroidInjector { } }
|
||||
|
||||
@Test
|
||||
fun profile() {
|
||||
var p = DefaultProfile().profile(5.0, 5.1 / 0.3, 0.0, Constants.MGDL)
|
||||
var p = DefaultProfile(injector).profile(5.0, 5.1 / 0.3, 0.0, Constants.MGDL)
|
||||
assertEquals(0.150, p.getBasalTimeFromMidnight(0), 0.001)
|
||||
assertEquals(15.0, p.getIcTimeFromMidnight(0), 0.001)
|
||||
assertEquals(11.8, p.getIsfTimeFromMidnight(0), 0.001)
|
||||
|
||||
p = DefaultProfile().profile(7.0, 10.0 / 0.4, 0.0, Constants.MGDL)
|
||||
p = DefaultProfile(injector).profile(7.0, 10.0 / 0.4, 0.0, Constants.MGDL)
|
||||
assertEquals(0.350, p.getBasalTimeFromMidnight(0), 0.001)
|
||||
assertEquals(15.0, p.getIcTimeFromMidnight(0), 0.001)
|
||||
assertEquals(6.8, p.getIsfTimeFromMidnight(0), 0.001)
|
||||
|
||||
p = DefaultProfile().profile(12.0, 25.0 / 0.5, 0.0, Constants.MGDL)
|
||||
p = DefaultProfile(injector).profile(12.0, 25.0 / 0.5, 0.0, Constants.MGDL)
|
||||
assertEquals(0.80, p.getBasalTimeFromMidnight(0), 0.001)
|
||||
assertEquals(10.0, p.getIcTimeFromMidnight(0), 0.001)
|
||||
assertEquals(2.2, p.getIsfTimeFromMidnight(0), 0.001)
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.db
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.androidaps.interfaces
|
||||
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.interfaces
|
|||
import android.content.Context
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.aps.loop
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.db.TemporaryBasal
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
|
|
|
@ -3,12 +3,11 @@ package info.nightscout.androidaps.plugins.configBuilder
|
|||
import dagger.Lazy
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
|
@ -17,7 +16,6 @@ import org.junit.Before
|
|||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
|
|
|
@ -1,15 +1,31 @@
|
|||
package info.nightscout.androidaps.plugins.constraints.signatureVerifier
|
||||
|
||||
import org.junit.Assert.fail
|
||||
import android.content.Context
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
|
||||
class SignatureVerifierPluginTest {
|
||||
class SignatureVerifierPluginTest : TestBase() {
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var context: Context
|
||||
private val rxBus = RxBusWrapper()
|
||||
|
||||
val injector = HasAndroidInjector { AndroidInjector { } }
|
||||
|
||||
@Test
|
||||
fun singleCharUnMapTest() {
|
||||
val plugin = SignatureVerifierPlugin(injector, aapsLogger, resourceHelper, sp, rxBus, context)
|
||||
val key = "2ΙšÄΠΒϨÒÇeЄtЄЗž-*Ж*ZcHijЊÄœ<|x\"Ε"
|
||||
fail() // TODO fix test
|
||||
//val unmapped = SignatureVerifierPlugin.getPlugin().singleCharUnMap(key)
|
||||
// assertEquals("32:99:61:C4:A0:92:E8:D2:C7:65:04:74:04:17:7E:2D:2A:16:2A:5A:63:48:69:6A:0A:C4:53:3C:7C:78:22:95", unmapped)
|
||||
val unmapped = plugin.singleCharUnMap(key)
|
||||
Assert.assertEquals("32:99:61:C4:A0:92:E8:D2:C7:65:04:74:04:17:7E:2D:2A:16:2A:5A:63:48:69:6A:0A:C4:53:3C:7C:78:22:95", unmapped)
|
||||
}
|
||||
}
|
|
@ -1,46 +1,29 @@
|
|||
package info.nightscout.androidaps.plugins.constraints.versionChecker
|
||||
|
||||
import android.content.Context
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.any
|
||||
import org.mockito.Mockito.eq
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.times
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.junit.MockitoRule
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
|
||||
class VersionCheckerUtilsKtTest {
|
||||
|
||||
|
||||
@get:Rule
|
||||
val mockitoRule: MockitoRule = MockitoJUnit.rule()
|
||||
class VersionCheckerUtilsKtTest : TestBase() {
|
||||
|
||||
lateinit var versionCheckerUtils: VersionCheckerUtils
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var sp: info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var rxBusWrapper: RxBusWrapper
|
||||
@Mock lateinit var context: Context
|
||||
|
||||
val rxBus = RxBusWrapper()
|
||||
|
||||
@Before fun setup() {
|
||||
versionCheckerUtils = VersionCheckerUtils()
|
||||
versionCheckerUtils = VersionCheckerUtils(aapsLogger, sp, resourceHelper, rxBus, context)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -118,6 +101,7 @@ class VersionCheckerUtilsKtTest {
|
|||
assertEquals("2.2.2", detectedVersion)
|
||||
}
|
||||
|
||||
/* TODO finish this tests
|
||||
// In case we merge a "x.x.x-dev" into master, don't see it as update.
|
||||
@Test
|
||||
fun `should return null on non-digit versions on master`() {
|
||||
|
@ -494,5 +478,5 @@ class VersionCheckerUtilsKtTest {
|
|||
PowerMockito.mockStatic(L::class.java)
|
||||
`when`(L.isEnabled(any())).thenReturn(true)
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDummy
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.data.PumpEnactResult
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.smsCommunicator
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.smsCommunicator
|
|||
import android.telephony.SmsManager
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.general.smsCommunicator
|
||||
|
||||
import android.telephony.SmsMessage
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.insulin
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
|
@ -12,15 +12,11 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.ArgumentMatchers.eq
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.junit.MockitoRule
|
||||
|
||||
/**
|
||||
* Created by adrian on 2019-12-25.
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.combo
|
|||
import android.content.Context
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.bolusInfo
|
||||
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import org.junit.Assert.assertEquals
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.danaR
|
|||
import android.content.Context
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.danaRKorean
|
|||
import android.content.Context
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.danaRv2
|
|||
import android.content.Context
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
|
|
|
@ -1,70 +1,38 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||
|
||||
import info.AAPSMocker
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSTestBase
|
||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin
|
||||
import info.nightscout.androidaps.queue.CommandQueue
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.mockito.Mock
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(MainApp::class, SP::class, L::class, ConfigBuilderPlugin::class, CommandQueue::class, DanaRKoreanPlugin::class, DanaRPlugin::class, DanaRv2Plugin::class)
|
||||
class MsgCheckValue_v2Test {
|
||||
@PrepareForTest(DanaRKoreanPlugin::class, DanaRPlugin::class, DanaRv2Plugin::class)
|
||||
class MsgCheckValue_v2Test : DanaRSTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgCheckValue_v2()
|
||||
val rxBus = RxBusWrapper()
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var danaRPlugin: DanaRPlugin
|
||||
@Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||
@Mock lateinit var danaRv2Plugin: DanaRv2Plugin
|
||||
@Mock lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
||||
val packet = MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 3.toByte()))
|
||||
val pump = DanaRPump.getInstance()
|
||||
Assert.assertEquals(DanaRPump.EXPORT_MODEL.toLong(), pump.model.toLong())
|
||||
}
|
||||
|
||||
fun createArray(length: Int, fillWith: Byte): ByteArray {
|
||||
val ret = ByteArray(length)
|
||||
for (i in 0 until length) {
|
||||
ret[i] = fillWith
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
fun createArray(length: Int, fillWith: Double): DoubleArray {
|
||||
val ret = DoubleArray(length)
|
||||
for (i in 0 until length) {
|
||||
ret[i] = fillWith
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@Before
|
||||
fun mock() {
|
||||
AAPSMocker.mockMainApp()
|
||||
AAPSMocker.mockApplicationContext()
|
||||
AAPSMocker.mockSP()
|
||||
AAPSMocker.mockL()
|
||||
AAPSMocker.mockConfigBuilder()
|
||||
AAPSMocker.mockCommandQueue()
|
||||
|
||||
PowerMockito.mockStatic(DanaRKoreanPlugin::class.java)
|
||||
val drk = PowerMockito.mock(DanaRKoreanPlugin::class.java)
|
||||
PowerMockito.`when`(DanaRKoreanPlugin.getPlugin()).thenReturn(drk)
|
||||
|
||||
PowerMockito.mockStatic(DanaRPlugin::class.java)
|
||||
val dr = PowerMockito.mock(DanaRPlugin::class.java)
|
||||
PowerMockito.`when`(DanaRPlugin.getPlugin()).thenReturn(dr)
|
||||
|
||||
PowerMockito.mockStatic(DanaRv2Plugin::class.java)
|
||||
val drv2 = PowerMockito.mock(DanaRv2Plugin::class.java)
|
||||
PowerMockito.`when`(DanaRv2Plugin.getPlugin()).thenReturn(drv2)
|
||||
Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.model)
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.sensitivity
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.source
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.source
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.source
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.source
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context
|
|||
import dagger.Lazy
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.androidaps.utils
|
||||
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.utils.wizard
|
|||
import android.content.Context
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.TestBase
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.data.IobTotal
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
|
|
Loading…
Reference in a new issue