From 1cd93cdc1ebfd50499096164f01671c465dc8f2b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 3 Sep 2023 22:31:47 +0200 Subject: [PATCH] shared-tests #8 --- pump/combo/build.gradle | 3 +- .../nightscout/pump/combo/ComboPluginTest.kt | 14 +- .../info/nightscout/pump/combo/TestBase.kt | 38 ----- pump/dana/build.gradle | 1 + .../androidaps/ProfileStoreObject.kt | 107 ------------ .../info/nightscout/androidaps/TestBase.kt | 37 ----- .../androidaps/TestBaseWithProfile.kt | 58 ------- .../{androidaps => pump}/dana/DanaPumpTest.kt | 7 +- pump/danar/build.gradle | 2 + .../androidaps/ProfileStoreObject.kt | 107 ------------ .../info/nightscout/androidaps/TestBase.kt | 38 ----- .../androidaps/TestBaseWithProfile.kt | 157 ------------------ .../nightscout/androidaps/TestPumpPlugin.kt | 68 -------- .../danaR/comm/MessageOriginalNamesTest.kt | 14 -- .../pump/danaR/comm/RecordTypesTest.kt | 12 -- .../comm/MsgSetAPSTempBasalStartRv2Test.kt | 47 ------ .../nightscout/androidaps/utils/CRCTest.kt | 13 -- .../pump/danaR/DanaRPluginTest.kt | 8 +- .../pump/danaR/comm/DanaRTestBase.kt | 6 +- .../pump/danaR/comm/MessageHashTableRTest.kt | 6 +- .../danaR/comm/MessageOriginalNamesTest.kt | 14 ++ .../pump/danaR/comm/MsgBolusProgressTest.kt | 6 +- .../pump/danaR/comm/MsgBolusStartTest.kt | 8 +- .../danaR/comm/MsgBolusStartWithSpeedTest.kt | 8 +- .../pump/danaR/comm/MsgBolusStopTest.kt | 6 +- .../pump/danaR/comm/MsgCheckValueTest.kt | 6 +- .../pump/danaR/comm/MsgErrorTest.kt | 8 +- .../pump/danaR/comm/MsgHistoryAlarmTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryAllDoneTest.kt | 6 +- .../pump/danaR/comm/MsgHistoryAllTest.kt | 8 +- .../danaR/comm/MsgHistoryBasalHourTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryBolusTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryCarboTest.kt | 2 +- .../danaR/comm/MsgHistoryDailyInsulinTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryDoneTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryErrorTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryGlucoseTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryNewDoneTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryNewTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryRefillTest.kt | 2 +- .../pump/danaR/comm/MsgHistorySuspendTest.kt | 2 +- .../danaR/comm/MsgInitConnStatusBasicTest.kt | 6 +- .../danaR/comm/MsgInitConnStatusBolusTest.kt | 8 +- .../danaR/comm/MsgInitConnStatusOptionTest.kt | 8 +- .../danaR/comm/MsgInitConnStatusTimeTest.kt | 8 +- .../pump/danaR/comm/MsgPCCommStartTest.kt | 2 +- .../pump/danaR/comm/MsgPCCommStopTest.kt | 2 +- .../comm/MsgSetActivateBasalProfileTest.kt | 6 +- .../pump/danaR/comm/MsgSetBasalProfileTest.kt | 6 +- .../pump/danaR/comm/MsgSetCarbsEntryTest.kt | 6 +- .../comm/MsgSetExtendedBolusStartTest.kt | 6 +- .../danaR/comm/MsgSetExtendedBolusStopTest.kt | 6 +- .../comm/MsgSetSingleBasalProfileTest.kt | 6 +- .../danaR/comm/MsgSetTempBasalStartTest.kt | 6 +- .../pump/danaR/comm/MsgSetTimeTest.kt | 6 +- .../pump/danaR/comm/MsgSetUserOptionsTest.kt | 6 +- .../danaR/comm/MsgSettingActiveProfileTest.kt | 6 +- .../comm/MsgSettingBasalProfileAllTest.kt | 2 +- .../pump/danaR/comm/MsgSettingBasalTest.kt | 6 +- .../pump/danaR/comm/MsgSettingGlucoseTest.kt | 6 +- .../danaR/comm/MsgSettingMaxValuesTest.kt | 6 +- .../pump/danaR/comm/MsgSettingMealTest.kt | 6 +- .../comm/MsgSettingProfileRatiosAllTest.kt | 6 +- .../danaR/comm/MsgSettingProfileRatiosTest.kt | 6 +- .../pump/danaR/comm/MsgSettingPumpTimeTest.kt | 6 +- .../danaR/comm/MsgSettingShippingInfoTest.kt | 6 +- .../danaR/comm/MsgSettingUserOptionsTest.kt | 6 +- .../pump/danaR/comm/MsgStatusBasicTest.kt | 6 +- .../danaR/comm/MsgStatusBolusExtendedTest.kt | 6 +- .../pump/danaR/comm/MsgStatusProfileTest.kt | 6 +- .../pump/danaR/comm/MsgStatusTempBasalTest.kt | 8 +- .../pump/danaR/comm/MsgStatusTest.kt | 6 +- .../pump/danaR/comm/RecordTypesTest.kt | 12 ++ .../pump/danaRKorean/DanaRKoreanPluginTest.kt | 12 +- .../comm/MessageHashTableRKoreanTest.kt | 8 +- .../pump/danaRv2/DanaRv2PluginTest.kt | 8 +- .../danaRv2/comm/MessageHashTableRv2Test.kt | 10 +- .../pump/danaRv2/comm/MsgCheckValueRv2Test.kt | 8 +- .../danaRv2/comm/MsgHistoryEventsRv2Test.kt | 10 +- .../comm/MsgSetAPSTempBasalStartRv2Test.kt | 47 ++++++ .../danaRv2/comm/MsgSetHistoryEntryRv2Test.kt | 10 +- .../pump/danaRv2/comm/MsgStatusAPSRv2Test.kt | 8 +- .../info/nightscout/pump/utils/CRCTest.kt | 14 ++ 83 files changed, 277 insertions(+), 889 deletions(-) delete mode 100644 pump/combo/src/test/java/info/nightscout/pump/combo/TestBase.kt delete mode 100644 pump/dana/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt delete mode 100644 pump/dana/src/test/java/info/nightscout/androidaps/TestBase.kt delete mode 100644 pump/dana/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt rename pump/dana/src/test/java/info/nightscout/{androidaps => pump}/dana/DanaPumpTest.kt (72%) delete mode 100644 pump/danar/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt delete mode 100644 pump/danar/src/test/java/info/nightscout/androidaps/TestBase.kt delete mode 100644 pump/danar/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt delete mode 100644 pump/danar/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt delete mode 100644 pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageOriginalNamesTest.kt delete mode 100644 pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/RecordTypesTest.kt delete mode 100644 pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStartRv2Test.kt delete mode 100644 pump/danar/src/test/java/info/nightscout/androidaps/utils/CRCTest.kt rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/DanaRPluginTest.kt (92%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/DanaRTestBase.kt (96%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MessageHashTableRTest.kt (75%) create mode 100644 pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MessageOriginalNamesTest.kt rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgBolusProgressTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgBolusStartTest.kt (76%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgBolusStartWithSpeedTest.kt (77%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgBolusStopTest.kt (80%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgCheckValueTest.kt (73%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgErrorTest.kt (70%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryAlarmTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryAllDoneTest.kt (67%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryAllTest.kt (71%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryBasalHourTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryBolusTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryCarboTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt (84%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryDoneTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryErrorTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryGlucoseTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryNewDoneTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryNewTest.kt (82%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistoryRefillTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgHistorySuspendTest.kt (83%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgInitConnStatusBasicTest.kt (73%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgInitConnStatusBolusTest.kt (70%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgInitConnStatusOptionTest.kt (68%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgInitConnStatusTimeTest.kt (69%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgPCCommStartTest.kt (84%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgPCCommStopTest.kt (84%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSetActivateBasalProfileTest.kt (73%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSetBasalProfileTest.kt (72%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSetCarbsEntryTest.kt (72%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSetExtendedBolusStartTest.kt (80%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSetExtendedBolusStopTest.kt (71%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSetSingleBasalProfileTest.kt (73%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSetTempBasalStartTest.kt (71%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSetTimeTest.kt (71%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSetUserOptionsTest.kt (70%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingActiveProfileTest.kt (64%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingBasalProfileAllTest.kt (85%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingBasalTest.kt (74%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingGlucoseTest.kt (71%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingMaxValuesTest.kt (60%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingMealTest.kt (59%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingProfileRatiosAllTest.kt (69%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingProfileRatiosTest.kt (69%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingPumpTimeTest.kt (84%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingShippingInfoTest.kt (70%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgSettingUserOptionsTest.kt (75%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgStatusBasicTest.kt (58%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgStatusBolusExtendedTest.kt (73%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgStatusProfileTest.kt (68%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgStatusTempBasalTest.kt (65%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaR/comm/MsgStatusTest.kt (57%) create mode 100644 pump/danar/src/test/java/info/nightscout/pump/danaR/comm/RecordTypesTest.kt rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaRKorean/DanaRKoreanPluginTest.kt (88%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt (68%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaRv2/DanaRv2PluginTest.kt (93%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaRv2/comm/MessageHashTableRv2Test.kt (73%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaRv2/comm/MsgCheckValueRv2Test.kt (61%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaRv2/comm/MsgHistoryEventsRv2Test.kt (62%) create mode 100644 pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgSetAPSTempBasalStartRv2Test.kt rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaRv2/comm/MsgSetHistoryEntryRv2Test.kt (65%) rename pump/danar/src/test/java/info/nightscout/{androidaps/plugins => }/pump/danaRv2/comm/MsgStatusAPSRv2Test.kt (65%) create mode 100644 pump/danar/src/test/java/info/nightscout/pump/utils/CRCTest.kt diff --git a/pump/combo/build.gradle b/pump/combo/build.gradle index 31d5153c42..ff6202ea71 100644 --- a/pump/combo/build.gradle +++ b/pump/combo/build.gradle @@ -25,7 +25,8 @@ dependencies { implementation project(':core:utils') implementation project(':app-wear-shared:shared') + testImplementation project(':app-wear-shared:shared-tests') + // RuffyScripter api "com.google.guava:guava:$guava_version" - } \ No newline at end of file diff --git a/pump/combo/src/test/java/info/nightscout/pump/combo/ComboPluginTest.kt b/pump/combo/src/test/java/info/nightscout/pump/combo/ComboPluginTest.kt index b6df3f7482..1d238e0cb4 100644 --- a/pump/combo/src/test/java/info/nightscout/pump/combo/ComboPluginTest.kt +++ b/pump/combo/src/test/java/info/nightscout/pump/combo/ComboPluginTest.kt @@ -3,7 +3,6 @@ package info.nightscout.pump.combo import android.content.Context import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.TestBase import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.profile.ProfileFunction @@ -17,7 +16,8 @@ import info.nightscout.rx.bus.RxBus import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil -import org.junit.Assert +import info.nightscout.sharedtests.TestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -58,8 +58,8 @@ class ComboPluginTest : TestBase() { comboPlugin.setValidBasalRateProfileSelectedOnPump(false) var c = Constraint(true) c = comboPlugin.isLoopInvocationAllowed(c) - Assert.assertEquals("Combo: No valid basal rate read from pump", c.getReasons(aapsLogger)) - Assert.assertEquals(false, c.value()) + Assertions.assertEquals("Combo: No valid basal rate read from pump", c.getReasons(aapsLogger)) + Assertions.assertEquals(false, c.value()) comboPlugin.setPluginEnabled(PluginType.PUMP, false) } @@ -68,18 +68,18 @@ class ComboPluginTest : TestBase() { val now = System.currentTimeMillis() val pumpTimestamp = now - now % 1000 // same timestamp, different bolus leads to different fake timestamp - Assert.assertNotEquals( + Assertions.assertNotEquals( comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.1, true)), comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true)) ) // different timestamp, same bolus leads to different fake timestamp - Assert.assertNotEquals( + Assertions.assertNotEquals( comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true)), comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp + 60 * 1000, 0.3, true)) ) // generated timestamp has second-precision val bolus = Bolus(pumpTimestamp, 0.2, true) val calculatedTimestamp = comboPlugin.generatePumpBolusId(bolus) - Assert.assertEquals(calculatedTimestamp, calculatedTimestamp - calculatedTimestamp % 1000) + Assertions.assertEquals(calculatedTimestamp, calculatedTimestamp - calculatedTimestamp % 1000) } } \ No newline at end of file diff --git a/pump/combo/src/test/java/info/nightscout/pump/combo/TestBase.kt b/pump/combo/src/test/java/info/nightscout/pump/combo/TestBase.kt deleted file mode 100644 index 8372cd9648..0000000000 --- a/pump/combo/src/test/java/info/nightscout/pump/combo/TestBase.kt +++ /dev/null @@ -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 anyObject(): T { - Mockito.any() - return uninitialized() - } - - @Suppress("Unchecked_Cast") - fun uninitialized(): T = null as T -} \ No newline at end of file diff --git a/pump/dana/build.gradle b/pump/dana/build.gradle index 5d061f18ce..aedc35aff8 100644 --- a/pump/dana/build.gradle +++ b/pump/dana/build.gradle @@ -36,5 +36,6 @@ dependencies { api "androidx.room:room-rxjava3:$room_version" kapt "androidx.room:room-compiler:$room_version" + testImplementation project(':app-wear-shared:shared-tests') testImplementation project(':core:main') // create profile from json } \ No newline at end of file diff --git a/pump/dana/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt b/pump/dana/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt deleted file mode 100644 index e4040d0369..0000000000 --- a/pump/dana/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt +++ /dev/null @@ -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() - - 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 { - val ret = ArrayList() - 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 } -} \ No newline at end of file diff --git a/pump/dana/src/test/java/info/nightscout/androidaps/TestBase.kt b/pump/dana/src/test/java/info/nightscout/androidaps/TestBase.kt deleted file mode 100644 index 4fd2aef548..0000000000 --- a/pump/dana/src/test/java/info/nightscout/androidaps/TestBase.kt +++ /dev/null @@ -1,37 +0,0 @@ -package info.nightscout.androidaps - -import info.nightscout.rx.AapsSchedulers -import info.nightscout.rx.TestAapsSchedulers -import info.nightscout.rx.logging.AAPSLoggerTest -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.extension.ExtendWith -import org.mockito.Mockito -import org.mockito.junit.jupiter.MockitoExtension -import org.mockito.junit.jupiter.MockitoSettings -import org.mockito.quality.Strictness -import java.util.Locale - -@ExtendWith(MockitoExtension::class) -@MockitoSettings(strictness = Strictness.LENIENT) -open class TestBase { - - val aapsLogger = AAPSLoggerTest() - val aapsSchedulers: AapsSchedulers = TestAapsSchedulers() - - @BeforeEach - fun setupLocale() { - Locale.setDefault(Locale.ENGLISH) - System.setProperty("disableFirebase", "true") - } - - // Workaround for Kotlin nullability. - // https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791 - // https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin - fun anyObject(): T { - Mockito.any() - return uninitialized() - } - - @Suppress("Unchecked_Cast") - fun uninitialized(): T = null as T -} \ No newline at end of file diff --git a/pump/dana/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt b/pump/dana/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt deleted file mode 100644 index 76235287ed..0000000000 --- a/pump/dana/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt +++ /dev/null @@ -1,58 +0,0 @@ -package info.nightscout.androidaps - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.core.utils.fabric.FabricPrivacy -import info.nightscout.interfaces.Config -import info.nightscout.interfaces.plugin.ActivePlugin -import info.nightscout.interfaces.profile.DefaultValueHelper -import info.nightscout.interfaces.profile.ProfileFunction -import info.nightscout.interfaces.profile.ProfileStore -import info.nightscout.rx.bus.RxBus -import info.nightscout.shared.interfaces.ResourceHelper -import info.nightscout.shared.utils.DateUtil -import org.json.JSONObject -import org.junit.jupiter.api.BeforeEach -import org.mockito.Mock - -@Suppress("SpellCheckingInspection") -open class TestBaseWithProfile : TestBase() { - - @Mock lateinit var activePluginProvider: ActivePlugin - @Mock lateinit var rh: ResourceHelper - @Mock lateinit var fabricPrivacy: FabricPrivacy - @Mock lateinit var profileFunction: ProfileFunction - @Mock lateinit var defaultValueHelper: DefaultValueHelper - @Mock lateinit var dateUtil: DateUtil - @Mock lateinit var config: Config - - val rxBus = RxBus(aapsSchedulers, aapsLogger) - - val profileInjector = HasAndroidInjector { - AndroidInjector { - } - } - - private lateinit var validProfileJSON: String - @Suppress("PropertyName") val TESTPROFILENAME = "someProfile" - - @BeforeEach - fun prepareMock() { - validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," + - "{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," + - "\"target_high\":[{\"time\":\"00:00\",\"value\":\"7\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}" - } - - fun getValidProfileStore(): ProfileStore { - validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," + - "{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," + - "\"target_high\":[{\"time\":\"00:00\",\"value\":\"7\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}" - - val json = JSONObject() - val store = JSONObject() - store.put(TESTPROFILENAME, JSONObject(validProfileJSON)) - json.put("defaultProfile", TESTPROFILENAME) - json.put("store", store) - return ProfileStoreObject(profileInjector, json, dateUtil) - } -} diff --git a/pump/dana/src/test/java/info/nightscout/androidaps/dana/DanaPumpTest.kt b/pump/dana/src/test/java/info/nightscout/pump/dana/DanaPumpTest.kt similarity index 72% rename from pump/dana/src/test/java/info/nightscout/androidaps/dana/DanaPumpTest.kt rename to pump/dana/src/test/java/info/nightscout/pump/dana/DanaPumpTest.kt index 7dab933399..bea0277eff 100644 --- a/pump/dana/src/test/java/info/nightscout/androidaps/dana/DanaPumpTest.kt +++ b/pump/dana/src/test/java/info/nightscout/pump/dana/DanaPumpTest.kt @@ -1,9 +1,7 @@ -package info.nightscout.androidaps.dana +package info.nightscout.pump.dana -import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.interfaces.profile.Instantiator -import info.nightscout.pump.dana.DanaPump -import info.nightscout.shared.sharedPreferences.SP +import info.nightscout.sharedtests.TestBaseWithProfile import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -11,7 +9,6 @@ import org.mockito.Mock class DanaPumpTest : TestBaseWithProfile() { - @Mock lateinit var sp: SP @Mock lateinit var instantiator: Instantiator private lateinit var sut: DanaPump diff --git a/pump/danar/build.gradle b/pump/danar/build.gradle index 2300a81cb6..5a29590ff8 100644 --- a/pump/danar/build.gradle +++ b/pump/danar/build.gradle @@ -15,6 +15,7 @@ android { } dependencies { + implementation 'androidx.media3:media3-common:1.1.1' implementation project(':app-wear-shared:shared') implementation project(':core:interfaces') implementation project(':core:utils') @@ -22,5 +23,6 @@ dependencies { implementation project(':core:validators') implementation project(':pump:dana') + testImplementation project(':app-wear-shared:shared-tests') testImplementation project(':core:main') } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt b/pump/danar/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt deleted file mode 100644 index e4040d0369..0000000000 --- a/pump/danar/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt +++ /dev/null @@ -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() - - 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 { - val ret = ArrayList() - 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 } -} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/TestBase.kt b/pump/danar/src/test/java/info/nightscout/androidaps/TestBase.kt deleted file mode 100644 index c56bdc19a8..0000000000 --- a/pump/danar/src/test/java/info/nightscout/androidaps/TestBase.kt +++ /dev/null @@ -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 anyObject(): T { - Mockito.any() - return uninitialized() - } - - @Suppress("Unchecked_Cast") - private fun uninitialized(): T = null as T -} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt b/pump/danar/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt deleted file mode 100644 index e801e3f513..0000000000 --- a/pump/danar/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt +++ /dev/null @@ -1,157 +0,0 @@ -package info.nightscout.androidaps - -import android.content.Context -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.core.extensions.pureProfileFromJson -import info.nightscout.core.profile.ProfileSealed -import info.nightscout.core.utils.fabric.FabricPrivacy -import info.nightscout.interfaces.Config -import info.nightscout.interfaces.iob.IobCobCalculator -import info.nightscout.interfaces.plugin.ActivePlugin -import info.nightscout.interfaces.profile.ProfileFunction -import info.nightscout.interfaces.profile.ProfileStore -import info.nightscout.rx.bus.RxBus -import info.nightscout.shared.interfaces.ResourceHelper -import info.nightscout.shared.utils.DateUtil -import org.json.JSONObject -import org.junit.jupiter.api.BeforeEach -import org.mockito.ArgumentMatchers.anyDouble -import org.mockito.ArgumentMatchers.anyInt -import org.mockito.ArgumentMatchers.anyString -import org.mockito.Mock -import org.mockito.Mockito -import org.mockito.invocation.InvocationOnMock - -@Suppress("SpellCheckingInspection") -open class TestBaseWithProfile : TestBase() { - - @Mock lateinit var activePluginProvider: ActivePlugin - @Mock lateinit var rh: ResourceHelper - @Mock lateinit var iobCobCalculator: IobCobCalculator - @Mock lateinit var fabricPrivacy: FabricPrivacy - @Mock lateinit var profileFunction: ProfileFunction - @Mock lateinit var config: Config - @Mock lateinit var context: Context - - lateinit var dateUtil: DateUtil - val rxBus = RxBus(aapsSchedulers, aapsLogger) - - val profileInjector = HasAndroidInjector { AndroidInjector { } } - - private lateinit var validProfileJSON: String - lateinit var validProfile: ProfileSealed.Pure - - @Suppress("PropertyName") val TESTPROFILENAME = "someProfile" - - @BeforeEach - fun prepareMock() { - validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," + - "{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," + - "\"target_high\":[{\"time\":\"00:00\",\"value\":\"7\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}" - dateUtil = DateUtil(context) - validProfile = ProfileSealed.Pure(pureProfileFromJson(JSONObject(validProfileJSON), dateUtil)!!) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - String.format(rh.gs(string), arg1) - }.`when`(rh).gs(anyInt(), anyInt()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - String.format(rh.gs(string), arg1) - }.`when`(rh).gs(anyInt(), anyDouble()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - String.format(rh.gs(string), arg1) - }.`when`(rh).gs(anyInt(), anyString()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - String.format(rh.gs(string), arg1, arg2) - }.`when`(rh).gs(anyInt(), anyString(), anyString()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - String.format(rh.gs(string), arg1, arg2) - }.`when`(rh).gs(anyInt(), anyString(), anyInt()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - String.format(rh.gs(string), arg1, arg2) - }.`when`(rh).gs(anyInt(), anyDouble(), anyString()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - String.format(rh.gs(string), arg1, arg2) - }.`when`(rh).gs(anyInt(), anyDouble(), anyInt()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - String.format(rh.gs(string), arg1, arg2) - }.`when`(rh).gs(anyInt(), anyInt(), anyInt()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - String.format(rh.gs(string), arg1, arg2) - }.`when`(rh).gs(anyInt(), anyInt(), anyString()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - val arg3 = invocation.getArgument(3) - String.format(rh.gs(string), arg1, arg2, arg3) - }.`when`(rh).gs(anyInt(), anyInt(), anyInt(), anyString()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - val arg3 = invocation.getArgument(3) - String.format(rh.gs(string), arg1, arg2, arg3) - }.`when`(rh).gs(anyInt(), anyInt(), anyString(), anyString()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - val arg3 = invocation.getArgument(3) - String.format(rh.gs(string), arg1, arg2, arg3) - }.`when`(rh).gs(anyInt(), anyDouble(), anyInt(), anyString()) - - Mockito.doAnswer { invocation: InvocationOnMock -> - val string = invocation.getArgument(0) - val arg1 = invocation.getArgument(1) - val arg2 = invocation.getArgument(2) - val arg3 = invocation.getArgument(3) - String.format(rh.gs(string), arg1, arg2, arg3) - }.`when`(rh).gs(anyInt(), anyString(), anyInt(), anyString()) - - } - - fun getValidProfileStore(): ProfileStore { - val json = JSONObject() - val store = JSONObject() - store.put(TESTPROFILENAME, JSONObject(validProfileJSON)) - json.put("defaultProfile", TESTPROFILENAME) - json.put("store", store) - return ProfileStoreObject(profileInjector, json, dateUtil) - } -} diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt b/pump/danar/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt deleted file mode 100644 index aad8035a99..0000000000 --- a/pump/danar/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt +++ /dev/null @@ -1,68 +0,0 @@ -package info.nightscout.androidaps - -import dagger.android.HasAndroidInjector -import info.nightscout.interfaces.profile.Profile -import info.nightscout.interfaces.pump.DetailedBolusInfo -import info.nightscout.interfaces.pump.Pump -import info.nightscout.interfaces.pump.PumpEnactResult -import info.nightscout.interfaces.pump.PumpSync -import info.nightscout.interfaces.pump.defs.ManufacturerType -import info.nightscout.interfaces.pump.defs.PumpDescription -import info.nightscout.interfaces.pump.defs.PumpType -import info.nightscout.interfaces.utils.TimeChangeType -import org.json.JSONObject - -@Suppress("MemberVisibilityCanBePrivate") -class TestPumpPlugin(val injector: HasAndroidInjector) : Pump { - - var connected = false - var isProfileSet = true - - override fun isConnected() = connected - override fun isConnecting() = false - override fun isHandshakeInProgress() = false - val lastData = 0L - - val baseBasal = 0.0 - override val pumpDescription = PumpDescription() - - override fun isInitialized(): Boolean = true - override fun isSuspended(): Boolean = false - override fun isBusy(): Boolean = false - override fun connect(reason: String) { - connected = true - } - - override fun disconnect(reason: String) { - connected = false - } - - override fun stopConnecting() { - connected = false - } - - override fun waitForDisconnectionInSeconds(): Int = 0 - override fun getPumpStatus(reason: String) {} - override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector) - override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet - override fun lastDataTime(): Long = lastData - override val baseBasalRate: Double = baseBasal - override val reservoirLevel: Double = 0.0 - override val batteryLevel: Int = 0 - override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true) - override fun stopBolusDelivering() {} - override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResult(injector).success(true) - override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResult(injector).success(true) - override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true) - override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true) - override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true) - override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject() - override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS - override fun model(): PumpType = PumpType.GENERIC_AAPS - override fun serialNumber(): String = "1" - override fun shortStatus(veryShort: Boolean): String = "" - override val isFakingTempsByExtendedBoluses: Boolean = false - override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true) - override fun canHandleDST(): Boolean = true - override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} -} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageOriginalNamesTest.kt b/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageOriginalNamesTest.kt deleted file mode 100644 index bdfa17fc8c..0000000000 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageOriginalNamesTest.kt +++ /dev/null @@ -1,14 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm - -import info.nightscout.androidaps.TestBase -import info.nightscout.androidaps.danar.comm.MessageOriginalNames -import org.junit.Assert -import org.junit.jupiter.api.Test - -class MessageOriginalNamesTest : TestBase() { - - @Test - fun getNameTest() { - Assert.assertEquals("CMD_CONNECT", MessageOriginalNames.getName(0x3001)) - } -} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/RecordTypesTest.kt b/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/RecordTypesTest.kt deleted file mode 100644 index c47b5f84d0..0000000000 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/RecordTypesTest.kt +++ /dev/null @@ -1,12 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm - -import info.nightscout.pump.dana.comm.RecordTypes -import org.junit.Assert -import org.junit.jupiter.api.Test - -class RecordTypesTest { - - @Test fun runTest() { - Assert.assertEquals(1.toByte(), RecordTypes.RECORD_TYPE_BOLUS) - } -} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStartRv2Test.kt b/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStartRv2Test.kt deleted file mode 100644 index 8a60c4f7b9..0000000000 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStartRv2Test.kt +++ /dev/null @@ -1,47 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.danaRv2.comm - -import info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2 -import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase -import org.junit.Assert -import org.junit.jupiter.api.Test - -class MsgSetAPSTempBasalStartRv2Test : DanaRTestBase() { - - @Test fun runTest() { - - // test low hard limit - var packet = MsgSetAPSTempBasalStart_v2(injector, -1, true, false) - Assert.assertEquals(0, packet.intFromBuff(packet.buffer, 0, 2)) - Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) - // test high hard limit - packet = MsgSetAPSTempBasalStart_v2(injector, 550, true, false) - Assert.assertEquals(500, packet.intFromBuff(packet.buffer, 0, 2)) - Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) - // test setting 15 min - packet = MsgSetAPSTempBasalStart_v2(injector, 50, true, false) - Assert.assertEquals(50, packet.intFromBuff(packet.buffer, 0, 2)) - Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) - // test setting 30 min - packet = MsgSetAPSTempBasalStart_v2(injector, 50, false, true) - Assert.assertEquals(50, packet.intFromBuff(packet.buffer, 0, 2)) - Assert.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1)) - // over 200% set always 15 min - packet = MsgSetAPSTempBasalStart_v2(injector, 250, false, true) - Assert.assertEquals(250, packet.intFromBuff(packet.buffer, 0, 2)) - Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) - // test low hard limit - packet = MsgSetAPSTempBasalStart_v2(injector, -1, false, true) - Assert.assertEquals(0, packet.intFromBuff(packet.buffer, 0, 2)) - Assert.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1)) - // test high hard limit - packet = MsgSetAPSTempBasalStart_v2(injector, 550, false, true) - Assert.assertEquals(500, packet.intFromBuff(packet.buffer, 0, 2)) - Assert.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) - - // test message decoding - packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte())) - Assert.assertEquals(true, packet.failed) - packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 1.toByte())) - Assert.assertEquals(false, packet.failed) - } -} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/utils/CRCTest.kt b/pump/danar/src/test/java/info/nightscout/androidaps/utils/CRCTest.kt deleted file mode 100644 index 04dcdb1352..0000000000 --- a/pump/danar/src/test/java/info/nightscout/androidaps/utils/CRCTest.kt +++ /dev/null @@ -1,13 +0,0 @@ -package info.nightscout.androidaps.utils - -import org.junit.Assert -import org.junit.jupiter.api.Test - -class CRCTest { - - @Test - fun getCrc16Test() { - val data = byteArrayOf(1,2,3,4,5,6,7,8,9,0) - Assert.assertEquals(27649.toShort(), CRC.getCrc16(data, 0, 10)) - } -} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/DanaRPluginTest.kt similarity index 92% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/DanaRPluginTest.kt index ad3e1b068a..a53ef197b8 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/DanaRPluginTest.kt @@ -1,8 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR +package info.nightscout.pump.danaR import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.danar.DanaRPlugin import info.nightscout.interfaces.Constants import info.nightscout.interfaces.constraints.Constraint @@ -14,7 +13,7 @@ import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.database.DanaHistoryDatabase -import info.nightscout.shared.sharedPreferences.SP +import info.nightscout.sharedtests.TestBaseWithProfile import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -24,7 +23,6 @@ import org.mockito.Mockito.`when` class DanaRPluginTest : TestBaseWithProfile() { @Mock lateinit var constraintChecker: Constraints - @Mock lateinit var sp: SP @Mock lateinit var commandQueue: CommandQueue @Mock lateinit var pumpSync: PumpSync @Mock lateinit var instantiator: Instantiator @@ -49,7 +47,7 @@ class DanaRPluginTest : TestBaseWithProfile() { `when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator) danaRPlugin = DanaRPlugin( - injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync, + injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync, uiInteraction, danaHistoryDatabase ) } diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/DanaRTestBase.kt similarity index 96% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/DanaRTestBase.kt index b14fad7e87..b806b5816a 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/DanaRTestBase.kt @@ -1,9 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.TestBase -import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.danar.DanaRPlugin @@ -22,6 +20,8 @@ import info.nightscout.rx.bus.RxBus import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil +import info.nightscout.sharedtests.TestBase +import info.nightscout.sharedtests.TestPumpPlugin import org.junit.jupiter.api.BeforeEach import org.mockito.ArgumentMatchers import org.mockito.Mock diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableRTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MessageHashTableRTest.kt similarity index 75% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableRTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MessageHashTableRTest.kt index 57818ee8a7..9f4c683f63 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableRTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MessageHashTableRTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MessageHashTableR import info.nightscout.interfaces.constraints.Constraint -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito @@ -12,6 +12,6 @@ class MessageHashTableRTest : DanaRTestBase() { Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) val messageHashTable = MessageHashTableR(injector) val testMessage = messageHashTable.findMessage(0x41f2) - Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName) + Assertions.assertEquals("CMD_HISTORY_ALL", testMessage.messageName) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MessageOriginalNamesTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MessageOriginalNamesTest.kt new file mode 100644 index 0000000000..d4196ec20f --- /dev/null +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MessageOriginalNamesTest.kt @@ -0,0 +1,14 @@ +package info.nightscout.pump.danaR.comm + +import info.nightscout.androidaps.danar.comm.MessageOriginalNames +import info.nightscout.sharedtests.TestBase +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class MessageOriginalNamesTest : TestBase() { + + @Test + fun getNameTest() { + Assertions.assertEquals("CMD_CONNECT", MessageOriginalNames.getName(0x3001)) + } +} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusProgressTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusProgressTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusProgressTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusProgressTest.kt index c8d958596f..499e6a3a9d 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusProgressTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusProgressTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgBolusProgress import info.nightscout.rx.events.EventOverviewBolusProgress -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers import org.mockito.Mockito.`when` @@ -19,6 +19,6 @@ class MsgBolusProgressTest : DanaRTestBase() { val array = ByteArray(100) putIntToArray(array, 0, 2 * 100) packet.handleMessage(array) - Assert.assertEquals(1.0, danaPump.bolusingTreatment?.insulin!!, 0.0) + Assertions.assertEquals(1.0, danaPump.bolusingTreatment?.insulin!!, 0.0) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusStartTest.kt similarity index 76% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusStartTest.kt index c712530d67..da974f3209 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusStartTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgBolusStart import info.nightscout.interfaces.constraints.Constraint -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -17,10 +17,10 @@ class MsgBolusStartTest : DanaRTestBase() { putByteToArray(array, 0, 1) packet.handleMessage(array) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) putByteToArray(array, 0, 2) packet.handleMessage(array) - Assert.assertEquals(false, packet.failed) + Assertions.assertEquals(false, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeedTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusStartWithSpeedTest.kt similarity index 77% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeedTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusStartWithSpeedTest.kt index b0c08a8202..ff2313a4a5 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeedTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusStartWithSpeedTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgBolusStartWithSpeed import info.nightscout.interfaces.constraints.Constraint -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito @@ -17,10 +17,10 @@ class MsgBolusStartWithSpeedTest : DanaRTestBase() { putByteToArray(array, 0, 1) packet.handleMessage(array) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) putByteToArray(array, 0, 2) packet.handleMessage(array) - Assert.assertEquals(false, packet.failed) + Assertions.assertEquals(false, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStopTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusStopTest.kt similarity index 80% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStopTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusStopTest.kt index b98d72e472..434397e720 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStopTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgBolusStopTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgBolusStop import info.nightscout.rx.events.EventOverviewBolusProgress -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -15,6 +15,6 @@ class MsgBolusStopTest : DanaRTestBase() { // test message decoding packet.handleMessage(ByteArray(100)) - Assert.assertEquals(true, danaPump.bolusStopped) + Assertions.assertEquals(true, danaPump.bolusStopped) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgCheckValueTest.kt similarity index 73% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgCheckValueTest.kt index ba9cfb8f55..753a197293 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgCheckValueTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgCheckValue import info.nightscout.pump.dana.DanaPump -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgCheckValueTest : DanaRTestBase() { @@ -14,6 +14,6 @@ class MsgCheckValueTest : DanaRTestBase() { val array = ByteArray(100) putByteToArray(array, 0, DanaPump.EXPORT_MODEL.toByte()) packet.handleMessage(array) - Assert.assertEquals(DanaPump.EXPORT_MODEL, danaPump.hwModel) + Assertions.assertEquals(DanaPump.EXPORT_MODEL, danaPump.hwModel) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgErrorTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgErrorTest.kt similarity index 70% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgErrorTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgErrorTest.kt index f5a010e91b..ffe330d1c8 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgErrorTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgErrorTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgError -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgErrorTest : DanaRTestBase() { @@ -14,10 +14,10 @@ class MsgErrorTest : DanaRTestBase() { putByteToArray(array, 0, 1) packet.handleMessage(array) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) // bigger than 8 - no error putByteToArray(array, 0, 10) packet.handleMessage(array) - Assert.assertEquals(false, packet.failed) + Assertions.assertEquals(false, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarmTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryAlarmTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarmTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryAlarmTest.kt index 5fd105a74c..7fd2850766 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarmTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryAlarmTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryAlarm import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllDoneTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryAllDoneTest.kt similarity index 67% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllDoneTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryAllDoneTest.kt index f25e096191..a8a791c753 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllDoneTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryAllDoneTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryAllDone -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgHistoryAllDoneTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgHistoryAllDoneTest : DanaRTestBase() { // test message decoding packet.handleMessage(ByteArray(0)) - Assert.assertEquals(true, danaPump.historyDoneReceived) + Assertions.assertEquals(true, danaPump.historyDoneReceived) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryAllTest.kt similarity index 71% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryAllTest.kt index 616e6bf678..41aec28054 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryAllTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryAll -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgHistoryAllTest : DanaRTestBase() { @@ -14,10 +14,10 @@ class MsgHistoryAllTest : DanaRTestBase() { putByteToArray(array, 0, 1) packet.handleMessage(array) - Assert.assertEquals(false, packet.failed) + Assertions.assertEquals(false, packet.failed) // passing an bigger number putByteToArray(array, 0, 17) packet.handleMessage(array) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHourTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryBasalHourTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHourTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryBasalHourTest.kt index acac58a3d3..7bf53e64eb 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHourTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryBasalHourTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryBasalHour import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolusTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryBolusTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolusTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryBolusTest.kt index 7325b5a4fb..a068aec0a7 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolusTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryBolusTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryBolus import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarboTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryCarboTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarboTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryCarboTest.kt index f9ad642608..250482d45e 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarboTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryCarboTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryCarbo import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt similarity index 84% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt index b574facc20..f335b46e20 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryDailyInsulin import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDoneTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryDoneTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDoneTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryDoneTest.kt index c07265501c..51faa8e20f 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDoneTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryDoneTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryDone import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryErrorTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryErrorTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryErrorTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryErrorTest.kt index 29f59bbfb0..486b339c2d 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryErrorTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryErrorTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryError import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucoseTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryGlucoseTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucoseTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryGlucoseTest.kt index 62004c79dd..fd78b83b5f 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucoseTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryGlucoseTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryGlucose import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewDoneTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryNewDoneTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewDoneTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryNewDoneTest.kt index 756d1087e6..b88ea9b402 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewDoneTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryNewDoneTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryNewDone import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryNewTest.kt similarity index 82% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryNewTest.kt index 14ffd6e4dc..c799828414 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryNewTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryNew import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefillTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryRefillTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefillTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryRefillTest.kt index 1f3c5172ee..5bf9fbad2a 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefillTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistoryRefillTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistoryRefill import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspendTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistorySuspendTest.kt similarity index 83% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspendTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistorySuspendTest.kt index d113fd851f..3b4ecd5db9 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspendTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgHistorySuspendTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgHistorySuspend import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBasicTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusBasicTest.kt similarity index 73% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBasicTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusBasicTest.kt index 422c5a47b7..848112ac97 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBasicTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusBasicTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgInitConnStatusBasic -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgInitConnStatusBasicTest : DanaRTestBase() { @@ -14,6 +14,6 @@ class MsgInitConnStatusBasicTest : DanaRTestBase() { putByteToArray(array, 0, 1) packet.handleMessage(array) - Assert.assertEquals(true, danaPump.pumpSuspended) + Assertions.assertEquals(true, danaPump.pumpSuspended) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBolusTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusBolusTest.kt similarity index 70% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBolusTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusBolusTest.kt index 4742e5386c..c021d5dc97 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBolusTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusBolusTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgInitConnStatusBolus -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgInitConnStatusBolusTest : DanaRTestBase() { @@ -14,10 +14,10 @@ class MsgInitConnStatusBolusTest : DanaRTestBase() { // message bigger than 22 packet.handleMessage(array) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) array = ByteArray(20) putByteToArray(array, 0, 1) packet.handleMessage(array) - Assert.assertEquals(true, danaPump.isExtendedBolusEnabled) + Assertions.assertEquals(true, danaPump.isExtendedBolusEnabled) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusOptionTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusOptionTest.kt similarity index 68% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusOptionTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusOptionTest.kt index 0f4ca09684..e3d734925d 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusOptionTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusOptionTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgInitConnStatusOption -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgInitConnStatusOptionTest : DanaRTestBase() { @@ -11,9 +11,9 @@ class MsgInitConnStatusOptionTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(20, 1.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) // message smaller than 21 packet.handleMessage(createArray(22, 1.toByte())) - Assert.assertEquals(false, danaPump.isPasswordOK) + Assertions.assertEquals(false, danaPump.isPasswordOK) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusTimeTest.kt similarity index 69% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusTimeTest.kt index 122543defe..ceb440fd75 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgInitConnStatusTimeTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgInitConnStatusTime -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgInitConnStatusTimeTest : DanaRTestBase() { @@ -11,9 +11,9 @@ class MsgInitConnStatusTimeTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(20, 1.toByte())) - Assert.assertEquals(false, packet.failed) + Assertions.assertEquals(false, packet.failed) // message smaller than 10 packet.handleMessage(createArray(15, 1.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStartTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgPCCommStartTest.kt similarity index 84% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStartTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgPCCommStartTest.kt index 79e99f5c73..41446dc024 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStartTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgPCCommStartTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgPCCommStart import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStopTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgPCCommStopTest.kt similarity index 84% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStopTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgPCCommStopTest.kt index 7db7ab28f3..0a79a531e6 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStopTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgPCCommStopTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgPCCommStop import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetActivateBasalProfileTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetActivateBasalProfileTest.kt similarity index 73% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetActivateBasalProfileTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetActivateBasalProfileTest.kt index a75ce2dbc5..8d77ca423a 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetActivateBasalProfileTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetActivateBasalProfileTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSetActivateBasalProfile -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSetActivateBasalProfileTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSetActivateBasalProfileTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetBasalProfileTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetBasalProfileTest.kt similarity index 72% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetBasalProfileTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetBasalProfileTest.kt index f754bed976..86ceb186ab 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetBasalProfileTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetBasalProfileTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSetBasalProfile -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSetBasalProfileTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSetBasalProfileTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 2.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetCarbsEntryTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetCarbsEntryTest.kt similarity index 72% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetCarbsEntryTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetCarbsEntryTest.kt index d6d592c4c1..ad047bfab3 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetCarbsEntryTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetCarbsEntryTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSetCarbsEntry -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSetCarbsEntryTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSetCarbsEntryTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStartTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetExtendedBolusStartTest.kt similarity index 80% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStartTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetExtendedBolusStartTest.kt index e37d9df817..2cea8ca437 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStartTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetExtendedBolusStartTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSetExtendedBolusStart import info.nightscout.interfaces.constraints.Constraint -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -14,7 +14,7 @@ class MsgSetExtendedBolusStartTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStopTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetExtendedBolusStopTest.kt similarity index 71% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStopTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetExtendedBolusStopTest.kt index 8ced436daa..fe44d4e4cf 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStopTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetExtendedBolusStopTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSetExtendedBolusStop -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSetExtendedBolusStopTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSetExtendedBolusStopTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetSingleBasalProfileTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetSingleBasalProfileTest.kt similarity index 73% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetSingleBasalProfileTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetSingleBasalProfileTest.kt index d7efc0e098..3da8839f3e 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetSingleBasalProfileTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetSingleBasalProfileTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSetSingleBasalProfile -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSetSingleBasalProfileTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSetSingleBasalProfileTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTempBasalStartTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetTempBasalStartTest.kt similarity index 71% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTempBasalStartTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetTempBasalStartTest.kt index d3c15c140a..03fc8ae944 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTempBasalStartTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetTempBasalStartTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSetTempBasalStart -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSetTempBasalStartTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSetTempBasalStartTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTimeTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetTimeTest.kt similarity index 71% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTimeTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetTimeTest.kt index d1a5e22c13..01986075b1 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTimeTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetTimeTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSetTime -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSetTimeTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSetTimeTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetUserOptionsTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetUserOptionsTest.kt similarity index 70% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetUserOptionsTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetUserOptionsTest.kt index a95ef72c0e..7f2e7209d8 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetUserOptionsTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSetUserOptionsTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSetUserOptions -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSetUserOptionsTest : DanaRTestBase() { @@ -10,6 +10,6 @@ class MsgSetUserOptionsTest : DanaRTestBase() { val packet = MsgSetUserOptions(injector) // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingActiveProfileTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingActiveProfileTest.kt similarity index 64% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingActiveProfileTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingActiveProfileTest.kt index a0ba4f4ff3..cbc9e9859b 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingActiveProfileTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingActiveProfileTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingActiveProfile -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSettingActiveProfileTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSettingActiveProfileTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 1), danaPump.activeProfile) + Assertions.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 1), danaPump.activeProfile) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalProfileAllTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingBasalProfileAllTest.kt similarity index 85% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalProfileAllTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingBasalProfileAllTest.kt index af9c6b27e0..f23c54d2ba 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalProfileAllTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingBasalProfileAllTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingBasalProfileAll import org.junit.jupiter.api.Test diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingBasalTest.kt similarity index 74% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingBasalTest.kt index d150689867..b42538b3a4 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingBasalTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingBasal import info.nightscout.interfaces.pump.defs.PumpDescription -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -15,6 +15,6 @@ class MsgSettingBasalTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(100, 1.toByte())) val expected = packet.intFromBuff(createArray(100, 1.toByte()), 2 * 1, 2) - Assert.assertEquals(expected.toDouble() / 100.0, danaPump.pumpProfiles!![danaPump.activeProfile][1], 0.0) + Assertions.assertEquals(expected.toDouble() / 100.0, danaPump.pumpProfiles!![danaPump.activeProfile][1], 0.0) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingGlucoseTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingGlucoseTest.kt similarity index 71% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingGlucoseTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingGlucoseTest.kt index 11128cc86d..19d06c9d1b 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingGlucoseTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingGlucoseTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingGlucose -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSettingGlucoseTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSettingGlucoseTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 1.toByte())) - Assert.assertEquals(1, danaPump.units) + Assertions.assertEquals(1, danaPump.units) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMaxValuesTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingMaxValuesTest.kt similarity index 60% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMaxValuesTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingMaxValuesTest.kt index 796b76185d..75ac12534a 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMaxValuesTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingMaxValuesTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingMaxValues -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSettingMaxValuesTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSettingMaxValuesTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2).toDouble() / 100.0, danaPump.maxBolus, 0.0) + Assertions.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2).toDouble() / 100.0, danaPump.maxBolus, 0.0) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMealTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingMealTest.kt similarity index 59% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMealTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingMealTest.kt index 33ca9eb1dc..367fcbcb25 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMealTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingMealTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingMeal -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSettingMealTest : DanaRTestBase() { @@ -11,6 +11,6 @@ class MsgSettingMealTest : DanaRTestBase() { // test message decoding packet.handleMessage(createArray(34, 1.toByte())) - Assert.assertEquals(packet.intFromBuff(createArray(10, 1.toByte()), 0, 1).toDouble() / 100.0, danaPump.bolusStep, 0.0) + Assertions.assertEquals(packet.intFromBuff(createArray(10, 1.toByte()), 0, 1).toDouble() / 100.0, danaPump.bolusStep, 0.0) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosAllTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingProfileRatiosAllTest.kt similarity index 69% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosAllTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingProfileRatiosAllTest.kt index c208a77145..a708f9caab 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosAllTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingProfileRatiosAllTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingProfileRatiosAll import info.nightscout.pump.dana.DanaPump -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSettingProfileRatiosAllTest : DanaRTestBase() { @@ -12,7 +12,7 @@ class MsgSettingProfileRatiosAllTest : DanaRTestBase() { danaPump.units = DanaPump.UNITS_MGDL // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.morningCIR) + Assertions.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.morningCIR) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingProfileRatiosTest.kt similarity index 69% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingProfileRatiosTest.kt index df59bd000f..a55c7d81fc 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingProfileRatiosTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingProfileRatios import info.nightscout.pump.dana.DanaPump -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSettingProfileRatiosTest : DanaRTestBase() { @@ -12,6 +12,6 @@ class MsgSettingProfileRatiosTest : DanaRTestBase() { danaPump.units = DanaPump.UNITS_MGDL // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.currentCIR) + Assertions.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.currentCIR) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingPumpTimeTest.kt similarity index 84% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingPumpTimeTest.kt index e63453ec6f..33052fff6a 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingPumpTimeTest.kt @@ -1,9 +1,9 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingPumpTime import info.nightscout.pump.dana.DanaPump import org.joda.time.DateTime -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSettingPumpTimeTest : DanaRTestBase() { @@ -22,6 +22,6 @@ class MsgSettingPumpTimeTest : DanaRTestBase() { packet.intFromBuff(bytes, 0, 1) ).millis packet.handleMessage(bytes) - Assert.assertEquals(time, danaPump.getPumpTime()) + Assertions.assertEquals(time, danaPump.getPumpTime()) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingShippingInfoTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingShippingInfoTest.kt similarity index 70% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingShippingInfoTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingShippingInfoTest.kt index f14e8e47de..eb4a0536ef 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingShippingInfoTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingShippingInfoTest.kt @@ -1,9 +1,9 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MessageBase import info.nightscout.androidaps.danar.comm.MsgSettingShippingInfo import info.nightscout.pump.dana.DanaPump -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSettingShippingInfoTest : DanaRTestBase() { @@ -13,6 +13,6 @@ class MsgSettingShippingInfoTest : DanaRTestBase() { danaPump.units = DanaPump.UNITS_MGDL // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(MessageBase.stringFromBuff(createArray(34, 7.toByte()), 0, 10), danaPump.serialNumber) + Assertions.assertEquals(MessageBase.stringFromBuff(createArray(34, 7.toByte()), 0, 10), danaPump.serialNumber) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingUserOptionsTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingUserOptionsTest.kt similarity index 75% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingUserOptionsTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingUserOptionsTest.kt index ff25f411b8..612d8e99b6 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingUserOptionsTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgSettingUserOptionsTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgSettingUserOptions import info.nightscout.pump.dana.DanaPump -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSettingUserOptionsTest : DanaRTestBase() { @@ -12,6 +12,6 @@ class MsgSettingUserOptionsTest : DanaRTestBase() { danaPump.units = DanaPump.UNITS_MGDL // test message decoding packet.handleMessage(createArray(48, 7.toByte())) - Assert.assertEquals(7, danaPump.lcdOnTimeSec) + Assertions.assertEquals(7, danaPump.lcdOnTimeSec) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBasicTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusBasicTest.kt similarity index 58% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBasicTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusBasicTest.kt index 21e9eb565b..de2eb8e352 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBasicTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusBasicTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgStatusBasic -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgStatusBasicTest : DanaRTestBase() { @@ -10,6 +10,6 @@ class MsgStatusBasicTest : DanaRTestBase() { val packet = MsgStatusBasic(injector) // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaPump.dailyTotalUnits, 0.0) + Assertions.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaPump.dailyTotalUnits, 0.0) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtendedTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusBolusExtendedTest.kt similarity index 73% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtendedTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusBolusExtendedTest.kt index 75957a7e9a..d3f869a2f9 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtendedTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusBolusExtendedTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended import info.nightscout.shared.utils.T -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgStatusBolusExtendedTest : DanaRTestBase() { @@ -15,6 +15,6 @@ class MsgStatusBolusExtendedTest : DanaRTestBase() { putByteToArray(array, 0, 1) putByteToArray(array, 1, 1) packet.handleMessage(array) - Assert.assertEquals(T.mins(30).msecs(), danaPump.extendedBolusDuration) + Assertions.assertEquals(T.mins(30).msecs(), danaPump.extendedBolusDuration) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusProfileTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusProfileTest.kt similarity index 68% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusProfileTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusProfileTest.kt index 7e46941a4e..b197d1378b 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusProfileTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusProfileTest.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgStatusProfile import info.nightscout.pump.dana.DanaPump -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgStatusProfileTest : DanaRTestBase() { @@ -12,6 +12,6 @@ class MsgStatusProfileTest : DanaRTestBase() { danaPump.units = DanaPump.UNITS_MGDL // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.currentCIR) + Assertions.assertEquals(packet.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaPump.currentCIR) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTempBasalTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusTempBasalTest.kt similarity index 65% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTempBasalTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusTempBasalTest.kt index 7e525b9609..df2125abc5 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTempBasalTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusTempBasalTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgStatusTempBasalTest : DanaRTestBase() { @@ -10,9 +10,9 @@ class MsgStatusTempBasalTest : DanaRTestBase() { val packet = MsgStatusTempBasal(injector) // test message decoding packet.handleMessage(createArray(34, 1.toByte())) - Assert.assertEquals(true, packet.isTempBasalInProgress) + Assertions.assertEquals(true, packet.isTempBasalInProgress) // passing an bigger number packet.handleMessage(createArray(34, 2.toByte())) - Assert.assertEquals(false, packet.isTempBasalInProgress) + Assertions.assertEquals(false, packet.isTempBasalInProgress) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusTest.kt similarity index 57% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusTest.kt index 68a0763d26..d5134f44dd 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/MsgStatusTest.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaR.comm +package info.nightscout.pump.danaR.comm import info.nightscout.androidaps.danar.comm.MsgStatus -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgStatusTest : DanaRTestBase() { @@ -10,6 +10,6 @@ class MsgStatusTest : DanaRTestBase() { val packet = MsgStatus(injector) // test message decoding packet.handleMessage(createArray(34, 7.toByte())) - Assert.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaPump.dailyTotalUnits, 0.0) + Assertions.assertEquals(packet.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaPump.dailyTotalUnits, 0.0) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/RecordTypesTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/RecordTypesTest.kt new file mode 100644 index 0000000000..f57cecf844 --- /dev/null +++ b/pump/danar/src/test/java/info/nightscout/pump/danaR/comm/RecordTypesTest.kt @@ -0,0 +1,12 @@ +package info.nightscout.pump.danaR.comm + +import info.nightscout.pump.dana.comm.RecordTypes +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class RecordTypesTest { + + @Test fun runTest() { + Assertions.assertEquals(1.toByte(), RecordTypes.RECORD_TYPE_BOLUS) + } +} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaRKorean/DanaRKoreanPluginTest.kt similarity index 88% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaRKorean/DanaRKoreanPluginTest.kt index 2c593f191a..d4b5969856 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaRKorean/DanaRKoreanPluginTest.kt @@ -1,8 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaRKorean +package info.nightscout.pump.danaRKorean import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin import info.nightscout.interfaces.Constants import info.nightscout.interfaces.constraints.Constraint @@ -14,7 +13,7 @@ import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.database.DanaHistoryDatabase -import info.nightscout.shared.sharedPreferences.SP +import info.nightscout.sharedtests.TestBaseWithProfile import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -24,7 +23,6 @@ import org.mockito.Mockito.`when` class DanaRKoreanPluginTest : TestBaseWithProfile() { @Mock lateinit var constraintChecker: Constraints - @Mock lateinit var sp: SP @Mock lateinit var commandQueue: CommandQueue @Mock lateinit var pumpSync: PumpSync @Mock lateinit var instantiator: Instantiator @@ -48,8 +46,10 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() { `when`(rh.gs(info.nightscout.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s") `when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator) - danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, - pumpSync, uiInteraction, danaHistoryDatabase) + danaRPlugin = DanaRKoreanPlugin( + injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, + pumpSync, uiInteraction, danaHistoryDatabase + ) } @Test @Throws(Exception::class) diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt similarity index 68% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt index 3899f83c7b..79fca9b748 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt @@ -1,9 +1,9 @@ -package info.nightscout.androidaps.plugins.pump.danaRKorean.comm +package info.nightscout.pump.danaRKorean.comm import info.nightscout.androidaps.danaRKorean.comm.MessageHashTableRKorean -import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase import info.nightscout.interfaces.constraints.Constraint -import org.junit.Assert +import info.nightscout.pump.danaR.comm.DanaRTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito @@ -13,6 +13,6 @@ class MessageHashTableRKoreanTest : DanaRTestBase() { Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) val messageHashTable = MessageHashTableRKorean(injector) val testMessage = messageHashTable.findMessage(0x41f2) - Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName) + Assertions.assertEquals("CMD_HISTORY_ALL", testMessage.messageName) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/DanaRv2PluginTest.kt similarity index 93% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaRv2/DanaRv2PluginTest.kt index 39fb63ab9b..9416b48960 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/DanaRv2PluginTest.kt @@ -1,8 +1,7 @@ -package info.nightscout.androidaps.plugins.pump.danaRv2 +package info.nightscout.pump.danaRv2 import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.danaRv2.DanaRv2Plugin import info.nightscout.interfaces.Constants import info.nightscout.interfaces.constraints.Constraint @@ -16,7 +15,7 @@ import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.database.DanaHistoryDatabase -import info.nightscout.shared.sharedPreferences.SP +import info.nightscout.sharedtests.TestBaseWithProfile import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -26,7 +25,6 @@ import org.mockito.Mockito.`when` class DanaRv2PluginTest : TestBaseWithProfile() { @Mock lateinit var constraintChecker: Constraints - @Mock lateinit var sp: SP @Mock lateinit var commandQueue: CommandQueue @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage @Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage @@ -53,7 +51,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() { `when`(rh.gs(info.nightscout.core.ui.R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator) danaRv2Plugin = DanaRv2Plugin( - injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, + injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, detailedBolusInfoStorage, temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync, uiInteraction, danaHistoryDatabase ) } diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2Test.kt b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MessageHashTableRv2Test.kt similarity index 73% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2Test.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MessageHashTableRv2Test.kt index 981a642288..178b1488fc 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2Test.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MessageHashTableRv2Test.kt @@ -1,11 +1,11 @@ -package info.nightscout.androidaps.plugins.pump.danaRv2.comm +package info.nightscout.pump.danaRv2.comm import info.nightscout.androidaps.danaRv2.comm.MessageHashTableRv2 import info.nightscout.androidaps.danaRv2.comm.MsgStatusAPS_v2 import info.nightscout.androidaps.danar.comm.MessageBase -import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase import info.nightscout.interfaces.constraints.Constraint -import org.junit.Assert +import info.nightscout.pump.danaR.comm.DanaRTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -17,11 +17,11 @@ class MessageHashTableRv2Test : DanaRTestBase() { val messageHashTableRv2 = MessageHashTableRv2(injector) val forTesting: MessageBase = MsgStatusAPS_v2(injector) val testPacket: MessageBase = messageHashTableRv2.findMessage(forTesting.command) - Assert.assertEquals(0xE001, testPacket.command.toLong()) + Assertions.assertEquals(0xE001, testPacket.command.toLong()) // try putting another command val testMessage = MessageBase(injector) testMessage.setCommand(0xE005) messageHashTableRv2.put(testMessage) - Assert.assertEquals(0xE005, messageHashTableRv2.findMessage(0xE005).command.toLong()) + Assertions.assertEquals(0xE005, messageHashTableRv2.findMessage(0xE005).command.toLong()) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValueRv2Test.kt b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgCheckValueRv2Test.kt similarity index 61% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValueRv2Test.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgCheckValueRv2Test.kt index 5bfac64677..224edabab5 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValueRv2Test.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgCheckValueRv2Test.kt @@ -1,9 +1,9 @@ -package info.nightscout.androidaps.plugins.pump.danaRv2.comm +package info.nightscout.pump.danaRv2.comm import info.nightscout.androidaps.danaRv2.comm.MsgCheckValue_v2 -import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase import info.nightscout.pump.dana.DanaPump -import org.junit.Assert +import info.nightscout.pump.danaR.comm.DanaRTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgCheckValueRv2Test : DanaRTestBase() { @@ -13,6 +13,6 @@ class MsgCheckValueRv2Test : DanaRTestBase() { val packet = MsgCheckValue_v2(injector) // test message decoding packet.handleMessage(createArray(34, 3.toByte())) - Assert.assertEquals(DanaPump.EXPORT_MODEL, danaPump.hwModel) + Assertions.assertEquals(DanaPump.EXPORT_MODEL, danaPump.hwModel) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEventsRv2Test.kt b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgHistoryEventsRv2Test.kt similarity index 62% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEventsRv2Test.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgHistoryEventsRv2Test.kt index 625c3f8551..d1f93d0f05 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEventsRv2Test.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgHistoryEventsRv2Test.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaRv2.comm +package info.nightscout.pump.danaRv2.comm import info.nightscout.androidaps.danaRv2.comm.MsgHistoryEventsV2 -import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase -import org.junit.Assert +import info.nightscout.pump.danaR.comm.DanaRTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgHistoryEventsRv2Test : DanaRTestBase() { @@ -15,10 +15,10 @@ class MsgHistoryEventsRv2Test : DanaRTestBase() { putByteToArray(array, 0, 0x01.toByte()) packet.handleMessage(array) - Assert.assertEquals(false, danaPump.historyDoneReceived) + Assertions.assertEquals(false, danaPump.historyDoneReceived) putByteToArray(array, 0, 0xFF.toByte()) packet.handleMessage(array) - Assert.assertEquals(true, danaPump.historyDoneReceived) + Assertions.assertEquals(true, danaPump.historyDoneReceived) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgSetAPSTempBasalStartRv2Test.kt b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgSetAPSTempBasalStartRv2Test.kt new file mode 100644 index 0000000000..283c131472 --- /dev/null +++ b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgSetAPSTempBasalStartRv2Test.kt @@ -0,0 +1,47 @@ +package info.nightscout.pump.danaRv2.comm + +import info.nightscout.androidaps.danaRv2.comm.MsgSetAPSTempBasalStart_v2 +import info.nightscout.pump.danaR.comm.DanaRTestBase +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class MsgSetAPSTempBasalStartRv2Test : DanaRTestBase() { + + @Test fun runTest() { + + // test low hard limit + var packet = MsgSetAPSTempBasalStart_v2(injector, -1, true, false) + Assertions.assertEquals(0, packet.intFromBuff(packet.buffer, 0, 2)) + Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) + // test high hard limit + packet = MsgSetAPSTempBasalStart_v2(injector, 550, true, false) + Assertions.assertEquals(500, packet.intFromBuff(packet.buffer, 0, 2)) + Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) + // test setting 15 min + packet = MsgSetAPSTempBasalStart_v2(injector, 50, true, false) + Assertions.assertEquals(50, packet.intFromBuff(packet.buffer, 0, 2)) + Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) + // test setting 30 min + packet = MsgSetAPSTempBasalStart_v2(injector, 50, false, true) + Assertions.assertEquals(50, packet.intFromBuff(packet.buffer, 0, 2)) + Assertions.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1)) + // over 200% set always 15 min + packet = MsgSetAPSTempBasalStart_v2(injector, 250, false, true) + Assertions.assertEquals(250, packet.intFromBuff(packet.buffer, 0, 2)) + Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) + // test low hard limit + packet = MsgSetAPSTempBasalStart_v2(injector, -1, false, true) + Assertions.assertEquals(0, packet.intFromBuff(packet.buffer, 0, 2)) + Assertions.assertEquals(packet.PARAM30MIN, packet.intFromBuff(packet.buffer, 2, 1)) + // test high hard limit + packet = MsgSetAPSTempBasalStart_v2(injector, 550, false, true) + Assertions.assertEquals(500, packet.intFromBuff(packet.buffer, 0, 2)) + Assertions.assertEquals(packet.PARAM15MIN, packet.intFromBuff(packet.buffer, 2, 1)) + + // test message decoding + packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte())) + Assertions.assertEquals(true, packet.failed) + packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 1.toByte())) + Assertions.assertEquals(false, packet.failed) + } +} \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetHistoryEntryRv2Test.kt b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgSetHistoryEntryRv2Test.kt similarity index 65% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetHistoryEntryRv2Test.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgSetHistoryEntryRv2Test.kt index e80d8a62de..5d6ab6232c 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetHistoryEntryRv2Test.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgSetHistoryEntryRv2Test.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaRv2.comm +package info.nightscout.pump.danaRv2.comm import info.nightscout.androidaps.danaRv2.comm.MsgSetHistoryEntry_v2 -import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase -import org.junit.Assert +import info.nightscout.pump.danaR.comm.DanaRTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgSetHistoryEntryRv2Test : DanaRTestBase() { @@ -12,9 +12,9 @@ class MsgSetHistoryEntryRv2Test : DanaRTestBase() { // test message decoding // != 1 fails packet.handleMessage(createArray(34, 2.toByte())) - Assert.assertEquals(true, packet.failed) + Assertions.assertEquals(true, packet.failed) // passing an bigger number packet.handleMessage(createArray(34, 1.toByte())) - Assert.assertEquals(false, packet.failed) + Assertions.assertEquals(false, packet.failed) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusAPSRv2Test.kt b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgStatusAPSRv2Test.kt similarity index 65% rename from pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusAPSRv2Test.kt rename to pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgStatusAPSRv2Test.kt index 54686e80cb..27adf07596 100644 --- a/pump/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusAPSRv2Test.kt +++ b/pump/danar/src/test/java/info/nightscout/pump/danaRv2/comm/MsgStatusAPSRv2Test.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.pump.danaRv2.comm +package info.nightscout.pump.danaRv2.comm import info.nightscout.androidaps.danaRv2.comm.MsgStatusAPS_v2 -import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase -import org.junit.Assert +import info.nightscout.pump.danaR.comm.DanaRTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MsgStatusAPSRv2Test : DanaRTestBase() { @@ -14,6 +14,6 @@ class MsgStatusAPSRv2Test : DanaRTestBase() { val testArray = createArray(34, 7.toByte()) val iob = packet.intFromBuff(testArray, 0, 2) / 100.0 packet.handleMessage(testArray) - Assert.assertEquals(iob, danaPump.iob, 0.0) + Assertions.assertEquals(iob, danaPump.iob, 0.0) } } \ No newline at end of file diff --git a/pump/danar/src/test/java/info/nightscout/pump/utils/CRCTest.kt b/pump/danar/src/test/java/info/nightscout/pump/utils/CRCTest.kt new file mode 100644 index 0000000000..f8e8390e3a --- /dev/null +++ b/pump/danar/src/test/java/info/nightscout/pump/utils/CRCTest.kt @@ -0,0 +1,14 @@ +package info.nightscout.pump.utils + +import info.nightscout.androidaps.utils.CRC +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class CRCTest { + + @Test + fun getCrc16Test() { + val data = byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 0) + Assertions.assertEquals(27649.toShort(), CRC.getCrc16(data, 0, 10)) + } +} \ No newline at end of file