From 8032cd8f42836d4843446b8df31d1d94d7644d32 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 4 Sep 2023 08:46:32 +0200 Subject: [PATCH] shared-tests #11 --- pump/medtrum/build.gradle | 1 + .../androidaps/ProfileStoreObject.kt | 107 ----------- .../info/nightscout/androidaps/TestBase.kt | 38 ---- .../androidaps/TestBaseWithProfile.kt | 177 ------------------ .../pump/medtrum/MedtrumPumpTest.kt | 14 +- .../pump/medtrum/MedtrumTestBase.kt | 4 +- .../medtrum/comm/WriteCommandPacketsTest.kt | 14 +- .../comm/packets/ActivatePacketTest.kt | 24 +-- .../comm/packets/AuthorizePacketTest.kt | 18 +- .../comm/packets/CancelBolusPacketTest.kt | 6 +- .../comm/packets/CancelTempBasalPacketTest.kt | 22 +-- .../comm/packets/ClearPumpAlarmPacketTest.kt | 8 +- .../comm/packets/GetDeviceTypePacketTest.kt | 22 +-- .../comm/packets/GetRecordPacketTest.kt | 12 +- .../medtrum/comm/packets/GetTimePacketTest.kt | 18 +- .../medtrum/comm/packets/MedtrumPacketTest.kt | 26 +-- .../comm/packets/NotificationPacketTest.kt | 30 +-- .../comm/packets/PollPatchPacketTest.kt | 6 +- .../medtrum/comm/packets/PrimePacketTest.kt | 6 +- .../comm/packets/ReadBolusStatePacketTest.kt | 14 +- .../medtrum/comm/packets/ResumePumpPacket.kt | 6 +- .../comm/packets/SetBasalProfilePacketTest.kt | 22 +-- .../comm/packets/SetBolusMotorPacketTest.kt | 6 +- .../comm/packets/SetBolusPacketTest.kt | 4 +- .../comm/packets/SetPatchPacketTest.kt | 4 +- .../comm/packets/SetTempBasalPacketTest.kt | 18 +- .../medtrum/comm/packets/SetTimePacketTest.kt | 6 +- .../comm/packets/SetTimeZonePacketTest.kt | 10 +- .../comm/packets/StopPatchPacketTest.kt | 16 +- .../comm/packets/SubscribePacketTest.kt | 6 +- .../comm/packets/SynchronizePacketTest.kt | 93 ++++++--- .../pump/medtrum/encryption/CryptTest.kt | 18 +- 32 files changed, 251 insertions(+), 525 deletions(-) delete mode 100644 pump/medtrum/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt delete mode 100644 pump/medtrum/src/test/java/info/nightscout/androidaps/TestBase.kt delete mode 100644 pump/medtrum/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt diff --git a/pump/medtrum/build.gradle b/pump/medtrum/build.gradle index 2f7325883b..f1f2e6a263 100644 --- a/pump/medtrum/build.gradle +++ b/pump/medtrum/build.gradle @@ -29,5 +29,6 @@ dependencies { implementation project(':pump:pump-common') implementation project(':core:utils') + testImplementation project(':app-wear-shared:shared-tests') testImplementation project(':core:main') } diff --git a/pump/medtrum/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt b/pump/medtrum/src/test/java/info/nightscout/androidaps/ProfileStoreObject.kt deleted file mode 100644 index 59c5c41b6b..0000000000 --- a/pump/medtrum/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(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 } -} diff --git a/pump/medtrum/src/test/java/info/nightscout/androidaps/TestBase.kt b/pump/medtrum/src/test/java/info/nightscout/androidaps/TestBase.kt deleted file mode 100644 index 67aa52703d..0000000000 --- a/pump/medtrum/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") - fun uninitialized(): T = null as T -} diff --git a/pump/medtrum/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt b/pump/medtrum/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt deleted file mode 100644 index ef46cbe7e0..0000000000 --- a/pump/medtrum/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt +++ /dev/null @@ -1,177 +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.database.entities.EffectiveProfileSwitch -import info.nightscout.database.entities.embedments.InsulinConfiguration -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.Mockito.`when` -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 - lateinit var effectiveProfileSwitch: EffectiveProfileSwitch - - @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 = Mockito.spy(DateUtil(context)) - `when`(dateUtil.now()).thenReturn(1656358822000) - validProfile = ProfileSealed.Pure(pureProfileFromJson(JSONObject(validProfileJSON), dateUtil)!!) - effectiveProfileSwitch = EffectiveProfileSwitch( - timestamp = dateUtil.now(), - basalBlocks = validProfile.basalBlocks, - isfBlocks = validProfile.isfBlocks, - icBlocks = validProfile.icBlocks, - targetBlocks = validProfile.targetBlocks, - glucoseUnit = EffectiveProfileSwitch.GlucoseUnit.MMOL, - originalProfileName = "", - originalCustomizedName = "", - originalTimeshift = 0, - originalPercentage = 100, - originalDuration = 0, - originalEnd = 0, - insulinConfiguration = InsulinConfiguration("", 0, 0) - ) - - 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/medtrum/src/test/java/info/nightscout/pump/medtrum/MedtrumPumpTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/MedtrumPumpTest.kt index fbedd2f0da..9da9b80f8a 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/MedtrumPumpTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/MedtrumPumpTest.kt @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum import info.nightscout.core.extensions.pureProfileFromJson import info.nightscout.core.profile.ProfileSealed import org.json.JSONObject +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* import java.time.LocalDate import java.time.LocalTime import java.time.ZoneId @@ -33,7 +33,7 @@ class MedtrumPumpTest : MedtrumTestBase() { // Expected values val expectedByteArray = byteArrayOf(7, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -20, 36, 2, 100, -123, 2) - assertEquals(expectedByteArray.contentToString(), result?.contentToString()) + Assertions.assertEquals(expectedByteArray.contentToString(), result?.contentToString()) } @Test fun buildMedtrumProfileArrayGiveProfileWhenValuesTooHighThenReturnNull() { @@ -50,7 +50,7 @@ class MedtrumPumpTest : MedtrumTestBase() { val result = medtrumPump.buildMedtrumProfileArray(profile) // Expected values - assertNull(result) + Assertions.assertNull(result) } @Test fun getCurrentHourlyBasalFromMedtrumProfileArrayGivenProfileWhenValuesSetThenReturnCorrectValue() { @@ -78,27 +78,27 @@ class MedtrumPumpTest : MedtrumTestBase() { val zonedDateTime0399 = localDate.atTime(localTime0399).atZone(ZoneId.systemDefault()) val time0399 = zonedDateTime0399.toInstant().toEpochMilli() val result = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray!!, time0399) - assertEquals(2.1, result, 0.01) + Assertions.assertEquals(2.1, result, 0.01) // For 22:30 val localTime2230 = LocalTime.of(22, 30) val zonedDateTime2230 = localDate.atTime(localTime2230).atZone(ZoneId.systemDefault()) val time2230 = zonedDateTime2230.toInstant().toEpochMilli() val result1 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2230) - assertEquals(1.7, result1, 0.01) + Assertions.assertEquals(1.7, result1, 0.01) // For 23:59 val localTime2359 = LocalTime.of(23, 59) val zonedDateTime2359 = localDate.atTime(localTime2359).atZone(ZoneId.systemDefault()) val time2359 = zonedDateTime2359.toInstant().toEpochMilli() val result2 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2359) - assertEquals(2.0, result2, 0.01) + Assertions.assertEquals(2.0, result2, 0.01) // For 00:00 val localTime0000 = LocalTime.of(0, 0) val zonedDateTime0000 = localDate.atTime(localTime0000).atZone(ZoneId.systemDefault()) val time0000 = zonedDateTime0000.toInstant().toEpochMilli() val result3 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time0000) - assertEquals(2.1, result3, 0.01) + Assertions.assertEquals(2.1, result3, 0.01) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/MedtrumTestBase.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/MedtrumTestBase.kt index 77e45b6834..a5b804f0cb 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/MedtrumTestBase.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/MedtrumTestBase.kt @@ -1,17 +1,15 @@ package info.nightscout.pump.medtrum -import info.nightscout.androidaps.TestBaseWithProfile -import info.nightscout.shared.sharedPreferences.SP import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.TemporaryBasalStorage import info.nightscout.interfaces.stats.TddCalculator +import info.nightscout.sharedtests.TestBaseWithProfile import org.junit.jupiter.api.BeforeEach import org.mockito.Mock import org.mockito.Mockito open class MedtrumTestBase : TestBaseWithProfile() { - @Mock lateinit var sp: SP @Mock lateinit var tddCalculator: TddCalculator @Mock lateinit var pumpSync: PumpSync @Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/WriteCommandPacketsTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/WriteCommandPacketsTest.kt index 42d7225856..52e62336e3 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/WriteCommandPacketsTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/WriteCommandPacketsTest.kt @@ -1,7 +1,7 @@ package info.nightscout.pump.medtrum.comm +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class WriteCommandPacketsTest { @@ -13,7 +13,7 @@ class WriteCommandPacketsTest { val cmdPackets = WriteCommandPackets(input, sequence) val output = cmdPackets.getNextPacket() - assertEquals(expect.contentToString(), output.contentToString()) + Assertions.assertEquals(expect.contentToString(), output.contentToString()) } @Test @@ -31,10 +31,10 @@ class WriteCommandPacketsTest { val output4 = cmdPackets.getNextPacket() - assertEquals(expect1.contentToString(), output1.contentToString()) - assertEquals(expect2.contentToString(), output2.contentToString()) - assertEquals(expect3.contentToString(), output3.contentToString()) - assertNull(output4) - assertEquals(true, cmdPackets.allPacketsConsumed()) + Assertions.assertEquals(expect1.contentToString(), output1.contentToString()) + Assertions.assertEquals(expect2.contentToString(), output2.contentToString()) + Assertions.assertEquals(expect3.contentToString(), output3.contentToString()) + Assertions.assertNull(output4) + Assertions.assertEquals(true, cmdPackets.allPacketsConsumed()) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ActivatePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ActivatePacketTest.kt index 784ba38c65..3b67e573f8 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ActivatePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ActivatePacketTest.kt @@ -5,8 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.comm.enums.AlarmSetting import info.nightscout.pump.medtrum.comm.enums.BasalType +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class ActivatePacketTest : MedtrumTestBase() { @@ -38,7 +38,7 @@ class ActivatePacketTest : MedtrumTestBase() { // Expected values val expectedByteArray = byteArrayOf(18, 0, 12, 1, 6, 0, 0, 30, 32, 3, 16, 14, 0, 0, 1, 3, 16, 14, 0, 0, 1, 2, 12, 12, 12) - assertEquals(expectedByteArray.contentToString(), result.contentToString()) + Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -64,15 +64,15 @@ class ActivatePacketTest : MedtrumTestBase() { val expectedBasalPatchId = 41L val expectedBasalStart = 1675605528000L - assertEquals(true, result) - assertEquals(expectedPatchId, medtrumPump.patchId) - assertEquals(expectedTime, medtrumPump.lastTimeReceivedFromPump) - assertEquals(expectedBasalType, medtrumPump.lastBasalType) - assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01) - assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence) - assertEquals(expectedBasalPatchId, medtrumPump.lastBasalPatchId) - assertEquals(expectedBasalStart, medtrumPump.lastBasalStartTime) - assertEquals(basalProfile, medtrumPump.actualBasalProfile) + Assertions.assertEquals(true, result) + Assertions.assertEquals(expectedPatchId, medtrumPump.patchId) + Assertions.assertEquals(expectedTime, medtrumPump.lastTimeReceivedFromPump) + Assertions.assertEquals(expectedBasalType, medtrumPump.lastBasalType) + Assertions.assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01) + Assertions.assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence) + Assertions.assertEquals(expectedBasalPatchId, medtrumPump.lastBasalPatchId) + Assertions.assertEquals(expectedBasalStart, medtrumPump.lastBasalStartTime) + Assertions.assertEquals(basalProfile, medtrumPump.actualBasalProfile) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -84,6 +84,6 @@ class ActivatePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertFalse(result) + Assertions.assertFalse(result) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/AuthorizePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/AuthorizePacketTest.kt index d566da4bb9..0244392562 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/AuthorizePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/AuthorizePacketTest.kt @@ -5,8 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumPump import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.extension.toByteArray +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class AuthorizePacketTest : MedtrumTestBase() { @@ -37,8 +37,8 @@ class AuthorizePacketTest : MedtrumTestBase() { val key = 3364239851 val type = 2 val expectedByteArray = byteArrayOf(opCode.toByte()) + type.toByte() + medtrumPump.patchSessionToken.toByteArray(4) + key.toByteArray(4) - assertEquals(10, result.size) - assertEquals(expectedByteArray.contentToString(), result.contentToString()) + Assertions.assertEquals(10, result.size) + Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) } @Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() { @@ -57,10 +57,10 @@ class AuthorizePacketTest : MedtrumTestBase() { // Expected values val swString = "$swVerX.$swVerY.$swVerZ" - assertTrue(result) - assertFalse(packet.failed) - assertEquals(deviceType, medtrumPump.deviceType) - assertEquals(swString, medtrumPump.swVersion) + Assertions.assertTrue(result) + Assertions.assertFalse(packet.failed) + Assertions.assertEquals(deviceType, medtrumPump.deviceType) + Assertions.assertEquals(swString, medtrumPump.swVersion) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -75,7 +75,7 @@ class AuthorizePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertFalse(result) - assertTrue(packet.failed) + Assertions.assertFalse(result) + Assertions.assertTrue(packet.failed) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/CancelBolusPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/CancelBolusPacketTest.kt index 63db77fc17..1c0bb47b11 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/CancelBolusPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/CancelBolusPacketTest.kt @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum.comm.packets import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class CancelBolusPacketTest : MedtrumTestBase() { @@ -28,7 +28,7 @@ class CancelBolusPacketTest : MedtrumTestBase() { // Expected values val expectedByteArray = byteArrayOf(opCode.toByte()) + 1.toByte() - assertEquals(2, result.size) - assertEquals(expectedByteArray.contentToString(), result.contentToString()) + Assertions.assertEquals(2, result.size) + Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/CancelTempBasalPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/CancelTempBasalPacketTest.kt index 4a12044bf0..ee4f252f65 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/CancelTempBasalPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/CancelTempBasalPacketTest.kt @@ -4,8 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.comm.enums.BasalType +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class CancelTempBasalPacketTest : MedtrumTestBase() { @@ -30,8 +30,8 @@ class CancelTempBasalPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(1, result.size) - assertEquals(opCode.toByte(), result[0]) + Assertions.assertEquals(1, result.size) + Assertions.assertEquals(opCode.toByte(), result[0]) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -49,12 +49,12 @@ class CancelTempBasalPacketTest : MedtrumTestBase() { val expectedStartTime = 1679575392000L val expectedPatchId = 146L - assertTrue(result) - assertEquals(expectedBasalType, medtrumPump.lastBasalType) - assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01) - assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence) - assertEquals(expectedStartTime, medtrumPump.lastBasalStartTime) - assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId) + Assertions.assertTrue(result) + Assertions.assertEquals(expectedBasalType, medtrumPump.lastBasalType) + Assertions.assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01) + Assertions.assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence) + Assertions.assertEquals(expectedStartTime, medtrumPump.lastBasalStartTime) + Assertions.assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -66,7 +66,7 @@ class CancelTempBasalPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertFalse(result) - assertTrue(packet.failed) + Assertions.assertFalse(result) + Assertions.assertTrue(packet.failed) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ClearPumpAlarmPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ClearPumpAlarmPacketTest.kt index 1798dd211c..056cd200f4 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ClearPumpAlarmPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ClearPumpAlarmPacketTest.kt @@ -4,8 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.extension.toInt +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class ClearPumpAlarmPacketTest : MedtrumTestBase() { @@ -29,8 +29,8 @@ class ClearPumpAlarmPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(3, result.size) - assertEquals(opCode.toByte(), result[0]) - assertEquals(clearCode, result.copyOfRange(1, 3).toInt()) + Assertions.assertEquals(3, result.size) + Assertions.assertEquals(opCode.toByte(), result[0]) + Assertions.assertEquals(clearCode, result.copyOfRange(1, 3).toInt()) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetDeviceTypePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetDeviceTypePacketTest.kt index 2bba04829a..c3e37cf08e 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetDeviceTypePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetDeviceTypePacketTest.kt @@ -4,8 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.extension.toByteArray +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class GetDeviceTypePacketTest : MedtrumTestBase() { @@ -28,8 +28,8 @@ class GetDeviceTypePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(1, result.size) - assertEquals(opCode.toByte(), result[0]) + Assertions.assertEquals(1, result.size) + Assertions.assertEquals(opCode.toByte(), result[0]) } @Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() { @@ -45,10 +45,10 @@ class GetDeviceTypePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(true, result) - assertEquals(false, packet.failed) - assertEquals(deviceType, packet.deviceType) - assertEquals(deviceSN, packet.deviceSN) + Assertions.assertEquals(true, result) + Assertions.assertEquals(false, packet.failed) + Assertions.assertEquals(deviceType, packet.deviceType) + Assertions.assertEquals(deviceSN, packet.deviceSN) } @@ -65,9 +65,9 @@ class GetDeviceTypePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response.sliceArray(0..response.size - 2)) // Expected values - assertEquals(false, result) - assertEquals(true, packet.failed) - assertEquals(0, packet.deviceType) - assertEquals(0, packet.deviceSN) + Assertions.assertEquals(false, result) + Assertions.assertEquals(true, packet.failed) + Assertions.assertEquals(0, packet.deviceType) + Assertions.assertEquals(0, packet.deviceSN) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetRecordPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetRecordPacketTest.kt index 23f5464913..1e69dff73b 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetRecordPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetRecordPacketTest.kt @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum.comm.packets import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class GetRecordPacketTest : MedtrumTestBase() { @@ -30,7 +30,7 @@ class GetRecordPacketTest : MedtrumTestBase() { // Expected values val expected = byteArrayOf(99, 4, 0, -110, 0) - assertEquals(expected.contentToString(), result.contentToString()) + Assertions.assertEquals(expected.contentToString(), result.contentToString()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -42,8 +42,8 @@ class GetRecordPacketTest : MedtrumTestBase() { val result = packet.handleResponse(data) // Expected values - assertEquals(true, result) - assertEquals(false, packet.failed) + Assertions.assertEquals(true, result) + Assertions.assertEquals(false, packet.failed) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -55,7 +55,7 @@ class GetRecordPacketTest : MedtrumTestBase() { val result = packet.handleResponse(data) // Expected values - assertEquals(false, result) - assertEquals(true, packet.failed) + Assertions.assertEquals(false, result) + Assertions.assertEquals(true, packet.failed) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetTimePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetTimePacketTest.kt index 5f382d588c..de947a2514 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetTimePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/GetTimePacketTest.kt @@ -5,8 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.extension.toByteArray import info.nightscout.pump.medtrum.util.MedtrumTimeUtil +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class GetTimePacketTest : MedtrumTestBase() { @@ -30,8 +30,8 @@ class GetTimePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(1, result.size) - assertEquals(opCode.toByte(), result[0]) + Assertions.assertEquals(1, result.size) + Assertions.assertEquals(opCode.toByte(), result[0]) } @Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() { @@ -46,9 +46,9 @@ class GetTimePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(true, result) - assertEquals(false, packet.failed) - assertEquals(MedtrumTimeUtil().convertPumpTimeToSystemTimeMillis(time), medtrumPump.lastTimeReceivedFromPump) + Assertions.assertEquals(true, result) + Assertions.assertEquals(false, packet.failed) + Assertions.assertEquals(MedtrumTimeUtil().convertPumpTimeToSystemTimeMillis(time), medtrumPump.lastTimeReceivedFromPump) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -63,8 +63,8 @@ class GetTimePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response.sliceArray(0..response.size - 2)) // Expected values - assertEquals(false, result) - assertEquals(true, packet.failed) - assertEquals(0, medtrumPump.lastTimeReceivedFromPump) + Assertions.assertEquals(false, result) + Assertions.assertEquals(true, packet.failed) + Assertions.assertEquals(0, medtrumPump.lastTimeReceivedFromPump) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/MedtrumPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/MedtrumPacketTest.kt index c65388572d..0469575c65 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/MedtrumPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/MedtrumPacketTest.kt @@ -4,8 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.extension.toByteArray +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class MedtrumPacketTest : MedtrumTestBase() { @@ -29,8 +29,8 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(result.size, 1) - assertEquals(result[0], opCode.toByte()) + Assertions.assertEquals(result.size, 1) + Assertions.assertEquals(result[0], opCode.toByte()) } @Test fun handleResponseGivenResponseWhenOpcodeIsCorrectThenResultTrue() { @@ -45,8 +45,8 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(result, true) - assertEquals(packet.failed, false) + Assertions.assertEquals(result, true) + Assertions.assertEquals(packet.failed, false) } @Test fun handleResponseGivenResponseWhenOpcodeIsIncorrectThenResultFalse() { @@ -61,8 +61,8 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(result, false) - assertEquals(packet.failed, true) + Assertions.assertEquals(result, false) + Assertions.assertEquals(packet.failed, true) } @Test fun handleResponseGivenResponseWhenResponseCodeIsWaitingThenResultFalse() { @@ -77,8 +77,8 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(result, false) - assertEquals(packet.failed, false) + Assertions.assertEquals(result, false) + Assertions.assertEquals(packet.failed, false) } @Test fun handleResponseGivenResponseWhenResponseCodeIsErrorThenResultFalse() { @@ -93,8 +93,8 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(false, result) - assertEquals(true, packet.failed) + Assertions.assertEquals(false, result) + Assertions.assertEquals(true, packet.failed) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -108,7 +108,7 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(false, result) - assertEquals(true, packet.failed) + Assertions.assertEquals(false, result) + Assertions.assertEquals(true, packet.failed) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacketTest.kt index 0dc4343b03..f26aca850b 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacketTest.kt @@ -6,8 +6,8 @@ import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.comm.enums.BasalType import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState import info.nightscout.rx.events.EventOverviewBolusProgress +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class NotificationPacketTest : MedtrumTestBase() { @@ -30,7 +30,7 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(byteArrayOf(state)) // Expected values - assertEquals(medtrumPump.pumpState, MedtrumPumpState.fromByte(state)) + Assertions.assertEquals(medtrumPump.pumpState, MedtrumPumpState.fromByte(state)) } @Test fun handleNotificationGivenBasalDataThenDataSaved() { @@ -41,12 +41,12 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(data) // Expected values - assertEquals(BasalType.ABSOLUTE_TEMP, medtrumPump.lastBasalType) - assertEquals(0.85, medtrumPump.lastBasalRate, 0.01) - assertEquals(25, medtrumPump.lastBasalSequence) - assertEquals(14, medtrumPump.lastBasalPatchId) - assertEquals(1685126612000, medtrumPump.lastBasalStartTime) - assertEquals(186.80, medtrumPump.reservoir, 0.01) + Assertions.assertEquals(BasalType.ABSOLUTE_TEMP, medtrumPump.lastBasalType) + Assertions.assertEquals(0.85, medtrumPump.lastBasalRate, 0.01) + Assertions.assertEquals(25, medtrumPump.lastBasalSequence) + Assertions.assertEquals(14, medtrumPump.lastBasalPatchId) + Assertions.assertEquals(1685126612000, medtrumPump.lastBasalStartTime) + Assertions.assertEquals(186.80, medtrumPump.reservoir, 0.01) } @Test fun handleNotificationGivenSequenceAndOtherDataThenDataSaved() { @@ -57,7 +57,7 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(data) // Expected values - assertEquals(167, medtrumPump.currentSequenceNumber) + Assertions.assertEquals(167, medtrumPump.currentSequenceNumber) } @Test fun handleNotificationGivenBolusInProgressThenDataSaved() { @@ -69,9 +69,9 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(data) // Expected values - assertEquals(false, medtrumPump.bolusDone) - assertEquals(0.15, medtrumPump.bolusingTreatment!!.insulin, 0.01) - assertEquals(163.5, medtrumPump.reservoir, 0.01) + Assertions.assertEquals(false, medtrumPump.bolusDone) + Assertions.assertEquals(0.15, medtrumPump.bolusingTreatment!!.insulin, 0.01) + Assertions.assertEquals(163.5, medtrumPump.reservoir, 0.01) } @Test fun handleNotificationGivenBolusFinishedThenDataSaved() { @@ -83,8 +83,8 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(data) // Expected values - assertEquals(true, medtrumPump.bolusDone) - assertEquals(1.65, medtrumPump.bolusingTreatment!!.insulin, 0.01) - assertEquals(161.95, medtrumPump.reservoir, 0.01) + Assertions.assertEquals(true, medtrumPump.bolusDone) + Assertions.assertEquals(1.65, medtrumPump.bolusingTreatment!!.insulin, 0.01) + Assertions.assertEquals(161.95, medtrumPump.reservoir, 0.01) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/PollPatchPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/PollPatchPacketTest.kt index e9d31b699a..0a7377989b 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/PollPatchPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/PollPatchPacketTest.kt @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum.comm.packets import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class PollPatchPacketTest : MedtrumTestBase() { @@ -27,7 +27,7 @@ class PollPatchPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(1, result.size) - assertEquals(opCode.toByte(), result[0]) + Assertions.assertEquals(1, result.size) + Assertions.assertEquals(opCode.toByte(), result[0]) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/PrimePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/PrimePacketTest.kt index e01646485e..1f415ab10a 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/PrimePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/PrimePacketTest.kt @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum.comm.packets import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class PrimePacketTest : MedtrumTestBase() { @@ -27,7 +27,7 @@ class PrimePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(1, result.size) - assertEquals(opCode.toByte(), result[0]) + Assertions.assertEquals(1, result.size) + Assertions.assertEquals(opCode.toByte(), result[0]) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ReadBolusStatePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ReadBolusStatePacketTest.kt index 56a7ebdea8..3bde0194a3 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ReadBolusStatePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ReadBolusStatePacketTest.kt @@ -4,8 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.extension.toByteArray +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class ReadBolusStatePacketTest : MedtrumTestBase() { @@ -31,9 +31,9 @@ class ReadBolusStatePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertTrue(result) - assertFalse(packet.failed) - assertEquals(bolusData.contentToString(), packet.bolusData.contentToString()) + Assertions.assertTrue(result) + Assertions.assertFalse(packet.failed) + Assertions.assertEquals(bolusData.contentToString(), packet.bolusData.contentToString()) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -47,8 +47,8 @@ class ReadBolusStatePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(false, result) - assertEquals(true, packet.failed) - assertEquals(byteArrayOf().contentToString(), packet.bolusData.contentToString()) + Assertions.assertEquals(false, result) + Assertions.assertEquals(true, packet.failed) + Assertions.assertEquals(byteArrayOf().contentToString(), packet.bolusData.contentToString()) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ResumePumpPacket.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ResumePumpPacket.kt index 92658b4b2f..5390f5bacc 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ResumePumpPacket.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/ResumePumpPacket.kt @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum.comm.packets import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class ResumePumpPacketTest : MedtrumTestBase() { @@ -27,7 +27,7 @@ class ResumePumpPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(1, result.size) - assertEquals(opCode.toByte(), result[0]) + Assertions.assertEquals(1, result.size) + Assertions.assertEquals(opCode.toByte(), result[0]) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBasalProfilePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBasalProfilePacketTest.kt index 13446ae01a..cd7f592dfd 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBasalProfilePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBasalProfilePacketTest.kt @@ -4,8 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.comm.enums.BasalType +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class SetBasalProfilePacketTest : MedtrumTestBase() { @@ -31,7 +31,7 @@ class SetBasalProfilePacketTest : MedtrumTestBase() { // Expected values val expected = byteArrayOf(opCode.toByte()) + 1.toByte() + basalProfile - assertEquals(expected.contentToString(), result.contentToString()) + Assertions.assertEquals(expected.contentToString(), result.contentToString()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -50,13 +50,13 @@ class SetBasalProfilePacketTest : MedtrumTestBase() { val expectedStartTime = 1679575392000L val expectedPatchId = 146L - assertTrue(result) - assertEquals(expectedBasalType, medtrumPump.lastBasalType) - assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01) - assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence) - assertEquals(expectedStartTime, medtrumPump.lastBasalStartTime) - assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId) - assertEquals(basalProfile, medtrumPump.actualBasalProfile) + Assertions.assertTrue(result) + Assertions.assertEquals(expectedBasalType, medtrumPump.lastBasalType) + Assertions.assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01) + Assertions.assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence) + Assertions.assertEquals(expectedStartTime, medtrumPump.lastBasalStartTime) + Assertions.assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId) + Assertions.assertEquals(basalProfile, medtrumPump.actualBasalProfile) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -69,7 +69,7 @@ class SetBasalProfilePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertFalse(result) - assertTrue(packet.failed) + Assertions.assertFalse(result) + Assertions.assertTrue(packet.failed) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBolusMotorPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBolusMotorPacketTest.kt index 4152867665..e6350e383f 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBolusMotorPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBolusMotorPacketTest.kt @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum.comm.packets import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class SetBolusMotorPacketTest : MedtrumTestBase() { @@ -28,7 +28,7 @@ class SetBolusMotorPacketTest : MedtrumTestBase() { // Expected values val expectedByteArray = byteArrayOf(opCode.toByte()) + 0.toByte() - assertEquals(2, result.size) - assertEquals(expectedByteArray.contentToString(), result.contentToString()) + Assertions.assertEquals(2, result.size) + Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBolusPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBolusPacketTest.kt index 595e3add88..b622345911 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBolusPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetBolusPacketTest.kt @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum.comm.packets import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class SetBolusPacketTest : MedtrumTestBase() { @@ -28,6 +28,6 @@ class SetBolusPacketTest : MedtrumTestBase() { // Expected values val expected = byteArrayOf(19, 1, 47, 0, 0) - assertEquals(expected.contentToString(), result.contentToString()) + Assertions.assertEquals(expected.contentToString(), result.contentToString()) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetPatchPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetPatchPacketTest.kt index ee81699403..924f3f129d 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetPatchPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetPatchPacketTest.kt @@ -4,8 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.comm.enums.AlarmSetting +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class SetPatchPacketTest : MedtrumTestBase() { @@ -33,6 +33,6 @@ class SetPatchPacketTest : MedtrumTestBase() { // Expected values val expected = byteArrayOf(35, 1, 32, 3, 16, 14, 0, 0, 12, 0, 0, 30) - assertEquals(expected.contentToString(), result.contentToString()) + Assertions.assertEquals(expected.contentToString(), result.contentToString()) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTempBasalPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTempBasalPacketTest.kt index 9cf9b3f967..ee1aee300f 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTempBasalPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTempBasalPacketTest.kt @@ -4,8 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.comm.enums.BasalType +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class SetTempBasalPacketTest : MedtrumTestBase() { @@ -31,7 +31,7 @@ class SetTempBasalPacketTest : MedtrumTestBase() { // Expected values val expected = byteArrayOf(24, 6, 25, 0, 60, 0) - assertEquals(expected.contentToString(), result.contentToString()) + Assertions.assertEquals(expected.contentToString(), result.contentToString()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -52,12 +52,12 @@ class SetTempBasalPacketTest : MedtrumTestBase() { val expectedStartTime = 1679575112000L val expectedPatchId = 146L - assertTrue(result) - assertEquals(expectedBasalType, medtrumPump.lastBasalType) - assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01) - assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence) - assertEquals(expectedStartTime, medtrumPump.lastBasalStartTime) - assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId) + Assertions.assertTrue(result) + Assertions.assertEquals(expectedBasalType, medtrumPump.lastBasalType) + Assertions.assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01) + Assertions.assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence) + Assertions.assertEquals(expectedStartTime, medtrumPump.lastBasalStartTime) + Assertions.assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -72,6 +72,6 @@ class SetTempBasalPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertFalse(result) + Assertions.assertFalse(result) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTimePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTimePacketTest.kt index 5ad7cde5ec..7d45db28dc 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTimePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTimePacketTest.kt @@ -5,8 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.extension.toByteArray import info.nightscout.pump.medtrum.util.MedtrumTimeUtil +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class SetTimePacketTest : MedtrumTestBase() { @@ -31,7 +31,7 @@ class SetTimePacketTest : MedtrumTestBase() { // Expected values val expectedByteArray = byteArrayOf(opCode.toByte()) + 2.toByte() + time.toByteArray(4) - assertEquals(6, result.size) - assertEquals(expectedByteArray.contentToString(), result.contentToString()) + Assertions.assertEquals(6, result.size) + Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTimeZonePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTimeZonePacketTest.kt index c2353a2904..4ef3ba9fae 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTimeZonePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SetTimeZonePacketTest.kt @@ -5,8 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.extension.toByteArray import info.nightscout.pump.medtrum.util.MedtrumTimeUtil +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class SetTimeZonePacketTest : MedtrumTestBase() { @@ -36,8 +36,8 @@ class SetTimeZonePacketTest : MedtrumTestBase() { // Expected values val expectedByteArray = byteArrayOf(opCode.toByte()) + offsetMinutes.toByteArray(2) + time.toByteArray(4) - assertEquals(7, result.size) - assertEquals(expectedByteArray.contentToString(), result.contentToString()) + Assertions.assertEquals(7, result.size) + Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -51,7 +51,7 @@ class SetTimeZonePacketTest : MedtrumTestBase() { // Expected values val expectedOffsetMinutes = 0 - assertTrue(result) - assertEquals(expectedOffsetMinutes, medtrumPump.pumpTimeZoneOffset) + Assertions.assertTrue(result) + Assertions.assertEquals(expectedOffsetMinutes, medtrumPump.pumpTimeZoneOffset) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/StopPatchPacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/StopPatchPacketTest.kt index 48fdf7a1fa..be58797655 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/StopPatchPacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/StopPatchPacketTest.kt @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum.comm.packets import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class StopPatchPacketTest : MedtrumTestBase() { @@ -28,8 +28,8 @@ class StopPatchPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(1, result.size) - assertEquals(opCode.toByte(), result[0]) + Assertions.assertEquals(1, result.size) + Assertions.assertEquals(opCode.toByte(), result[0]) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -43,9 +43,9 @@ class StopPatchPacketTest : MedtrumTestBase() { // Expected values val expectedPatchId = 146L val expectedStopSequence = 23 - assertTrue(result) - assertEquals(expectedPatchId, medtrumPump.lastStopPatchId) - assertEquals(expectedStopSequence, medtrumPump.lastStopSequence) + Assertions.assertTrue(result) + Assertions.assertEquals(expectedPatchId, medtrumPump.lastStopPatchId) + Assertions.assertEquals(expectedStopSequence, medtrumPump.lastStopSequence) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -57,7 +57,7 @@ class StopPatchPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertFalse(result) - assertTrue(packet.failed) + Assertions.assertFalse(result) + Assertions.assertTrue(packet.failed) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SubscribePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SubscribePacketTest.kt index a49eea7087..341cc260c9 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SubscribePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SubscribePacketTest.kt @@ -4,8 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.extension.toByteArray +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class SubscribePacketTest : MedtrumTestBase() { @@ -29,7 +29,7 @@ class SubscribePacketTest : MedtrumTestBase() { // Expected values val expectedByteArray = byteArrayOf(opCode.toByte()) + 4095.toByteArray(2) - assertEquals(3, result.size) - assertEquals(expectedByteArray.contentToString(), result.contentToString()) + Assertions.assertEquals(3, result.size) + Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SynchronizePacketTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SynchronizePacketTest.kt index 1ed10a92bb..7d1d872723 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SynchronizePacketTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/packets/SynchronizePacketTest.kt @@ -6,8 +6,8 @@ import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.comm.enums.BasalType import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState import info.nightscout.pump.medtrum.extension.toByteArray +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class SynchronizePacketTest : MedtrumTestBase() { @@ -35,8 +35,8 @@ class SynchronizePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - assertEquals(1, result.size) - assertEquals(opCode.toByte(), result[0]) + Assertions.assertEquals(1, result.size) + Assertions.assertEquals(opCode.toByte(), result[0]) } @Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() { @@ -53,9 +53,9 @@ class SynchronizePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(true, result) - assertEquals(false, packet.failed) - assertEquals(state, packet.medtrumPump.pumpState.state) + Assertions.assertEquals(true, result) + Assertions.assertEquals(false, packet.failed) + Assertions.assertEquals(state, packet.medtrumPump.pumpState.state) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -71,31 +71,80 @@ class SynchronizePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - assertEquals(false, result) - assertEquals(true, packet.failed) + Assertions.assertEquals(false, result) + Assertions.assertEquals(true, packet.failed) } @Test fun handleResponseContainingSyncDataThenDataSaved() { // Inputs - val data = byteArrayOf(47, 3, 3, 1, 0, 0, 32, -18, 13, -128, 5, 0, -128, 0, 0, 6, 25, 0, 14, 0, 84, -93, -83, 17, 17, 64, 0, -104, 14, -8, -119, -83, 17, -16, 11, 90, 26, 0, 14, 0, -69, 31, 0, 0, -116, 14, -56) + val data = + byteArrayOf( + 47, + 3, + 3, + 1, + 0, + 0, + 32, + -18, + 13, + -128, + 5, + 0, + -128, + 0, + 0, + 6, + 25, + 0, + 14, + 0, + 84, + -93, + -83, + 17, + 17, + 64, + 0, + -104, + 14, + -8, + -119, + -83, + 17, + -16, + 11, + 90, + 26, + 0, + 14, + 0, + -69, + 31, + 0, + 0, + -116, + 14, + -56 + ) // Call val packet = SynchronizePacket(packetInjector) val result = packet.handleResponse(data) // Expected values - assertEquals(true, result) - assertEquals(false, packet.failed) - assertEquals(MedtrumPumpState.ACTIVE, packet.medtrumPump.pumpState) - assertEquals(BasalType.ABSOLUTE_TEMP, packet.medtrumPump.lastBasalType) - assertEquals(0.85, packet.medtrumPump.lastBasalRate, 0.01) - assertEquals(25, packet.medtrumPump.lastBasalSequence) - assertEquals(14, packet.medtrumPump.lastBasalPatchId) - assertEquals(1685126612000, packet.medtrumPump.lastBasalStartTime) - assertEquals(8123, packet.medtrumPump.patchAge) - assertEquals(186.80, packet.medtrumPump.reservoir, 0.01) - assertEquals(1685120120000, packet.medtrumPump.patchStartTime) - assertEquals(5.96875, packet.medtrumPump.batteryVoltage_A, 0.01) - assertEquals(2.8125, packet.medtrumPump.batteryVoltage_B, 0.01) + Assertions.assertEquals(true, result) + Assertions.assertEquals(false, packet.failed) + Assertions.assertEquals(MedtrumPumpState.ACTIVE, packet.medtrumPump.pumpState) + Assertions.assertEquals(BasalType.ABSOLUTE_TEMP, packet.medtrumPump.lastBasalType) + Assertions.assertEquals(0.85, packet.medtrumPump.lastBasalRate, 0.01) + Assertions.assertEquals(25, packet.medtrumPump.lastBasalSequence) + Assertions.assertEquals(14, packet.medtrumPump.lastBasalPatchId) + Assertions.assertEquals(1685126612000, packet.medtrumPump.lastBasalStartTime) + Assertions.assertEquals(8123, packet.medtrumPump.patchAge) + Assertions.assertEquals(186.80, packet.medtrumPump.reservoir, 0.01) + Assertions.assertEquals(1685120120000, packet.medtrumPump.patchStartTime) + Assertions.assertEquals(5.96875, packet.medtrumPump.batteryVoltage_A, 0.01) + Assertions.assertEquals(2.8125, packet.medtrumPump.batteryVoltage_B, 0.01) } } diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/encryption/CryptTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/encryption/CryptTest.kt index 3df6b85c73..2871bdfd14 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/encryption/CryptTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/encryption/CryptTest.kt @@ -1,7 +1,7 @@ package info.nightscout.pump.medtrum.encryption +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import org.junit.Assert.* class CryptTest { @@ -9,19 +9,19 @@ class CryptTest { fun givenSNExpectKey() { val crypt = Crypt() - val input: Long = 2859923929 - val expect: Long = 3364239851 - val output: Long = crypt.keyGen(input) - assertEquals(expect, output) + val input = 2859923929 + val expect = 3364239851 + val output: Long = crypt.keyGen(input) + Assertions.assertEquals(expect, output) } @Test fun givenSNExpectReal() { val crypt = Crypt() - val input: Long = 2859923929 - val expect: Long = 126009121 - val output: Long = crypt.simpleDecrypt(input) - assertEquals(expect, output) + val input = 2859923929 + val expect: Long = 126009121 + val output: Long = crypt.simpleDecrypt(input) + Assertions.assertEquals(expect, output) } }