shared-tests #9
This commit is contained in:
parent
1cd93cdc1e
commit
328188fa63
|
@ -37,5 +37,6 @@ dependencies {
|
||||||
implementation project(':pump:dana')
|
implementation project(':pump:dana')
|
||||||
implementation project(':app-wear-shared:shared')
|
implementation project(':app-wear-shared:shared')
|
||||||
|
|
||||||
|
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")
|
|
||||||
fun <T> uninitialized(): T = null as T
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
package info.nightscout.androidaps
|
|
||||||
|
|
||||||
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.plugin.ActivePlugin
|
|
||||||
import info.nightscout.interfaces.profile.DefaultValueHelper
|
|
||||||
import info.nightscout.interfaces.profile.Profile
|
|
||||||
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
|
|
||||||
lateinit var validProfile: Profile
|
|
||||||
@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\"}"
|
|
||||||
validProfile = ProfileSealed.Pure(pureProfileFromJson(JSONObject(validProfileJSON), dateUtil)!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
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,6 +1,5 @@
|
||||||
package info.nightscout.pump.danars
|
package info.nightscout.pump.danars
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
@ -11,7 +10,7 @@ import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.ArgumentMatchers.eq
|
import org.mockito.ArgumentMatchers.eq
|
||||||
|
@ -21,7 +20,6 @@ import org.mockito.Mockito
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
class DanaRSPluginTest : DanaRSTestBase() {
|
class DanaRSPluginTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var context: Context
|
|
||||||
@Mock lateinit var constraintChecker: Constraints
|
@Mock lateinit var constraintChecker: Constraints
|
||||||
@Mock lateinit var commandQueue: CommandQueue
|
@Mock lateinit var commandQueue: CommandQueue
|
||||||
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||||
|
@ -38,9 +36,9 @@ class DanaRSPluginTest : DanaRSTestBase() {
|
||||||
danaPump.maxBasal = 0.8
|
danaPump.maxBasal = 0.8
|
||||||
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
||||||
danaRSPlugin.applyBasalConstraints(c, validProfile)
|
danaRSPlugin.applyBasalConstraints(c, validProfile)
|
||||||
Assert.assertEquals(java.lang.Double.valueOf(0.8), c.value(), 0.0001)
|
Assertions.assertEquals(java.lang.Double.valueOf(0.8), c.value(), 0.0001)
|
||||||
Assert.assertEquals("DanaRS: limitingbasalratio", c.getReasons(aapsLogger))
|
Assertions.assertEquals("DanaRS: limitingbasalratio", c.getReasons(aapsLogger))
|
||||||
Assert.assertEquals("DanaRS: limitingbasalratio", c.getMostLimitedReasons(aapsLogger))
|
Assertions.assertEquals("DanaRS: limitingbasalratio", c.getMostLimitedReasons(aapsLogger))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -50,9 +48,9 @@ class DanaRSPluginTest : DanaRSTestBase() {
|
||||||
danaPump.maxBasal = 0.8
|
danaPump.maxBasal = 0.8
|
||||||
val c = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
val c = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
||||||
danaRSPlugin.applyBasalPercentConstraints(c, validProfile)
|
danaRSPlugin.applyBasalPercentConstraints(c, validProfile)
|
||||||
Assert.assertEquals(200, c.value())
|
Assertions.assertEquals(200, c.value())
|
||||||
Assert.assertEquals("DanaRS: limitingpercentrate", c.getReasons(aapsLogger))
|
Assertions.assertEquals("DanaRS: limitingpercentrate", c.getReasons(aapsLogger))
|
||||||
Assert.assertEquals("DanaRS: limitingpercentrate", c.getMostLimitedReasons(aapsLogger))
|
Assertions.assertEquals("DanaRS: limitingpercentrate", c.getMostLimitedReasons(aapsLogger))
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package info.nightscout.pump.danars
|
package info.nightscout.pump.danars
|
||||||
|
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
|
||||||
import info.nightscout.interfaces.profile.Instantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
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.danars.comm.DanaRSPacket
|
import info.nightscout.pump.danars.comm.DanaRSPacket
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
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
|
||||||
|
@ -13,7 +12,6 @@ import org.mockito.Mockito
|
||||||
|
|
||||||
open class DanaRSTestBase : TestBaseWithProfile() {
|
open class DanaRSTestBase : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
|
||||||
@Mock lateinit var instantiator: Instantiator
|
@Mock lateinit var instantiator: Instantiator
|
||||||
@Mock lateinit var uiInteraction: UiInteraction
|
@Mock lateinit var uiInteraction: UiInteraction
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRSPacketBasalSetTemporaryBasalTest : DanaRSTestBase() {
|
class DanaRSPacketBasalSetTemporaryBasalTest : DanaRSTestBase() {
|
||||||
|
@ -21,14 +21,14 @@ class DanaRSPacketBasalSetTemporaryBasalTest : DanaRSTestBase() {
|
||||||
// params
|
// params
|
||||||
val params = testPacket.getRequestParams()
|
val params = testPacket.getRequestParams()
|
||||||
// is ratio 50
|
// is ratio 50
|
||||||
Assert.assertEquals(50.toByte(), params[0])
|
Assertions.assertEquals(50.toByte(), params[0])
|
||||||
// is duration 20
|
// is duration 20
|
||||||
Assert.assertEquals(20.toByte(), params[1])
|
Assertions.assertEquals(20.toByte(), params[1])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, testPacket.failed)
|
Assertions.assertEquals(false, testPacket.failed)
|
||||||
testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, testPacket.failed)
|
Assertions.assertEquals(true, testPacket.failed)
|
||||||
Assert.assertEquals("BASAL__SET_TEMPORARY_BASAL", testPacket.friendlyName)
|
Assertions.assertEquals("BASAL__SET_TEMPORARY_BASAL", testPacket.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.dana.comm.RecordTypes
|
import info.nightscout.pump.dana.comm.RecordTypes
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryRecordDao
|
import info.nightscout.pump.dana.database.DanaHistoryRecordDao
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
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.Mock
|
import org.mockito.Mock
|
||||||
import java.util.GregorianCalendar
|
import java.util.GregorianCalendar
|
||||||
|
@ -44,14 +44,14 @@ class DanaRSPacketHistoryAlarmTest : DanaRSTestBase() {
|
||||||
putByteToArray(array, 9, 100) // value
|
putByteToArray(array, 9, 100) // value
|
||||||
|
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(RecordTypes.RECORD_TYPE_ALARM, packet.danaRHistoryRecord.code)
|
Assertions.assertEquals(RecordTypes.RECORD_TYPE_ALARM, packet.danaRHistoryRecord.code)
|
||||||
val date = GregorianCalendar().also {
|
val date = GregorianCalendar().also {
|
||||||
it.clear()
|
it.clear()
|
||||||
it.set(2019, 1, 4, 20, 11, 35)
|
it.set(2019, 1, 4, 20, 11, 35)
|
||||||
}
|
}
|
||||||
Assert.assertEquals(date.timeInMillis, packet.danaRHistoryRecord.timestamp)
|
Assertions.assertEquals(date.timeInMillis, packet.danaRHistoryRecord.timestamp)
|
||||||
Assert.assertEquals("Occlusion", packet.danaRHistoryRecord.alarm)
|
Assertions.assertEquals("Occlusion", packet.danaRHistoryRecord.alarm)
|
||||||
Assert.assertEquals(3.56, packet.danaRHistoryRecord.value, 0.01)
|
Assertions.assertEquals(3.56, packet.danaRHistoryRecord.value, 0.01)
|
||||||
Assert.assertEquals("REVIEW__ALARM", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__ALARM", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,20 +2,16 @@ package info.nightscout.pump.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
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.Mock
|
|
||||||
import org.mockito.Mockito.anyDouble
|
import org.mockito.Mockito.anyDouble
|
||||||
import org.mockito.Mockito.anyInt
|
import org.mockito.Mockito.anyInt
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
|
||||||
class DanaRSPacketNotifyDeliveryCompleteTest : DanaRSTestBase() {
|
class DanaRSPacketNotifyDeliveryCompleteTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var activePlugin: ActivePlugin
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
if (it is DanaRSPacketNotifyDeliveryComplete) {
|
if (it is DanaRSPacketNotifyDeliveryComplete) {
|
||||||
|
@ -33,10 +29,10 @@ class DanaRSPacketNotifyDeliveryCompleteTest : DanaRSTestBase() {
|
||||||
danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0)
|
danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0)
|
||||||
val packet = DanaRSPacketNotifyDeliveryComplete(packetInjector)
|
val packet = DanaRSPacketNotifyDeliveryComplete(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(17, 0.toByte()))
|
packet.handleMessage(createArray(17, 0.toByte()))
|
||||||
Assert.assertEquals(true, danaPump.bolusDone)
|
Assertions.assertEquals(true, danaPump.bolusDone)
|
||||||
Assert.assertEquals("NOTIFY__DELIVERY_COMPLETE", packet.friendlyName)
|
Assertions.assertEquals("NOTIFY__DELIVERY_COMPLETE", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRSPacketOptionSetUserOptionTest : DanaRSTestBase() {
|
class DanaRSPacketOptionSetUserOptionTest : DanaRSTestBase() {
|
||||||
|
@ -21,13 +21,13 @@ class DanaRSPacketOptionSetUserOptionTest : DanaRSTestBase() {
|
||||||
val packet = DanaRSPacketOptionSetUserOption(packetInjector)
|
val packet = DanaRSPacketOptionSetUserOption(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
val params = packet.getRequestParams()
|
val params = packet.getRequestParams()
|
||||||
Assert.assertEquals((danaPump.lcdOnTimeSec and 0xff).toByte(), params[3])
|
Assertions.assertEquals((danaPump.lcdOnTimeSec and 0xff).toByte(), params[3])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(3, 0.toByte()))
|
packet.handleMessage(createArray(3, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
// everything ok :)
|
// everything ok :)
|
||||||
packet.handleMessage(createArray(17, 1.toByte()))
|
packet.handleMessage(createArray(17, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("OPTION__SET_USER_OPTION", packet.friendlyName)
|
Assertions.assertEquals("OPTION__SET_USER_OPTION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,2 +0,0 @@
|
||||||
package info.nightscout.pump.danars.comm
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
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.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
@ -41,6 +41,6 @@ class DanaRsMessageHashTableTest : DanaRSTestBase() {
|
||||||
val danaRSMessageHashTable = DanaRSMessageHashTable(packetInjector)
|
val danaRSMessageHashTable = DanaRSMessageHashTable(packetInjector)
|
||||||
val forTesting: DanaRSPacket = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, 0, 0, 0)
|
val forTesting: DanaRSPacket = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, 0, 0, 0)
|
||||||
val testPacket: DanaRSPacket = danaRSMessageHashTable.findMessage(forTesting.command)
|
val testPacket: DanaRSPacket = danaRSMessageHashTable.findMessage(forTesting.command)
|
||||||
Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.opCode.toLong())
|
Assertions.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.opCode.toLong())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketApsBasalSetTemporaryBasalTest : DanaRSTestBase() {
|
class DanaRsPacketApsBasalSetTemporaryBasalTest : DanaRSTestBase() {
|
||||||
|
@ -21,36 +21,36 @@ class DanaRsPacketApsBasalSetTemporaryBasalTest : DanaRSTestBase() {
|
||||||
|
|
||||||
// under 100% should last 30 min
|
// under 100% should last 30 min
|
||||||
var packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 0)
|
var packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 0)
|
||||||
Assert.assertEquals(0, packet.temporaryBasalRatio)
|
Assertions.assertEquals(0, packet.temporaryBasalRatio)
|
||||||
Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM30MIN, packet.temporaryBasalDuration)
|
Assertions.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM30MIN, packet.temporaryBasalDuration)
|
||||||
//constructor with param
|
//constructor with param
|
||||||
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 10)
|
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 10)
|
||||||
Assert.assertEquals(10, packet.temporaryBasalRatio)
|
Assertions.assertEquals(10, packet.temporaryBasalRatio)
|
||||||
Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM30MIN, packet.temporaryBasalDuration)
|
Assertions.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM30MIN, packet.temporaryBasalDuration)
|
||||||
// over 100% should last 15 min
|
// over 100% should last 15 min
|
||||||
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 150)
|
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 150)
|
||||||
Assert.assertEquals(150, packet.temporaryBasalRatio)
|
Assertions.assertEquals(150, packet.temporaryBasalRatio)
|
||||||
Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM15MIN, packet.temporaryBasalDuration)
|
Assertions.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM15MIN, packet.temporaryBasalDuration)
|
||||||
// test low hard limit
|
// test low hard limit
|
||||||
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, -1)
|
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, -1)
|
||||||
Assert.assertEquals(0, packet.temporaryBasalRatio)
|
Assertions.assertEquals(0, packet.temporaryBasalRatio)
|
||||||
Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM30MIN, packet.temporaryBasalDuration)
|
Assertions.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM30MIN, packet.temporaryBasalDuration)
|
||||||
// test high hard limit
|
// test high hard limit
|
||||||
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 550)
|
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 550)
|
||||||
Assert.assertEquals(500, packet.temporaryBasalRatio)
|
Assertions.assertEquals(500, packet.temporaryBasalRatio)
|
||||||
Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM15MIN, packet.temporaryBasalDuration)
|
Assertions.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM15MIN, packet.temporaryBasalDuration)
|
||||||
// test message generation
|
// test message generation
|
||||||
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 260)
|
packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 260)
|
||||||
val generatedCode = packet.getRequestParams()
|
val generatedCode = packet.getRequestParams()
|
||||||
Assert.assertEquals(3, generatedCode.size.toLong())
|
Assertions.assertEquals(3, generatedCode.size.toLong())
|
||||||
Assert.assertEquals(4.toByte(), generatedCode[0])
|
Assertions.assertEquals(4.toByte(), generatedCode[0])
|
||||||
Assert.assertEquals(1.toByte(), generatedCode[1])
|
Assertions.assertEquals(1.toByte(), generatedCode[1])
|
||||||
Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM15MIN.toUByte(), generatedCode[2].toUByte())
|
Assertions.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM15MIN.toUByte(), generatedCode[2].toUByte())
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BASAL__APS_SET_TEMPORARY_BASAL", packet.friendlyName)
|
Assertions.assertEquals("BASAL__APS_SET_TEMPORARY_BASAL", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,12 @@
|
||||||
package info.nightscout.pump.danars.comm
|
package info.nightscout.pump.danars.comm
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
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.Mock
|
import org.mockito.Mock
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
@ -16,8 +14,6 @@ import java.util.GregorianCalendar
|
||||||
|
|
||||||
class DanaRsPacketApsHistoryEventsTest : DanaRSTestBase() {
|
class DanaRsPacketApsHistoryEventsTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var context: Context
|
|
||||||
@Mock lateinit var activePlugin: ActivePlugin
|
|
||||||
@Mock lateinit var pumpSync: PumpSync
|
@Mock lateinit var pumpSync: PumpSync
|
||||||
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||||
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
||||||
|
@ -48,18 +44,18 @@ class DanaRsPacketApsHistoryEventsTest : DanaRSTestBase() {
|
||||||
val returnedValues = testPacket.getRequestParams()
|
val returnedValues = testPacket.getRequestParams()
|
||||||
val expectedValues = getCalender(now)
|
val expectedValues = getCalender(now)
|
||||||
//year
|
//year
|
||||||
Assert.assertEquals(expectedValues[0], returnedValues[0])
|
Assertions.assertEquals(expectedValues[0], returnedValues[0])
|
||||||
//month
|
//month
|
||||||
Assert.assertEquals(expectedValues[1], returnedValues[1])
|
Assertions.assertEquals(expectedValues[1], returnedValues[1])
|
||||||
//day of month
|
//day of month
|
||||||
Assert.assertEquals(expectedValues[2], returnedValues[2])
|
Assertions.assertEquals(expectedValues[2], returnedValues[2])
|
||||||
// hour
|
// hour
|
||||||
Assert.assertEquals(expectedValues[3], returnedValues[3])
|
Assertions.assertEquals(expectedValues[3], returnedValues[3])
|
||||||
// minute
|
// minute
|
||||||
Assert.assertEquals(expectedValues[4], returnedValues[4])
|
Assertions.assertEquals(expectedValues[4], returnedValues[4])
|
||||||
// second
|
// second
|
||||||
Assert.assertEquals(expectedValues[5], returnedValues[5])
|
Assertions.assertEquals(expectedValues[5], returnedValues[5])
|
||||||
Assert.assertEquals("APS_HISTORY_EVENTS", testPacket.friendlyName)
|
Assertions.assertEquals("APS_HISTORY_EVENTS", testPacket.friendlyName)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCalender(from: Long): ByteArray {
|
private fun getCalender(from: Long): ByteArray {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketApsSetEventHistoryTest : DanaRSTestBase() {
|
class DanaRsPacketApsSetEventHistoryTest : DanaRSTestBase() {
|
||||||
|
@ -25,26 +25,26 @@ class DanaRsPacketApsSetEventHistoryTest : DanaRSTestBase() {
|
||||||
val now = dateUtil.now()
|
val now = dateUtil.now()
|
||||||
var historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, -1, 0)
|
var historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, -1, 0)
|
||||||
var testParams = historyTest.getRequestParams()
|
var testParams = historyTest.getRequestParams()
|
||||||
Assert.assertEquals(0.toByte(), testParams[8])
|
Assertions.assertEquals(0.toByte(), testParams[8])
|
||||||
// 5g carbs
|
// 5g carbs
|
||||||
historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, 5, 0)
|
historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, 5, 0)
|
||||||
testParams = historyTest.getRequestParams()
|
testParams = historyTest.getRequestParams()
|
||||||
Assert.assertEquals(5.toByte(), testParams[8])
|
Assertions.assertEquals(5.toByte(), testParams[8])
|
||||||
// 150g carbs
|
// 150g carbs
|
||||||
historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, 150, 0)
|
historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, 150, 0)
|
||||||
testParams = historyTest.getRequestParams()
|
testParams = historyTest.getRequestParams()
|
||||||
Assert.assertEquals(150.toByte(), testParams[8])
|
Assertions.assertEquals(150.toByte(), testParams[8])
|
||||||
// test message generation
|
// test message generation
|
||||||
historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, 5, 0)
|
historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, 5, 0)
|
||||||
testParams = historyTest.getRequestParams()
|
testParams = historyTest.getRequestParams()
|
||||||
Assert.assertEquals(5.toByte(), testParams[8])
|
Assertions.assertEquals(5.toByte(), testParams[8])
|
||||||
Assert.assertEquals(11, testParams.size)
|
Assertions.assertEquals(11, testParams.size)
|
||||||
Assert.assertEquals(DanaPump.HistoryEntry.CARBS.value.toByte(), testParams[0])
|
Assertions.assertEquals(DanaPump.HistoryEntry.CARBS.value.toByte(), testParams[0])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
historyTest.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
historyTest.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, historyTest.failed)
|
Assertions.assertEquals(false, historyTest.failed)
|
||||||
historyTest.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
historyTest.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, historyTest.failed)
|
Assertions.assertEquals(true, historyTest.failed)
|
||||||
Assert.assertEquals("APS_SET_EVENT_HISTORY", historyTest.friendlyName)
|
Assertions.assertEquals("APS_SET_EVENT_HISTORY", historyTest.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() {
|
class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() {
|
||||||
|
@ -28,9 +28,9 @@ class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() {
|
||||||
putIntToArray(array, 0, (1.0 * 100).toInt())
|
putIntToArray(array, 0, (1.0 * 100).toInt())
|
||||||
putByteToArray(array, 2, (0.05 * 100).toInt().toByte())
|
putByteToArray(array, 2, (0.05 * 100).toInt().toByte())
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(1.0, danaPump.maxBasal, 0.0)
|
Assertions.assertEquals(1.0, danaPump.maxBasal, 0.0)
|
||||||
Assert.assertEquals(0.05, danaPump.basalStep, 0.0)
|
Assertions.assertEquals(0.05, danaPump.basalStep, 0.0)
|
||||||
Assert.assertTrue(packet.failed)
|
Assertions.assertTrue(packet.failed)
|
||||||
Assert.assertEquals("BASAL__GET_BASAL_RATE", packet.friendlyName)
|
Assertions.assertEquals("BASAL__GET_BASAL_RATE", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBasalGetProfileNumberTest : DanaRSTestBase() {
|
class DanaRsPacketBasalGetProfileNumberTest : DanaRSTestBase() {
|
||||||
|
@ -23,7 +23,7 @@ class DanaRsPacketBasalGetProfileNumberTest : DanaRSTestBase() {
|
||||||
val array = ByteArray(100)
|
val array = ByteArray(100)
|
||||||
putByteToArray(array, 0, 1.toByte())
|
putByteToArray(array, 0, 1.toByte())
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(1, danaPump.activeProfile)
|
Assertions.assertEquals(1, danaPump.activeProfile)
|
||||||
Assert.assertEquals("BASAL__GET_PROFILE_NUMBER", packet.friendlyName)
|
Assertions.assertEquals("BASAL__GET_PROFILE_NUMBER", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBasalSetCancelTemporaryBasalTest : DanaRSTestBase() {
|
class DanaRsPacketBasalSetCancelTemporaryBasalTest : DanaRSTestBase() {
|
||||||
|
@ -20,9 +20,9 @@ class DanaRsPacketBasalSetCancelTemporaryBasalTest : DanaRSTestBase() {
|
||||||
val packet = DanaRSPacketBasalSetCancelTemporaryBasal(packetInjector)
|
val packet = DanaRSPacketBasalSetCancelTemporaryBasal(packetInjector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(3, 0.toByte()))
|
packet.handleMessage(createArray(3, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(createArray(3, 1.toByte()))
|
packet.handleMessage(createArray(3, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BASAL__CANCEL_TEMPORARY_BASAL", packet.friendlyName)
|
Assertions.assertEquals("BASAL__CANCEL_TEMPORARY_BASAL", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBasalSetProfileBasalRateTest : DanaRSTestBase() {
|
class DanaRsPacketBasalSetProfileBasalRateTest : DanaRSTestBase() {
|
||||||
|
@ -21,14 +21,14 @@ class DanaRsPacketBasalSetProfileBasalRateTest : DanaRSTestBase() {
|
||||||
// test params
|
// test params
|
||||||
val testParams = packet.getRequestParams()
|
val testParams = packet.getRequestParams()
|
||||||
// is profile 1
|
// is profile 1
|
||||||
Assert.assertEquals(1.toByte(), testParams[0])
|
Assertions.assertEquals(1.toByte(), testParams[0])
|
||||||
// is value 100
|
// is value 100
|
||||||
Assert.assertEquals(100.toByte(), testParams[3])
|
Assertions.assertEquals(100.toByte(), testParams[3])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BASAL__SET_PROFILE_BASAL_RATE", packet.friendlyName)
|
Assertions.assertEquals("BASAL__SET_PROFILE_BASAL_RATE", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBasalSetProfileNumberTest : DanaRSTestBase() {
|
class DanaRsPacketBasalSetProfileNumberTest : DanaRSTestBase() {
|
||||||
|
@ -21,12 +21,12 @@ class DanaRsPacketBasalSetProfileNumberTest : DanaRSTestBase() {
|
||||||
// test params
|
// test params
|
||||||
val testParams = packet.getRequestParams()
|
val testParams = packet.getRequestParams()
|
||||||
// is profile 1
|
// is profile 1
|
||||||
Assert.assertEquals(1.toByte(), testParams[0])
|
Assertions.assertEquals(1.toByte(), testParams[0])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BASAL__SET_PROFILE_NUMBER", packet.friendlyName)
|
Assertions.assertEquals("BASAL__SET_PROFILE_NUMBER", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBasalSetSuspendOffTest : DanaRSTestBase() {
|
class DanaRsPacketBasalSetSuspendOffTest : DanaRSTestBase() {
|
||||||
|
@ -20,9 +20,9 @@ class DanaRsPacketBasalSetSuspendOffTest : DanaRSTestBase() {
|
||||||
val packet = DanaRSPacketBasalSetSuspendOff(packetInjector)
|
val packet = DanaRSPacketBasalSetSuspendOff(packetInjector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BASAL__SET_SUSPEND_OFF", packet.friendlyName)
|
Assertions.assertEquals("BASAL__SET_SUSPEND_OFF", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBasalSetSuspendOnTest : DanaRSTestBase() {
|
class DanaRsPacketBasalSetSuspendOnTest : DanaRSTestBase() {
|
||||||
|
@ -20,9 +20,9 @@ class DanaRsPacketBasalSetSuspendOnTest : DanaRSTestBase() {
|
||||||
val packet = DanaRSPacketBasalSetSuspendOn(packetInjector)
|
val packet = DanaRSPacketBasalSetSuspendOn(packetInjector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BASAL__SET_SUSPEND_ON", packet.friendlyName)
|
Assertions.assertEquals("BASAL__SET_SUSPEND_ON", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBolusGetBolusOptionTest : DanaRSTestBase() {
|
class DanaRsPacketBolusGetBolusOptionTest : DanaRSTestBase() {
|
||||||
|
@ -25,15 +25,15 @@ class DanaRsPacketBolusGetBolusOptionTest : DanaRSTestBase() {
|
||||||
// test message decoding
|
// test message decoding
|
||||||
//if dataArray is 1 pump.isExtendedBolusEnabled should be true
|
//if dataArray is 1 pump.isExtendedBolusEnabled should be true
|
||||||
packet.handleMessage(createArray(21, 1.toByte()))
|
packet.handleMessage(createArray(21, 1.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
//Are options saved to pump
|
//Are options saved to pump
|
||||||
Assert.assertEquals(false, !danaPump.isExtendedBolusEnabled)
|
Assertions.assertEquals(false, !danaPump.isExtendedBolusEnabled)
|
||||||
Assert.assertEquals(1, danaPump.bolusCalculationOption)
|
Assertions.assertEquals(1, danaPump.bolusCalculationOption)
|
||||||
Assert.assertEquals(1, danaPump.missedBolusConfig)
|
Assertions.assertEquals(1, danaPump.missedBolusConfig)
|
||||||
packet.handleMessage(createArray(21, 0.toByte()))
|
packet.handleMessage(createArray(21, 0.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
//Are options saved to pump
|
//Are options saved to pump
|
||||||
Assert.assertEquals(true, !danaPump.isExtendedBolusEnabled)
|
Assertions.assertEquals(true, !danaPump.isExtendedBolusEnabled)
|
||||||
Assert.assertEquals("BOLUS__GET_BOLUS_OPTION", packet.friendlyName)
|
Assertions.assertEquals("BOLUS__GET_BOLUS_OPTION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBolusGetCalculationInformationTest : DanaRSTestBase() {
|
class DanaRsPacketBolusGetCalculationInformationTest : DanaRSTestBase() {
|
||||||
|
@ -19,12 +19,12 @@ class DanaRsPacketBolusGetCalculationInformationTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketBolusGetCalculationInformation(packetInjector)
|
val packet = DanaRSPacketBolusGetCalculationInformation(packetInjector)
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(24, 0.toByte()))
|
packet.handleMessage(createArray(24, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(createArray(24, 1.toByte()))
|
packet.handleMessage(createArray(24, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BOLUS__GET_CALCULATION_INFORMATION", packet.friendlyName)
|
Assertions.assertEquals("BOLUS__GET_CALCULATION_INFORMATION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.dana.DanaPump
|
import info.nightscout.pump.dana.DanaPump
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBolusGetCirCfArrayTest : DanaRSTestBase() {
|
class DanaRsPacketBolusGetCirCfArrayTest : DanaRSTestBase() {
|
||||||
|
@ -21,14 +21,14 @@ class DanaRsPacketBolusGetCirCfArrayTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketBolusGetCIRCFArray(packetInjector)
|
val packet = DanaRSPacketBolusGetCIRCFArray(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
// are pump units MG/DL ???
|
// are pump units MG/DL ???
|
||||||
Assert.assertEquals(DanaPump.UNITS_MGDL, danaPump.units)
|
Assertions.assertEquals(DanaPump.UNITS_MGDL, danaPump.units)
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(createArray(34, 3.toByte()))
|
packet.handleMessage(createArray(34, 3.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BOLUS__GET_CIR_CF_ARRAY", packet.friendlyName)
|
Assertions.assertEquals("BOLUS__GET_CIR_CF_ARRAY", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
@ -36,15 +35,15 @@ class DanaRsPacketBolusGetStepBolusInformationTest : DanaRSTestBase() {
|
||||||
putByteToArray(array, 10, 100) // bolus step 1
|
putByteToArray(array, 10, 100) // bolus step 1
|
||||||
|
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertTrue(packet.failed)
|
Assertions.assertTrue(packet.failed)
|
||||||
Assert.assertEquals(6.0, danaPump.initialBolusAmount, 0.01)
|
Assertions.assertEquals(6.0, danaPump.initialBolusAmount, 0.01)
|
||||||
val lastBolus = Calendar.getInstance()
|
val lastBolus = Calendar.getInstance()
|
||||||
lastBolus.timeInMillis = danaPump.lastBolusTime
|
lastBolus.timeInMillis = danaPump.lastBolusTime
|
||||||
Assert.assertEquals(13, lastBolus.get(Calendar.HOUR_OF_DAY))
|
Assertions.assertEquals(13, lastBolus.get(Calendar.HOUR_OF_DAY))
|
||||||
Assert.assertEquals(20, lastBolus.get(Calendar.MINUTE))
|
Assertions.assertEquals(20, lastBolus.get(Calendar.MINUTE))
|
||||||
Assertions.assertEquals(12.5, danaPump.lastBolusAmount, 0.01)
|
Assertions.assertEquals(12.5, danaPump.lastBolusAmount, 0.01)
|
||||||
Assert.assertEquals(25.0, danaPump.maxBolus, 0.01)
|
Assertions.assertEquals(25.0, danaPump.maxBolus, 0.01)
|
||||||
Assert.assertEquals(1.0, danaPump.bolusStep, 0.01)
|
Assertions.assertEquals(1.0, danaPump.bolusStep, 0.01)
|
||||||
Assert.assertEquals("BOLUS__GET_STEP_BOLUS_INFORMATION", packet.friendlyName)
|
Assertions.assertEquals("BOLUS__GET_STEP_BOLUS_INFORMATION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBolusSetBolusOptionTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetBolusOptionTest : DanaRSTestBase() {
|
||||||
|
@ -20,16 +20,16 @@ class DanaRsPacketBolusSetBolusOptionTest : DanaRSTestBase() {
|
||||||
val packet = DanaRSPacketBolusSetBolusOption(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
val packet = DanaRSPacketBolusSetBolusOption(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
// test params
|
// test params
|
||||||
val testParams = packet.getRequestParams()
|
val testParams = packet.getRequestParams()
|
||||||
Assert.assertEquals(0.toByte(), testParams[0])
|
Assertions.assertEquals(0.toByte(), testParams[0])
|
||||||
Assert.assertEquals(0.toByte(), testParams[18])
|
Assertions.assertEquals(0.toByte(), testParams[18])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
// DanaRPump testPump = DanaRPump.getInstance();
|
// DanaRPump testPump = DanaRPump.getInstance();
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BOLUS__SET_BOLUS_OPTION", packet.friendlyName)
|
Assertions.assertEquals("BOLUS__SET_BOLUS_OPTION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBolusSetExtendedBolusCancelTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetExtendedBolusCancelTest : DanaRSTestBase() {
|
||||||
|
@ -18,12 +18,12 @@ class DanaRsPacketBolusSetExtendedBolusCancelTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketBolusSetExtendedBolusCancel(packetInjector)
|
val packet = DanaRSPacketBolusSetExtendedBolusCancel(packetInjector)
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BOLUS__SET_EXTENDED_BOLUS_CANCEL", packet.friendlyName)
|
Assertions.assertEquals("BOLUS__SET_EXTENDED_BOLUS_CANCEL", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBolusSetExtendedBolusTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetExtendedBolusTest : DanaRSTestBase() {
|
||||||
|
@ -19,17 +19,17 @@ class DanaRsPacketBolusSetExtendedBolusTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketBolusSetExtendedBolus(packetInjector, 1.0, 1)
|
val packet = DanaRSPacketBolusSetExtendedBolus(packetInjector, 1.0, 1)
|
||||||
// test params
|
// test params
|
||||||
val testparams = packet.getRequestParams()
|
val testParams = packet.getRequestParams()
|
||||||
Assert.assertEquals(100.toByte(), testparams[0])
|
Assertions.assertEquals(100.toByte(), testParams[0])
|
||||||
Assert.assertEquals(1.toByte(), testparams[2])
|
Assertions.assertEquals(1.toByte(), testParams[2])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
// DanaRPump testPump = DanaRPump.getInstance();
|
// DanaRPump testPump = DanaRPump.getInstance();
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BOLUS__SET_EXTENDED_BOLUS", packet.friendlyName)
|
Assertions.assertEquals("BOLUS__SET_EXTENDED_BOLUS", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.pump.danars.comm
|
package info.nightscout.pump.danars.comm
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
@ -11,7 +10,7 @@ import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -21,7 +20,6 @@ class DanaRsPacketBolusSetStepBolusStartTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var constraintChecker: Constraints
|
@Mock lateinit var constraintChecker: Constraints
|
||||||
@Mock lateinit var commandQueue: CommandQueue
|
@Mock lateinit var commandQueue: CommandQueue
|
||||||
@Mock lateinit var context: Context
|
|
||||||
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||||
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
||||||
@Mock lateinit var pumpSync: PumpSync
|
@Mock lateinit var pumpSync: PumpSync
|
||||||
|
@ -43,14 +41,14 @@ class DanaRsPacketBolusSetStepBolusStartTest : DanaRSTestBase() {
|
||||||
val packet = DanaRSPacketBolusSetStepBolusStart(packetInjector)
|
val packet = DanaRSPacketBolusSetStepBolusStart(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
val testParams = packet.getRequestParams()
|
val testParams = packet.getRequestParams()
|
||||||
Assert.assertEquals(0.toByte(), testParams[0])
|
Assertions.assertEquals(0.toByte(), testParams[0])
|
||||||
Assert.assertEquals(0.toByte(), testParams[2])
|
Assertions.assertEquals(0.toByte(), testParams[2])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(byteArrayOf(1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte()))
|
packet.handleMessage(byteArrayOf(1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("BOLUS__SET_STEP_BOLUS_START", packet.friendlyName)
|
Assertions.assertEquals("BOLUS__SET_STEP_BOLUS_START", packet.friendlyName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
|
|
@ -2,19 +2,15 @@ package info.nightscout.pump.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
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.Mock
|
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
|
||||||
class DanaRsPacketBolusSetStepBolusStopTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetStepBolusStopTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var activePlugin: ActivePlugin
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
if (it is DanaRSPacketBolusSetStepBolusStop) {
|
if (it is DanaRSPacketBolusSetStepBolusStop) {
|
||||||
|
@ -33,9 +29,9 @@ class DanaRsPacketBolusSetStepBolusStopTest : DanaRSTestBase() {
|
||||||
val testPacket = DanaRSPacketBolusSetStepBolusStop(packetInjector)
|
val testPacket = DanaRSPacketBolusSetStepBolusStop(packetInjector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, testPacket.failed)
|
Assertions.assertEquals(false, testPacket.failed)
|
||||||
testPacket.handleMessage(byteArrayOf(1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte()))
|
testPacket.handleMessage(byteArrayOf(1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, testPacket.failed)
|
Assertions.assertEquals(true, testPacket.failed)
|
||||||
Assert.assertEquals("BOLUS__SET_STEP_BOLUS_STOP", testPacket.friendlyName)
|
Assertions.assertEquals("BOLUS__SET_STEP_BOLUS_STOP", testPacket.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketEtcKeepConnectionTest : DanaRSTestBase() {
|
class DanaRsPacketEtcKeepConnectionTest : DanaRSTestBase() {
|
||||||
|
@ -18,12 +18,12 @@ class DanaRsPacketEtcKeepConnectionTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketEtcKeepConnection(packetInjector)
|
val packet = DanaRSPacketEtcKeepConnection(packetInjector)
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(byteArrayOf(1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte()))
|
packet.handleMessage(byteArrayOf(1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("ETC__KEEP_CONNECTION", packet.friendlyName)
|
Assertions.assertEquals("ETC__KEEP_CONNECTION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketEtcSetHistorySaveTest : DanaRSTestBase() {
|
class DanaRsPacketEtcSetHistorySaveTest : DanaRSTestBase() {
|
||||||
|
@ -20,13 +20,13 @@ class DanaRsPacketEtcSetHistorySaveTest : DanaRSTestBase() {
|
||||||
val packet = DanaRSPacketEtcSetHistorySave(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 2)
|
val packet = DanaRSPacketEtcSetHistorySave(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 2)
|
||||||
// test params
|
// test params
|
||||||
val testParams = packet.getRequestParams()
|
val testParams = packet.getRequestParams()
|
||||||
Assert.assertEquals(2.toByte(), testParams[8])
|
Assertions.assertEquals(2.toByte(), testParams[8])
|
||||||
Assert.assertEquals((2 ushr 8).toByte(), testParams[9])
|
Assertions.assertEquals((2 ushr 8).toByte(), testParams[9])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("ETC__SET_HISTORY_SAVE", packet.friendlyName)
|
Assertions.assertEquals("ETC__SET_HISTORY_SAVE", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketGeneralGetPumpCheckTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetPumpCheckTest : DanaRSTestBase() {
|
||||||
|
@ -22,14 +22,14 @@ class DanaRsPacketGeneralGetPumpCheckTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
var packet = DanaRSPacketGeneralGetPumpCheck(packetInjector)
|
var packet = DanaRSPacketGeneralGetPumpCheck(packetInjector)
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
// test for the length message
|
// test for the length message
|
||||||
packet.handleMessage(createArray(1, 0.toByte()))
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
packet = DanaRSPacketGeneralGetPumpCheck(packetInjector)
|
packet = DanaRSPacketGeneralGetPumpCheck(packetInjector)
|
||||||
packet.handleMessage(createArray(15, 0.toByte()))
|
packet.handleMessage(createArray(15, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
Assert.assertEquals("REVIEW__GET_PUMP_CHECK", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__GET_PUMP_CHECK", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketGeneralGetShippingInformationTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetShippingInformationTest : DanaRSTestBase() {
|
||||||
|
@ -22,13 +22,13 @@ class DanaRsPacketGeneralGetShippingInformationTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
var packet = DanaRSPacketGeneralGetShippingInformation(packetInjector)
|
var packet = DanaRSPacketGeneralGetShippingInformation(packetInjector)
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
// test for the length message
|
// test for the length message
|
||||||
packet.handleMessage(createArray(1, 0.toByte()))
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
// everything ok :)
|
// everything ok :)
|
||||||
packet = DanaRSPacketGeneralGetShippingInformation(packetInjector)
|
packet = DanaRSPacketGeneralGetShippingInformation(packetInjector)
|
||||||
Assert.assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketGeneralGetShippingVersionTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetShippingVersionTest : DanaRSTestBase() {
|
||||||
|
@ -22,8 +22,8 @@ class DanaRsPacketGeneralGetShippingVersionTest : DanaRSTestBase() {
|
||||||
// test message decoding
|
// test message decoding
|
||||||
val ver = byteArrayOf((-78).toByte(), (-127).toByte(), (66).toByte(), (80).toByte(), (78).toByte(), (45).toByte(), (51).toByte(), (46).toByte(), (48).toByte(), (46).toByte(), (48).toByte())
|
val ver = byteArrayOf((-78).toByte(), (-127).toByte(), (66).toByte(), (80).toByte(), (78).toByte(), (45).toByte(), (51).toByte(), (46).toByte(), (48).toByte(), (46).toByte(), (48).toByte())
|
||||||
packet.handleMessage(ver)
|
packet.handleMessage(ver)
|
||||||
Assert.assertFalse(packet.failed)
|
Assertions.assertFalse(packet.failed)
|
||||||
Assert.assertEquals("BPN-3.0.0", danaPump.bleModel)
|
Assertions.assertEquals("BPN-3.0.0", danaPump.bleModel)
|
||||||
Assert.assertEquals("GENERAL__GET_SHIPPING_VERSION", packet.friendlyName)
|
Assertions.assertEquals("GENERAL__GET_SHIPPING_VERSION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketGeneralGetUserTimeChangeFlagTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetUserTimeChangeFlagTest : DanaRSTestBase() {
|
||||||
|
@ -18,14 +18,14 @@ class DanaRsPacketGeneralGetUserTimeChangeFlagTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
var packet = DanaRSPacketGeneralGetUserTimeChangeFlag(packetInjector)
|
var packet = DanaRSPacketGeneralGetUserTimeChangeFlag(packetInjector)
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
// test for the length message
|
// test for the length message
|
||||||
packet.handleMessage(createArray(1, 0.toByte()))
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
packet = DanaRSPacketGeneralGetUserTimeChangeFlag(packetInjector)
|
packet = DanaRSPacketGeneralGetUserTimeChangeFlag(packetInjector)
|
||||||
packet.handleMessage(createArray(18, 0.toByte()))
|
packet.handleMessage(createArray(18, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
Assert.assertEquals("REVIEW__GET_USER_TIME_CHANGE_FLAG", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__GET_USER_TIME_CHANGE_FLAG", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketGeneralInitialScreenInformationTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralInitialScreenInformationTest : DanaRSTestBase() {
|
||||||
|
@ -19,15 +19,15 @@ class DanaRsPacketGeneralInitialScreenInformationTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
var packet = DanaRSPacketGeneralInitialScreenInformation(packetInjector)
|
var packet = DanaRSPacketGeneralInitialScreenInformation(packetInjector)
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
// test for the length message
|
// test for the length message
|
||||||
packet.handleMessage(createArray(1, 0.toByte()))
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
packet = DanaRSPacketGeneralInitialScreenInformation(packetInjector)
|
packet = DanaRSPacketGeneralInitialScreenInformation(packetInjector)
|
||||||
packet.handleMessage(createArray(17, 1.toByte()))
|
packet.handleMessage(createArray(17, 1.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
Assert.assertEquals(true, danaPump.pumpSuspended)
|
Assertions.assertEquals(true, danaPump.pumpSuspended)
|
||||||
Assert.assertEquals("REVIEW__INITIAL_SCREEN_INFORMATION", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__INITIAL_SCREEN_INFORMATION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketGeneralSetHistoryUploadModeTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralSetHistoryUploadModeTest : DanaRSTestBase() {
|
||||||
|
@ -19,13 +19,13 @@ class DanaRsPacketGeneralSetHistoryUploadModeTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketGeneralSetHistoryUploadMode(packetInjector, 1)
|
val packet = DanaRSPacketGeneralSetHistoryUploadMode(packetInjector, 1)
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(1.toByte(), packet.getRequestParams()[0])
|
Assertions.assertEquals(1.toByte(), packet.getRequestParams()[0])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(3, 0.toByte()))
|
packet.handleMessage(createArray(3, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
// everything ok :)
|
// everything ok :)
|
||||||
packet.handleMessage(createArray(17, 1.toByte()))
|
packet.handleMessage(createArray(17, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("REVIEW__SET_HISTORY_UPLOAD_MODE", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__SET_HISTORY_UPLOAD_MODE", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketGeneralSetUserTimeChangeFlagClearTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralSetUserTimeChangeFlagClearTest : DanaRSTestBase() {
|
||||||
|
@ -19,13 +19,13 @@ class DanaRsPacketGeneralSetUserTimeChangeFlagClearTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketGeneralSetUserTimeChangeFlagClear(packetInjector)
|
val packet = DanaRSPacketGeneralSetUserTimeChangeFlagClear(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(3, 0.toByte()))
|
packet.handleMessage(createArray(3, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
// everything ok :)
|
// everything ok :)
|
||||||
packet.handleMessage(createArray(17, 1.toByte()))
|
packet.handleMessage(createArray(17, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistoryAllHistoryTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryAllHistoryTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistoryAllHistoryTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistoryAllHistory(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistoryAllHistory(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__ALL_HISTORY", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__ALL_HISTORY", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistoryBasalTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryBasalTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistoryBasalTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistoryBasal(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistoryBasal(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__BASAL", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__BASAL", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistoryBloodGlucoseTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryBloodGlucoseTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistoryBloodGlucoseTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistoryBloodGlucose(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistoryBloodGlucose(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__BLOOD_GLUCOSE", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__BLOOD_GLUCOSE", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistoryBolusTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryBolusTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistoryBolusTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistoryBolus(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistoryBolus(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__BOLUS", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__BOLUS", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistoryCarbohydrateTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryCarbohydrateTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistoryCarbohydrateTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistoryCarbohydrate(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistoryCarbohydrate(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__CARBOHYDRATE", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__CARBOHYDRATE", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistoryDailyTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryDailyTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistoryDailyTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistoryDaily(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistoryDaily(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__DAILY", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__DAILY", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistoryPrimeTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryPrimeTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistoryPrimeTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistoryPrime(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistoryPrime(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__PRIME", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__PRIME", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistoryRefillTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryRefillTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistoryRefillTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistoryRefill(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistoryRefill(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__REFILL", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__REFILL", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistorySuspendTest : DanaRSTestBase() {
|
class DanaRsPacketHistorySuspendTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistorySuspendTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistorySuspend(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistorySuspend(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__SUSPEND", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__SUSPEND", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketHistoryTemporaryTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryTemporaryTest : DanaRSTestBase() {
|
||||||
|
@ -22,6 +22,6 @@ class DanaRsPacketHistoryTemporaryTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketHistoryTemporary(packetInjector, System.currentTimeMillis())
|
val packet = DanaRSPacketHistoryTemporary(packetInjector, System.currentTimeMillis())
|
||||||
Assert.assertEquals("REVIEW__TEMPORARY", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__TEMPORARY", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
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.Mock
|
import org.mockito.Mock
|
||||||
|
|
||||||
|
@ -28,13 +28,13 @@ class DanaRsPacketNotifyAlarmTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketNotifyAlarm(packetInjector)
|
val packet = DanaRSPacketNotifyAlarm(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(17, 0x01.toByte()))
|
packet.handleMessage(createArray(17, 0x01.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
// no error
|
// no error
|
||||||
packet.handleMessage(createArray(17, 0.toByte()))
|
packet.handleMessage(createArray(17, 0.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("NOTIFY__ALARM", packet.friendlyName)
|
Assertions.assertEquals("NOTIFY__ALARM", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.pump.danars.comm
|
package info.nightscout.pump.danars.comm
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
|
@ -11,7 +10,7 @@ import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
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.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.ArgumentMatchers
|
import org.mockito.ArgumentMatchers
|
||||||
|
@ -23,7 +22,6 @@ class DanaRsPacketNotifyDeliveryRateDisplayTest : DanaRSTestBase() {
|
||||||
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
|
||||||
@Mock lateinit var constraintChecker: Constraints
|
@Mock lateinit var constraintChecker: Constraints
|
||||||
@Mock lateinit var commandQueue: CommandQueue
|
@Mock lateinit var commandQueue: CommandQueue
|
||||||
@Mock lateinit var context: Context
|
|
||||||
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||||
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
||||||
@Mock lateinit var pumpSync: PumpSync
|
@Mock lateinit var pumpSync: PumpSync
|
||||||
|
@ -46,15 +44,15 @@ class DanaRsPacketNotifyDeliveryRateDisplayTest : DanaRSTestBase() {
|
||||||
// val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(1.0, Treatment(treatmentInjector))
|
// val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(1.0, Treatment(treatmentInjector))
|
||||||
val packet = DanaRSPacketNotifyDeliveryRateDisplay(packetInjector)
|
val packet = DanaRSPacketNotifyDeliveryRateDisplay(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
// 0% delivered
|
// 0% delivered
|
||||||
packet.handleMessage(createArray(17, 0.toByte()))
|
packet.handleMessage(createArray(17, 0.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
// 100 % delivered
|
// 100 % delivered
|
||||||
packet.handleMessage(createArray(17, 1.toByte()))
|
packet.handleMessage(createArray(17, 1.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
Assert.assertEquals("NOTIFY__DELIVERY_RATE_DISPLAY", packet.friendlyName)
|
Assertions.assertEquals("NOTIFY__DELIVERY_RATE_DISPLAY", packet.friendlyName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketNotifyMissedBolusAlarmTest : DanaRSTestBase() {
|
class DanaRsPacketNotifyMissedBolusAlarmTest : DanaRSTestBase() {
|
||||||
|
@ -19,13 +19,13 @@ class DanaRsPacketNotifyMissedBolusAlarmTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketNotifyMissedBolusAlarm(packetInjector)
|
val packet = DanaRSPacketNotifyMissedBolusAlarm(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(6, 0.toByte()))
|
packet.handleMessage(createArray(6, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
// everything ok :)
|
// everything ok :)
|
||||||
packet.handleMessage(createArray(6, 1.toByte()))
|
packet.handleMessage(createArray(6, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("NOTIFY__MISSED_BOLUS_ALARM", packet.friendlyName)
|
Assertions.assertEquals("NOTIFY__MISSED_BOLUS_ALARM", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
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 DanaRsPacketOptionGetPumpTimeTest : DanaRSTestBase() {
|
class DanaRsPacketOptionGetPumpTimeTest : DanaRSTestBase() {
|
||||||
|
@ -32,7 +32,7 @@ class DanaRsPacketOptionGetPumpTimeTest : DanaRSTestBase() {
|
||||||
putByteToArray(array, 5, 35) // second 35
|
putByteToArray(array, 5, 35) // second 35
|
||||||
|
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(DateTime(2019, 2, 4, 20, 11, 35).millis, danaPump.getPumpTime())
|
Assertions.assertEquals(DateTime(2019, 2, 4, 20, 11, 35).millis, danaPump.getPumpTime())
|
||||||
Assert.assertEquals("OPTION__GET_PUMP_TIME", packet.friendlyName)
|
Assertions.assertEquals("OPTION__GET_PUMP_TIME", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketOptionGetUserOptionTest : DanaRSTestBase() {
|
class DanaRsPacketOptionGetUserOptionTest : DanaRSTestBase() {
|
||||||
|
@ -20,14 +20,14 @@ class DanaRsPacketOptionGetUserOptionTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketOptionGetUserOption(packetInjector)
|
val packet = DanaRSPacketOptionGetUserOption(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(20, 0.toByte()))
|
packet.handleMessage(createArray(20, 0.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
// everything ok :)
|
// everything ok :)
|
||||||
packet.handleMessage(createArray(20, 5.toByte()))
|
packet.handleMessage(createArray(20, 5.toByte()))
|
||||||
Assert.assertEquals(5, danaPump.lcdOnTimeSec)
|
Assertions.assertEquals(5, danaPump.lcdOnTimeSec)
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
Assert.assertEquals("OPTION__GET_USER_OPTION", packet.friendlyName)
|
Assertions.assertEquals("OPTION__GET_USER_OPTION", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
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 DanaRsPacketOptionSetPumpTimeTest : DanaRSTestBase() {
|
class DanaRsPacketOptionSetPumpTimeTest : DanaRSTestBase() {
|
||||||
|
@ -23,18 +23,18 @@ class DanaRsPacketOptionSetPumpTimeTest : DanaRSTestBase() {
|
||||||
val packet = DanaRSPacketOptionSetPumpTime(packetInjector, date.millis)
|
val packet = DanaRSPacketOptionSetPumpTime(packetInjector, date.millis)
|
||||||
// test params
|
// test params
|
||||||
val params = packet.getRequestParams()
|
val params = packet.getRequestParams()
|
||||||
Assert.assertEquals((date.year - 2000 and 0xff).toByte(), params[0]) // 2019 -> 19
|
Assertions.assertEquals((date.year - 2000 and 0xff).toByte(), params[0]) // 2019 -> 19
|
||||||
Assert.assertEquals((date.monthOfYear and 0xff).toByte(), params[1])
|
Assertions.assertEquals((date.monthOfYear and 0xff).toByte(), params[1])
|
||||||
Assert.assertEquals((date.dayOfMonth and 0xff).toByte(), params[2])
|
Assertions.assertEquals((date.dayOfMonth and 0xff).toByte(), params[2])
|
||||||
Assert.assertEquals((date.hourOfDay and 0xff).toByte(), params[3])
|
Assertions.assertEquals((date.hourOfDay and 0xff).toByte(), params[3])
|
||||||
Assert.assertEquals((date.minuteOfHour and 0xff).toByte(), params[4])
|
Assertions.assertEquals((date.minuteOfHour and 0xff).toByte(), params[4])
|
||||||
Assert.assertEquals((date.secondOfMinute and 0xff).toByte(), params[5])
|
Assertions.assertEquals((date.secondOfMinute and 0xff).toByte(), params[5])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(3, 0.toByte()))
|
packet.handleMessage(createArray(3, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
// everything ok :)
|
// everything ok :)
|
||||||
packet.handleMessage(createArray(17, 1.toByte()))
|
packet.handleMessage(createArray(17, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("OPTION__SET_PUMP_TIME", packet.friendlyName)
|
Assertions.assertEquals("OPTION__SET_PUMP_TIME", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketReviewBolusAvgTest : DanaRSTestBase() {
|
class DanaRsPacketReviewBolusAvgTest : DanaRSTestBase() {
|
||||||
|
@ -19,13 +19,13 @@ class DanaRsPacketReviewBolusAvgTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRSPacketReviewBolusAvg(packetInjector)
|
val packet = DanaRSPacketReviewBolusAvg(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(0, packet.getRequestParams().size)
|
Assertions.assertEquals(0, packet.getRequestParams().size)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(12, 0.toByte()))
|
packet.handleMessage(createArray(12, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assertions.assertEquals(false, packet.failed)
|
||||||
// every average equals 1
|
// every average equals 1
|
||||||
packet.handleMessage(createArray(12, 1.toByte()))
|
packet.handleMessage(createArray(12, 1.toByte()))
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assertions.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("REVIEW__BOLUS_AVG", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__BOLUS_AVG", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketReviewGetPumpDecRatioTest : DanaRSTestBase() {
|
class DanaRsPacketReviewGetPumpDecRatioTest : DanaRSTestBase() {
|
||||||
|
@ -23,7 +23,7 @@ class DanaRsPacketReviewGetPumpDecRatioTest : DanaRSTestBase() {
|
||||||
val array = ByteArray(100)
|
val array = ByteArray(100)
|
||||||
putByteToArray(array, 0, 4.toByte())
|
putByteToArray(array, 0, 4.toByte())
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(20, danaPump.decRatio)
|
Assertions.assertEquals(20, danaPump.decRatio)
|
||||||
Assert.assertEquals("REVIEW__GET_PUMP_DEC_RATIO", packet.friendlyName)
|
Assertions.assertEquals("REVIEW__GET_PUMP_DEC_RATIO", packet.friendlyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue