shared-tests #8
This commit is contained in:
parent
3477fcb46a
commit
1cd93cdc1e
|
@ -25,7 +25,8 @@ dependencies {
|
||||||
implementation project(':core:utils')
|
implementation project(':core:utils')
|
||||||
implementation project(':app-wear-shared:shared')
|
implementation project(':app-wear-shared:shared')
|
||||||
|
|
||||||
|
testImplementation project(':app-wear-shared:shared-tests')
|
||||||
|
|
||||||
// RuffyScripter
|
// RuffyScripter
|
||||||
api "com.google.guava:guava:$guava_version"
|
api "com.google.guava:guava:$guava_version"
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@ package info.nightscout.pump.combo
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
@ -17,7 +16,8 @@ import info.nightscout.rx.bus.RxBus
|
||||||
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 info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import org.junit.Assert
|
import info.nightscout.sharedtests.TestBase
|
||||||
|
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
|
||||||
|
@ -58,8 +58,8 @@ class ComboPluginTest : TestBase() {
|
||||||
comboPlugin.setValidBasalRateProfileSelectedOnPump(false)
|
comboPlugin.setValidBasalRateProfileSelectedOnPump(false)
|
||||||
var c = Constraint(true)
|
var c = Constraint(true)
|
||||||
c = comboPlugin.isLoopInvocationAllowed(c)
|
c = comboPlugin.isLoopInvocationAllowed(c)
|
||||||
Assert.assertEquals("Combo: No valid basal rate read from pump", c.getReasons(aapsLogger))
|
Assertions.assertEquals("Combo: No valid basal rate read from pump", c.getReasons(aapsLogger))
|
||||||
Assert.assertEquals(false, c.value())
|
Assertions.assertEquals(false, c.value())
|
||||||
comboPlugin.setPluginEnabled(PluginType.PUMP, false)
|
comboPlugin.setPluginEnabled(PluginType.PUMP, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,18 +68,18 @@ class ComboPluginTest : TestBase() {
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
val pumpTimestamp = now - now % 1000
|
val pumpTimestamp = now - now % 1000
|
||||||
// same timestamp, different bolus leads to different fake timestamp
|
// same timestamp, different bolus leads to different fake timestamp
|
||||||
Assert.assertNotEquals(
|
Assertions.assertNotEquals(
|
||||||
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.1, true)),
|
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.1, true)),
|
||||||
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true))
|
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true))
|
||||||
)
|
)
|
||||||
// different timestamp, same bolus leads to different fake timestamp
|
// different timestamp, same bolus leads to different fake timestamp
|
||||||
Assert.assertNotEquals(
|
Assertions.assertNotEquals(
|
||||||
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true)),
|
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true)),
|
||||||
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp + 60 * 1000, 0.3, true))
|
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp + 60 * 1000, 0.3, true))
|
||||||
)
|
)
|
||||||
// generated timestamp has second-precision
|
// generated timestamp has second-precision
|
||||||
val bolus = Bolus(pumpTimestamp, 0.2, true)
|
val bolus = Bolus(pumpTimestamp, 0.2, true)
|
||||||
val calculatedTimestamp = comboPlugin.generatePumpBolusId(bolus)
|
val calculatedTimestamp = comboPlugin.generatePumpBolusId(bolus)
|
||||||
Assert.assertEquals(calculatedTimestamp, calculatedTimestamp - calculatedTimestamp % 1000)
|
Assertions.assertEquals(calculatedTimestamp, calculatedTimestamp - calculatedTimestamp % 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,38 +0,0 @@
|
||||||
package info.nightscout.androidaps
|
|
||||||
|
|
||||||
import info.nightscout.rx.AapsSchedulers
|
|
||||||
import info.nightscout.rx.TestAapsSchedulers
|
|
||||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith
|
|
||||||
import org.mockito.Mockito
|
|
||||||
import org.mockito.junit.jupiter.MockitoExtension
|
|
||||||
import org.mockito.junit.jupiter.MockitoSettings
|
|
||||||
import org.mockito.quality.Strictness
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
|
||||||
@ExtendWith(MockitoExtension::class)
|
|
||||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
|
||||||
open class TestBase {
|
|
||||||
|
|
||||||
val aapsLogger = AAPSLoggerTest()
|
|
||||||
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
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
|
|
||||||
}
|
|
|
@ -36,5 +36,6 @@ dependencies {
|
||||||
api "androidx.room:room-rxjava3:$room_version"
|
api "androidx.room:room-rxjava3:$room_version"
|
||||||
kapt "androidx.room:room-compiler:$room_version"
|
kapt "androidx.room:room-compiler:$room_version"
|
||||||
|
|
||||||
|
testImplementation project(':app-wear-shared:shared-tests')
|
||||||
testImplementation project(':core:main') // create profile from json
|
testImplementation project(':core:main') // create profile from json
|
||||||
}
|
}
|
|
@ -1,107 +0,0 @@
|
||||||
package info.nightscout.androidaps
|
|
||||||
|
|
||||||
import androidx.collection.ArrayMap
|
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.core.extensions.pureProfileFromJson
|
|
||||||
import info.nightscout.core.profile.ProfileSealed
|
|
||||||
import info.nightscout.interfaces.Config
|
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
|
||||||
import info.nightscout.interfaces.profile.ProfileStore
|
|
||||||
import info.nightscout.interfaces.profile.PureProfile
|
|
||||||
import info.nightscout.interfaces.utils.HardLimits
|
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
|
||||||
import info.nightscout.rx.bus.RxBus
|
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
|
||||||
import org.json.JSONException
|
|
||||||
import org.json.JSONObject
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
|
||||||
@Inject lateinit var activePlugin: ActivePlugin
|
|
||||||
@Inject lateinit var config: Config
|
|
||||||
@Inject lateinit var rh: ResourceHelper
|
|
||||||
@Inject lateinit var rxBus: RxBus
|
|
||||||
@Inject lateinit var hardLimits: HardLimits
|
|
||||||
|
|
||||||
init {
|
|
||||||
injector.androidInjector().inject(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
|
||||||
|
|
||||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
|
||||||
|
|
||||||
private fun getStore(): JSONObject? {
|
|
||||||
try {
|
|
||||||
if (data.has("store")) return data.getJSONObject("store")
|
|
||||||
} catch (e: JSONException) {
|
|
||||||
aapsLogger.error("Unhandled exception", e)
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getStartDate(): Long {
|
|
||||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
|
||||||
return try {
|
|
||||||
dateUtil.fromISODateString(iso)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
|
||||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
|
||||||
|
|
||||||
override fun getDefaultProfileName(): String? {
|
|
||||||
val defaultProfileName = data.optString("defaultProfile")
|
|
||||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getProfileList(): ArrayList<CharSequence> {
|
|
||||||
val ret = ArrayList<CharSequence>()
|
|
||||||
getStore()?.keys()?.let { keys ->
|
|
||||||
while (keys.hasNext()) {
|
|
||||||
val profileName = keys.next() as String
|
|
||||||
ret.add(profileName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
|
||||||
var profile: PureProfile? = null
|
|
||||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
|
||||||
getStore()?.let { store ->
|
|
||||||
if (store.has(profileName)) {
|
|
||||||
profile = cachedObjects[profileName]
|
|
||||||
if (profile == null) {
|
|
||||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
|
||||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
|
||||||
profile?.let { cachedObjects[profileName] = profile }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return profile
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
|
||||||
getStore()?.let { store ->
|
|
||||||
if (store.has(profileName))
|
|
||||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override val allProfilesValid: Boolean
|
|
||||||
get() = getProfileList()
|
|
||||||
.asSequence()
|
|
||||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
|
||||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
|
||||||
.all { it?.isValid == true }
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package info.nightscout.androidaps
|
|
||||||
|
|
||||||
import info.nightscout.rx.AapsSchedulers
|
|
||||||
import info.nightscout.rx.TestAapsSchedulers
|
|
||||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith
|
|
||||||
import org.mockito.Mockito
|
|
||||||
import org.mockito.junit.jupiter.MockitoExtension
|
|
||||||
import org.mockito.junit.jupiter.MockitoSettings
|
|
||||||
import org.mockito.quality.Strictness
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension::class)
|
|
||||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
|
||||||
open class TestBase {
|
|
||||||
|
|
||||||
val aapsLogger = AAPSLoggerTest()
|
|
||||||
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
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
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
package info.nightscout.androidaps
|
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
|
||||||
import info.nightscout.interfaces.Config
|
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
|
||||||
import info.nightscout.interfaces.profile.DefaultValueHelper
|
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
|
||||||
import info.nightscout.interfaces.profile.ProfileStore
|
|
||||||
import info.nightscout.rx.bus.RxBus
|
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
|
||||||
import org.json.JSONObject
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
|
||||||
import org.mockito.Mock
|
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
|
||||||
open class TestBaseWithProfile : TestBase() {
|
|
||||||
|
|
||||||
@Mock lateinit var activePluginProvider: ActivePlugin
|
|
||||||
@Mock lateinit var rh: ResourceHelper
|
|
||||||
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
|
||||||
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
|
||||||
@Mock lateinit var dateUtil: DateUtil
|
|
||||||
@Mock lateinit var config: Config
|
|
||||||
|
|
||||||
val rxBus = RxBus(aapsSchedulers, aapsLogger)
|
|
||||||
|
|
||||||
val profileInjector = HasAndroidInjector {
|
|
||||||
AndroidInjector {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private lateinit var validProfileJSON: String
|
|
||||||
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
fun prepareMock() {
|
|
||||||
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
|
|
||||||
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +
|
|
||||||
"\"target_high\":[{\"time\":\"00:00\",\"value\":\"7\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getValidProfileStore(): ProfileStore {
|
|
||||||
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
|
|
||||||
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +
|
|
||||||
"\"target_high\":[{\"time\":\"00:00\",\"value\":\"7\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
|
||||||
|
|
||||||
val json = JSONObject()
|
|
||||||
val store = JSONObject()
|
|
||||||
store.put(TESTPROFILENAME, JSONObject(validProfileJSON))
|
|
||||||
json.put("defaultProfile", TESTPROFILENAME)
|
|
||||||
json.put("store", store)
|
|
||||||
return ProfileStoreObject(profileInjector, json, dateUtil)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,7 @@
|
||||||
package info.nightscout.androidaps.dana
|
package info.nightscout.pump.dana
|
||||||
|
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
|
||||||
import info.nightscout.interfaces.profile.Instantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
|
||||||
import org.junit.jupiter.api.Assertions
|
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
|
||||||
|
@ -11,7 +9,6 @@ import org.mockito.Mock
|
||||||
|
|
||||||
class DanaPumpTest : TestBaseWithProfile() {
|
class DanaPumpTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
|
||||||
@Mock lateinit var instantiator: Instantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
|
|
||||||
private lateinit var sut: DanaPump
|
private lateinit var sut: DanaPump
|
|
@ -15,6 +15,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation 'androidx.media3:media3-common:1.1.1'
|
||||||
implementation project(':app-wear-shared:shared')
|
implementation project(':app-wear-shared:shared')
|
||||||
implementation project(':core:interfaces')
|
implementation project(':core:interfaces')
|
||||||
implementation project(':core:utils')
|
implementation project(':core:utils')
|
||||||
|
@ -22,5 +23,6 @@ dependencies {
|
||||||
implementation project(':core:validators')
|
implementation project(':core:validators')
|
||||||
implementation project(':pump:dana')
|
implementation project(':pump:dana')
|
||||||
|
|
||||||
|
testImplementation project(':app-wear-shared:shared-tests')
|
||||||
testImplementation project(':core:main')
|
testImplementation project(':core:main')
|
||||||
}
|
}
|
|
@ -1,107 +0,0 @@
|
||||||
package info.nightscout.androidaps
|
|
||||||
|
|
||||||
import androidx.collection.ArrayMap
|
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.core.extensions.pureProfileFromJson
|
|
||||||
import info.nightscout.core.profile.ProfileSealed
|
|
||||||
import info.nightscout.interfaces.Config
|
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
|
||||||
import info.nightscout.interfaces.profile.ProfileStore
|
|
||||||
import info.nightscout.interfaces.profile.PureProfile
|
|
||||||
import info.nightscout.interfaces.utils.HardLimits
|
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
|
||||||
import info.nightscout.rx.bus.RxBus
|
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
|
||||||
import org.json.JSONException
|
|
||||||
import org.json.JSONObject
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
|
||||||
@Inject lateinit var activePlugin: ActivePlugin
|
|
||||||
@Inject lateinit var config: Config
|
|
||||||
@Inject lateinit var rh: ResourceHelper
|
|
||||||
@Inject lateinit var rxBus: RxBus
|
|
||||||
@Inject lateinit var hardLimits: HardLimits
|
|
||||||
|
|
||||||
init {
|
|
||||||
injector.androidInjector().inject(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
|
||||||
|
|
||||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
|
||||||
|
|
||||||
private fun getStore(): JSONObject? {
|
|
||||||
try {
|
|
||||||
if (data.has("store")) return data.getJSONObject("store")
|
|
||||||
} catch (e: JSONException) {
|
|
||||||
aapsLogger.error("Unhandled exception", e)
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getStartDate(): Long {
|
|
||||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
|
||||||
return try {
|
|
||||||
dateUtil.fromISODateString(iso)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
|
||||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
|
||||||
|
|
||||||
override fun getDefaultProfileName(): String? {
|
|
||||||
val defaultProfileName = data.optString("defaultProfile")
|
|
||||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getProfileList(): ArrayList<CharSequence> {
|
|
||||||
val ret = ArrayList<CharSequence>()
|
|
||||||
getStore()?.keys()?.let { keys ->
|
|
||||||
while (keys.hasNext()) {
|
|
||||||
val profileName = keys.next() as String
|
|
||||||
ret.add(profileName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
|
||||||
var profile: PureProfile? = null
|
|
||||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
|
||||||
getStore()?.let { store ->
|
|
||||||
if (store.has(profileName)) {
|
|
||||||
profile = cachedObjects[profileName]
|
|
||||||
if (profile == null) {
|
|
||||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
|
||||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
|
||||||
profile?.let { cachedObjects[profileName] = profile }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return profile
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
|
||||||
getStore()?.let { store ->
|
|
||||||
if (store.has(profileName))
|
|
||||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override val allProfilesValid: Boolean
|
|
||||||
get() = getProfileList()
|
|
||||||
.asSequence()
|
|
||||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
|
||||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
|
||||||
.all { it?.isValid == true }
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package info.nightscout.androidaps
|
|
||||||
|
|
||||||
import info.nightscout.rx.AapsSchedulers
|
|
||||||
import info.nightscout.rx.TestAapsSchedulers
|
|
||||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith
|
|
||||||
import org.mockito.Mockito
|
|
||||||
import org.mockito.junit.jupiter.MockitoExtension
|
|
||||||
import org.mockito.junit.jupiter.MockitoSettings
|
|
||||||
import org.mockito.quality.Strictness
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
|
||||||
@ExtendWith(MockitoExtension::class)
|
|
||||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
|
||||||
open class TestBase {
|
|
||||||
|
|
||||||
val aapsLogger = AAPSLoggerTest()
|
|
||||||
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
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")
|
|
||||||
private fun <T> uninitialized(): T = null as T
|
|
||||||
}
|
|
|
@ -1,157 +0,0 @@
|
||||||
package info.nightscout.androidaps
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dagger.android.AndroidInjector
|
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.core.extensions.pureProfileFromJson
|
|
||||||
import info.nightscout.core.profile.ProfileSealed
|
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
|
||||||
import info.nightscout.interfaces.Config
|
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
|
||||||
import info.nightscout.interfaces.profile.ProfileStore
|
|
||||||
import info.nightscout.rx.bus.RxBus
|
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
|
||||||
import org.json.JSONObject
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
|
||||||
import org.mockito.ArgumentMatchers.anyDouble
|
|
||||||
import org.mockito.ArgumentMatchers.anyInt
|
|
||||||
import org.mockito.ArgumentMatchers.anyString
|
|
||||||
import org.mockito.Mock
|
|
||||||
import org.mockito.Mockito
|
|
||||||
import org.mockito.invocation.InvocationOnMock
|
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
|
||||||
open class TestBaseWithProfile : TestBase() {
|
|
||||||
|
|
||||||
@Mock lateinit var activePluginProvider: ActivePlugin
|
|
||||||
@Mock lateinit var rh: ResourceHelper
|
|
||||||
@Mock lateinit var iobCobCalculator: IobCobCalculator
|
|
||||||
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
|
||||||
@Mock lateinit var config: Config
|
|
||||||
@Mock lateinit var context: Context
|
|
||||||
|
|
||||||
lateinit var dateUtil: DateUtil
|
|
||||||
val rxBus = RxBus(aapsSchedulers, aapsLogger)
|
|
||||||
|
|
||||||
val profileInjector = HasAndroidInjector { AndroidInjector { } }
|
|
||||||
|
|
||||||
private lateinit var validProfileJSON: String
|
|
||||||
lateinit var validProfile: ProfileSealed.Pure
|
|
||||||
|
|
||||||
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
fun prepareMock() {
|
|
||||||
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
|
|
||||||
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +
|
|
||||||
"\"target_high\":[{\"time\":\"00:00\",\"value\":\"7\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
|
||||||
dateUtil = DateUtil(context)
|
|
||||||
validProfile = ProfileSealed.Pure(pureProfileFromJson(JSONObject(validProfileJSON), dateUtil)!!)
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<Int?>(1)
|
|
||||||
String.format(rh.gs(string), arg1)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyInt())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<Double?>(1)
|
|
||||||
String.format(rh.gs(string), arg1)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyDouble())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<String?>(1)
|
|
||||||
String.format(rh.gs(string), arg1)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyString())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<String?>(1)
|
|
||||||
val arg2 = invocation.getArgument<String?>(2)
|
|
||||||
String.format(rh.gs(string), arg1, arg2)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyString(), anyString())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<String?>(1)
|
|
||||||
val arg2 = invocation.getArgument<Int?>(2)
|
|
||||||
String.format(rh.gs(string), arg1, arg2)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyString(), anyInt())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<Double?>(1)
|
|
||||||
val arg2 = invocation.getArgument<String?>(2)
|
|
||||||
String.format(rh.gs(string), arg1, arg2)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyDouble(), anyString())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<Double?>(1)
|
|
||||||
val arg2 = invocation.getArgument<Int?>(2)
|
|
||||||
String.format(rh.gs(string), arg1, arg2)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyDouble(), anyInt())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<Int?>(1)
|
|
||||||
val arg2 = invocation.getArgument<Int?>(2)
|
|
||||||
String.format(rh.gs(string), arg1, arg2)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyInt(), anyInt())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<Int?>(1)
|
|
||||||
val arg2 = invocation.getArgument<String?>(2)
|
|
||||||
String.format(rh.gs(string), arg1, arg2)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyInt(), anyString())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<Int?>(1)
|
|
||||||
val arg2 = invocation.getArgument<Int?>(2)
|
|
||||||
val arg3 = invocation.getArgument<String?>(3)
|
|
||||||
String.format(rh.gs(string), arg1, arg2, arg3)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyInt(), anyInt(), anyString())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<Int?>(1)
|
|
||||||
val arg2 = invocation.getArgument<String?>(2)
|
|
||||||
val arg3 = invocation.getArgument<String?>(3)
|
|
||||||
String.format(rh.gs(string), arg1, arg2, arg3)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyInt(), anyString(), anyString())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<Double?>(1)
|
|
||||||
val arg2 = invocation.getArgument<Int?>(2)
|
|
||||||
val arg3 = invocation.getArgument<String?>(3)
|
|
||||||
String.format(rh.gs(string), arg1, arg2, arg3)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyDouble(), anyInt(), anyString())
|
|
||||||
|
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
|
||||||
val string = invocation.getArgument<Int>(0)
|
|
||||||
val arg1 = invocation.getArgument<String?>(1)
|
|
||||||
val arg2 = invocation.getArgument<Int?>(2)
|
|
||||||
val arg3 = invocation.getArgument<String?>(3)
|
|
||||||
String.format(rh.gs(string), arg1, arg2, arg3)
|
|
||||||
}.`when`(rh).gs(anyInt(), anyString(), anyInt(), anyString())
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getValidProfileStore(): ProfileStore {
|
|
||||||
val json = JSONObject()
|
|
||||||
val store = JSONObject()
|
|
||||||
store.put(TESTPROFILENAME, JSONObject(validProfileJSON))
|
|
||||||
json.put("defaultProfile", TESTPROFILENAME)
|
|
||||||
json.put("store", store)
|
|
||||||
return ProfileStoreObject(profileInjector, json, dateUtil)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
package info.nightscout.androidaps
|
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.interfaces.profile.Profile
|
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
|
||||||
import info.nightscout.interfaces.pump.Pump
|
|
||||||
import info.nightscout.interfaces.pump.PumpEnactResult
|
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
|
||||||
import info.nightscout.interfaces.pump.defs.ManufacturerType
|
|
||||||
import info.nightscout.interfaces.pump.defs.PumpDescription
|
|
||||||
import info.nightscout.interfaces.pump.defs.PumpType
|
|
||||||
import info.nightscout.interfaces.utils.TimeChangeType
|
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
|
|
||||||
|
|
||||||
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, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResult(injector).success(true)
|
|
||||||
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): 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.AAPS
|
|
||||||
override fun model(): PumpType = PumpType.GENERIC_AAPS
|
|
||||||
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) {}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.TestBase
|
|
||||||
import info.nightscout.androidaps.danar.comm.MessageOriginalNames
|
|
||||||
import org.junit.Assert
|
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
|
|
||||||
class MessageOriginalNamesTest : TestBase() {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun getNameTest() {
|
|
||||||
Assert.assertEquals("CMD_CONNECT", MessageOriginalNames.getName(0x3001))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
|
||||||
|
|
||||||
import info.nightscout.pump.dana.comm.RecordTypes
|
|
||||||
import org.junit.Assert
|
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
|
|
||||||
class RecordTypesTest {
|
|
||||||
|
|
||||||
@Test fun runTest() {
|
|
||||||
Assert.assertEquals(1.toByte(), RecordTypes.RECORD_TYPE_BOLUS)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
|
||||||
import org.junit.Assert
|
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
|
|
||||||
class MsgSetAPSTempBasalStartRv2Test : DanaRTestBase() {
|
|
||||||
|
|
||||||
@Test fun runTest() {
|
|
||||||
|
|
||||||
// test low hard limit
|
|
||||||
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 = 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 = 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 = MsgSetAPSTempBasalStart_v2(injector, 50, false, true)
|
|
||||||
Assert.assertEquals(50, packet.intFromBuff(packet.buffer, 0, 2))
|
|
||||||
Assert.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
|
||||||
// over 200% set always 15 min
|
|
||||||
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 = MsgSetAPSTempBasalStart_v2(injector, -1, false, true)
|
|
||||||
Assert.assertEquals(0, packet.intFromBuff(packet.buffer, 0, 2))
|
|
||||||
Assert.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
|
||||||
// test high hard limit
|
|
||||||
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))
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte()))
|
|
||||||
Assert.assertEquals(true, packet.failed)
|
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 1.toByte()))
|
|
||||||
Assert.assertEquals(false, packet.failed)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package info.nightscout.androidaps.utils
|
|
||||||
|
|
||||||
import org.junit.Assert
|
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
|
|
||||||
class CRCTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun getCrc16Test() {
|
|
||||||
val data = byteArrayOf(1,2,3,4,5,6,7,8,9,0)
|
|
||||||
Assert.assertEquals(27649.toShort(), CRC.getCrc16(data, 0, 10))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR
|
package info.nightscout.pump.danaR
|
||||||
|
|
||||||
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.danar.DanaRPlugin
|
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
@ -14,7 +13,7 @@ import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import org.junit.jupiter.api.Assertions
|
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
|
||||||
|
@ -24,7 +23,6 @@ import org.mockito.Mockito.`when`
|
||||||
class DanaRPluginTest : TestBaseWithProfile() {
|
class DanaRPluginTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var constraintChecker: Constraints
|
@Mock lateinit var constraintChecker: Constraints
|
||||||
@Mock lateinit var sp: SP
|
|
||||||
@Mock lateinit var commandQueue: CommandQueue
|
@Mock lateinit var commandQueue: CommandQueue
|
||||||
@Mock lateinit var pumpSync: PumpSync
|
@Mock lateinit var pumpSync: PumpSync
|
||||||
@Mock lateinit var instantiator: Instantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
|
@ -49,7 +47,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
danaRPlugin = DanaRPlugin(
|
danaRPlugin = DanaRPlugin(
|
||||||
injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync,
|
injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync,
|
||||||
uiInteraction, danaHistoryDatabase
|
uiInteraction, danaHistoryDatabase
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -1,9 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
|
||||||
import info.nightscout.androidaps.TestPumpPlugin
|
|
||||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||||
|
@ -22,6 +20,8 @@ import info.nightscout.rx.bus.RxBus
|
||||||
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 info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
|
import info.nightscout.sharedtests.TestBase
|
||||||
|
import info.nightscout.sharedtests.TestPumpPlugin
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.mockito.ArgumentMatchers
|
import org.mockito.ArgumentMatchers
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MessageHashTableR
|
import info.nightscout.androidaps.danar.comm.MessageHashTableR
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
|
|
||||||
|
@ -12,6 +12,6 @@ class MessageHashTableRTest : DanaRTestBase() {
|
||||||
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
val messageHashTable = MessageHashTableR(injector)
|
val messageHashTable = MessageHashTableR(injector)
|
||||||
val testMessage = messageHashTable.findMessage(0x41f2)
|
val testMessage = messageHashTable.findMessage(0x41f2)
|
||||||
Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
Assertions.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.danar.comm.MessageOriginalNames
|
||||||
|
import info.nightscout.sharedtests.TestBase
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
class MessageOriginalNamesTest : TestBase() {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun getNameTest() {
|
||||||
|
Assertions.assertEquals("CMD_CONNECT", MessageOriginalNames.getName(0x3001))
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgBolusProgress
|
import info.nightscout.androidaps.danar.comm.MsgBolusProgress
|
||||||
import info.nightscout.rx.events.EventOverviewBolusProgress
|
import info.nightscout.rx.events.EventOverviewBolusProgress
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.ArgumentMatchers
|
import org.mockito.ArgumentMatchers
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
@ -19,6 +19,6 @@ class MsgBolusProgressTest : DanaRTestBase() {
|
||||||
val array = ByteArray(100)
|
val array = ByteArray(100)
|
||||||
putIntToArray(array, 0, 2 * 100)
|
putIntToArray(array, 0, 2 * 100)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(1.0, danaPump.bolusingTreatment?.insulin!!, 0.0)
|
Assertions.assertEquals(1.0, danaPump.bolusingTreatment?.insulin!!, 0.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgBolusStart
|
import info.nightscout.androidaps.danar.comm.MsgBolusStart
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ class MsgBolusStartTest : DanaRTestBase() {
|
||||||
|
|
||||||
putByteToArray(array, 0, 1)
|
putByteToArray(array, 0, 1)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
|
|
||||||
putByteToArray(array, 0, 2)
|
putByteToArray(array, 0, 2)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgBolusStartWithSpeed
|
import info.nightscout.androidaps.danar.comm.MsgBolusStartWithSpeed
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ class MsgBolusStartWithSpeedTest : DanaRTestBase() {
|
||||||
|
|
||||||
putByteToArray(array, 0, 1)
|
putByteToArray(array, 0, 1)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
|
|
||||||
putByteToArray(array, 0, 2)
|
putByteToArray(array, 0, 2)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgBolusStop
|
import info.nightscout.androidaps.danar.comm.MsgBolusStop
|
||||||
import info.nightscout.rx.events.EventOverviewBolusProgress
|
import info.nightscout.rx.events.EventOverviewBolusProgress
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
|
||||||
|
@ -15,6 +15,6 @@ class MsgBolusStopTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(ByteArray(100))
|
packet.handleMessage(ByteArray(100))
|
||||||
Assert.assertEquals(true, danaPump.bolusStopped)
|
Assertions.assertEquals(true, danaPump.bolusStopped)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgCheckValue
|
import info.nightscout.androidaps.danar.comm.MsgCheckValue
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgCheckValueTest : DanaRTestBase() {
|
class MsgCheckValueTest : DanaRTestBase() {
|
||||||
|
@ -14,6 +14,6 @@ class MsgCheckValueTest : DanaRTestBase() {
|
||||||
val array = ByteArray(100)
|
val array = ByteArray(100)
|
||||||
putByteToArray(array, 0, DanaPump.EXPORT_MODEL.toByte())
|
putByteToArray(array, 0, DanaPump.EXPORT_MODEL.toByte())
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(DanaPump.EXPORT_MODEL, danaPump.hwModel)
|
Assertions.assertEquals(DanaPump.EXPORT_MODEL, danaPump.hwModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgError
|
import info.nightscout.androidaps.danar.comm.MsgError
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgErrorTest : DanaRTestBase() {
|
class MsgErrorTest : DanaRTestBase() {
|
||||||
|
@ -14,10 +14,10 @@ class MsgErrorTest : DanaRTestBase() {
|
||||||
|
|
||||||
putByteToArray(array, 0, 1)
|
putByteToArray(array, 0, 1)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
// bigger than 8 - no error
|
// bigger than 8 - no error
|
||||||
putByteToArray(array, 0, 10)
|
putByteToArray(array, 0, 10)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryAlarm
|
import info.nightscout.androidaps.danar.comm.MsgHistoryAlarm
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryAllDone
|
import info.nightscout.androidaps.danar.comm.MsgHistoryAllDone
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgHistoryAllDoneTest : DanaRTestBase() {
|
class MsgHistoryAllDoneTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgHistoryAllDoneTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(ByteArray(0))
|
packet.handleMessage(ByteArray(0))
|
||||||
Assert.assertEquals(true, danaPump.historyDoneReceived)
|
Assertions.assertEquals(true, danaPump.historyDoneReceived)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryAll
|
import info.nightscout.androidaps.danar.comm.MsgHistoryAll
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgHistoryAllTest : DanaRTestBase() {
|
class MsgHistoryAllTest : DanaRTestBase() {
|
||||||
|
@ -14,10 +14,10 @@ class MsgHistoryAllTest : DanaRTestBase() {
|
||||||
|
|
||||||
putByteToArray(array, 0, 1)
|
putByteToArray(array, 0, 1)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
// passing an bigger number
|
// passing an bigger number
|
||||||
putByteToArray(array, 0, 17)
|
putByteToArray(array, 0, 17)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryBasalHour
|
import info.nightscout.androidaps.danar.comm.MsgHistoryBasalHour
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryBolus
|
import info.nightscout.androidaps.danar.comm.MsgHistoryBolus
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryCarbo
|
import info.nightscout.androidaps.danar.comm.MsgHistoryCarbo
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryDailyInsulin
|
import info.nightscout.androidaps.danar.comm.MsgHistoryDailyInsulin
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryDone
|
import info.nightscout.androidaps.danar.comm.MsgHistoryDone
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryError
|
import info.nightscout.androidaps.danar.comm.MsgHistoryError
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryGlucose
|
import info.nightscout.androidaps.danar.comm.MsgHistoryGlucose
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryNewDone
|
import info.nightscout.androidaps.danar.comm.MsgHistoryNewDone
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryNew
|
import info.nightscout.androidaps.danar.comm.MsgHistoryNew
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistoryRefill
|
import info.nightscout.androidaps.danar.comm.MsgHistoryRefill
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgHistorySuspend
|
import info.nightscout.androidaps.danar.comm.MsgHistorySuspend
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusBasic
|
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusBasic
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgInitConnStatusBasicTest : DanaRTestBase() {
|
class MsgInitConnStatusBasicTest : DanaRTestBase() {
|
||||||
|
@ -14,6 +14,6 @@ class MsgInitConnStatusBasicTest : DanaRTestBase() {
|
||||||
|
|
||||||
putByteToArray(array, 0, 1)
|
putByteToArray(array, 0, 1)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(true, danaPump.pumpSuspended)
|
Assertions.assertEquals(true, danaPump.pumpSuspended)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusBolus
|
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusBolus
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgInitConnStatusBolusTest : DanaRTestBase() {
|
class MsgInitConnStatusBolusTest : DanaRTestBase() {
|
||||||
|
@ -14,10 +14,10 @@ class MsgInitConnStatusBolusTest : DanaRTestBase() {
|
||||||
|
|
||||||
// message bigger than 22
|
// message bigger than 22
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
array = ByteArray(20)
|
array = ByteArray(20)
|
||||||
putByteToArray(array, 0, 1)
|
putByteToArray(array, 0, 1)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(true, danaPump.isExtendedBolusEnabled)
|
Assertions.assertEquals(true, danaPump.isExtendedBolusEnabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusOption
|
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusOption
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgInitConnStatusOptionTest : DanaRTestBase() {
|
class MsgInitConnStatusOptionTest : DanaRTestBase() {
|
||||||
|
@ -11,9 +11,9 @@ class MsgInitConnStatusOptionTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(20, 1.toByte()))
|
packet.handleMessage(createArray(20, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
// message smaller than 21
|
// message smaller than 21
|
||||||
packet.handleMessage(createArray(22, 1.toByte()))
|
packet.handleMessage(createArray(22, 1.toByte()))
|
||||||
Assert.assertEquals(false, danaPump.isPasswordOK)
|
Assertions.assertEquals(false, danaPump.isPasswordOK)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusTime
|
import info.nightscout.androidaps.danar.comm.MsgInitConnStatusTime
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgInitConnStatusTimeTest : DanaRTestBase() {
|
class MsgInitConnStatusTimeTest : DanaRTestBase() {
|
||||||
|
@ -11,9 +11,9 @@ class MsgInitConnStatusTimeTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(20, 1.toByte()))
|
packet.handleMessage(createArray(20, 1.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
// message smaller than 10
|
// message smaller than 10
|
||||||
packet.handleMessage(createArray(15, 1.toByte()))
|
packet.handleMessage(createArray(15, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgPCCommStart
|
import info.nightscout.androidaps.danar.comm.MsgPCCommStart
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgPCCommStop
|
import info.nightscout.androidaps.danar.comm.MsgPCCommStop
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSetActivateBasalProfile
|
import info.nightscout.androidaps.danar.comm.MsgSetActivateBasalProfile
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSetActivateBasalProfileTest : DanaRTestBase() {
|
class MsgSetActivateBasalProfileTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSetActivateBasalProfileTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSetBasalProfile
|
import info.nightscout.androidaps.danar.comm.MsgSetBasalProfile
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSetBasalProfileTest : DanaRTestBase() {
|
class MsgSetBasalProfileTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSetBasalProfileTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 2.toByte()))
|
packet.handleMessage(createArray(34, 2.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSetCarbsEntry
|
import info.nightscout.androidaps.danar.comm.MsgSetCarbsEntry
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSetCarbsEntryTest : DanaRTestBase() {
|
class MsgSetCarbsEntryTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSetCarbsEntryTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSetExtendedBolusStart
|
import info.nightscout.androidaps.danar.comm.MsgSetExtendedBolusStart
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class MsgSetExtendedBolusStartTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSetExtendedBolusStop
|
import info.nightscout.androidaps.danar.comm.MsgSetExtendedBolusStop
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSetExtendedBolusStopTest : DanaRTestBase() {
|
class MsgSetExtendedBolusStopTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSetExtendedBolusStopTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSetSingleBasalProfile
|
import info.nightscout.androidaps.danar.comm.MsgSetSingleBasalProfile
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSetSingleBasalProfileTest : DanaRTestBase() {
|
class MsgSetSingleBasalProfileTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSetSingleBasalProfileTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSetTempBasalStart
|
import info.nightscout.androidaps.danar.comm.MsgSetTempBasalStart
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSetTempBasalStartTest : DanaRTestBase() {
|
class MsgSetTempBasalStartTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSetTempBasalStartTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSetTime
|
import info.nightscout.androidaps.danar.comm.MsgSetTime
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSetTimeTest : DanaRTestBase() {
|
class MsgSetTimeTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSetTimeTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSetUserOptions
|
import info.nightscout.androidaps.danar.comm.MsgSetUserOptions
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSetUserOptionsTest : DanaRTestBase() {
|
class MsgSetUserOptionsTest : DanaRTestBase() {
|
||||||
|
@ -10,6 +10,6 @@ class MsgSetUserOptionsTest : DanaRTestBase() {
|
||||||
val packet = MsgSetUserOptions(injector)
|
val packet = MsgSetUserOptions(injector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingActiveProfile
|
import info.nightscout.androidaps.danar.comm.MsgSettingActiveProfile
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSettingActiveProfileTest : DanaRTestBase() {
|
class MsgSettingActiveProfileTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSettingActiveProfileTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 1), danaPump.activeProfile)
|
Assertions.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 1), danaPump.activeProfile)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingBasalProfileAll
|
import info.nightscout.androidaps.danar.comm.MsgSettingBasalProfileAll
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingBasal
|
import info.nightscout.androidaps.danar.comm.MsgSettingBasal
|
||||||
import info.nightscout.interfaces.pump.defs.PumpDescription
|
import info.nightscout.interfaces.pump.defs.PumpDescription
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
|
||||||
|
@ -15,6 +15,6 @@ class MsgSettingBasalTest : DanaRTestBase() {
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(100, 1.toByte()))
|
packet.handleMessage(createArray(100, 1.toByte()))
|
||||||
val expected = packet.intFromBuff(createArray(100, 1.toByte()), 2 * 1, 2)
|
val expected = packet.intFromBuff(createArray(100, 1.toByte()), 2 * 1, 2)
|
||||||
Assert.assertEquals(expected.toDouble() / 100.0, danaPump.pumpProfiles!![danaPump.activeProfile][1], 0.0)
|
Assertions.assertEquals(expected.toDouble() / 100.0, danaPump.pumpProfiles!![danaPump.activeProfile][1], 0.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingGlucose
|
import info.nightscout.androidaps.danar.comm.MsgSettingGlucose
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSettingGlucoseTest : DanaRTestBase() {
|
class MsgSettingGlucoseTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSettingGlucoseTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
Assert.assertEquals(1, danaPump.units)
|
Assertions.assertEquals(1, danaPump.units)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingMaxValues
|
import info.nightscout.androidaps.danar.comm.MsgSettingMaxValues
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSettingMaxValuesTest : DanaRTestBase() {
|
class MsgSettingMaxValuesTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSettingMaxValuesTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2).toDouble() / 100.0, danaPump.maxBolus, 0.0)
|
Assertions.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2).toDouble() / 100.0, danaPump.maxBolus, 0.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingMeal
|
import info.nightscout.androidaps.danar.comm.MsgSettingMeal
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSettingMealTest : DanaRTestBase() {
|
class MsgSettingMealTest : DanaRTestBase() {
|
||||||
|
@ -11,6 +11,6 @@ class MsgSettingMealTest : DanaRTestBase() {
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
Assert.assertEquals(packet.intFromBuff(createArray(10, 1.toByte()), 0, 1).toDouble() / 100.0, danaPump.bolusStep, 0.0)
|
Assertions.assertEquals(packet.intFromBuff(createArray(10, 1.toByte()), 0, 1).toDouble() / 100.0, danaPump.bolusStep, 0.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingProfileRatiosAll
|
import info.nightscout.androidaps.danar.comm.MsgSettingProfileRatiosAll
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSettingProfileRatiosAllTest : DanaRTestBase() {
|
class MsgSettingProfileRatiosAllTest : DanaRTestBase() {
|
||||||
|
@ -12,7 +12,7 @@ class MsgSettingProfileRatiosAllTest : DanaRTestBase() {
|
||||||
danaPump.units = DanaPump.UNITS_MGDL
|
danaPump.units = DanaPump.UNITS_MGDL
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.morningCIR)
|
Assertions.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.morningCIR)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingProfileRatios
|
import info.nightscout.androidaps.danar.comm.MsgSettingProfileRatios
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSettingProfileRatiosTest : DanaRTestBase() {
|
class MsgSettingProfileRatiosTest : DanaRTestBase() {
|
||||||
|
@ -12,6 +12,6 @@ class MsgSettingProfileRatiosTest : DanaRTestBase() {
|
||||||
danaPump.units = DanaPump.UNITS_MGDL
|
danaPump.units = DanaPump.UNITS_MGDL
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.currentCIR)
|
Assertions.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.currentCIR)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingPumpTime
|
import info.nightscout.androidaps.danar.comm.MsgSettingPumpTime
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSettingPumpTimeTest : DanaRTestBase() {
|
class MsgSettingPumpTimeTest : DanaRTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class MsgSettingPumpTimeTest : DanaRTestBase() {
|
||||||
packet.intFromBuff(bytes, 0, 1)
|
packet.intFromBuff(bytes, 0, 1)
|
||||||
).millis
|
).millis
|
||||||
packet.handleMessage(bytes)
|
packet.handleMessage(bytes)
|
||||||
Assert.assertEquals(time, danaPump.getPumpTime())
|
Assertions.assertEquals(time, danaPump.getPumpTime())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MessageBase
|
import info.nightscout.androidaps.danar.comm.MessageBase
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingShippingInfo
|
import info.nightscout.androidaps.danar.comm.MsgSettingShippingInfo
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSettingShippingInfoTest : DanaRTestBase() {
|
class MsgSettingShippingInfoTest : DanaRTestBase() {
|
||||||
|
@ -13,6 +13,6 @@ class MsgSettingShippingInfoTest : DanaRTestBase() {
|
||||||
danaPump.units = DanaPump.UNITS_MGDL
|
danaPump.units = DanaPump.UNITS_MGDL
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(MessageBase.stringFromBuff(createArray(34, 7.toByte()), 0, 10), danaPump.serialNumber)
|
Assertions.assertEquals(MessageBase.stringFromBuff(createArray(34, 7.toByte()), 0, 10), danaPump.serialNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgSettingUserOptions
|
import info.nightscout.androidaps.danar.comm.MsgSettingUserOptions
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSettingUserOptionsTest : DanaRTestBase() {
|
class MsgSettingUserOptionsTest : DanaRTestBase() {
|
||||||
|
@ -12,6 +12,6 @@ class MsgSettingUserOptionsTest : DanaRTestBase() {
|
||||||
danaPump.units = DanaPump.UNITS_MGDL
|
danaPump.units = DanaPump.UNITS_MGDL
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(48, 7.toByte()))
|
packet.handleMessage(createArray(48, 7.toByte()))
|
||||||
Assert.assertEquals(7, danaPump.lcdOnTimeSec)
|
Assertions.assertEquals(7, danaPump.lcdOnTimeSec)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgStatusBasic
|
import info.nightscout.androidaps.danar.comm.MsgStatusBasic
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgStatusBasicTest : DanaRTestBase() {
|
class MsgStatusBasicTest : DanaRTestBase() {
|
||||||
|
@ -10,6 +10,6 @@ class MsgStatusBasicTest : DanaRTestBase() {
|
||||||
val packet = MsgStatusBasic(injector)
|
val packet = MsgStatusBasic(injector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaPump.dailyTotalUnits, 0.0)
|
Assertions.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaPump.dailyTotalUnits, 0.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended
|
import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended
|
||||||
import info.nightscout.shared.utils.T
|
import info.nightscout.shared.utils.T
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgStatusBolusExtendedTest : DanaRTestBase() {
|
class MsgStatusBolusExtendedTest : DanaRTestBase() {
|
||||||
|
@ -15,6 +15,6 @@ class MsgStatusBolusExtendedTest : DanaRTestBase() {
|
||||||
putByteToArray(array, 0, 1)
|
putByteToArray(array, 0, 1)
|
||||||
putByteToArray(array, 1, 1)
|
putByteToArray(array, 1, 1)
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(T.mins(30).msecs(), danaPump.extendedBolusDuration)
|
Assertions.assertEquals(T.mins(30).msecs(), danaPump.extendedBolusDuration)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgStatusProfile
|
import info.nightscout.androidaps.danar.comm.MsgStatusProfile
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgStatusProfileTest : DanaRTestBase() {
|
class MsgStatusProfileTest : DanaRTestBase() {
|
||||||
|
@ -12,6 +12,6 @@ class MsgStatusProfileTest : DanaRTestBase() {
|
||||||
danaPump.units = DanaPump.UNITS_MGDL
|
danaPump.units = DanaPump.UNITS_MGDL
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.currentCIR)
|
Assertions.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.currentCIR)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal
|
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgStatusTempBasalTest : DanaRTestBase() {
|
class MsgStatusTempBasalTest : DanaRTestBase() {
|
||||||
|
@ -10,9 +10,9 @@ class MsgStatusTempBasalTest : DanaRTestBase() {
|
||||||
val packet = MsgStatusTempBasal(injector)
|
val packet = MsgStatusTempBasal(injector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.isTempBasalInProgress)
|
Assertions.assertEquals(true, packet.isTempBasalInProgress)
|
||||||
// passing an bigger number
|
// passing an bigger number
|
||||||
packet.handleMessage(createArray(34, 2.toByte()))
|
packet.handleMessage(createArray(34, 2.toByte()))
|
||||||
Assert.assertEquals(false, packet.isTempBasalInProgress)
|
Assertions.assertEquals(false, packet.isTempBasalInProgress)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danar.comm.MsgStatus
|
import info.nightscout.androidaps.danar.comm.MsgStatus
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgStatusTest : DanaRTestBase() {
|
class MsgStatusTest : DanaRTestBase() {
|
||||||
|
@ -10,6 +10,6 @@ class MsgStatusTest : DanaRTestBase() {
|
||||||
val packet = MsgStatus(injector)
|
val packet = MsgStatus(injector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 7.toByte()))
|
packet.handleMessage(createArray(34, 7.toByte()))
|
||||||
Assert.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaPump.dailyTotalUnits, 0.0)
|
Assertions.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaPump.dailyTotalUnits, 0.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package info.nightscout.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.pump.dana.comm.RecordTypes
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
class RecordTypesTest {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
Assertions.assertEquals(1.toByte(), RecordTypes.RECORD_TYPE_BOLUS)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRKorean
|
package info.nightscout.pump.danaRKorean
|
||||||
|
|
||||||
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.danaRKorean.DanaRKoreanPlugin
|
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
@ -14,7 +13,7 @@ import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import org.junit.jupiter.api.Assertions
|
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
|
||||||
|
@ -24,7 +23,6 @@ import org.mockito.Mockito.`when`
|
||||||
class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var constraintChecker: Constraints
|
@Mock lateinit var constraintChecker: Constraints
|
||||||
@Mock lateinit var sp: SP
|
|
||||||
@Mock lateinit var commandQueue: CommandQueue
|
@Mock lateinit var commandQueue: CommandQueue
|
||||||
@Mock lateinit var pumpSync: PumpSync
|
@Mock lateinit var pumpSync: PumpSync
|
||||||
@Mock lateinit var instantiator: Instantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
|
@ -48,8 +46,10 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy,
|
danaRPlugin = DanaRKoreanPlugin(
|
||||||
pumpSync, uiInteraction, danaHistoryDatabase)
|
injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy,
|
||||||
|
pumpSync, uiInteraction, danaHistoryDatabase
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @Throws(Exception::class)
|
@Test @Throws(Exception::class)
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRKorean.comm
|
package info.nightscout.pump.danaRKorean.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danaRKorean.comm.MessageHashTableRKorean
|
import info.nightscout.androidaps.danaRKorean.comm.MessageHashTableRKorean
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import org.junit.Assert
|
import info.nightscout.pump.danaR.comm.DanaRTestBase
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
|
|
||||||
|
@ -13,6 +13,6 @@ class MessageHashTableRKoreanTest : DanaRTestBase() {
|
||||||
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
val messageHashTable = MessageHashTableRKorean(injector)
|
val messageHashTable = MessageHashTableRKorean(injector)
|
||||||
val testMessage = messageHashTable.findMessage(0x41f2)
|
val testMessage = messageHashTable.findMessage(0x41f2)
|
||||||
Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
Assertions.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2
|
package info.nightscout.pump.danaRv2
|
||||||
|
|
||||||
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.danaRv2.DanaRv2Plugin
|
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
@ -16,7 +15,7 @@ import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import org.junit.jupiter.api.Assertions
|
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
|
||||||
|
@ -26,7 +25,6 @@ import org.mockito.Mockito.`when`
|
||||||
class DanaRv2PluginTest : TestBaseWithProfile() {
|
class DanaRv2PluginTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var constraintChecker: Constraints
|
@Mock lateinit var constraintChecker: Constraints
|
||||||
@Mock lateinit var sp: SP
|
|
||||||
@Mock lateinit var commandQueue: CommandQueue
|
@Mock lateinit var commandQueue: CommandQueue
|
||||||
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||||
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
||||||
|
@ -53,7 +51,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator)
|
||||||
danaRv2Plugin = DanaRv2Plugin(
|
danaRv2Plugin = DanaRv2Plugin(
|
||||||
injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage,
|
injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, detailedBolusInfoStorage,
|
||||||
temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync, uiInteraction, danaHistoryDatabase
|
temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync, uiInteraction, danaHistoryDatabase
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
package info.nightscout.pump.danaRv2.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danaRv2.comm.MessageHashTableRv2
|
import info.nightscout.androidaps.danaRv2.comm.MessageHashTableRv2
|
||||||
import info.nightscout.androidaps.danaRv2.comm.MsgStatusAPS_v2
|
import info.nightscout.androidaps.danaRv2.comm.MsgStatusAPS_v2
|
||||||
import info.nightscout.androidaps.danar.comm.MessageBase
|
import info.nightscout.androidaps.danar.comm.MessageBase
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import org.junit.Assert
|
import info.nightscout.pump.danaR.comm.DanaRTestBase
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
|
||||||
|
@ -17,11 +17,11 @@ class MessageHashTableRv2Test : DanaRTestBase() {
|
||||||
val messageHashTableRv2 = MessageHashTableRv2(injector)
|
val messageHashTableRv2 = MessageHashTableRv2(injector)
|
||||||
val forTesting: MessageBase = MsgStatusAPS_v2(injector)
|
val forTesting: MessageBase = MsgStatusAPS_v2(injector)
|
||||||
val testPacket: MessageBase = messageHashTableRv2.findMessage(forTesting.command)
|
val testPacket: MessageBase = messageHashTableRv2.findMessage(forTesting.command)
|
||||||
Assert.assertEquals(0xE001, testPacket.command.toLong())
|
Assertions.assertEquals(0xE001, testPacket.command.toLong())
|
||||||
// try putting another command
|
// try putting another command
|
||||||
val testMessage = MessageBase(injector)
|
val testMessage = MessageBase(injector)
|
||||||
testMessage.setCommand(0xE005)
|
testMessage.setCommand(0xE005)
|
||||||
messageHashTableRv2.put(testMessage)
|
messageHashTableRv2.put(testMessage)
|
||||||
Assert.assertEquals(0xE005, messageHashTableRv2.findMessage(0xE005).command.toLong())
|
Assertions.assertEquals(0xE005, messageHashTableRv2.findMessage(0xE005).command.toLong())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
package info.nightscout.pump.danaRv2.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danaRv2.comm.MsgCheckValue_v2
|
import info.nightscout.androidaps.danaRv2.comm.MsgCheckValue_v2
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import org.junit.Assert
|
import info.nightscout.pump.danaR.comm.DanaRTestBase
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgCheckValueRv2Test : DanaRTestBase() {
|
class MsgCheckValueRv2Test : DanaRTestBase() {
|
||||||
|
@ -13,6 +13,6 @@ class MsgCheckValueRv2Test : DanaRTestBase() {
|
||||||
val packet = MsgCheckValue_v2(injector)
|
val packet = MsgCheckValue_v2(injector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 3.toByte()))
|
packet.handleMessage(createArray(34, 3.toByte()))
|
||||||
Assert.assertEquals(DanaPump.EXPORT_MODEL, danaPump.hwModel)
|
Assertions.assertEquals(DanaPump.EXPORT_MODEL, danaPump.hwModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
package info.nightscout.pump.danaRv2.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danaRv2.comm.MsgHistoryEventsV2
|
import info.nightscout.androidaps.danaRv2.comm.MsgHistoryEventsV2
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
import info.nightscout.pump.danaR.comm.DanaRTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgHistoryEventsRv2Test : DanaRTestBase() {
|
class MsgHistoryEventsRv2Test : DanaRTestBase() {
|
||||||
|
@ -15,10 +15,10 @@ class MsgHistoryEventsRv2Test : DanaRTestBase() {
|
||||||
|
|
||||||
putByteToArray(array, 0, 0x01.toByte())
|
putByteToArray(array, 0, 0x01.toByte())
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(false, danaPump.historyDoneReceived)
|
Assertions.assertEquals(false, danaPump.historyDoneReceived)
|
||||||
|
|
||||||
putByteToArray(array, 0, 0xFF.toByte())
|
putByteToArray(array, 0, 0xFF.toByte())
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(true, danaPump.historyDoneReceived)
|
Assertions.assertEquals(true, danaPump.historyDoneReceived)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package info.nightscout.pump.danaRv2.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2
|
||||||
|
import info.nightscout.pump.danaR.comm.DanaRTestBase
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
class MsgSetAPSTempBasalStartRv2Test : DanaRTestBase() {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
|
||||||
|
// test low hard limit
|
||||||
|
var packet = MsgSetAPSTempBasalStart_v2(injector, -1, true, false)
|
||||||
|
Assertions.assertEquals(0, packet.intFromBuff(packet.buffer, 0, 2))
|
||||||
|
Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||||
|
// test high hard limit
|
||||||
|
packet = MsgSetAPSTempBasalStart_v2(injector, 550, true, false)
|
||||||
|
Assertions.assertEquals(500, packet.intFromBuff(packet.buffer, 0, 2))
|
||||||
|
Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||||
|
// test setting 15 min
|
||||||
|
packet = MsgSetAPSTempBasalStart_v2(injector, 50, true, false)
|
||||||
|
Assertions.assertEquals(50, packet.intFromBuff(packet.buffer, 0, 2))
|
||||||
|
Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||||
|
// test setting 30 min
|
||||||
|
packet = MsgSetAPSTempBasalStart_v2(injector, 50, false, true)
|
||||||
|
Assertions.assertEquals(50, packet.intFromBuff(packet.buffer, 0, 2))
|
||||||
|
Assertions.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||||
|
// over 200% set always 15 min
|
||||||
|
packet = MsgSetAPSTempBasalStart_v2(injector, 250, false, true)
|
||||||
|
Assertions.assertEquals(250, packet.intFromBuff(packet.buffer, 0, 2))
|
||||||
|
Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||||
|
// test low hard limit
|
||||||
|
packet = MsgSetAPSTempBasalStart_v2(injector, -1, false, true)
|
||||||
|
Assertions.assertEquals(0, packet.intFromBuff(packet.buffer, 0, 2))
|
||||||
|
Assertions.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||||
|
// test high hard limit
|
||||||
|
packet = MsgSetAPSTempBasalStart_v2(injector, 550, false, true)
|
||||||
|
Assertions.assertEquals(500, packet.intFromBuff(packet.buffer, 0, 2))
|
||||||
|
Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1))
|
||||||
|
|
||||||
|
// test message decoding
|
||||||
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
|
Assertions.assertEquals(true, packet.failed)
|
||||||
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 1.toByte()))
|
||||||
|
Assertions.assertEquals(false, packet.failed)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
package info.nightscout.pump.danaRv2.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danaRv2.comm.MsgSetHistoryEntry_v2
|
import info.nightscout.androidaps.danaRv2.comm.MsgSetHistoryEntry_v2
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
import info.nightscout.pump.danaR.comm.DanaRTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgSetHistoryEntryRv2Test : DanaRTestBase() {
|
class MsgSetHistoryEntryRv2Test : DanaRTestBase() {
|
||||||
|
@ -12,9 +12,9 @@ class MsgSetHistoryEntryRv2Test : DanaRTestBase() {
|
||||||
// test message decoding
|
// test message decoding
|
||||||
// != 1 fails
|
// != 1 fails
|
||||||
packet.handleMessage(createArray(34, 2.toByte()))
|
packet.handleMessage(createArray(34, 2.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
// passing an bigger number
|
// passing an bigger number
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
package info.nightscout.pump.danaRv2.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.danaRv2.comm.MsgStatusAPS_v2
|
import info.nightscout.androidaps.danaRv2.comm.MsgStatusAPS_v2
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
import info.nightscout.pump.danaR.comm.DanaRTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MsgStatusAPSRv2Test : DanaRTestBase() {
|
class MsgStatusAPSRv2Test : DanaRTestBase() {
|
||||||
|
@ -14,6 +14,6 @@ class MsgStatusAPSRv2Test : DanaRTestBase() {
|
||||||
val testArray = createArray(34, 7.toByte())
|
val testArray = createArray(34, 7.toByte())
|
||||||
val iob = packet.intFromBuff(testArray, 0, 2) / 100.0
|
val iob = packet.intFromBuff(testArray, 0, 2) / 100.0
|
||||||
packet.handleMessage(testArray)
|
packet.handleMessage(testArray)
|
||||||
Assert.assertEquals(iob, danaPump.iob, 0.0)
|
Assertions.assertEquals(iob, danaPump.iob, 0.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package info.nightscout.pump.utils
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.utils.CRC
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
class CRCTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun getCrc16Test() {
|
||||||
|
val data = byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
|
||||||
|
Assertions.assertEquals(27649.toShort(), CRC.getCrc16(data, 0, 10))
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue