From f281c0f6d29096535017c41d83a756b13837776c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:24:34 +0000 Subject: [PATCH 001/127] chore(deps): bump dagger_version from 2.48 to 2.48.1 Bumps `dagger_version` from 2.48 to 2.48.1. Updates `com.google.dagger:dagger-android-processor` from 2.48 to 2.48.1 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.48...dagger-2.48.1) Updates `com.google.dagger:dagger-compiler` from 2.48 to 2.48.1 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.48...dagger-2.48.1) Updates `com.google.dagger:dagger` from 2.48 to 2.48.1 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.48...dagger-2.48.1) Updates `com.google.dagger:dagger-android` from 2.48 to 2.48.1 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.48...dagger-2.48.1) Updates `com.google.dagger:dagger-android-support` from 2.48 to 2.48.1 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.48...dagger-2.48.1) --- updated-dependencies: - dependency-name: com.google.dagger:dagger-android-processor dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.dagger:dagger-compiler dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.dagger:dagger dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.dagger:dagger-android dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.dagger:dagger-android-support dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9bc7d38a6b..2018776afb 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { rxkotlin_version = '3.0.1' room_version = '2.5.2' lifecycle_version = '2.6.2' - dagger_version = '2.48' + dagger_version = '2.48.1' coroutines_version = '1.7.3' activity_version = '1.7.2' fragmentktx_version = '1.6.1' From 584c0142630dec825c185b4ea044144d87845488 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:34:25 -0700 Subject: [PATCH 002/127] Rewrites CarbTimerImplTest with matchers Issue #2745 --- .../plugins/automation/CarbTimerImplTest.kt | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/CarbTimerImplTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/CarbTimerImplTest.kt index cdc4949442..a0ebc85a9b 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/CarbTimerImplTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/CarbTimerImplTest.kt @@ -16,9 +16,9 @@ import app.aaps.plugins.automation.triggers.Trigger import app.aaps.plugins.automation.ui.TimerUtil import app.aaps.shared.impl.utils.DateUtilImpl import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.any @@ -52,27 +52,24 @@ class CarbTimerImplTest : TestBase() { private lateinit var automationPlugin: AutomationPlugin - @BeforeEach - fun init() { + @BeforeEach fun init() { Mockito.`when`(rh.gs(anyInt())).thenReturn("") Mockito.`when`(profileFunction.getUnits()).thenReturn(GlucoseUnit.MGDL) dateUtil = DateUtilImpl(context) timerUtil = TimerUtil(context) automationPlugin = AutomationPlugin( - injector, rh, context, sp, fabricPrivacy, loop, rxBus, constraintChecker, aapsLogger, aapsSchedulers, config, locationServiceHelper, dateUtil, - activePlugin, timerUtil + injector, rh, context, sp, fabricPrivacy, loop, rxBus, constraintChecker, aapsLogger, aapsSchedulers, config, locationServiceHelper, dateUtil, activePlugin, timerUtil ) } - @Test - fun doTest() { - Assertions.assertEquals(0, automationPlugin.size()) + @Test fun doTest() { + assertThat(automationPlugin.size()).isEqualTo(0) automationPlugin.scheduleAutomationEventEatReminder() - Assertions.assertEquals(1, automationPlugin.size()) + assertThat(automationPlugin.size()).isEqualTo(1) automationPlugin.removeAutomationEventEatReminder() - Assertions.assertEquals(0, automationPlugin.size()) + assertThat(automationPlugin.size()).isEqualTo(0) automationPlugin.scheduleTimeToEatReminder(1) Mockito.verify(context, Mockito.times(1)).startActivity(any()) } -} \ No newline at end of file +} From 8a4607549e6ba4b6bdd5ef242c15bebe3cf0e306 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:36:12 -0700 Subject: [PATCH 003/127] Rewrites AutomationEventTest with matchers Issue #2745 --- .../plugins/automation/AutomationEventTest.kt | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/AutomationEventTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/AutomationEventTest.kt index 62c6ff9ef3..cf76da7f1a 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/AutomationEventTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/AutomationEventTest.kt @@ -10,12 +10,13 @@ import app.aaps.plugins.automation.triggers.TriggerConnector import app.aaps.plugins.automation.triggers.TriggerConnectorTest import app.aaps.plugins.automation.triggers.TriggerDummy import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mock +import org.skyscreamer.jsonassert.JSONAssert class AutomationEventTest : TestBase() { @@ -40,8 +41,7 @@ class AutomationEventTest : TestBase() { } } - @Test - fun testCloneEvent() { + @Test fun testCloneEvent() { // create test object val event = AutomationEventObject(injector) event.title = "Test" @@ -51,33 +51,32 @@ class AutomationEventTest : TestBase() { // export to json val eventJsonExpected = "{\"userAction\":false,\"autoRemove\":false,\"readOnly\":false,\"trigger\":\"{\\\"data\\\":{\\\"connectorType\\\":\\\"AND\\\",\\\"triggerList\\\":[\\\"{\\\\\\\"data\\\\\\\":{\\\\\\\"connectorType\\\\\\\":\\\\\\\"AND\\\\\\\",\\\\\\\"triggerList\\\\\\\":[]},\\\\\\\"type\\\\\\\":\\\\\\\"TriggerConnector\\\\\\\"}\\\"]},\\\"type\\\":\\\"TriggerConnector\\\"}\",\"title\":\"Test\",\"systemAction\":false,\"actions\":[\"{\\\"type\\\":\\\"ActionLoopEnable\\\"}\"],\"enabled\":true}" - Assertions.assertEquals(eventJsonExpected, event.toJSON()) + JSONAssert.assertEquals(eventJsonExpected, event.toJSON(), true) // clone val clone = AutomationEventObject(injector).fromJSON(eventJsonExpected, 1) // check title - Assertions.assertEquals(event.title, clone.title) + assertThat(clone.title).isEqualTo(event.title) // check trigger - Assertions.assertNotNull(clone.trigger) - Assertions.assertFalse(event.trigger === clone.trigger) // not the same object reference - Assertions.assertEquals(event.trigger.javaClass, clone.trigger.javaClass) - Assertions.assertEquals(event.trigger.toJSON(), clone.trigger.toJSON()) + assertThat(clone.trigger).isNotNull() + assertThat(event.trigger).isNotSameInstanceAs(clone.trigger) + assertThat(event.trigger.javaClass).isNotInstanceOf(clone.trigger.javaClass) + JSONAssert.assertEquals(event.trigger.toJSON(), clone.trigger.toJSON(), true) // check action - Assertions.assertEquals(1, clone.actions.size) - Assertions.assertFalse(event.actions === clone.actions) // not the same object reference - Assertions.assertEquals(clone.toJSON(), clone.toJSON()) + assertThat(clone.actions).hasSize(1) + assertThat(event.actions).isNotSameInstanceAs(clone.actions) + JSONAssert.assertEquals(clone.toJSON(), clone.toJSON(), true) } - @Test - fun hasStopProcessing() { + @Test fun hasStopProcessing() { val event = AutomationEventObject(injector) event.title = "Test" event.trigger = TriggerDummy(injector).instantiate(JSONObject(TriggerConnectorTest().oneItem)) as TriggerConnector - Assertions.assertFalse(event.hasStopProcessing()) + assertThat(event.hasStopProcessing()).isFalse() event.addAction(ActionStopProcessing(injector)) - Assertions.assertTrue(event.hasStopProcessing()) + assertThat(event.hasStopProcessing()).isTrue() } } From eb3e2372398485749d1d642f652007238c23b987 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:38:16 -0700 Subject: [PATCH 004/127] Rewrites BolusTimerImplTest with matchers Issue #2745 --- .../app/aaps/plugins/automation/BolusTimerImplTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/BolusTimerImplTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/BolusTimerImplTest.kt index 05c5a35952..d5bca898fe 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/BolusTimerImplTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/BolusTimerImplTest.kt @@ -16,9 +16,9 @@ import app.aaps.plugins.automation.triggers.Trigger import app.aaps.plugins.automation.ui.TimerUtil import app.aaps.shared.impl.utils.DateUtilImpl import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyInt @@ -63,10 +63,10 @@ class BolusTimerImplTest : TestBase() { @Test fun doTest() { - Assertions.assertEquals(0, automationPlugin.size()) + assertThat(automationPlugin.size()).isEqualTo(0) automationPlugin.scheduleAutomationEventBolusReminder() - Assertions.assertEquals(1, automationPlugin.size()) + assertThat(automationPlugin.size()).isEqualTo(1) automationPlugin.removeAutomationEventBolusReminder() - Assertions.assertEquals(0, automationPlugin.size()) + assertThat(automationPlugin.size()).isEqualTo(0) } -} \ No newline at end of file +} From 7d4cd89cece3fc580c7d72e6be35789900f62374 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:42:43 -0700 Subject: [PATCH 005/127] Rewrites ComposeTriggerTest with matchers Issue #2745 --- .../plugins/automation/ComposeTriggerTest.kt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/ComposeTriggerTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/ComposeTriggerTest.kt index ef6b8225df..f0c109595c 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/ComposeTriggerTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/ComposeTriggerTest.kt @@ -4,14 +4,14 @@ import app.aaps.plugins.automation.triggers.Trigger import app.aaps.plugins.automation.triggers.TriggerConnector import app.aaps.plugins.automation.triggers.TriggerDummy import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ComposeTriggerTest : TestBase() { - var injector: HasAndroidInjector = HasAndroidInjector { AndroidInjector { } } + val injector: HasAndroidInjector = HasAndroidInjector { AndroidInjector { } } @Test fun testTriggerList() { val root = TriggerConnector(injector) @@ -23,16 +23,11 @@ class ComposeTriggerTest : TestBase() { root.list.add(t1) val t2: Trigger = TriggerDummy(injector) root.list.add(t2) - Assertions.assertEquals(3, root.size()) - Assertions.assertEquals(t0, root.list[0]) - Assertions.assertEquals(t1, root.list[1]) - Assertions.assertEquals(t2, root.list[2]) + assertThat(root.list).containsExactly(t0, t1, t2).inOrder() // remove a trigger root.list.remove(t1) - Assertions.assertEquals(2, root.size()) - Assertions.assertEquals(t0, root.list[0]) - Assertions.assertEquals(t2, root.list[1]) + assertThat(root.list).containsExactly(t0, t2).inOrder() } @Test @@ -44,6 +39,6 @@ class ComposeTriggerTest : TestBase() { t[i] = TriggerDummy(injector) root.list.add(t[i]!!) } - Assertions.assertEquals(4, root.size()) + assertThat(root.size()).isEqualTo(4) } -} \ No newline at end of file +} From 06b219aadefd96981437b07c12cceae9655ccba7 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:43:51 -0700 Subject: [PATCH 006/127] Rewrites StaticLabelTest with matchers Issue #2745 --- .../aaps/plugins/automation/elements/StaticLabelTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/StaticLabelTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/StaticLabelTest.kt index a753926321..c3b59768f1 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/StaticLabelTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/StaticLabelTest.kt @@ -2,7 +2,7 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerDummy import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -10,9 +10,9 @@ class StaticLabelTest : TriggerTestBase() { @Test fun constructor() { var sl = StaticLabel(rh, "any", TriggerDummy(injector)) - Assertions.assertEquals("any", sl.label) + assertThat(sl.label).isEqualTo("any") `when`(rh.gs(app.aaps.core.ui.R.string.pumplimit)).thenReturn("pump limit") sl = StaticLabel(rh, app.aaps.core.ui.R.string.pumplimit, TriggerDummy(injector)) - Assertions.assertEquals("pump limit", sl.label) + assertThat(sl.label).isEqualTo("pump limit") } -} \ No newline at end of file +} From 23372a31678c2038b5109292d6d44fec13fb9418 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:45:27 -0700 Subject: [PATCH 007/127] Rewrites InputBgTest with matchers Issue #2745 --- .../plugins/automation/elements/InputBgTest.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputBgTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputBgTest.kt index 7ac891bc13..49af000a2d 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputBgTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputBgTest.kt @@ -2,7 +2,7 @@ package app.aaps.plugins.automation.elements import app.aaps.core.interfaces.db.GlucoseUnit import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -12,16 +12,16 @@ class InputBgTest : TriggerTestBase() { @Test fun setValueTest() { var i: InputBg = InputBg(profileFunction).setUnits(GlucoseUnit.MMOL).setValue(5.0) - Assertions.assertEquals(5.0, i.value, 0.01) - Assertions.assertEquals(InputBg.MMOL_MIN, i.minValue, 0.01) + assertThat(i.value).isWithin(0.01).of(5.0) + assertThat(i.minValue).isWithin(0.01).of(InputBg.MMOL_MIN) i = InputBg(profileFunction).setValue(100.0).setUnits(GlucoseUnit.MGDL) - Assertions.assertEquals(100.0, i.value, 0.01) - Assertions.assertEquals(InputBg.MGDL_MIN, i.minValue, 0.01) - Assertions.assertEquals(GlucoseUnit.MGDL, i.units) + assertThat(i.value).isWithin(0.01).of(100.0) + assertThat(i.minValue).isWithin(0.01).of(InputBg.MGDL_MIN) + assertThat(i.units).isEqualTo(GlucoseUnit.MGDL) } @BeforeEach fun prepare() { `when`(profileFunction.getUnits()).thenReturn(GlucoseUnit.MGDL) } -} \ No newline at end of file +} From 3e378248616f61a1655db1657ef3c76c0ea2b8f5 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:46:12 -0700 Subject: [PATCH 008/127] Rewrites InputTempTargetTest with matchers Issue #2745 --- .../plugins/automation/elements/InputTempTargetTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputTempTargetTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputTempTargetTest.kt index 314fb2afa8..e7afa04635 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputTempTargetTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputTempTargetTest.kt @@ -2,7 +2,7 @@ package app.aaps.plugins.automation.elements import app.aaps.core.interfaces.db.GlucoseUnit import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class InputTempTargetTest : TriggerTestBase() { @@ -11,10 +11,10 @@ class InputTempTargetTest : TriggerTestBase() { val i = InputTempTarget(profileFunction) i.units = GlucoseUnit.MMOL i.value = 5.0 - Assertions.assertEquals(5.0, i.value, 0.01) + assertThat(i.value).isWithin(0.01).of(5.0) i.units = GlucoseUnit.MGDL i.value = 100.0 - Assertions.assertEquals(100.0, i.value, 0.01) - Assertions.assertEquals(GlucoseUnit.MGDL, i.units) + assertThat(i.value).isWithin(0.01).of(100.0) + assertThat(i.units).isEqualTo(GlucoseUnit.MGDL) } -} \ No newline at end of file +} From 53961a41046ba3a5342cbcf06f1baf1004264410 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:48:06 -0700 Subject: [PATCH 009/127] Rewrites LabelWithElementTest with matchers Issue #2745 --- .../automation/elements/LabelWithElementTest.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/LabelWithElementTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/LabelWithElementTest.kt index 612a3abc7b..c173ffff28 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/LabelWithElementTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/LabelWithElementTest.kt @@ -1,16 +1,17 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test +import kotlin.test.assertIs class LabelWithElementTest : TriggerTestBase() { @Test fun constructorTest() { val l = LabelWithElement(rh, "A", "B", InputInsulin()) - Assertions.assertEquals("A", l.textPre) - Assertions.assertEquals("B", l.textPost) - Assertions.assertEquals(InputInsulin::class.java, l.element!!.javaClass) + assertThat(l.textPre).isEqualTo("A") + assertThat(l.textPost).isEqualTo("B") + assertIs(l.element) } -} \ No newline at end of file +} From 1466092a59927e33437a32a63d692afa5d37f033 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:49:50 -0700 Subject: [PATCH 010/127] Rewrites ComparatorConnectTest with matchers Issue #2745 --- .../plugins/automation/elements/ComparatorConnectTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorConnectTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorConnectTest.kt index 3c833198d0..b4b8da7f7d 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorConnectTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorConnectTest.kt @@ -1,18 +1,18 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class ComparatorConnectTest : TriggerTestBase() { @Test fun labelsTest() { - Assertions.assertEquals(2, ComparatorConnect.Compare.labels(rh).size) + assertThat(ComparatorConnect.Compare.labels(rh)).hasSize(2) } @Test fun setValueTest() { val c = ComparatorConnect(rh) c.value = ComparatorConnect.Compare.ON_DISCONNECT - Assertions.assertEquals(ComparatorConnect.Compare.ON_DISCONNECT, c.value) + assertThat(c.value).isEqualTo(ComparatorConnect.Compare.ON_DISCONNECT) } -} \ No newline at end of file +} From 214dae1b2482b9b61b8e49af90a659d3f757b6a5 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:52:51 -0700 Subject: [PATCH 011/127] Rewrites InputStringTest with matchers Issue #2745 --- .../app/aaps/plugins/automation/elements/InputStringTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputStringTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputStringTest.kt index 6f38866a2e..66155c69f7 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputStringTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputStringTest.kt @@ -1,7 +1,7 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class InputStringTest : TriggerTestBase() { @@ -9,6 +9,6 @@ class InputStringTest : TriggerTestBase() { @Test fun setValueTest() { val i = InputString() i.value = "asd" - Assertions.assertEquals("asd", i.value) + assertThat(i.value).isEqualTo("asd") } -} \ No newline at end of file +} From 9f5333645ec8704463e13a0bc63504c26fcc77fb Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:52:59 -0700 Subject: [PATCH 012/127] Rewrites InputPercentTest with matchers Issue #2745 --- .../aaps/plugins/automation/elements/InputPercentTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputPercentTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputPercentTest.kt index b7a0941824..d8298f7daf 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputPercentTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputPercentTest.kt @@ -1,7 +1,7 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class InputPercentTest : TriggerTestBase() { @@ -9,6 +9,6 @@ class InputPercentTest : TriggerTestBase() { @Test fun setValueTest() { val i = InputPercent() i.value = 10.0 - Assertions.assertEquals(10.0, i.value, 0.01) + assertThat(i.value).isWithin(0.01).of(10.0) } -} \ No newline at end of file +} From f8b0404cc38f142f83966a120e4c05d658c930a3 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:56:31 -0700 Subject: [PATCH 013/127] Rewrites LayoutBuilderTest with matchers Issue #2745 --- .../plugins/automation/elements/LayoutBuilderTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/LayoutBuilderTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/LayoutBuilderTest.kt index ab0cae1c6d..c76f25a83e 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/LayoutBuilderTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/LayoutBuilderTest.kt @@ -3,7 +3,7 @@ package app.aaps.plugins.automation.elements import app.aaps.shared.tests.TestBase import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class LayoutBuilderTest : TestBase() { @@ -14,15 +14,15 @@ class LayoutBuilderTest : TestBase() { val layoutBuilder = LayoutBuilder() val inputInsulin = InputInsulin() layoutBuilder.add(inputInsulin) - Assertions.assertEquals(1, layoutBuilder.mElements.size) + assertThat(layoutBuilder.mElements).hasSize(1) } @Test fun addConditionalTest() { val layoutBuilder = LayoutBuilder() val inputInsulin = InputInsulin() layoutBuilder.maybeAdd(inputInsulin, true) - Assertions.assertEquals(1, layoutBuilder.mElements.size) + assertThat(layoutBuilder.mElements).hasSize(1) layoutBuilder.maybeAdd(inputInsulin, false) - Assertions.assertEquals(1, layoutBuilder.mElements.size) + assertThat(layoutBuilder.mElements).hasSize(1) } -} \ No newline at end of file +} From 11fa9f6539d7824277f3f17ff13bf672ff11b7ae Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 20:59:28 -0700 Subject: [PATCH 014/127] Rewrites ComparatorExistsTest with matchers Issue #2745 --- .../plugins/automation/elements/ComparatorExistsTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorExistsTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorExistsTest.kt index 7f456c514d..d2a7021f05 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorExistsTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorExistsTest.kt @@ -1,18 +1,18 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class ComparatorExistsTest : TriggerTestBase() { @Test fun labelsTest() { - Assertions.assertEquals(2, ComparatorExists.Compare.labels(rh).size) + assertThat(ComparatorExists.Compare.labels(rh)).hasSize(2) } @Test fun setValueTest() { val c = ComparatorExists(rh) c.value = ComparatorExists.Compare.NOT_EXISTS - Assertions.assertEquals(ComparatorExists.Compare.NOT_EXISTS, c.value) + assertThat(c.value).isEqualTo(ComparatorExists.Compare.NOT_EXISTS) } -} \ No newline at end of file +} From 38c01372ee5a3983e160f3924ed4f8310d6faaf8 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:01:49 -0700 Subject: [PATCH 015/127] Rewrites ComparatorTest with matchers Issue #2745 --- .../automation/elements/ComparatorTest.kt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorTest.kt index 80f31ab078..6363e834f3 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/ComparatorTest.kt @@ -1,35 +1,35 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class ComparatorTest : TriggerTestBase() { @Test fun checkTest() { - Assertions.assertTrue(Comparator.Compare.IS_EQUAL.check(1, 1)) - Assertions.assertTrue(Comparator.Compare.IS_LESSER.check(1, 2)) - Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(1, 2)) - Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 2)) - Assertions.assertTrue(Comparator.Compare.IS_GREATER.check(2, 1)) - Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 1)) - Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 2)) - Assertions.assertFalse(Comparator.Compare.IS_LESSER.check(2, 1)) - Assertions.assertFalse(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 1)) - Assertions.assertFalse(Comparator.Compare.IS_GREATER.check(1, 2)) - Assertions.assertFalse(Comparator.Compare.IS_EQUAL_OR_GREATER.check(1, 2)) -// Assertions.assertTrue(Comparator.Compare.IS_NOT_AVAILABLE.check(1, null)) + assertThat(Comparator.Compare.IS_EQUAL.check(1, 1)).isTrue() + assertThat(Comparator.Compare.IS_LESSER.check(1, 2)).isTrue() + assertThat(Comparator.Compare.IS_EQUAL_OR_LESSER.check(1, 2)).isTrue() + assertThat(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 2)).isTrue() + assertThat(Comparator.Compare.IS_GREATER.check(2, 1)).isTrue() + assertThat(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 1)).isTrue() + assertThat(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 2)).isTrue() + assertThat(Comparator.Compare.IS_LESSER.check(2, 1)).isFalse() + assertThat(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 1)).isFalse() + assertThat(Comparator.Compare.IS_GREATER.check(1, 2)).isFalse() + assertThat(Comparator.Compare.IS_EQUAL_OR_GREATER.check(1, 2)).isFalse() +// assertThat(Comparator.Compare.IS_NOT_AVAILABLE.check(1, null)).isTrue() } @Test fun labelsTest() { - Assertions.assertEquals(6, Comparator.Compare.labels(rh).size) + assertThat(Comparator.Compare.labels(rh)).hasSize(6) } @Test fun setValueTest() { val c: Comparator = Comparator(rh).setValue(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_GREATER, c.value) + assertThat(c.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_GREATER) } -} \ No newline at end of file +} From 59215f03e5248400ee9d1ccb6839d32a67f9e9fd Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:06:47 -0700 Subject: [PATCH 016/127] Rewrites InputDurationTest with matchers Issue #2745 --- .../automation/elements/InputDurationTest.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputDurationTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputDurationTest.kt index 3e58875146..08e5492b29 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputDurationTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputDurationTest.kt @@ -1,20 +1,20 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class InputDurationTest : TriggerTestBase() { @Test fun setValueTest() { var i = InputDuration(5, InputDuration.TimeUnit.MINUTES) - Assertions.assertEquals(5, i.value) - Assertions.assertEquals(InputDuration.TimeUnit.MINUTES, i.unit) + assertThat(i.value).isEqualTo(5) + assertThat(i.unit).isEqualTo(InputDuration.TimeUnit.MINUTES) i = InputDuration(5, InputDuration.TimeUnit.HOURS) - Assertions.assertEquals(5, i.value) - Assertions.assertEquals(InputDuration.TimeUnit.HOURS, i.unit) - Assertions.assertEquals(5 * 60, i.getMinutes()) + assertThat(i.value).isEqualTo(5) + assertThat(i.unit).isEqualTo(InputDuration.TimeUnit.HOURS) + assertThat(i.getMinutes()).isEqualTo(5 * 60) i.setMinutes(60) - Assertions.assertEquals(1, i.value) + assertThat(i.value).isEqualTo(1) } -} \ No newline at end of file +} From d4c3f21bee81c867190efbaef998003fd1fe04ee Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:08:54 -0700 Subject: [PATCH 017/127] Rewrites InputCarePortalEventTest with matchers Issue #2745 --- .../automation/elements/InputCarePortalEventTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputCarePortalEventTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputCarePortalEventTest.kt index e380c24420..1d875a2cd2 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputCarePortalEventTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputCarePortalEventTest.kt @@ -1,19 +1,19 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class InputCarePortalEventTest : TriggerTestBase() { @Test fun labelsTest() { - Assertions.assertEquals(4, InputCarePortalMenu.EventType.labels(rh).size) + assertThat(InputCarePortalMenu.EventType.labels(rh)).hasSize(4) } @Test fun setValueTest() { val cp = InputCarePortalMenu(rh, InputCarePortalMenu.EventType.EXERCISE) - Assertions.assertEquals(InputCarePortalMenu.EventType.EXERCISE, cp.value) + assertThat(cp.value).isEqualTo(InputCarePortalMenu.EventType.EXERCISE) } -} \ No newline at end of file +} From 6454616c686cb6741d68fdd79c03351f3e3d9ffb Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:09:08 -0700 Subject: [PATCH 018/127] Rewrites InputInsulinTest with matchers Issue #2745 --- .../aaps/plugins/automation/elements/InputInsulinTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputInsulinTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputInsulinTest.kt index 7aaac4450e..968f904627 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputInsulinTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputInsulinTest.kt @@ -1,7 +1,7 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class InputInsulinTest : TriggerTestBase() { @@ -9,6 +9,6 @@ class InputInsulinTest : TriggerTestBase() { @Test fun setValueTest() { val i = InputInsulin() i.value = 5.0 - Assertions.assertEquals(5.0, i.value, 0.01) + assertThat(i.value).isWithin(0.01).of(5.0) } -} \ No newline at end of file +} From 2603ede988cebb525d042120f905bc0ae837a40b Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:09:20 -0700 Subject: [PATCH 019/127] Rewrites InputProfileNameTest with matchers Issue #2745 --- .../plugins/automation/elements/InputProfileNameTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputProfileNameTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputProfileNameTest.kt index abb47c9377..42810b4a09 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputProfileNameTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/elements/InputProfileNameTest.kt @@ -1,15 +1,15 @@ package app.aaps.plugins.automation.elements import app.aaps.plugins.automation.triggers.TriggerTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class InputProfileNameTest : TriggerTestBase() { @Test fun setValue() { val inputProfileName = InputProfileName(rh, activePlugin, "Test") - Assertions.assertEquals("Test", inputProfileName.value) + assertThat(inputProfileName.value).isEqualTo("Test") inputProfileName.value = "Test2" - Assertions.assertEquals("Test2", inputProfileName.value) + assertThat(inputProfileName.value).isEqualTo("Test2") } -} \ No newline at end of file +} From c89a916d5fd077bd4ddf970c038f2a5c1b11dd8e Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:19:48 -0700 Subject: [PATCH 020/127] Rewrites ActionAlarmTest with matchers Issue #2745 --- .../automation/actions/ActionAlarmTest.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionAlarmTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionAlarmTest.kt index a3f345f01d..96da47527a 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionAlarmTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionAlarmTest.kt @@ -10,14 +10,15 @@ import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.InputString import app.aaps.plugins.automation.ui.TimerUtil import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers import org.mockito.Mock import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class ActionAlarmTest : TestBase() { @@ -54,39 +55,39 @@ class ActionAlarmTest : TestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.alarm, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(app.aaps.core.ui.R.string.alarm) } @Test fun shortDescriptionTest() { sut.text = InputString("Asd") - Assertions.assertEquals("Alarm: %s", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Alarm: %s") } @Test fun iconTest() { - Assertions.assertEquals(app.aaps.core.main.R.drawable.ic_access_alarm_24dp, sut.icon()) + assertThat(sut.icon()).isEqualTo(app.aaps.core.main.R.drawable.ic_access_alarm_24dp) } @Test fun doActionTest() { sut.text = InputString("Asd") sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) + assertThat(result.success).isTrue() } }) } @Test fun hasDialogTest() { - Assertions.assertTrue(sut.hasDialog()) + assertThat(sut.hasDialog()).isTrue() } @Test fun toJSONTest() { sut.text = InputString("Asd") - Assertions.assertEquals("{\"data\":{\"text\":\"Asd\"},\"type\":\"ActionAlarm\"}", sut.toJSON()) + JSONAssert.assertEquals("""{"data":{"text":"Asd"},"type":"ActionAlarm"}""", sut.toJSON(), true) } @Test fun fromJSONTest() { sut.text = InputString("Asd") - sut.fromJSON("{\"text\":\"Asd\"}") - Assertions.assertEquals("Asd", sut.text.value) + sut.fromJSON("""{"text":"Asd"}""") + assertThat(sut.text.value).isEqualTo("Asd") } -} \ No newline at end of file +} From 99b959229a03680ef2807fdc4286936071bd9237 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:23:39 -0700 Subject: [PATCH 021/127] Rewrites ActionLoopSuspendTest with matchers Issue #2745 --- .../automation/actions/ActionLoopSuspendTest.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopSuspendTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopSuspendTest.kt index e0f43e9f0c..bf2529ec8b 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopSuspendTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopSuspendTest.kt @@ -3,7 +3,7 @@ package app.aaps.plugins.automation.actions import app.aaps.core.interfaces.queue.Callback import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.InputDuration -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito @@ -24,16 +24,16 @@ class ActionLoopSuspendTest : ActionsTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.suspendloop, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(app.aaps.core.ui.R.string.suspendloop) } @Test fun shortDescriptionTest() { sut.minutes = InputDuration(30, InputDuration.TimeUnit.MINUTES) - Assertions.assertEquals("Suspend loop for 30 min", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Suspend loop for 30 min") } @Test fun iconTest() { - Assertions.assertEquals(R.drawable.ic_pause_circle_outline_24dp, sut.icon()) + assertThat(sut.icon()).isEqualTo(R.drawable.ic_pause_circle_outline_24dp) } @Test fun doActionTest() { @@ -57,11 +57,11 @@ class ActionLoopSuspendTest : ActionsTestBase() { a.minutes = InputDuration(20, InputDuration.TimeUnit.MINUTES) val b = ActionLoopSuspend(injector) b.apply(a) - Assertions.assertEquals(20, b.minutes.getMinutes().toLong()) + assertThat(b.minutes.getMinutes().toLong()).isEqualTo(20) } @Test fun hasDialogTest() { val a = ActionLoopSuspend(injector) - Assertions.assertTrue(a.hasDialog()) + assertThat(a.hasDialog()).isTrue() } -} \ No newline at end of file +} From 260d877e1d32f0791131fcb1090afcc0f38b5ab1 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:23:47 -0700 Subject: [PATCH 022/127] Rewrites ActionSendSMSTest with matchers Issue #2745 --- .../automation/actions/ActionSendSMSTest.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionSendSMSTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionSendSMSTest.kt index e75812ccbb..5b115116bc 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionSendSMSTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionSendSMSTest.kt @@ -3,11 +3,12 @@ package app.aaps.plugins.automation.actions import app.aaps.core.interfaces.queue.Callback import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.InputString -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyString import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class ActionSendSMSTest : ActionsTestBase() { @@ -23,15 +24,15 @@ class ActionSendSMSTest : ActionsTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(R.string.sendsmsactiondescription, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(R.string.sendsmsactiondescription) } @Test fun shortDescriptionTest() { - Assertions.assertEquals("Send SMS: ", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Send SMS: ") } @Test fun iconTest() { - Assertions.assertEquals(R.drawable.ic_notifications, sut.icon()) + assertThat(sut.icon()).isEqualTo(R.drawable.ic_notifications) } @Test fun doActionTest() { @@ -39,22 +40,22 @@ class ActionSendSMSTest : ActionsTestBase() { sut.text = InputString("Asd") sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) + assertThat(result.success).isTrue() } }) } @Test fun hasDialogTest() { - Assertions.assertTrue(sut.hasDialog()) + assertThat(sut.hasDialog()).isTrue() } @Test fun toJSONTest() { sut.text = InputString("Asd") - Assertions.assertEquals("{\"data\":{\"text\":\"Asd\"},\"type\":\"ActionSendSMS\"}", sut.toJSON()) + JSONAssert.assertEquals("""{"data":{"text":"Asd"},"type":"ActionSendSMS"}""", sut.toJSON(), true) } @Test fun fromJSONTest() { - sut.fromJSON("{\"text\":\"Asd\"}") - Assertions.assertEquals("Asd", sut.text.value) + sut.fromJSON("""{"text":"Asd"}""") + assertThat(sut.text.value).isEqualTo("Asd") } -} \ No newline at end of file +} From 20e6ed2c7b5e1efb4fab116f4f07dc6ffaa29821 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:30:03 -0700 Subject: [PATCH 023/127] Rewrites ActionProfileSwitchPercentTest with matchers Issue #2745 --- .../actions/ActionProfileSwitchPercentTest.kt | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionProfileSwitchPercentTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionProfileSwitchPercentTest.kt index d40c9d784b..655a45cf5b 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionProfileSwitchPercentTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionProfileSwitchPercentTest.kt @@ -4,11 +4,12 @@ import app.aaps.core.interfaces.queue.Callback import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.InputDuration import app.aaps.plugins.automation.elements.InputPercent -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class ActionProfileSwitchPercentTest : ActionsTestBase() { @@ -24,17 +25,17 @@ class ActionProfileSwitchPercentTest : ActionsTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(R.string.profilepercentage, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(R.string.profilepercentage) } @Test fun shortDescriptionTest() { sut.pct = InputPercent(100.0) sut.duration = InputDuration(30, InputDuration.TimeUnit.MINUTES) - Assertions.assertEquals("Start profile 100% for 30 min", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Start profile 100% for 30 min") } @Test fun iconTest() { - Assertions.assertEquals(app.aaps.core.ui.R.drawable.ic_actions_profileswitch, sut.icon()) + assertThat(sut.icon()).isEqualTo(app.aaps.core.ui.R.drawable.ic_actions_profileswitch) } @Test fun doActionTest() { @@ -43,25 +44,25 @@ class ActionProfileSwitchPercentTest : ActionsTestBase() { sut.duration = InputDuration(30, InputDuration.TimeUnit.MINUTES) sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) + assertThat(result.success).isTrue() } }) Mockito.verify(profileFunction, Mockito.times(1)).createProfileSwitch(30, 110, 0) } @Test fun hasDialogTest() { - Assertions.assertTrue(sut.hasDialog()) + assertThat(sut.hasDialog()).isTrue() } @Test fun toJSONTest() { sut.pct = InputPercent(100.0) sut.duration = InputDuration(30, InputDuration.TimeUnit.MINUTES) - Assertions.assertEquals("{\"data\":{\"percentage\":100,\"durationInMinutes\":30},\"type\":\"ActionProfileSwitchPercent\"}", sut.toJSON()) + JSONAssert.assertEquals("""{"data":{"percentage":100,"durationInMinutes":30},"type":"ActionProfileSwitchPercent"}""", sut.toJSON(), true) } @Test fun fromJSONTest() { - sut.fromJSON("{\"percentage\":100,\"durationInMinutes\":30}") - Assertions.assertEquals(100.0, sut.pct.value, 0.001) - Assertions.assertEquals(30.0, sut.duration.getMinutes().toDouble(), 0.001) + sut.fromJSON("""{"percentage":100,"durationInMinutes":30}""") + assertThat(sut.pct.value).isWithin(0.001).of(100.0) + assertThat(sut.duration.getMinutes().toDouble()).isWithin(0.001).of(30.0) } -} \ No newline at end of file +} From 69471e8d3e0c6c1b3023458eb031c1c054e3b7c4 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:31:38 -0700 Subject: [PATCH 024/127] Rewrites ActionLoopResumeTest with matchers Issue #2745 --- .../plugins/automation/actions/ActionLoopResumeTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopResumeTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopResumeTest.kt index c022e95fcc..ca1e5eee78 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopResumeTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopResumeTest.kt @@ -6,7 +6,7 @@ import app.aaps.database.impl.transactions.CancelCurrentOfflineEventIfAnyTransac import app.aaps.database.impl.transactions.Transaction import app.aaps.plugins.automation.R import io.reactivex.rxjava3.core.Single -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -25,15 +25,15 @@ class ActionLoopResumeTest : ActionsTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.resumeloop, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(app.aaps.core.ui.R.string.resumeloop) } @Test fun shortDescriptionTest() { - Assertions.assertEquals("Resume loop", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Resume loop") } @Test fun iconTest() { - Assertions.assertEquals(R.drawable.ic_replay_24dp, sut.icon()) + assertThat(sut.icon()).isEqualTo(R.drawable.ic_replay_24dp) } @Test fun doActionTest() { @@ -64,4 +64,4 @@ class ActionLoopResumeTest : ActionsTestBase() { }) //Mockito.verify(loopPlugin, Mockito.times(1)).suspendTo(0) } -} \ No newline at end of file +} From 26d562edac8b8f334f84a5ef9b1a51d9351f5a84 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:31:51 -0700 Subject: [PATCH 025/127] Rewrites ActionStartTempTargetTest with matchers Issue #2745 --- .../actions/ActionStartTempTargetTest.kt | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStartTempTargetTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStartTempTargetTest.kt index 0acb80f798..28d98cc37d 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStartTempTargetTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStartTempTargetTest.kt @@ -9,11 +9,12 @@ import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.InputDuration import app.aaps.plugins.automation.elements.InputTempTarget import io.reactivex.rxjava3.core.Single -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class ActionStartTempTargetTest : ActionsTestBase() { @@ -27,18 +28,18 @@ class ActionStartTempTargetTest : ActionsTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(R.string.starttemptarget, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(R.string.starttemptarget) } @Test fun shortDescriptionTest() { sut.value = InputTempTarget(profileFunction) sut.value.value = 100.0 sut.duration = InputDuration(30, InputDuration.TimeUnit.MINUTES) - Assertions.assertEquals("Start temp target: 100mg/dl@null(Automation)", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Start temp target: 100mg/dl@null(Automation)") } @Test fun iconTest() { - Assertions.assertEquals(app.aaps.core.main.R.drawable.ic_temptarget_high, sut.icon()) + assertThat(sut.icon()).isEqualTo(app.aaps.core.main.R.drawable.ic_temptarget_high) } @Test fun doActionTest() { @@ -78,27 +79,27 @@ class ActionStartTempTargetTest : ActionsTestBase() { sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) + assertThat(result.success).isTrue() } }) Mockito.verify(repository, Mockito.times(1)).runTransactionForResult(anyObject>()) } @Test fun hasDialogTest() { - Assertions.assertTrue(sut.hasDialog()) + assertThat(sut.hasDialog()).isTrue() } @Test fun toJSONTest() { sut.value = InputTempTarget(profileFunction) sut.value.value = 100.0 sut.duration = InputDuration(30, InputDuration.TimeUnit.MINUTES) - Assertions.assertEquals("{\"data\":{\"durationInMinutes\":30,\"units\":\"mg/dl\",\"value\":100},\"type\":\"ActionStartTempTarget\"}", sut.toJSON()) + JSONAssert.assertEquals("""{"data":{"durationInMinutes":30,"units":"mg/dl","value":100},"type":"ActionStartTempTarget"}""", sut.toJSON(), true) } @Test fun fromJSONTest() { - sut.fromJSON("{\"value\":100,\"durationInMinutes\":30,\"units\":\"mg/dl\"}") - Assertions.assertEquals(GlucoseUnit.MGDL, sut.value.units) - Assertions.assertEquals(100.0, sut.value.value, 0.001) - Assertions.assertEquals(30.0, sut.duration.getMinutes().toDouble(), 0.001) + sut.fromJSON("""{"value":100,"durationInMinutes":30,"units":"mg/dl"}""") + assertThat(sut.value.units).isEqualTo(GlucoseUnit.MGDL) + assertThat(sut.value.value).isWithin(0.001).of(100.0) + assertThat(sut.duration.getMinutes().toDouble()).isWithin(0.001).of(30.0) } -} \ No newline at end of file +} From 89a9329c6da33f57475a69c59d7e952dba567d1c Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:34:32 -0700 Subject: [PATCH 026/127] Rewrites ActionNotificationTest with matchers Issue #2745 --- .../actions/ActionNotificationTest.kt | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionNotificationTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionNotificationTest.kt index 79f6697abf..c143ca279a 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionNotificationTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionNotificationTest.kt @@ -14,13 +14,14 @@ import app.aaps.shared.tests.TestBase import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import io.reactivex.rxjava3.core.Completable -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers import org.mockito.Mock import org.mockito.Mockito import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class ActionNotificationTest : TestBase() { @@ -60,22 +61,22 @@ class ActionNotificationTest : TestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.notification, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(app.aaps.core.ui.R.string.notification) } @Test fun shortDescriptionTest() { sut.text = InputString("Asd") - Assertions.assertEquals("Notification: %s", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Notification: %s") } @Test fun iconTest() { - Assertions.assertEquals(R.drawable.ic_notifications, sut.icon()) + assertThat(sut.icon()).isEqualTo(R.drawable.ic_notifications) } @Test fun doActionTest() { sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) + assertThat(result.success).isTrue() } }) Mockito.verify(rxBusMocked, Mockito.times(2)).send(anyObject()) @@ -83,20 +84,21 @@ class ActionNotificationTest : TestBase() { } @Test fun hasDialogTest() { - Assertions.assertTrue(sut.hasDialog()) + assertThat(sut.hasDialog()) } @Test fun toJSONTest() { sut.text = InputString("Asd") - Assertions.assertEquals( - "{\"data\":{\"text\":\"Asd\"},\"type\":\"ActionNotification\"}", - sut.toJSON() + JSONAssert.assertEquals( + """{"data":{"text":"Asd"},"type":"ActionNotification"}""", + sut.toJSON(), + true, ) } @Test fun fromJSONTest() { sut.text = InputString("Asd") - sut.fromJSON("{\"text\":\"Asd\"}") - Assertions.assertEquals("Asd", sut.text.value) + sut.fromJSON("""{"text":"Asd"}""") + assertThat(sut.text.value).isEqualTo("Asd") } -} \ No newline at end of file +} From efb18e35e3d4c1c7d770318b6fbcc1df29510e1f Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:41:27 -0700 Subject: [PATCH 027/127] Rewrites ActionDummyTest with matchers Issue #2745 --- .../automation/actions/ActionDummyTest.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionDummyTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionDummyTest.kt index e551d18003..c35544c4b6 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionDummyTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionDummyTest.kt @@ -1,20 +1,20 @@ package app.aaps.plugins.automation.actions +import kotlin.test.assertIs import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ActionDummyTest : ActionsTestBase() { @Test fun instantiateTest() { - var action: Action? = ActionDummy(injector).instantiate(JSONObject("{\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.ActionDummy\"}")) - Assertions.assertTrue(action is ActionDummy) + var action: Action? = ActionDummy(injector).instantiate(JSONObject("""{"type":"info.nightscout.androidaps.plugins.general.automation.actions.ActionDummy"}""")) + assertIs(action) - action = ActionDummy(injector).instantiate(JSONObject("{\"type\":\"app.aaps.plugins.automation.actions.ActionDummy\"}")) - Assertions.assertTrue(action is ActionDummy) + action = ActionDummy(injector).instantiate(JSONObject("""{"type":"app.aaps.plugins.automation.actions.ActionDummy"}""")) + assertIs(action) - action = ActionDummy(injector).instantiate(JSONObject("{\"type\":\"ActionDummy\"}")) - Assertions.assertTrue(action is ActionDummy) + action = ActionDummy(injector).instantiate(JSONObject("""{"type":"ActionDummy"}""")) + assertIs(action) } -} \ No newline at end of file +} From ecb7586ed04ceffba049cd07de3023c7ab0270f7 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:43:21 -0700 Subject: [PATCH 028/127] Rewrites ActionStopTempTargetTest with matchers Issue #2745 --- .../actions/ActionStopTempTargetTest.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStopTempTargetTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStopTempTargetTest.kt index 6b9f69ada8..c67c8177f7 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStopTempTargetTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStopTempTargetTest.kt @@ -6,11 +6,12 @@ import app.aaps.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTran import app.aaps.database.impl.transactions.Transaction import app.aaps.plugins.automation.R import io.reactivex.rxjava3.core.Single -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class ActionStopTempTargetTest : ActionsTestBase() { @@ -24,15 +25,15 @@ class ActionStopTempTargetTest : ActionsTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.stoptemptarget, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(app.aaps.core.ui.R.string.stoptemptarget) } @Test fun shortDescriptionTest() { - Assertions.assertEquals("Stop temp target", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Stop temp target") } @Test fun iconTest() { - Assertions.assertEquals(R.drawable.ic_stop_24dp, sut.icon()) + assertThat(sut.icon()).isEqualTo(R.drawable.ic_stop_24dp) } @Test fun doActionTest() { @@ -52,22 +53,22 @@ class ActionStopTempTargetTest : ActionsTestBase() { sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) + assertThat(result.success).isTrue() } }) Mockito.verify(repository, Mockito.times(1)).runTransactionForResult((anyObject>())) } @Test fun hasDialogTest() { - Assertions.assertFalse(sut.hasDialog()) + assertThat(sut.hasDialog()).isFalse() } @Test fun toJSONTest() { - Assertions.assertEquals("{\"type\":\"ActionStopTempTarget\"}", sut.toJSON()) + JSONAssert.assertEquals("""{"type":"ActionStopTempTarget"}""", sut.toJSON(), true) } @Test fun fromJSONTest() { - sut.fromJSON("{\"reason\":\"Test\"}") - Assertions.assertNotNull(sut) + sut.fromJSON("""{"reason":"Test"}""") + assertThat(sut).isNotNull() } -} \ No newline at end of file +} From db16ded9810cef8471b448baab59b873ef39e7db Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:47:20 -0700 Subject: [PATCH 029/127] Rewrites ActionProfileSwitchTest with matchers Issue #2745 --- .../actions/ActionProfileSwitchTest.kt | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionProfileSwitchTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionProfileSwitchTest.kt index b0fd27aefe..bb1a1980c1 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionProfileSwitchTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionProfileSwitchTest.kt @@ -3,7 +3,7 @@ package app.aaps.plugins.automation.actions import app.aaps.core.interfaces.queue.Callback import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.InputProfileName -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyLong @@ -11,13 +11,14 @@ import org.mockito.Mockito import org.mockito.Mockito.anyInt import org.mockito.Mockito.anyString import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert + +private const val STRING_JSON = """{"data":{"profileToSwitchTo":"Test"},"type":"ActionProfileSwitch"}""" class ActionProfileSwitchTest : ActionsTestBase() { private lateinit var sut: ActionProfileSwitch - private val stringJson = "{\"data\":{\"profileToSwitchTo\":\"Test\"},\"type\":\"ActionProfileSwitch\"}" - @BeforeEach fun setUp() { `when`(rh.gs(R.string.profilename)).thenReturn("Change profile to") `when`(rh.gs(R.string.changengetoprofilename)).thenReturn("Change profile to %s") @@ -30,11 +31,11 @@ class ActionProfileSwitchTest : ActionsTestBase() { } @Test fun friendlyName() { - Assertions.assertEquals(R.string.profilename, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(R.string.profilename) } @Test fun shortDescriptionTest() { - Assertions.assertEquals("Change profile to ", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Change profile to ") } @Test fun doAction() { @@ -43,7 +44,7 @@ class ActionProfileSwitchTest : ActionsTestBase() { sut.inputProfileName = InputProfileName(rh, activePlugin, "") sut.doAction(object : Callback() { override fun run() { - Assertions.assertFalse(result.success) + assertThat(result.success).isFalse() } }) @@ -52,7 +53,7 @@ class ActionProfileSwitchTest : ActionsTestBase() { sut.inputProfileName = InputProfileName(rh, activePlugin, "someProfile") sut.doAction(object : Callback() { override fun run() { - Assertions.assertFalse(result.success) + assertThat(result.success).isFalse() } }) @@ -62,8 +63,8 @@ class ActionProfileSwitchTest : ActionsTestBase() { sut.inputProfileName = InputProfileName(rh, activePlugin, "Test") sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) - Assertions.assertEquals("Already set", result.comment) + assertThat(result.success).isTrue() + assertThat(result.comment).isEqualTo("Already set") } }) @@ -72,8 +73,8 @@ class ActionProfileSwitchTest : ActionsTestBase() { sut.inputProfileName = InputProfileName(rh, activePlugin, "Test") sut.doAction(object : Callback() { override fun run() { - Assertions.assertFalse(result.success) - Assertions.assertEquals("not exists", result.comment) + assertThat(result.success).isFalse() + assertThat(result.comment).isEqualTo("not exists") } }) @@ -83,29 +84,28 @@ class ActionProfileSwitchTest : ActionsTestBase() { sut.inputProfileName = InputProfileName(rh, activePlugin, TESTPROFILENAME) sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) - Assertions.assertEquals("OK", result.comment) + assertThat(result.success).isTrue() + assertThat(result.comment).isEqualTo("OK") } }) Mockito.verify(profileFunction, Mockito.times(1)).createProfileSwitch(anyObject(), anyString(), anyInt(), anyInt(), anyInt(), anyLong()) } @Test fun hasDialogTest() { - Assertions.assertTrue(sut.hasDialog()) + assertThat(sut.hasDialog()).isTrue() } @Test fun toJSONTest() { sut.inputProfileName = InputProfileName(rh, activePlugin, "Test") - Assertions.assertEquals(stringJson, sut.toJSON()) + JSONAssert.assertEquals(STRING_JSON, sut.toJSON(), true) } @Test fun fromJSONTest() { - val data = "{\"profileToSwitchTo\":\"Test\"}" - sut.fromJSON(data) - Assertions.assertEquals("Test", sut.inputProfileName.value) + sut.fromJSON("""{"profileToSwitchTo":"Test"}""") + assertThat(sut.inputProfileName.value).isEqualTo("Test") } @Test fun iconTest() { - Assertions.assertEquals(app.aaps.core.ui.R.drawable.ic_actions_profileswitch, sut.icon()) + assertThat(sut.icon()).isEqualTo(app.aaps.core.ui.R.drawable.ic_actions_profileswitch) } -} \ No newline at end of file +} From ab93dbe33e7328f2b4c6f16c9a19baa1b811e5c0 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:48:57 -0700 Subject: [PATCH 030/127] Rewrites ActionStopProcessingTest with matchers Issue #2745 --- .../automation/actions/ActionStopProcessingTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStopProcessingTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStopProcessingTest.kt index 0f35c81370..d9d84d1fdf 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStopProcessingTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionStopProcessingTest.kt @@ -2,7 +2,7 @@ package app.aaps.plugins.automation.actions import app.aaps.core.interfaces.queue.Callback import app.aaps.plugins.automation.R -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -20,25 +20,25 @@ class ActionStopProcessingTest : ActionsTestBase() { @Test fun friendlyNameTest() { - Assertions.assertEquals(R.string.stop_processing, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(R.string.stop_processing) } @Test fun shortDescriptionTest() { - Assertions.assertEquals("Stop processing", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Stop processing") } @Test fun iconTest() { - Assertions.assertEquals(R.drawable.ic_stop_24dp, sut.icon()) + assertThat(sut.icon()).isEqualTo(R.drawable.ic_stop_24dp) } @Test fun doActionTest() { sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) + assertThat(result.success).isTrue() } }) } -} \ No newline at end of file +} From 3172b3c265a567394bd654f7963ccfc0a63295c3 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:50:00 -0700 Subject: [PATCH 031/127] Rewrites ActionLoopEnableTest with matchers Issue #2745 --- .../plugins/automation/actions/ActionLoopEnableTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopEnableTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopEnableTest.kt index 879e1b1ac3..9db6493dff 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopEnableTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopEnableTest.kt @@ -3,7 +3,7 @@ package app.aaps.plugins.automation.actions import app.aaps.core.interfaces.plugin.PluginType import app.aaps.core.interfaces.queue.Callback import app.aaps.plugins.automation.R -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito @@ -24,15 +24,15 @@ class ActionLoopEnableTest : ActionsTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.enableloop, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(app.aaps.core.ui.R.string.enableloop) } @Test fun shortDescriptionTest() { - Assertions.assertEquals("Enable loop", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Enable loop") } @Test fun iconTest() { - Assertions.assertEquals(R.drawable.ic_play_circle_outline_24dp, sut.icon()) + assertThat(sut.icon()).isEqualTo(R.drawable.ic_play_circle_outline_24dp) } @Test fun doActionTest() { @@ -52,4 +52,4 @@ class ActionLoopEnableTest : ActionsTestBase() { Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, true) Mockito.verify(configBuilder, Mockito.times(1)).storeSettings("ActionLoopEnable") } -} \ No newline at end of file +} From 3a88e89a80c9ac8eb8b568a5455909504a999b33 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:51:00 -0700 Subject: [PATCH 032/127] Rewrites ActionLoopDisableTest with matchers Issue #2745 --- .../automation/actions/ActionLoopDisableTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopDisableTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopDisableTest.kt index 2916e31936..2167e66d0a 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopDisableTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionLoopDisableTest.kt @@ -3,7 +3,7 @@ package app.aaps.plugins.automation.actions import app.aaps.core.interfaces.plugin.PluginType import app.aaps.core.interfaces.queue.Callback import app.aaps.plugins.automation.R -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.eq @@ -27,17 +27,17 @@ class ActionLoopDisableTest : ActionsTestBase() { @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.disableloop, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(app.aaps.core.ui.R.string.disableloop) } @Test fun shortDescriptionTest() { - Assertions.assertEquals("Disable loop", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Disable loop") } @Test fun iconTest() { - Assertions.assertEquals(R.drawable.ic_stop_24dp, sut.icon()) + assertThat(sut.icon()).isEqualTo(R.drawable.ic_stop_24dp) } @Test @@ -60,4 +60,4 @@ class ActionLoopDisableTest : ActionsTestBase() { Mockito.verify(configBuilder, Mockito.times(1)).storeSettings("ActionLoopDisable") Mockito.verify(commandQueue, Mockito.times(1)).cancelTempBasal(eq(true), anyObject()) } -} \ No newline at end of file +} From f51206e41724a208893c9baa98953dbc2df13dad Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:54:33 -0700 Subject: [PATCH 033/127] Rewrites ActionCarePortalEventTest with matchers Issue #2745 --- .../actions/ActionCarePortalEventTest.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionCarePortalEventTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionCarePortalEventTest.kt index a17c89966b..da5dcfda01 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionCarePortalEventTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/actions/ActionCarePortalEventTest.kt @@ -8,11 +8,12 @@ import app.aaps.plugins.automation.elements.InputCarePortalMenu import app.aaps.plugins.automation.elements.InputDuration import app.aaps.plugins.automation.elements.InputString import io.reactivex.rxjava3.core.Single -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class ActionCarePortalEventTest : ActionsTestBase() { @@ -35,41 +36,42 @@ class ActionCarePortalEventTest : ActionsTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.careportal, sut.friendlyName()) + assertThat(sut.friendlyName()).isEqualTo(app.aaps.core.ui.R.string.careportal) } @Test fun shortDescriptionTest() { - Assertions.assertEquals("Note : Asd", sut.shortDescription()) + assertThat(sut.shortDescription()).isEqualTo("Note : Asd") } @Test fun iconTest() { - Assertions.assertEquals(app.aaps.core.main.R.drawable.ic_cp_note, sut.icon()) + assertThat(sut.icon()).isEqualTo(app.aaps.core.main.R.drawable.ic_cp_note) } @Test fun doActionTest() { sut.doAction(object : Callback() { override fun run() { - Assertions.assertTrue(result.success) + assertThat(result.success).isTrue() } }) } @Test fun hasDialogTest() { - Assertions.assertTrue(sut.hasDialog()) + assertThat(sut.hasDialog()).isTrue() } @Test fun toJSONTest() { - Assertions.assertEquals( - "{\"data\":{\"note\":\"Asd\",\"cpEvent\":\"NOTE\",\"durationInMinutes\":5},\"type\":\"ActionCarePortalEvent\"}", - sut.toJSON() + JSONAssert.assertEquals( + """{"data":{"note":"Asd","cpEvent":"NOTE","durationInMinutes":5},"type":"ActionCarePortalEvent"}""", + sut.toJSON(), + true, ) } @Test fun fromJSONTest() { sut.note = InputString("Asd") - sut.fromJSON("{\"note\":\"Asd\",\"cpEvent\":\"NOTE\",\"durationInMinutes\":5}") - Assertions.assertEquals("Asd", sut.note.value) - Assertions.assertEquals(5, sut.duration.value) - Assertions.assertEquals(InputCarePortalMenu.EventType.NOTE, sut.cpEvent.value) + sut.fromJSON("""{"note":"Asd","cpEvent":"NOTE","durationInMinutes":5}""") + assertThat(sut.note.value).isEqualTo("Asd") + assertThat(sut.duration.value).isEqualTo(5) + assertThat(sut.cpEvent.value).isEqualTo(InputCarePortalMenu.EventType.NOTE) } -} \ No newline at end of file +} From 88cd20c4d6e0c8e5e335da4174bce3e7f1d75f06 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:59:51 -0700 Subject: [PATCH 034/127] Rewrites TriggerBgTest with matchers Issue #2745 --- .../automation/triggers/TriggerBgTest.kt | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBgTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBgTest.kt index 47bcb54ad3..1adcd1f3cc 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBgTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBgTest.kt @@ -6,10 +6,11 @@ import app.aaps.database.entities.GlucoseValue import app.aaps.plugins.automation.elements.Comparator import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerBgTest : TriggerTestBase() { @@ -22,37 +23,37 @@ class TriggerBgTest : TriggerTestBase() { fun shouldRunTest() { `when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateOneCurrentRecordBgData()) var t: TriggerBg = TriggerBg(injector).setUnits(GlucoseUnit.MMOL).setValue(4.1).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(214.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(214.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(214.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(215.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(215.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(215.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(213.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(213.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() `when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(ArrayList()) t = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(213.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerBg(injector).comparator(Comparator.Compare.IS_NOT_AVAILABLE) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() } @Test fun copyConstructorTest() { val t: TriggerBg = TriggerBg(injector).setUnits(GlucoseUnit.MGDL).setValue(213.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) val t1 = t.duplicate() as TriggerBg - Assertions.assertEquals(213.0, t1.bg.value, 0.01) - Assertions.assertEquals(GlucoseUnit.MGDL, t1.bg.units) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value) + assertThat(t1.bg.value).isWithin(0.01).of(213.0) + assertThat(t1.bg.units).isEqualTo(GlucoseUnit.MGDL) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER) } private var bgJson = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"bg\":4.1,\"units\":\"mmol\"},\"type\":\"TriggerBg\"}" @@ -60,16 +61,16 @@ class TriggerBgTest : TriggerTestBase() { @Test fun toJSONTest() { val t: TriggerBg = TriggerBg(injector).setUnits(GlucoseUnit.MMOL).setValue(4.1).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(bgJson, t.toJSON()) + JSONAssert.assertEquals(bgJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t: TriggerBg = TriggerBg(injector).setUnits(GlucoseUnit.MMOL).setValue(4.1).comparator(Comparator.Compare.IS_EQUAL) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerBg - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value) - Assertions.assertEquals(4.1, t2.bg.value, 0.01) - Assertions.assertEquals(GlucoseUnit.MMOL, t2.bg.units) + assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t2.bg.value).isWithin(0.01).of(4.1) + assertThat(t2.bg.units).isEqualTo(GlucoseUnit.MMOL) } @Test @@ -82,4 +83,4 @@ class TriggerBgTest : TriggerTestBase() { list.add(InMemoryGlucoseValue(value = 214.0, timestamp = now - 1, trendArrow = GlucoseValue.TrendArrow.FLAT, sourceSensor = GlucoseValue.SourceSensor.UNKNOWN)) return list } -} \ No newline at end of file +} From 8966f0b8cc8a467b8acff083bbba628ad8490e3c Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 21:59:58 -0700 Subject: [PATCH 035/127] Rewrites TriggerTempTargetValueTest with matchers Issue #2745 --- .../triggers/TriggerTempTargetValueTest.kt | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetValueTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetValueTest.kt index ad599d9f32..5aba9e5018 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetValueTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetValueTest.kt @@ -8,10 +8,10 @@ import app.aaps.plugins.automation.elements.Comparator import com.google.common.truth.Truth.assertThat import io.reactivex.rxjava3.core.Single import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerTempTargetValueTest : TriggerTestBase() { @@ -36,37 +36,37 @@ class TriggerTempTargetValueTest : TriggerTestBase() { ) ) var t: TriggerTempTargetValue = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MMOL).setValue(7.7).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MGDL).setValue(140.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MGDL).setValue(140.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MGDL).setValue(140.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MGDL).setValue(139.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MGDL).setValue(141.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MGDL).setValue(141.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MGDL).setValue(139.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MGDL).setValue(139.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertFalse(t.shouldRun()) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() + assertThat(t.shouldRun()).isFalse() t = TriggerTempTargetValue(injector).comparator(Comparator.Compare.IS_NOT_AVAILABLE) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() `when`(repository.getTemporaryTargetActiveAt(dateUtil.now())).thenReturn(Single.just(ValueWrapper.Absent())) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() } @Test fun copyConstructorTest() { val t: TriggerTempTargetValue = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MGDL).setValue(140.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) val t1 = t.duplicate() as TriggerTempTargetValue - Assertions.assertEquals(140.0, t1.ttValue.value, 0.01) - Assertions.assertEquals(GlucoseUnit.MGDL, t1.ttValue.units) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value) + assertThat(t1.ttValue.value).isWithin(0.01).of(140.0) + assertThat(t1.ttValue.units).isEqualTo(GlucoseUnit.MGDL) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER) } private var ttJson = "{\"data\":{\"tt\":7.7,\"comparator\":\"IS_EQUAL\",\"units\":\"mmol\"},\"type\":\"TriggerTempTargetValue\"}" @@ -74,16 +74,16 @@ class TriggerTempTargetValueTest : TriggerTestBase() { @Test fun toJSONTest() { val t: TriggerTempTargetValue = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MMOL).setValue(7.7).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(ttJson, t.toJSON()) + JSONAssert.assertEquals(ttJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t: TriggerTempTargetValue = TriggerTempTargetValue(injector).setUnits(GlucoseUnit.MMOL).setValue(7.7).comparator(Comparator.Compare.IS_EQUAL) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerTempTargetValue - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value) - Assertions.assertEquals(7.7, t2.ttValue.value, 0.01) - Assertions.assertEquals(GlucoseUnit.MMOL, t2.ttValue.units) + assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t2.ttValue.value).isWithin(0.01).of(7.7) + assertThat(t2.ttValue.units).isEqualTo(GlucoseUnit.MMOL) } @Test From 350172ebe7f2f017072d2f4c551b9d87009d5efd Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:08:07 -0700 Subject: [PATCH 036/127] Rewrites TriggerAutosensValueTest with matchers Issue #2745 --- .../triggers/TriggerAutosensValueTest.kt | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerAutosensValueTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerAutosensValueTest.kt index 35ba9e53d8..0f5618c6f8 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerAutosensValueTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerAutosensValueTest.kt @@ -5,11 +5,11 @@ import app.aaps.plugins.automation.elements.Comparator import app.aaps.plugins.main.iob.iobCobCalculator.data.AutosensDataObject import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers import org.mockito.Mockito import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerAutosensValueTest : TriggerTestBase() { @@ -20,53 +20,53 @@ class TriggerAutosensValueTest : TriggerTestBase() { var t = TriggerAutosensValue(injector) t.autosens.value = 110.0 t.comparator.value = Comparator.Compare.IS_EQUAL - Assertions.assertEquals(110.0, t.autosens.value, 0.01) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t.comparator.value) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.autosens.value).isWithin(0.01).of(110.0) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t.shouldRun()).isFalse() t = TriggerAutosensValue(injector) t.autosens.value = 100.0 t.comparator.value = Comparator.Compare.IS_EQUAL - Assertions.assertEquals(100.0, t.autosens.value, 0.01) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.autosens.value).isWithin(0.01).of(100.0) + assertThat(t.shouldRun()).isTrue() t = TriggerAutosensValue(injector) t.autosens.value = 50.0 t.comparator.value = Comparator.Compare.IS_EQUAL_OR_GREATER - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerAutosensValue(injector) t.autosens.value = 310.0 t.comparator.value = Comparator.Compare.IS_EQUAL_OR_LESSER - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerAutosensValue(injector) t.autosens.value = 420.0 t.comparator.value = Comparator.Compare.IS_EQUAL - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerAutosensValue(injector) t.autosens.value = 390.0 t.comparator.value = Comparator.Compare.IS_EQUAL_OR_LESSER - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerAutosensValue(injector) t.autosens.value = 390.0 t.comparator.value = Comparator.Compare.IS_EQUAL_OR_GREATER - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerAutosensValue(injector) t.autosens.value = 20.0 t.comparator.value = Comparator.Compare.IS_EQUAL_OR_GREATER - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerAutosensValue(injector) t.autosens.value = 390.0 t.comparator.value = Comparator.Compare.IS_EQUAL_OR_LESSER - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() `when`(autosensDataStore.getLastAutosensData(anyObject(), anyObject(), anyObject())).thenReturn(AutosensDataObject(injector)) t = TriggerAutosensValue(injector) t.autosens.value = 80.0 t.comparator.value = Comparator.Compare.IS_EQUAL_OR_LESSER - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() // Test autosensData == null and Comparator == IS_NOT_AVAILABLE `when`(autosensDataStore.getLastAutosensData(anyObject(), anyObject(), anyObject())).thenReturn(null) t = TriggerAutosensValue(injector) t.comparator.value = Comparator.Compare.IS_NOT_AVAILABLE - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() } @Test @@ -75,8 +75,8 @@ class TriggerAutosensValueTest : TriggerTestBase() { t.autosens.value = 213.0 t.comparator.value = Comparator.Compare.IS_EQUAL_OR_LESSER val t1 = t.duplicate() as TriggerAutosensValue - Assertions.assertEquals(213.0, t1.autosens.value, 0.01) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value) + assertThat(t1.autosens.value).isWithin(0.01).of(213.0) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER) } private var asJson = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"value\":410},\"type\":\"TriggerAutosensValue\"}" @@ -86,7 +86,7 @@ class TriggerAutosensValueTest : TriggerTestBase() { val t = TriggerAutosensValue(injector) t.autosens.value = 410.0 t.comparator.value = Comparator.Compare.IS_EQUAL - Assertions.assertEquals(asJson, t.toJSON()) + JSONAssert.assertEquals(asJson, t.toJSON(), true) } @Test @@ -95,15 +95,13 @@ class TriggerAutosensValueTest : TriggerTestBase() { t.autosens.value = 410.0 t.comparator.value = Comparator.Compare.IS_EQUAL val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerAutosensValue - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value) - Assertions.assertEquals(410.0, t2.autosens.value, 0.01) + assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t2.autosens.value).isWithin(0.01).of(410.0) } @Test fun iconTest() { assertThat(TriggerAutosensValue(injector).icon().get()).isEqualTo(R.drawable.ic_as) } - private fun generateAutosensData(): AutosensDataObject { - return AutosensDataObject(injector) - } -} \ No newline at end of file + private fun generateAutosensData() = AutosensDataObject(injector) +} From 83cee8558d591a073b4450a80816cee7a7ce4b84 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:08:14 -0700 Subject: [PATCH 037/127] Rewrites TriggerCOBTest with matchers Issue #2745 --- .../automation/triggers/TriggerCOBTest.kt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerCOBTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerCOBTest.kt index 83e0930252..9829977f1d 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerCOBTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerCOBTest.kt @@ -4,11 +4,11 @@ import app.aaps.core.interfaces.iob.CobInfo import app.aaps.plugins.automation.elements.Comparator import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerCOBTest : TriggerTestBase() { @@ -20,44 +20,44 @@ class TriggerCOBTest : TriggerTestBase() { // COB value is 6 `when`(iobCobCalculator.getCobInfo("AutomationTriggerCOB")).thenReturn(CobInfo(0, 6.0, 2.0)) var t: TriggerCOB = TriggerCOB(injector).setValue(1.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerCOB(injector).setValue(6.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerCOB(injector).setValue(5.0).comparator(Comparator.Compare.IS_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerCOB(injector).setValue(5.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerCOB(injector).setValue(6.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerCOB(injector).setValue(1.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerCOB(injector).setValue(10.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerCOB(injector).setValue(5.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() } @Test fun copyConstructorTest() { val t: TriggerCOB = TriggerCOB(injector).setValue(213.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertEquals(213.0, t.cob.value, 0.01) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value) + assertThat(t.cob.value).isWithin(0.01).of(213.0) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER) } private var bgJson = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"carbs\":4},\"type\":\"TriggerCOB\"}" @Test fun toJSONTest() { val t: TriggerCOB = TriggerCOB(injector).setValue(4.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(bgJson, t.toJSON()) + JSONAssert.assertEquals(bgJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t: TriggerCOB = TriggerCOB(injector).setValue(4.0).comparator(Comparator.Compare.IS_EQUAL) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerCOB - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value) - Assertions.assertEquals(4.0, t2.cob.value, 0.01) + assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t2.cob.value).isWithin(0.01).of(4.0) } @Test fun iconTest() { assertThat(TriggerCOB(injector).icon().get()).isEqualTo(app.aaps.core.main.R.drawable.ic_cp_bolus_carbs) } -} \ No newline at end of file +} From 7fa8b87f6dcbd99a40aae99230abc28d2b48cc0c Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:08:24 -0700 Subject: [PATCH 038/127] Rewrites TriggerLocationTest with matchers Issue #2745 --- .../triggers/TriggerLocationTest.kt | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerLocationTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerLocationTest.kt index c6a7ab9dff..fc082c1ca2 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerLocationTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerLocationTest.kt @@ -6,7 +6,6 @@ import app.aaps.plugins.automation.elements.InputLocationMode import com.google.common.truth.Truth.assertThat import org.json.JSONException import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` @@ -24,10 +23,10 @@ class TriggerLocationTest : TriggerTestBase() { t.distance.setValue(2.0) t.modeSelected.value = InputLocationMode.Mode.INSIDE val t1 = t.duplicate() as TriggerLocation - Assertions.assertEquals(213.0, t1.latitude.value, 0.01) - Assertions.assertEquals(212.0, t1.longitude.value, 0.01) - Assertions.assertEquals(2.0, t1.distance.value, 0.01) - Assertions.assertEquals(InputLocationMode.Mode.INSIDE, t1.modeSelected.value) + assertThat(t1.latitude.value).isWithin(0.01).of(213.0) + assertThat(t1.longitude.value).isWithin(0.01).of(212.0) + assertThat(t1.distance.value).isWithin(0.01).of(2.0) + assertThat(t1.modeSelected.value).isEqualTo(InputLocationMode.Mode.INSIDE) } @Test fun shouldRunTest() { @@ -37,12 +36,12 @@ class TriggerLocationTest : TriggerTestBase() { t.distance.setValue(2.0) // t.modeSelected.setValue(InputLocationMode.Mode.OUTSIDE); `when`(locationDataContainer.lastLocation).thenReturn(null) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() `when`(locationDataContainer.lastLocation).thenReturn(mockedLocation()) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerLocation(injector) t.distance.setValue(-500.0) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() //Test of GOING_IN - last mode should be OUTSIDE, and current mode should be INSIDE t = TriggerLocation(injector) @@ -51,9 +50,9 @@ class TriggerLocationTest : TriggerTestBase() { `when`(locationDataContainer.lastLocation).thenReturn(null) `when`(locationDataContainer.lastLocation).thenReturn(mockedLocationOut()) t.modeSelected.value = InputLocationMode.Mode.GOING_IN - Assertions.assertEquals(t.lastMode, InputLocationMode.Mode.OUTSIDE) - Assertions.assertEquals(t.currentMode(5.0), InputLocationMode.Mode.INSIDE) - Assertions.assertTrue(t.shouldRun()) + assertThat(InputLocationMode.Mode.OUTSIDE).isEqualTo(t.lastMode) + assertThat(InputLocationMode.Mode.INSIDE).isEqualTo(t.currentMode(5.0)) + assertThat(t.shouldRun()).isTrue() //Test of GOING_OUT - last mode should be INSIDE, and current mode should be OUTSIDE // Currently unavailable due to problems with Location mocking @@ -67,7 +66,7 @@ class TriggerLocationTest : TriggerTestBase() { t.distance.setValue(2.0) t.modeSelected.value = InputLocationMode.Mode.OUTSIDE // t.modeSelected = t.modeSelected.value - Assertions.assertEquals(locationJson, t.toJSON()) + assertThat(t.toJSON()).isEqualTo(locationJson) } @Test @Throws(JSONException::class) fun fromJSONTest() { @@ -77,18 +76,18 @@ class TriggerLocationTest : TriggerTestBase() { t.distance.setValue(2.0) t.modeSelected.value = InputLocationMode.Mode.INSIDE val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerLocation - Assertions.assertEquals(t.latitude.value, t2.latitude.value, 0.01) - Assertions.assertEquals(t.longitude.value, t2.longitude.value, 0.01) - Assertions.assertEquals(t.distance.value, t2.distance.value, 0.01) - Assertions.assertEquals(t.modeSelected.value, t2.modeSelected.value) + assertThat(t2.latitude.value).isWithin(0.01).of(t.latitude.value) + assertThat(t2.longitude.value).isWithin(0.01).of(t.longitude.value) + assertThat(t2.distance.value).isWithin(0.01).of(t.distance.value) + assertThat(t2.modeSelected.value).isEqualTo(t.modeSelected.value) } @Test fun friendlyNameTest() { - Assertions.assertEquals(R.string.location, TriggerLocation(injector).friendlyName()) + assertThat(TriggerLocation(injector).friendlyName()).isEqualTo(R.string.location) } @Test fun friendlyDescriptionTest() { - Assertions.assertEquals(null, TriggerLocation(injector).friendlyDescription()) //not mocked } + assertThat(TriggerLocation(injector).friendlyDescription()).isNull() //not mocked } } @Test fun iconTest() { @@ -110,4 +109,4 @@ class TriggerLocationTest : TriggerTestBase() { newLocation.accuracy = 1f return newLocation } -} \ No newline at end of file +} From 8b98f5d4707a7304d7fdb33969655c19e5bc46ea Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:11:57 -0700 Subject: [PATCH 039/127] Rewrites TriggerWifiSsidTest with matchers Issue #2745 --- .../triggers/TriggerWifiSsidTest.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerWifiSsidTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerWifiSsidTest.kt index cd62a20eac..f6a01be146 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerWifiSsidTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerWifiSsidTest.kt @@ -6,9 +6,9 @@ import app.aaps.plugins.automation.elements.Comparator import com.google.common.truth.Truth.assertThat import org.json.JSONException import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerWifiSsidTest : TriggerTestBase() { @@ -17,40 +17,40 @@ class TriggerWifiSsidTest : TriggerTestBase() { `when`(receiverStatusStore.lastNetworkEvent).thenReturn(e) var t: TriggerWifiSsid = TriggerWifiSsid(injector).setValue("aSSID 1").comparator(Comparator.Compare.IS_EQUAL) e.wifiConnected = false - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() e.wifiConnected = true e.ssid = "otherSSID" - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() e.wifiConnected = true e.ssid = "aSSID 1" - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerWifiSsid(injector).setValue("aSSID 1").comparator(Comparator.Compare.IS_NOT_AVAILABLE) e.wifiConnected = false - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() // no network data `when`(receiverStatusStore.lastNetworkEvent).thenReturn(null) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() } @Test fun copyConstructorTest() { val t: TriggerWifiSsid = TriggerWifiSsid(injector).setValue("aSSID").comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) val t1 = t.duplicate() as TriggerWifiSsid - Assertions.assertEquals("aSSID", t1.ssid.value) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value) + assertThat(t1.ssid.value).isEqualTo("aSSID") + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER) } var json = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"ssid\":\"aSSID\"},\"type\":\"TriggerWifiSsid\"}" @Test fun toJSONTest() { val t: TriggerWifiSsid = TriggerWifiSsid(injector).setValue("aSSID").comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(json, t.toJSON()) + JSONAssert.assertEquals(json, t.toJSON(), true) } @Test @Throws(JSONException::class) fun fromJSONTest() { val t: TriggerWifiSsid = TriggerWifiSsid(injector).setValue("aSSID").comparator(Comparator.Compare.IS_EQUAL) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerWifiSsid - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value) - Assertions.assertEquals("aSSID", t2.ssid.value) + assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t2.ssid.value).isEqualTo("aSSID") } @Test fun iconTest() { @@ -58,10 +58,10 @@ class TriggerWifiSsidTest : TriggerTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.ns_wifi_ssids, TriggerWifiSsid(injector).friendlyName()) + assertThat(TriggerWifiSsid(injector).friendlyName()).isEqualTo(app.aaps.core.ui.R.string.ns_wifi_ssids) } @Test fun friendlyDescriptionTest() { - Assertions.assertEquals(null, TriggerWifiSsid(injector).friendlyDescription()) //not mocked + assertThat(TriggerWifiSsid(injector).friendlyDescription()).isNull() //not mocked } -} \ No newline at end of file +} From 23af5387331749ba5605a88242539d97837640a3 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:14:29 -0700 Subject: [PATCH 040/127] Rewrites TriggerRecurringTimeTest with matchers Issue #2745 --- .../automation/triggers/TriggerRecurringTimeTest.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerRecurringTimeTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerRecurringTimeTest.kt index 336196ba80..fa4d367046 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerRecurringTimeTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerRecurringTimeTest.kt @@ -2,11 +2,12 @@ package app.aaps.plugins.automation.triggers import app.aaps.core.interfaces.utils.MidnightTime import app.aaps.core.interfaces.utils.T +import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito +import org.skyscreamer.jsonassert.JSONAssert class TriggerRecurringTimeTest : TriggerTestBase() { @@ -19,12 +20,12 @@ class TriggerRecurringTimeTest : TriggerTestBase() { var t: TriggerRecurringTime = TriggerRecurringTime(injector).time(89) t.days.setAll(true) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() // scheduled 1 min before t = TriggerRecurringTime(injector).time(94) t.days.setAll(true) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() } private var timeJson = @@ -33,13 +34,13 @@ class TriggerRecurringTimeTest : TriggerTestBase() { @Test fun toJSONTest() { val t = TriggerRecurringTime(injector).time(4444) - Assertions.assertEquals(timeJson, t.toJSON()) + JSONAssert.assertEquals(timeJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t = TriggerRecurringTime(injector).time(4444) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerRecurringTime - Assertions.assertEquals(4444, t2.time.value) + assertThat(t2.time.value).isEqualTo(4444) } -} \ No newline at end of file +} From 9f44f30f7d4ebd7c455b54733b2957b66bf05d1c Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:16:26 -0700 Subject: [PATCH 041/127] Rewrites TriggerBTDeviceTest with matchers Issue #2745 --- .../automation/triggers/TriggerBTDeviceTest.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBTDeviceTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBTDeviceTest.kt index 91b912d9ef..c0a7cfd89a 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBTDeviceTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBTDeviceTest.kt @@ -3,8 +3,8 @@ package app.aaps.plugins.automation.triggers import app.aaps.plugins.automation.elements.ComparatorConnect import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import org.skyscreamer.jsonassert.JSONAssert class TriggerBTDeviceTest : TriggerTestBase() { @@ -19,14 +19,14 @@ class TriggerBTDeviceTest : TriggerTestBase() { @Test fun toJSON() { val t = TriggerBTDevice(injector) t.btDevice.value = someName - Assertions.assertEquals(btJson, t.toJSON()) + JSONAssert.assertEquals(btJson, t.toJSON(), true) } @Test fun fromJSON() { val t2 = TriggerDummy(injector).instantiate(JSONObject(btJson)) as TriggerBTDevice - Assertions.assertEquals(ComparatorConnect.Compare.ON_CONNECT, t2.comparator.value) - Assertions.assertEquals("Headset", t2.btDevice.value) + assertThat(t2.comparator.value).isEqualTo(ComparatorConnect.Compare.ON_CONNECT) + assertThat(t2.btDevice.value).isEqualTo("Headset") } @Test @@ -40,7 +40,7 @@ class TriggerBTDeviceTest : TriggerTestBase() { it.btDevice.value = someName } val t1 = t.duplicate() as TriggerBTDevice - Assertions.assertEquals("Headset", t1.btDevice.value) - Assertions.assertEquals(ComparatorConnect.Compare.ON_DISCONNECT, t.comparator.value) + assertThat(t1.btDevice.value).isEqualTo("Headset") + assertThat(t.comparator.value).isEqualTo(ComparatorConnect.Compare.ON_DISCONNECT) } -} \ No newline at end of file +} From de404686633473de997ce50981fc2c5922bd3094 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:37:36 -0700 Subject: [PATCH 042/127] Rewrites TriggerProfilePercentTest with matchers Issue #2745 --- .../triggers/TriggerProfilePercentTest.kt | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerProfilePercentTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerProfilePercentTest.kt index fdaba24f13..9becc46ad7 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerProfilePercentTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerProfilePercentTest.kt @@ -4,10 +4,10 @@ import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.Comparator import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerProfilePercentTest : TriggerTestBase() { @@ -17,43 +17,43 @@ class TriggerProfilePercentTest : TriggerTestBase() { @Test fun shouldRunTest() { var t: TriggerProfilePercent = TriggerProfilePercent(injector).setValue(101.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerProfilePercent(injector).setValue(100.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerProfilePercent(injector).setValue(100.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerProfilePercent(injector).setValue(90.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerProfilePercent(injector).setValue(100.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerProfilePercent(injector).setValue(101.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerProfilePercent(injector).setValue(215.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerProfilePercent(injector).setValue(110.0).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerProfilePercent(injector).setValue(90.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() } @Test fun copyConstructorTest() { val t: TriggerProfilePercent = TriggerProfilePercent(injector).setValue(213.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) val t1 = t.duplicate() as TriggerProfilePercent - Assertions.assertEquals(213.0, t1.pct.value, 0.01) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value) + assertThat( t1.pct.value).isWithin(0.01).of(213.0) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER) } private val bgJson = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"percentage\":110},\"type\":\"TriggerProfilePercent\"}" @Test fun toJSONTest() { val t: TriggerProfilePercent = TriggerProfilePercent(injector).setValue(110.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(bgJson, t.toJSON()) + JSONAssert.assertEquals(bgJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t: TriggerProfilePercent = TriggerProfilePercent(injector).setValue(120.0).comparator(Comparator.Compare.IS_EQUAL) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerProfilePercent - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value) - Assertions.assertEquals(120.0, t2.pct.value, 0.01) + assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t2.pct.value).isWithin(0.01).of(120.0) } @Test fun iconTest() { @@ -61,6 +61,6 @@ class TriggerProfilePercentTest : TriggerTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(R.string.profilepercentage, TriggerProfilePercent(injector).friendlyName()) // not mocked + assertThat(TriggerProfilePercent(injector).friendlyName()).isEqualTo(R.string.profilepercentage) // not mocked } -} \ No newline at end of file +} From 3aafe1212a1037a2bd0e3edd89741df8fada87ee Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:37:47 -0700 Subject: [PATCH 043/127] Rewrites TriggerBolusAgoTest with matchers Issue #2745 --- .../triggers/TriggerBolusAgoTest.kt | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBolusAgoTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBolusAgoTest.kt index 8f53218183..4e5cf8e277 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBolusAgoTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerBolusAgoTest.kt @@ -7,9 +7,9 @@ import com.google.common.truth.Truth.assertThat import io.reactivex.rxjava3.core.Single import org.json.JSONException import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerBolusAgoTest : TriggerTestBase() { @@ -29,26 +29,26 @@ class TriggerBolusAgoTest : TriggerTestBase() { ) `when`(dateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min var t = TriggerBolusAgo(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(110, t.minutesAgo.value) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t.comparator.value) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.minutesAgo.value).isEqualTo(110) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t.shouldRun()).isFalse() t = TriggerBolusAgo(injector).setValue(10).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(10, t.minutesAgo.value) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.minutesAgo.value).isEqualTo(10) + assertThat(t.shouldRun()).isTrue() t = TriggerBolusAgo(injector).setValue(5).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerBolusAgo(injector).setValue(310).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerBolusAgo(injector).setValue(420).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerBolusAgo(injector).setValue(390).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerBolusAgo(injector).setValue(390).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerBolusAgo(injector).setValue(2).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerBolusAgo(injector).setValue(390).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() // Set last bolus time to 0 `when`(repository.getLastBolusRecordOfTypeWrapped(Bolus.Type.NORMAL)).thenReturn( Single.just( @@ -62,30 +62,30 @@ class TriggerBolusAgoTest : TriggerTestBase() { ) ) t = TriggerBolusAgo(injector).comparator(Comparator.Compare.IS_NOT_AVAILABLE) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() } @Test fun copyConstructorTest() { val t: TriggerBolusAgo = TriggerBolusAgo(injector).setValue(213).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) val t1 = t.duplicate() as TriggerBolusAgo - Assertions.assertEquals(213, t1.minutesAgo.value) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value) + assertThat(t1.minutesAgo.value).isEqualTo(213) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER) } private var lbJson = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"minutesAgo\":410},\"type\":\"TriggerBolusAgo\"}" @Test fun toJSONTest() { val t: TriggerBolusAgo = TriggerBolusAgo(injector).setValue(410).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(lbJson, t.toJSON()) + JSONAssert.assertEquals(lbJson, t.toJSON(), true) } @Test @Throws(JSONException::class) fun fromJSONTest() { val t: TriggerBolusAgo = TriggerBolusAgo(injector).setValue(410).comparator(Comparator.Compare.IS_EQUAL) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerBolusAgo - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value) - Assertions.assertEquals(410, t2.minutesAgo.value) + assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t2.minutesAgo.value).isEqualTo(410) } @Test fun iconTest() { assertThat(TriggerBolusAgo(injector).icon().get()).isEqualTo(app.aaps.core.main.R.drawable.ic_bolus) } -} \ No newline at end of file +} From 570e3adea52c08b6c05d9290fba0f2a2b6a7ac0e Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:37:55 -0700 Subject: [PATCH 044/127] Rewrites TriggerDummyTest with matchers Issue #2745 --- .../plugins/automation/triggers/TriggerDummyTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerDummyTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerDummyTest.kt index c0fcd70444..8e2f9da367 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerDummyTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerDummyTest.kt @@ -1,7 +1,7 @@ package app.aaps.plugins.automation.triggers +import kotlin.test.assertIs import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class TriggerDummyTest : TriggerTestBase() { @@ -9,13 +9,13 @@ class TriggerDummyTest : TriggerTestBase() { @Test fun instantiateTest() { var trigger: Trigger? = TriggerDummy(injector).instantiate(JSONObject("{\"data\":{},\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDummy\"}")) - Assertions.assertTrue(trigger is TriggerDummy) + assertIs(trigger) trigger = TriggerDummy(injector).instantiate(JSONObject("{\"data\":{},\"type\":\"app.aaps.plugins.automation.triggers.TriggerDummy\"}")) - Assertions.assertTrue(trigger is TriggerDummy) + assertIs(trigger) trigger = TriggerDummy(injector).instantiate(JSONObject("{\"data\":{},\"type\":\"TriggerDummy\"}")) - Assertions.assertTrue(trigger is TriggerDummy) + assertIs(trigger) } -} \ No newline at end of file +} From e259d8e45e9dac0ff275a9038ffb09b10b26bf26 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:38:00 -0700 Subject: [PATCH 045/127] Rewrites TriggerHeartRateTest with matchers Issue #2745 --- .../triggers/TriggerHeartRateTest.kt | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerHeartRateTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerHeartRateTest.kt index 27e395df15..5e7b7a5c7f 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerHeartRateTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerHeartRateTest.kt @@ -3,19 +3,20 @@ package app.aaps.plugins.automation.triggers import app.aaps.database.entities.HeartRate import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.Comparator +import com.google.common.truth.Truth.assertThat import io.reactivex.rxjava3.core.Single import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerHeartRateTest : TriggerTestBase() { @Test fun friendlyName() { - Assertions.assertEquals(R.string.triggerHeartRate, TriggerHeartRate(injector).friendlyName()) + assertThat(TriggerHeartRate(injector).friendlyName()).isEqualTo(R.string.triggerHeartRate) } @Test @@ -23,7 +24,7 @@ class TriggerHeartRateTest : TriggerTestBase() { val t = TriggerHeartRate(injector) `when`(rh.gs(Comparator.Compare.IS_EQUAL_OR_GREATER.stringRes)).thenReturn(">") `when`(rh.gs(R.string.triggerHeartRateDesc, ">", 80.0)).thenReturn("test") - Assertions.assertEquals("test", t.friendlyDescription()) + assertThat(t.friendlyDescription()).isEqualTo("test") } @Test @@ -33,16 +34,16 @@ class TriggerHeartRateTest : TriggerTestBase() { comparator.value = Comparator.Compare.IS_GREATER } val dup = t.duplicate() as TriggerHeartRate - Assertions.assertNotSame(t, dup) - Assertions.assertEquals(100.0, dup.heartRate.value, 0.01) - Assertions.assertEquals(Comparator.Compare.IS_GREATER, dup.comparator.value) + assertThat(dup).isNotSameInstanceAs(t) + assertThat(dup.heartRate.value).isWithin(0.01).of(100.0) + assertThat(dup.comparator.value).isEqualTo(Comparator.Compare.IS_GREATER) } @Test fun shouldRunNotAvailable() { val t = TriggerHeartRate(injector).apply { comparator.value = Comparator.Compare.IS_NOT_AVAILABLE } - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() verifyNoMoreInteractions(repository) } @@ -53,7 +54,7 @@ class TriggerHeartRateTest : TriggerTestBase() { comparator.value = Comparator.Compare.IS_GREATER } `when`(repository.getHeartRatesFromTime(now - t.averageHeartRateDurationMillis)).thenReturn(Single.just(emptyList())) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() verify(repository).getHeartRatesFromTime(now - t.averageHeartRateDurationMillis) verifyNoMoreInteractions(repository) } @@ -69,7 +70,7 @@ class TriggerHeartRateTest : TriggerTestBase() { HeartRate(duration = 300_000, timestamp = now, beatsPerMinute = 60.0, device = "test"), ) `when`(repository.getHeartRatesFromTime(now - t.averageHeartRateDurationMillis)).thenReturn(Single.just(hrs)) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() verify(repository).getHeartRatesFromTime(now - t.averageHeartRateDurationMillis) verifyNoMoreInteractions(repository) } @@ -84,7 +85,7 @@ class TriggerHeartRateTest : TriggerTestBase() { HeartRate(duration = 300_000, timestamp = now, beatsPerMinute = 120.0, device = "test"), ) `when`(repository.getHeartRatesFromTime(now - t.averageHeartRateDurationMillis)).thenReturn(Single.just(hrs)) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() verify(repository).getHeartRatesFromTime(now - t.averageHeartRateDurationMillis) verifyNoMoreInteractions(repository) } @@ -95,9 +96,9 @@ class TriggerHeartRateTest : TriggerTestBase() { heartRate.value = 100.0 comparator.value = Comparator.Compare.IS_GREATER } - Assertions.assertEquals(Comparator.Compare.IS_GREATER, t.comparator.value) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_GREATER) - Assertions.assertEquals("""{"data":{"comparator":"IS_GREATER","heartRate":100},"type":"TriggerHeartRate"}""".trimMargin(), t.toJSON()) + JSONAssert.assertEquals("""{"data":{"comparator":"IS_GREATER","heartRate":100},"type":"TriggerHeartRate"}""", t.toJSON(), true) } @Test @@ -107,7 +108,7 @@ class TriggerHeartRateTest : TriggerTestBase() { """{"data":{"comparator":"IS_GREATER","heartRate":100},"type":"TriggerHeartRate"}""" ) ) as TriggerHeartRate - Assertions.assertEquals(Comparator.Compare.IS_GREATER, t.comparator.value) - Assertions.assertEquals(100.0, t.heartRate.value, 0.01) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_GREATER) + assertThat(t.heartRate.value).isWithin(0.01).of(100.0) } -} \ No newline at end of file +} From c7c858a46b8aef5170005683e454df69de5499f6 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:38:05 -0700 Subject: [PATCH 046/127] Rewrites TriggerIobTest with matchers Issue #2745 --- .../automation/triggers/TriggerIobTest.kt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerIobTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerIobTest.kt index e90b719e62..4afe63be8a 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerIobTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerIobTest.kt @@ -5,11 +5,11 @@ import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.Comparator import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerIobTest : TriggerTestBase() { @@ -20,43 +20,43 @@ class TriggerIobTest : TriggerTestBase() { @Test fun shouldRunTest() { `when`(iobCobCalculator.calculateFromTreatmentsAndTemps(ArgumentMatchers.anyLong(), anyObject())).thenReturn(generateIobRecordData()) var t: TriggerIob = TriggerIob(injector).setValue(1.1).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerIob(injector).setValue(1.0).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerIob(injector).setValue(0.8).comparator(Comparator.Compare.IS_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerIob(injector).setValue(0.8).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerIob(injector).setValue(0.9).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerIob(injector).setValue(1.2).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerIob(injector).setValue(1.1).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerIob(injector).setValue(1.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() t = TriggerIob(injector).setValue(0.9).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() } @Test fun copyConstructorTest() { val t: TriggerIob = TriggerIob(injector).setValue(213.0).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertEquals(213.0, t.insulin.value, 0.01) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value) + assertThat(t.insulin.value).isWithin(0.01).of(213.0) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER) } private var bgJson = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"insulin\":4.1},\"type\":\"TriggerIob\"}" @Test fun toJSONTest() { val t: TriggerIob = TriggerIob(injector).setValue(4.1).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(bgJson, t.toJSON()) + JSONAssert.assertEquals(bgJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t: TriggerIob = TriggerIob(injector).setValue(4.1).comparator(Comparator.Compare.IS_EQUAL) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerIob - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value) - Assertions.assertEquals(4.1, t2.insulin.value, 0.01) + assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t2.insulin.value).isWithin(0.01).of(4.1) } @Test fun iconTest() { @@ -68,4 +68,4 @@ class TriggerIobTest : TriggerTestBase() { iobTotal.iob = 1.0 return iobTotal } -} \ No newline at end of file +} From a801306d40f5319a493432a0ea91528495b6c4ec Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:38:12 -0700 Subject: [PATCH 047/127] Rewrites TriggerPumpLastConnectionTest with matchers Issue #2745 --- .../triggers/TriggerPumpLastConnectionTest.kt | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerPumpLastConnectionTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerPumpLastConnectionTest.kt index 3189efd24c..e11ef0461b 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerPumpLastConnectionTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerPumpLastConnectionTest.kt @@ -4,9 +4,9 @@ import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.Comparator import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerPumpLastConnectionTest : TriggerTestBase() { @@ -14,42 +14,42 @@ class TriggerPumpLastConnectionTest : TriggerTestBase() { fun shouldRunTest() { // System.currentTimeMillis() is always 0 // and so is every last connection time - Assertions.assertEquals(0L, testPumpPlugin.lastDataTime()) + assertThat(testPumpPlugin.lastDataTime()).isEqualTo(0L) `when`(dateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min var t = TriggerPumpLastConnection(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(110, t.minutesAgo.value) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t.comparator.value) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.minutesAgo.value).isEqualTo(110) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t.shouldRun()).isFalse() t = TriggerPumpLastConnection(injector).setValue(10).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(10, t.minutesAgo.value) - Assertions.assertFalse(t.shouldRun()) // 0 == 10 -> FALSE + assertThat(t.minutesAgo.value).isEqualTo(10) + assertThat(t.shouldRun()).isFalse() // 0 == 10 -> FALSE t = TriggerPumpLastConnection(injector).setValue(5).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER) - Assertions.assertTrue(t.shouldRun()) // 5 => 0 -> TRUE + assertThat(t.shouldRun()).isTrue() // 5 => 0 -> TRUE t = TriggerPumpLastConnection(injector).setValue(310).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) - Assertions.assertFalse(t.shouldRun()) // 310 <= 0 -> FALSE + assertThat(t.shouldRun()).isFalse() // 310 <= 0 -> FALSE t = TriggerPumpLastConnection(injector).setValue(420).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertFalse(t.shouldRun()) // 420 == 0 -> FALSE + assertThat(t.shouldRun()).isFalse() // 420 == 0 -> FALSE } @Test fun copyConstructorTest() { val t: TriggerPumpLastConnection = TriggerPumpLastConnection(injector).setValue(213).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) val t1 = t.duplicate() as TriggerPumpLastConnection - Assertions.assertEquals(213, t1.minutesAgo.value) - Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value) + assertThat(t1.minutesAgo.value).isEqualTo(213) + assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER) } private var lbJson = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"minutesAgo\":410},\"type\":\"TriggerPumpLastConnection\"}" @Test fun toJSONTest() { val t: TriggerPumpLastConnection = TriggerPumpLastConnection(injector).setValue(410).comparator(Comparator.Compare.IS_EQUAL) - Assertions.assertEquals(lbJson, t.toJSON()) + JSONAssert.assertEquals(lbJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t: TriggerPumpLastConnection = TriggerPumpLastConnection(injector).setValue(410).comparator(Comparator.Compare.IS_EQUAL) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerPumpLastConnection - Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value) - Assertions.assertEquals(410, t2.minutesAgo.value) + assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL) + assertThat(t2.minutesAgo.value).isEqualTo(410) } @Test fun iconTest() { @@ -57,6 +57,6 @@ class TriggerPumpLastConnectionTest : TriggerTestBase() { } @Test fun friendlyNameTest() { - Assertions.assertEquals(R.string.automation_trigger_pump_last_connection_label, TriggerPumpLastConnection(injector).friendlyName()) + assertThat(TriggerPumpLastConnection(injector).friendlyName()).isEqualTo(R.string.automation_trigger_pump_last_connection_label) } -} \ No newline at end of file +} From b2fe352555ed184c9f31393b8e8011dc655a47a6 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:38:20 -0700 Subject: [PATCH 048/127] Rewrites TriggerTempTargetTest with matchers Issue #2745 --- .../triggers/TriggerTempTargetTest.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetTest.kt index 180f6fafbe..663c89180c 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetTest.kt @@ -4,8 +4,8 @@ import app.aaps.plugins.automation.R import app.aaps.plugins.automation.elements.ComparatorExists import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import org.skyscreamer.jsonassert.JSONAssert class TriggerTempTargetTest : TriggerTestBase() { @@ -13,36 +13,36 @@ class TriggerTempTargetTest : TriggerTestBase() { @Test fun shouldRunTest() { `when`(repository.getTemporaryTargetActiveAt(anyObject())).thenReturn(null) var t: TriggerTempTarget = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.EXISTS) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() `when`(repository.getTemporaryTargetActiveAt(anyObject())).thenReturn(TemporaryTarget(duration = 0, highTarget = 0.0, lowTarget = 0.0, reason = TemporaryTarget.Reason.CUSTOM, timestamp = 0)) t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.EXISTS) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() } */ @Test fun copyConstructorTest() { val t: TriggerTempTarget = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS) val t1 = t.duplicate() as TriggerTempTarget - Assertions.assertEquals(ComparatorExists.Compare.NOT_EXISTS, t1.comparator.value) + assertThat(t1.comparator.value).isEqualTo(ComparatorExists.Compare.NOT_EXISTS) } private var ttJson = "{\"data\":{\"comparator\":\"EXISTS\"},\"type\":\"TriggerTempTarget\"}" @Test fun toJSONTest() { val t: TriggerTempTarget = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.EXISTS) - Assertions.assertEquals(ttJson, t.toJSON()) + JSONAssert.assertEquals(ttJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t: TriggerTempTarget = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerTempTarget - Assertions.assertEquals(ComparatorExists.Compare.NOT_EXISTS, t2.comparator.value) + assertThat(t2.comparator.value).isEqualTo(ComparatorExists.Compare.NOT_EXISTS) } @Test fun iconTest() { assertThat(TriggerTempTarget(injector).icon().get()).isEqualTo(R.drawable.ic_keyboard_tab) } -} \ No newline at end of file +} From 60c4d70a3f1d431e6b1f7bc3591a8be76812be86 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:38:30 -0700 Subject: [PATCH 049/127] Rewrites TriggerTimeRangeTest with matchers Issue #2745 --- .../triggers/TriggerTimeRangeTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTimeRangeTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTimeRangeTest.kt index a828c2035f..5eb4f3bca1 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTimeRangeTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTimeRangeTest.kt @@ -4,10 +4,10 @@ import app.aaps.core.interfaces.utils.MidnightTime import app.aaps.plugins.automation.R import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mockito.`when` +import org.skyscreamer.jsonassert.JSONAssert class TriggerTimeRangeTest : TriggerTestBase() { @@ -25,47 +25,47 @@ class TriggerTimeRangeTest : TriggerTestBase() { fun shouldRunTest() { // range starts 1 min in the future var t: TriggerTimeRange = TriggerTimeRange(injector).period((now + 1).toInt(), (now + 30).toInt()) - Assertions.assertEquals(false, t.shouldRun()) + assertThat(t.shouldRun()).isFalse() // range starts 30 min back t = TriggerTimeRange(injector).period((now - 30).toInt(), (now + 30).toInt()) - Assertions.assertEquals(true, t.shouldRun()) + assertThat(t.shouldRun()).isTrue() // Period is all day long t = TriggerTimeRange(injector).period(1, 1440) - Assertions.assertEquals(true, t.shouldRun()) + assertThat(t.shouldRun()).isTrue() } @Test fun toJSONTest() { val t: TriggerTimeRange = TriggerTimeRange(injector).period((now - 1).toInt(), (now + 30).toInt()) - Assertions.assertEquals(timeJson, t.toJSON()) + JSONAssert.assertEquals(timeJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t: TriggerTimeRange = TriggerTimeRange(injector).period(120, 180) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerTimeRange - Assertions.assertEquals((now - 1).toInt(), t2.period(753, 360).range.start) - Assertions.assertEquals(360, t2.period(753, 360).range.end) + assertThat(t2.period(753, 360).range.start).isEqualTo((now - 1).toInt()) + assertThat(t2.period(753, 360).range.end).isEqualTo(360) } @Test fun copyConstructorTest() { val t = TriggerTimeRange(injector) t.period(now.toInt(), (now + 30).toInt()) val t1 = t.duplicate() as TriggerTimeRange - Assertions.assertEquals(now.toInt(), t1.range.start) + assertThat(t1.range.start).isEqualTo(now.toInt()) } @Test fun friendlyNameTest() { - Assertions.assertEquals(R.string.time_range, TriggerTimeRange(injector).friendlyName()) + assertThat(TriggerTimeRange(injector).friendlyName()).isEqualTo(R.string.time_range) } @Test fun friendlyDescriptionTest() { - Assertions.assertEquals("Time is between 12:34PM and 12:34PM", TriggerTimeRange(injector).friendlyDescription()) + assertThat(TriggerTimeRange(injector).friendlyDescription()).isEqualTo("Time is between 12:34PM and 12:34PM") } @Test fun iconTest() { assertThat(TriggerTimeRange(injector).icon().get()).isEqualTo(app.aaps.core.main.R.drawable.ic_access_alarm_24dp) } -} \ No newline at end of file +} From 3c855524136a1ee5eb65885ae8b6ba44fcb66cd2 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Wed, 4 Oct 2023 22:38:36 -0700 Subject: [PATCH 050/127] Rewrites TriggerTimeTest with matchers Issue #2745 --- .../automation/triggers/TriggerTimeTest.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTimeTest.kt b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTimeTest.kt index 75736e9784..8dd027b6b7 100644 --- a/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTimeTest.kt +++ b/plugins/automation/src/test/kotlin/app/aaps/plugins/automation/triggers/TriggerTimeTest.kt @@ -4,9 +4,9 @@ import app.aaps.core.interfaces.utils.T import app.aaps.plugins.automation.R import com.google.common.truth.Truth.assertThat import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito +import org.skyscreamer.jsonassert.JSONAssert class TriggerTimeTest : TriggerTestBase() { @@ -19,11 +19,11 @@ class TriggerTimeTest : TriggerTestBase() { // scheduled 1 min before var t: TriggerTime = TriggerTime(injector).runAt(now - T.mins(1).msecs()) - Assertions.assertTrue(t.shouldRun()) + assertThat(t.shouldRun()).isTrue() // scheduled 1 min in the future t = TriggerTime(injector).runAt(now + T.mins(1).msecs()) - Assertions.assertFalse(t.shouldRun()) + assertThat(t.shouldRun()).isFalse() } private var timeJson = "{\"data\":{\"runAt\":1656358762000},\"type\":\"TriggerTime\"}" @@ -31,14 +31,14 @@ class TriggerTimeTest : TriggerTestBase() { @Test fun toJSONTest() { val t: TriggerTime = TriggerTime(injector).runAt(now - T.mins(1).msecs()) - Assertions.assertEquals(timeJson, t.toJSON()) + JSONAssert.assertEquals(timeJson, t.toJSON(), true) } @Test fun fromJSONTest() { val t: TriggerTime = TriggerTime(injector).runAt(now - T.mins(1).msecs()) val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerTime - Assertions.assertEquals(now - T.mins(1).msecs(), t2.time.value) + assertThat(t2.time.value).isEqualTo(now - T.mins(1).msecs()) } @Test @@ -46,22 +46,22 @@ class TriggerTimeTest : TriggerTestBase() { val t = TriggerTime(injector) t.runAt(now) val t1 = t.duplicate() as TriggerTime - Assertions.assertEquals(now, t1.time.value) + assertThat(t1.time.value).isEqualTo(now) } @Test fun friendlyNameTest() { - Assertions.assertEquals(app.aaps.core.ui.R.string.time, TriggerTime(injector).friendlyName()) + assertThat(TriggerTime(injector).friendlyName()).isEqualTo(app.aaps.core.ui.R.string.time) } @Test fun friendlyDescriptionTest() { Mockito.`when`(rh.gs(R.string.atspecifiedtime)).thenReturn("At %1\$s") - Assertions.assertTrue(TriggerTime(injector).friendlyDescription().startsWith("At ")) + assertThat(TriggerTime(injector).friendlyDescription()).startsWith("At ") } @Test fun iconTest() { assertThat(TriggerTime(injector).icon().get()).isEqualTo(app.aaps.core.main.R.drawable.ic_access_alarm_24dp) } -} \ No newline at end of file +} From a27dae802ae7f0eafbfc7474ecf8cd24eb5f367d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 5 Oct 2023 10:27:15 +0200 Subject: [PATCH 051/127] New Crowdin updates (#2868) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) --- core/ui/src/main/res/values-nb-rNO/strings.xml | 4 ++-- plugins/main/src/main/res/values-nb-rNO/strings.xml | 2 +- wear/src/main/res/values-nb-rNO/strings.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/ui/src/main/res/values-nb-rNO/strings.xml b/core/ui/src/main/res/values-nb-rNO/strings.xml index 2d1f670671..5c7ae8153d 100644 --- a/core/ui/src/main/res/values-nb-rNO/strings.xml +++ b/core/ui/src/main/res/values-nb-rNO/strings.xml @@ -64,7 +64,7 @@ Karbo Ugyldig profil! INGEN PROFIL VALGT - ]]> + ]]> Dato Enheter DIA @@ -136,7 +136,7 @@ lavt Gjennomsnitt TIR - ]]> + ]]> FJERN Aktiver profil tilbakestill diff --git a/plugins/main/src/main/res/values-nb-rNO/strings.xml b/plugins/main/src/main/res/values-nb-rNO/strings.xml index 0292646795..19baf4f493 100644 --- a/plugins/main/src/main/res/values-nb-rNO/strings.xml +++ b/plugins/main/src/main/res/values-nb-rNO/strings.xml @@ -332,7 +332,7 @@ g t Det er ikke angitt noen aktiv profil! - Profil:\n\nTidsforskyving: %1$d\nProsent: %2$d%%\" + Profil:\n\nTidsforskyving: %1$d\nProsent: %2$d%% %1$.2fE %1$.0f%% Ingen profil valgt Bare bruk i APS-modus! diff --git a/wear/src/main/res/values-nb-rNO/strings.xml b/wear/src/main/res/values-nb-rNO/strings.xml index 26da0990f7..5165e2eaa1 100644 --- a/wear/src/main/res/values-nb-rNO/strings.xml +++ b/wear/src/main/res/values-nb-rNO/strings.xml @@ -80,7 +80,7 @@ Versjon: Flere innstillinger for urskive Vennligst sjekk urskiveinnstillinger. - MidlMål + Midl. mål Kalkulator Kalk Behandling From 0f134ac95e6025227f08ea85486d84dad91e15ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 08:31:18 +0000 Subject: [PATCH 052/127] chore(deps): bump androidx.activity:activity-ktx from 1.7.2 to 1.8.0 Bumps androidx.activity:activity-ktx from 1.7.2 to 1.8.0. --- updated-dependencies: - dependency-name: androidx.activity:activity-ktx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9bc7d38a6b..4748d85643 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { lifecycle_version = '2.6.2' dagger_version = '2.48' coroutines_version = '1.7.3' - activity_version = '1.7.2' + activity_version = '1.8.0' fragmentktx_version = '1.6.1' ormLite_version = '4.46' gson_version = '2.10.1' From b50c59d69854ef2b10daef3a37d77c70d8354596 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 08:31:27 +0000 Subject: [PATCH 053/127] chore(deps): bump androidx.navigation:navigation-fragment-ktx Bumps androidx.navigation:navigation-fragment-ktx from 2.7.3 to 2.7.4. --- updated-dependencies: - dependency-name: androidx.navigation:navigation-fragment-ktx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9bc7d38a6b..8d217f97fd 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { fragmentktx_version = '1.6.1' ormLite_version = '4.46' gson_version = '2.10.1' - nav_version = '2.7.3' + nav_version = '2.7.4' appcompat_version = '1.6.1' material_version = '1.9.0' gridlayout_version = '1.0.0' From 852ad019d7058617c4f2f7b38e96b9930cceb943 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 22:07:09 -0700 Subject: [PATCH 054/127] Rewrites ComboPluginTest with matchers Issue #2745 --- .../nightscout/pump/combo/ComboPluginTest.kt | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) 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 926af70f2b..ac537623b8 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 @@ -12,11 +12,11 @@ import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.ui.UiInteraction import app.aaps.core.interfaces.utils.DateUtil import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.combo.ruffyscripter.RuffyScripter import info.nightscout.pump.combo.ruffyscripter.history.Bolus -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -56,8 +56,8 @@ class ComboPluginTest : TestBase() { comboPlugin.setPluginEnabled(PluginType.PUMP, true) comboPlugin.setValidBasalRateProfileSelectedOnPump(false) val c = comboPlugin.isLoopInvocationAllowed(ConstraintObject(true, aapsLogger)) - Assertions.assertEquals("Combo: No valid basal rate read from pump", c.getReasons()) - Assertions.assertEquals(false, c.value()) + assertThat(c.getReasons()).isEqualTo("Combo: No valid basal rate read from pump") + assertThat(c.value()).isFalse() comboPlugin.setPluginEnabled(PluginType.PUMP, false) } @@ -66,18 +66,16 @@ class ComboPluginTest : TestBase() { val now = System.currentTimeMillis() val pumpTimestamp = now - now % 1000 // same timestamp, different bolus leads to different fake timestamp - Assertions.assertNotEquals( - comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.1, true)), + assertThat( comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true)) - ) + ).isNotEqualTo(comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.1, true))) // different timestamp, same bolus leads to different fake timestamp - Assertions.assertNotEquals( - comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true)), + assertThat( comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp + 60 * 1000, 0.3, true)) - ) + ).isNotEqualTo(comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true))) // generated timestamp has second-precision val bolus = Bolus(pumpTimestamp, 0.2, true) val calculatedTimestamp = comboPlugin.generatePumpBolusId(bolus) - Assertions.assertEquals(calculatedTimestamp, calculatedTimestamp - calculatedTimestamp % 1000) + assertThat(calculatedTimestamp - calculatedTimestamp % 1000).isEqualTo(calculatedTimestamp) } -} \ No newline at end of file +} From 94a72c1cd05291267ddcb6c76ef3da5304d1a804 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 22:18:59 -0700 Subject: [PATCH 055/127] Rewrites MedtronicPumpHistoryDecoderUTest with matchers Issue #2745 --- .../comm/history/pump/MedtronicPumpHistoryDecoderUTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pump/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoderUTest.kt b/pump/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoderUTest.kt index 9d3cd74fef..dc86e8aefc 100644 --- a/pump/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoderUTest.kt +++ b/pump/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoderUTest.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump import app.aaps.core.interfaces.ui.UiInteraction +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicTestBase import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RawHistoryPage import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil import info.nightscout.pump.common.utils.ByteUtil -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -162,7 +162,7 @@ class MedtronicPumpHistoryDecoderUTest : MedtronicTestBase() { "5A 0F 20 F4 0C 03 15 19 11 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 11 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 01 12 12 00 25 DE 2D 43 15 01 50 50 00 26 EA 2D 43 15 01 4B 4B 00 2C C9 34 43 15 62 00 2F CB 17 03 15 01 33 33 00 16 DE 37 43 15 07 00 00 07 FE 23 95 6D 23 95 0A 08 00 2B 00 00 00 00 07 FE 03 8E 2C 04 70 38 00 00 04 70 38 00 00 00 00 00 00 04 70 64 06 00 00 00 06 08 00 2B 00 00 00 2C A0 2F E3 01 04 15 33 00 2F E7 04 44 15 00 16 03 2F E7 04 44 15 33 28 3B C2 06 44 15 00 16 01 3B C2 06 44 15 08 08 17 DB 0B 44 15 00 26 00 06 26 00 0C 26 00 12 28 00 18 26 00 1E 26 00 24 24 00 2A 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 18 17 DB 0B 44 15 00 26 00 02 26 00 04 26 00 06 24 00 08 24 00 0A 24 00 0C 26 00 0E 26 00 10 26 00 12 28 00 14 28 00 16 28 00 18 26 00 1A 26 00 1C 26 00 1E 26 00 20 26 00 22 26 00 24 24 00 26 24 00 28 24 00 2A 26 00 2C 26 00 2E 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 45 45 00 28 E9 2B 44 15 19 00 00 C1 0D 04 15 1A 00 15 C3 0D 04 15 1A 01 33 C3 0D 04 15 01 28 28 00 07 CC 2E 44 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 2D", MedtronicDeviceType.Medtronic_522_722 ) - Assertions.assertEquals(20, pumpHistoryEntries.size.toLong()) + assertThat(pumpHistoryEntries).hasSize(20) } @Test @Throws(Exception::class) fun historyProblem_423_duzy78() { @@ -170,7 +170,7 @@ class MedtronicPumpHistoryDecoderUTest : MedtronicTestBase() { "16 00 08 D0 0E 51 15 33 60 0A D0 0E 51 15 00 16 01 0A D0 0E 51 15 33 00 07 DF 0E 51 15 00 16 00 07 DF 0E 51 15 33 6C 09 DF 0E 51 15 00 16 01 09 DF 0E 51 15 33 00 25 ED 0E 51 15 00 16 00 25 ED 0E 51 15 33 2C 27 ED 0E 51 15 00 16 01 27 ED 0E 51 15 33 00 07 F4 0E 51 15 00 16 00 07 F4 0E 51 15 33 00 09 F4 0E 51 15 00 16 01 09 F4 0E 51 15 33 2C 25 D5 0F 51 15 00 16 01 25 D5 0F 51 15 01 3C 3C 00 30 D5 4F 51 15 33 2C 25 F7 0F 51 15 00 16 01 25 F7 0F 51 15 33 00 07 C6 10 51 15 00 16 00 07 C6 10 51 15 33 30 09 C6 10 51 15 00 16 01 09 C6 10 51 15 33 30 25 E8 10 51 15 00 16 01 25 E8 10 51 15 33 30 24 CF 11 51 15 00 16 01 24 CF 11 51 15 33 00 23 E4 11 51 15 00 16 00 23 E4 11 51 15 33 3C 25 E4 11 51 15 00 16 01 25 E4 11 51 15 33 00 23 E8 11 51 15 00 16 00 23 E8 11 51 15 33 4A 25 E8 11 51 15 00 16 01 25 E8 11 51 15 33 00 19 EE 11 51 15 00 16 00 19 EE 11 51 15 33 30 1B EE 11 51 15 00 16 01 1B EE 11 51 15 33 00 23 F2 11 51 15 00 16 00 23 F2 11 51 15 33 3E 25 F2 11 51 15 00 16 01 25 F2 11 51 15 33 00 24 C0 12 51 15 00 16 00 24 C0 12 51 15 33 5E 25 C0 12 51 15 00 16 01 25 C0 12 51 15 33 00 23 CF 12 51 15 00 16 00 23 CF 12 51 15 33 64 25 CF 12 51 15 00 16 01 25 CF 12 51 15 33 00 23 D9 12 51 15 00 16 00 23 D9 12 51 15 33 6A 25 D9 12 51 15 00 16 01 25 D9 12 51 15 33 00 23 E9 12 51 15 00 16 00 23 E9 12 51 15 33 30 25 E9 12 51 15 00 16 01 25 E9 12 51 15 01 16 16 00 10 C2 53 51 15 33 30 24 CF 13 51 15 00 16 01 24 CF 13 51 15 33 30 04 EE 13 51 15 00 16 01 04 EE 13 51 15 01 14 14 00 3B F0 53 51 15 33 00 22 C0 14 51 15 00 16 00 22 C0 14 51 15 33 22 24 C0 14 51 15 00 16 01 24 C0 14 51 15 33 22 03 DF 14 51 15 00 16 01 03 DF 14 51 15 1E 00 37 E1 14 11 15 1F 00 01 EE 14 11 15 33 22 03 C6 15 51 15 00 16 01 03 C6 15 51 15 33 00 20 D9 15 51 15 00 16 00 20 D9 15 51 15 33 34 22 D9 15 51 15 00 16 01 22 D9 15 51 15 39 14 0E DF 35 71 15 83 92 40 01 0B 0B 00 37 E0 55 51 15 33 00 21 E3 15 51 15 00 16 00 21 E3 15 51 15 33 22 22 E3 15 51 15 00 16 01 22 E3 15 51 15 33 00 21 E8 15 51 15 00 16 00 21 E8 15 51 15 33 30 23 E8 15 51 15 00 16 01 23 E8 15 51 15 33 00 20 ED 15 51 15 00 16 00 20 ED 15 51 15 33 22 22 ED 15 51 15 00 16 01 22 ED 15 51 15 33 00 03 F8 15 51 15 00 16 00 03 F8 15 51 15 33 32 05 F8 15 51 15 00 16 01 05 F8 15 51 15 33 00 01 CB 16 51 15 00 16 00 01 CB 16 51 15 33 20 03 CB 16 51 15 00 16 01 03 CB 16 51 15 33 2A 20 ED 16 51 15 00 16 01 20 ED 16 51 15 33 00 02 F8 16 51 15 00 16 00 02 F8 16 51 15 33 2C 04 F8 16 51 15 00 16 01 04 F8 16 51 15 33 00 1F CA 17 51 15 00 16 00 1F CA 17 51 15 33 34 21 CA 17 51 15 00 16 01 21 CA 17 51 15 33 00 1F D4 17 51 15 00 16 00 1F D4 17 51 15 33 38 21 D4 17 51 15 00 16 01 21 D4 17 51 15 33 00 15 EE 17 51 15 00 16 00 15 EE 17 51 15 33 42 17 EE 17 51 15 00 16 01 17 EE 17 51 15 07 00 00 08 0A 31 95 6C 31 95 05 00 A1 A1 A1 01 00 00 08 0A 04 8E 39 03 7C 2B 00 00 03 7C 2B 00 00 00 00 00 00 03 7C 64 07 00 00 00 07 33 00 05 C1 00 52 15 00 16 00 05 C1 00 52 15 33 50 07 C1 00 52 15 00 16 01 07 C1 00 52 15 33 00 01 CB 00 52 15 00 16 00 01 CB 00 52 15 33 26 03 CB 00 52 15 00 16 01 03 CB 00 52 15 33 00 1E DE 00 52 15 00 00 00 8F 0E", MedtronicDeviceType.Medtronic_515_715 ) - Assertions.assertEquals(131, pumpHistoryEntries.size.toLong()) + assertThat(pumpHistoryEntries).hasSize(131) } @Test @Throws(Exception::class) fun historyProblem_476_OpossumGit() { @@ -178,7 +178,7 @@ class MedtronicPumpHistoryDecoderUTest : MedtronicTestBase() { "08 07 50 05 0D 4D 15 00 18 00 08 14 00 0E 10 00 14 08 00 1E 12 00 26 16 00 2B 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 18 50 05 0D 4D 15 00 18 00 02 18 00 04 18 00 06 18 00 08 14 00 0A 14 00 0C 14 00 0E 10 00 10 10 00 12 10 00 14 08 00 16 08 00 18 08 00 1A 08 00 1C 08 00 1E 14 00 20 14 00 22 14 00 24 14 00 26 16 00 28 16 00 2A 16 00 2C 1C 00 2E 1C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 04 04 00 44 09 4D 4D 15 33 06 57 15 0D 4D 15 00 16 01 57 15 0D 4D 15 33 00 77 15 0D 4D 15 00 16 00 77 15 0D 4D 15 33 00 5D 16 0D 4D 15 00 16 04 5D 16 0D 4D 15 33 00 61 1A 0D 4D 15 00 16 00 61 1A 0D 4D 15 5D 00 5E 31 0D 0D 15 1A 00 6E 31 0D 0D 15 06 03 04 D2 6E 31 6D 0D 15 0C 03 11 40 00 01 05 64 01 13 40 00 01 05 17 00 0A 41 00 01 05 18 00 40 39 15 0D 15 21 00 53 04 16 0D 15 03 00 00 00 58 57 09 36 0D 15 5D 01 78 0A 16 0D 15 64 01 78 0A 16 8D 15 2C 68 78 0A 16 8D 15 24 3C 78 0A 16 8D 15 63 02 78 0A 16 8D 15 1B 12 78 0A 16 8D 15 65 61 78 0A 16 8D 15 61 00 78 0A 16 8D 15 32 0E 78 0A 16 8D 15 66 00 78 0A 16 8D 15 3C 01 78 0A 16 8D 15 3D 88 32 93 00 00 00 3E 00 00 00 00 00 00 26 01 78 0A 16 8D 15 27 01 B2 08 00 00 00 28 00 00 00 00 00 00 60 00 78 0A 16 4D 15 23 00 78 0A 16 8D 15 5E 01 78 0A 16 8D 15 2D 01 78 0A 16 8D 15 5A 0F 78 0A 16 8D 15 49 13 00 07 12 0A 1E 0B 2A 0A 00 00 00 00 00 00 00 00 00 23 08 27 2C 23 00 00 00 00 00 00 00 00 00 00 00 32 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 13 00 07 12 0A 1E 0B 2A 0A 00 00 00 00 00 00 00 00 00 23 08 27 2C 23 00 00 00 00 00 00 00 00 00 00 00 32 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 62 00 78 0A 16 8D 15 5F 51 78 0A 16 8D 15 4F 00 78 0A 16 8D 15 40 01 00 6F 1C 16 1E 00 3C 14 00 1E 3C 1F 15 70 40 01 00 6F 1C 16 1E 00 3C 14 00 1E 3C 1F 15 70 08 18 78 0A 16 8D 15 00 18 00 02 18 00 04 18 00 06 18 00 08 14 00 0A 14 00 0C 14 00 0E 10 00 10 10 00 12 10 00 14 08 00 16 08 00 18 08 00 1A 08 00 1C 08 00 1E 14 00 20 14 00 22 14 00 24 14 00 26 16 00 28 16 00 2A 16 00 2C 1C 00 2E 1C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D6 06", MedtronicDeviceType.Medtronic_522_722 ) - Assertions.assertEquals(41, pumpHistoryEntries.size.toLong()) + assertThat(pumpHistoryEntries).hasSize(41) } @Throws(Exception::class) From 81514c984b0063e1a15b2a7eaf661851875610ce Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 22:25:05 -0700 Subject: [PATCH 056/127] Rewrites PumpHistoryEntryUTest with matchers Issue #2745 --- .../medtronic/comm/history/pump/PumpHistoryEntryUTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pump/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/PumpHistoryEntryUTest.kt b/pump/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/PumpHistoryEntryUTest.kt index 0eb9612fcf..8b07c7dc2c 100644 --- a/pump/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/PumpHistoryEntryUTest.kt +++ b/pump/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/PumpHistoryEntryUTest.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicTestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test /** @@ -10,12 +10,12 @@ import org.junit.jupiter.api.Test */ class PumpHistoryEntryUTest : MedtronicTestBase() { - @Test + @Test fun checkIsAfter() { val dateObject = 20191010000000L val queryObject = 20191009000000L val phe = PumpHistoryEntry() phe.atechDateTime = dateObject - Assertions.assertTrue(phe.isAfter(queryObject)) + assertThat(phe.isAfter(queryObject)).isTrue() } } From 5755ca8fdc8ba467231b347a9ce7da4f5bcd9f2b Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 22:27:26 -0700 Subject: [PATCH 057/127] Rewrites VirtualPumpPluginUTest with matchers Issue #2745 --- .../app/aaps/pump/virtual/VirtualPumpPluginUTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pump/virtual/src/test/kotlin/app/aaps/pump/virtual/VirtualPumpPluginUTest.kt b/pump/virtual/src/test/kotlin/app/aaps/pump/virtual/VirtualPumpPluginUTest.kt index ce9dad23db..e928ff25f8 100644 --- a/pump/virtual/src/test/kotlin/app/aaps/pump/virtual/VirtualPumpPluginUTest.kt +++ b/pump/virtual/src/test/kotlin/app/aaps/pump/virtual/VirtualPumpPluginUTest.kt @@ -14,7 +14,7 @@ import app.aaps.core.interfaces.utils.DateUtil import app.aaps.core.interfaces.utils.fabric.FabricPrivacy import app.aaps.shared.tests.TestBase import dagger.android.AndroidInjector -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -49,7 +49,7 @@ class VirtualPumpPluginUTest : TestBase() { fun refreshConfiguration() { `when`(sp.getString(app.aaps.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") virtualPumpPlugin.refreshConfiguration() - Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) + assertThat(virtualPumpPlugin.pumpType).isEqualTo(PumpType.ACCU_CHEK_COMBO) } @Test @@ -58,6 +58,6 @@ class VirtualPumpPluginUTest : TestBase() { virtualPumpPlugin.refreshConfiguration() `when`(sp.getString(app.aaps.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") virtualPumpPlugin.refreshConfiguration() - Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) + assertThat(virtualPumpPlugin.pumpType).isEqualTo(PumpType.ACCU_CHEK_COMBO) } -} \ No newline at end of file +} From 102cac6fa8ec6ff12f78051101446072482b8f67 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 22:38:28 -0700 Subject: [PATCH 058/127] Rewrites RFSpyTest with matchers Issue #2745 --- .../pump/common/hw/rileylink/ble/RFSpyTest.kt | 114 ++++-------------- 1 file changed, 24 insertions(+), 90 deletions(-) diff --git a/pump/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.kt b/pump/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.kt index 85ecd40eda..428e10281c 100644 --- a/pump/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.kt +++ b/pump/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.kt @@ -1,100 +1,34 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @Suppress("SpellCheckingInspection") class RFSpyTest : TestBase() { @Test fun testGetFirmwareVersion() { - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_1_0, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.0") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_1_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_1_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1.13") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_2_0, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_2_0, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0.1") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_2_2, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_2_2, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.16") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_2_2, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.17") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_2_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_2_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.0") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_2_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.17") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_3_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_3_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0.1") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_3_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_3_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1.13") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_4_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_4_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0.4") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_4_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.3") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.Version_4_x, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.5.7") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.UnknownVersion, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.UnknownVersion, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0.0") - ) - Assertions.assertEquals( - RileyLinkFirmwareVersion.UnknownVersion, - RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.5.5") - ) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.0")).isEqualTo(RileyLinkFirmwareVersion.Version_1_0) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1")).isEqualTo(RileyLinkFirmwareVersion.Version_1_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1.13")).isEqualTo(RileyLinkFirmwareVersion.Version_1_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0")).isEqualTo(RileyLinkFirmwareVersion.Version_2_0) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0.1")).isEqualTo(RileyLinkFirmwareVersion.Version_2_0) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2")).isEqualTo(RileyLinkFirmwareVersion.Version_2_2) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.16")).isEqualTo(RileyLinkFirmwareVersion.Version_2_2) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.17")).isEqualTo(RileyLinkFirmwareVersion.Version_2_2) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3")).isEqualTo(RileyLinkFirmwareVersion.Version_2_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.0")).isEqualTo(RileyLinkFirmwareVersion.Version_2_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.17")).isEqualTo(RileyLinkFirmwareVersion.Version_2_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0")).isEqualTo(RileyLinkFirmwareVersion.Version_3_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0.1")).isEqualTo(RileyLinkFirmwareVersion.Version_3_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1")).isEqualTo(RileyLinkFirmwareVersion.Version_3_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1.13")).isEqualTo(RileyLinkFirmwareVersion.Version_3_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0")).isEqualTo(RileyLinkFirmwareVersion.Version_4_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0.4")).isEqualTo(RileyLinkFirmwareVersion.Version_4_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.3")).isEqualTo(RileyLinkFirmwareVersion.Version_4_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.5.7")).isEqualTo(RileyLinkFirmwareVersion.Version_4_x) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0")).isEqualTo(RileyLinkFirmwareVersion.UnknownVersion) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0.0")).isEqualTo(RileyLinkFirmwareVersion.UnknownVersion) + assertThat(RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.5.5")).isEqualTo(RileyLinkFirmwareVersion.UnknownVersion) } -} \ No newline at end of file +} From df233bbb81b4395ab8da58f7316bedd98238e76b Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 22:52:31 -0700 Subject: [PATCH 059/127] Rewrites OmnipodErosPumpPluginTest with matchers Issue #2745 --- .../omnipod/eros/OmnipodErosPumpPluginTest.kt | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPluginTest.kt b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPluginTest.kt index a9f079cc50..e006ffd4d4 100644 --- a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPluginTest.kt +++ b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPluginTest.kt @@ -11,6 +11,7 @@ import app.aaps.core.interfaces.utils.DecimalFormatter import app.aaps.implementation.utils.DecimalFormatterImpl import app.aaps.shared.tests.TestBase import app.aaps.shared.tests.rx.TestAapsSchedulers +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil @@ -19,7 +20,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodE import info.nightscout.pump.common.defs.TempBasalPair import org.joda.time.DateTimeZone import org.joda.time.tz.UTCProvider -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers @@ -100,17 +100,17 @@ class OmnipodErosPumpPluginTest : TestBase() { val result5 = plugin.setTempBasalPercent(-50, 60, profile, false, PumpSync.TemporaryBasalType.NORMAL) // Then return correct values - Assertions.assertEquals(result1.absolute, 0.4, 0.01) - Assertions.assertEquals(result1.duration, 30) - Assertions.assertEquals(result2.absolute, 25.0, 0.01) - Assertions.assertEquals(result2.duration, 30000) - Assertions.assertEquals(result3.absolute, 0.0, 0.01) - Assertions.assertEquals(result3.duration, 30) - Assertions.assertEquals(result4.absolute, -1.0, 0.01) - Assertions.assertEquals(result4.duration, -1) + assertThat(result1.absolute).isWithin(0.01).of(0.4) + assertThat(result1.duration).isEqualTo(30) + assertThat(result2.absolute).isWithin(0.01).of(25.0) + assertThat(result2.duration).isEqualTo(30000) + assertThat(result3.absolute).isWithin(0.01).of(0.0) + assertThat(result3.duration).isEqualTo(30) + assertThat(result4.absolute).isWithin(0.01).of(-1.0) + assertThat(result4.duration).isEqualTo(-1) // this is validated downstream, see TempBasalExtraCommand - Assertions.assertEquals(result5.absolute, -0.25, 0.01) - Assertions.assertEquals(result5.duration, 60) + assertThat(result5.absolute).isWithin(0.01).of(-0.25) + assertThat(result5.duration).isEqualTo(60) // Given zero basal `when`(profile.getBasal()).thenReturn(0.0) @@ -120,10 +120,10 @@ class OmnipodErosPumpPluginTest : TestBase() { result2 = plugin.setTempBasalPercent(0, 0, profile, false, PumpSync.TemporaryBasalType.NORMAL) // Then return zero values - Assertions.assertEquals(result1.absolute, 0.0, 0.01) - Assertions.assertEquals(result1.duration, 90) - Assertions.assertEquals(result2.absolute, -1.0, 0.01) - Assertions.assertEquals(result2.duration, -1) + assertThat(result1.absolute).isWithin(0.01).of(0.0) + assertThat(result1.duration).isEqualTo(90) + assertThat(result2.absolute).isWithin(0.01).of(-1.0) + assertThat(result2.duration).isEqualTo(-1) // Given unhealthy basal `when`(profile.getBasal()).thenReturn(500.0) @@ -131,12 +131,10 @@ class OmnipodErosPumpPluginTest : TestBase() { result1 = plugin.setTempBasalPercent(80, 30, profile, false, PumpSync.TemporaryBasalType.NORMAL) // Then return sane values - Assertions.assertEquals( - result1.absolute, - PumpType.OMNIPOD_EROS.determineCorrectBasalSize(500.0 * 0.8), - 0.01 + assertThat(result1.absolute).isWithin(0.01).of( + PumpType.OMNIPOD_EROS.determineCorrectBasalSize(500.0 * 0.8) ) - Assertions.assertEquals(result1.duration, 30) + assertThat(result1.duration).isEqualTo(30) // Given weird basal `when`(profile.getBasal()).thenReturn(1.234567) @@ -144,8 +142,8 @@ class OmnipodErosPumpPluginTest : TestBase() { result1 = plugin.setTempBasalPercent(280, 600, profile, false, PumpSync.TemporaryBasalType.NORMAL) // Then return sane values - Assertions.assertEquals(result1.absolute, 3.4567876, 0.01) - Assertions.assertEquals(result1.duration, 600) + assertThat(result1.absolute).isWithin(0.01).of(3.4567876) + assertThat(result1.duration).isEqualTo(600) // Given negative basal `when`(profile.getBasal()).thenReturn(-1.234567) @@ -153,7 +151,7 @@ class OmnipodErosPumpPluginTest : TestBase() { result1 = plugin.setTempBasalPercent(280, 510, profile, false, PumpSync.TemporaryBasalType.NORMAL) // Then return negative value (this is validated further downstream, see TempBasalExtraCommand) - Assertions.assertEquals(result1.absolute, -3.4567876, 0.01) - Assertions.assertEquals(result1.duration, 510) + assertThat(result1.absolute).isWithin(0.01).of(-3.4567876) + assertThat(result1.duration).isEqualTo(510) } -} \ No newline at end of file +} From 65b551936191ee8d9032318aad6c619dad1c4dfa Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 22:54:57 -0700 Subject: [PATCH 060/127] Rewrites AapsErosPodStateManagerTest with matchers Issue #2745 --- .../manager/AapsErosPodStateManagerTest.kt | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsErosPodStateManagerTest.kt b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsErosPodStateManagerTest.kt index 8880aa2ae6..a4a03a759e 100644 --- a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsErosPodStateManagerTest.kt +++ b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsErosPodStateManagerTest.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.eros.manager import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FirmwareVersion import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodProgressStatus import org.joda.time.DateTime @@ -9,7 +10,6 @@ import org.joda.time.DateTimeUtils import org.joda.time.DateTimeZone import org.joda.time.Duration import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mock @@ -28,11 +28,10 @@ class AapsErosPodStateManagerTest : TestBase() { 0, 0, FirmwareVersion(1, 1, 1), FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS ) - Assertions.assertEquals(now, podStateManager.time) - Assertions.assertEquals( + assertThat(podStateManager.time).isEqualTo(now) + assertThat(podStateManager.scheduleOffset).isEqualTo( Duration.standardHours(1) - .plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), - podStateManager.scheduleOffset + .plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))) ) } @@ -52,11 +51,10 @@ class AapsErosPodStateManagerTest : TestBase() { // The system time zone has been updated, but the pod session state's time zone hasn't // So the pods time should not have been changed - Assertions.assertEquals(now, podStateManager.time) - Assertions.assertEquals( + assertThat(podStateManager.time).isEqualTo(now) + assertThat(podStateManager.scheduleOffset).isEqualTo( Duration.standardHours(1) - .plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), - podStateManager.scheduleOffset + .plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))) ) } @@ -77,15 +75,14 @@ class AapsErosPodStateManagerTest : TestBase() { // Both the system time zone have been updated // So the pods time should have been changed (to +2 hours) - Assertions.assertEquals(now.withZone(newTimeZone), podStateManager.time) - Assertions.assertEquals( + assertThat(podStateManager.time).isEqualTo(now.withZone(newTimeZone)) + assertThat(podStateManager.scheduleOffset).isEqualTo( Duration.standardHours(3) - .plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), - podStateManager.scheduleOffset + .plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))) ) } @AfterEach fun tearDown() { DateTimeUtils.setCurrentMillisSystem() } -} \ No newline at end of file +} From 89366e54b8fadb007eae879abe8a1da1e4c69481 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 22:57:53 -0700 Subject: [PATCH 061/127] Rewrites AapsOmnipodErosManagerTest with matchers Issue #2745 --- .../AapsOmnipodErosManagerTest.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/AapsOmnipodErosManagerTest.kt b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/AapsOmnipodErosManagerTest.kt index 319949317b..5cd712ad0f 100644 --- a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/AapsOmnipodErosManagerTest.kt +++ b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/AapsOmnipodErosManagerTest.kt @@ -2,9 +2,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communicatio import app.aaps.core.interfaces.profile.Profile import app.aaps.core.interfaces.profile.Profile.ProfileValue +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodErosManager import org.joda.time.Duration -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito import kotlin.test.assertFailsWith @@ -22,16 +22,16 @@ internal class AapsOmnipodErosManagerTest { ) val basalSchedule = AapsOmnipodErosManager.mapProfileToBasalSchedule(profile) val entries = basalSchedule.entries - Assertions.assertEquals(3, entries.size) + assertThat(entries).hasSize(3) val entry1 = entries[0] - Assertions.assertEquals(Duration.standardSeconds(0), entry1.startTime) - Assertions.assertEquals(0.5, entry1.rate, 0.000001) + assertThat(entry1.startTime).isEqualTo(Duration.standardSeconds(0)) + assertThat(entry1.rate).isWithin(0.000001).of(0.5) val entry2 = entries[1] - Assertions.assertEquals(Duration.standardSeconds(18000), entry2.startTime) - Assertions.assertEquals(1.0, entry2.rate, 0.000001) + assertThat(entry2.startTime).isEqualTo(Duration.standardSeconds(18000)) + assertThat(entry2.rate).isWithin(0.000001).of(1.0) val entry3 = entries[2] - Assertions.assertEquals(Duration.standardSeconds(50400), entry3.startTime) - Assertions.assertEquals(3.05, entry3.rate, 0.000001) + assertThat(entry3.startTime).isEqualTo(Duration.standardSeconds(50400)) + assertThat(entry3.rate).isWithin(0.000001).of(3.05) } @Test fun invalidProfileNullProfile() { @@ -90,6 +90,6 @@ internal class AapsOmnipodErosManagerTest { ) val basalSchedule = AapsOmnipodErosManager.mapProfileToBasalSchedule(profile) val basalScheduleEntry = basalSchedule.entries[0] - Assertions.assertEquals(0.05, basalScheduleEntry.rate, 0.000001) + assertThat(basalScheduleEntry.rate).isWithin(0.000001).of(0.05) } } From f388285ff59ae56ce6544995061a0089cad6b208 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Thu, 5 Oct 2023 23:10:32 -0700 Subject: [PATCH 062/127] Rewrites PodInfoResponseTest with matchers Issue #2745 --- .../response/podinfo/PodInfoResponseTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/message/response/podinfo/PodInfoResponseTest.kt b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/message/response/podinfo/PodInfoResponseTest.kt index bf97fff625..f989ffe4d8 100644 --- a/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/message/response/podinfo/PodInfoResponseTest.kt +++ b/pump/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/communication/message/response/podinfo/PodInfoResponseTest.kt @@ -3,35 +3,35 @@ package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communicatio import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodInfoType import info.nightscout.pump.common.utils.ByteUtil -import org.junit.jupiter.api.Assertions +import kotlin.test.assertIsNot import org.junit.jupiter.api.Test internal class PodInfoResponseTest { @Test fun testRawData() { - val encodedData = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d") + val encodedData = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d")!! val podInfoResponse = PodInfoResponse(encodedData) - Assertions.assertArrayEquals(encodedData, podInfoResponse.rawData) + assertThat(podInfoResponse.rawData.asList()).containsExactlyElementsIn(encodedData.asIterable()).inOrder() } @Test fun testRawDataWithLongerMessage() { - val encodedData = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d01") - val expected = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d") + val encodedData = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d01")!! + val expected = ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d")!! val podInfoResponse = PodInfoResponse(encodedData) - Assertions.assertArrayEquals(expected, podInfoResponse.rawData) + assertThat(podInfoResponse.rawData.asList()).containsExactlyElementsIn(expected.asIterable()).inOrder() } @Test fun testMessageDecoding() { val podInfoResponse = PodInfoResponse(ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d")) - Assertions.assertEquals(PodInfoType.DETAILED_STATUS, podInfoResponse.subType) + assertThat(podInfoResponse.subType).isEqualTo(PodInfoType.DETAILED_STATUS) val podInfo = podInfoResponse.podInfo as PodInfoDetailedStatus - Assertions.assertFalse(podInfo.isFaultAccessingTables) - Assertions.assertEquals(0x01, podInfo.errorEventInfo.internalVariable.toInt()) + assertThat(podInfo.isFaultAccessingTables).isFalse() + assertThat(podInfo.errorEventInfo.internalVariable.toInt()).isEqualTo(0x01) } @Test fun testInvalidPodInfoTypeMessageDecoding() { val podInfoResponse = PodInfoResponse(ByteUtil.fromHexString("0216020d0000000000ab6a038403ff03860000285708030d")) - Assertions.assertEquals(PodInfoType.DETAILED_STATUS, podInfoResponse.subType) - assertThat(podInfoResponse.podInfo).isNotInstanceOf(PodInfoActiveAlerts::class.java) + assertThat(podInfoResponse.subType).isEqualTo(PodInfoType.DETAILED_STATUS) + assertIsNot(podInfoResponse.podInfo) } } From e9e81c8945493737448cb7f9500ff6b1d2006407 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 08:38:53 +0000 Subject: [PATCH 063/127] chore(deps): bump com.google.android.material:material Bumps [com.google.android.material:material](https://github.com/material-components/material-components-android) from 1.9.0 to 1.10.0. - [Release notes](https://github.com/material-components/material-components-android/releases) - [Commits](https://github.com/material-components/material-components-android/compare/1.9.0...1.10.0) --- updated-dependencies: - dependency-name: com.google.android.material:material dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 785c40ae91..d01c614d33 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ buildscript { gson_version = '2.10.1' nav_version = '2.7.4' appcompat_version = '1.6.1' - material_version = '1.9.0' + material_version = '1.10.0' gridlayout_version = '1.0.0' constraintlayout_version = '2.1.4' preferencektx_version = '1.2.1' From aaaa8b055b62cad358878922092131c410eef4be Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 6 Oct 2023 22:23:20 +0200 Subject: [PATCH 064/127] New Crowdin updates (#2877) * New translations strings.xml (Russian) * New translations strings.xml (Russian) * New translations exam.xml (Russian) * New translations strings.xml (Russian) * New translations strings.xml (Slovak) * New translations strings.xml (Slovak) * New translations exam.xml (Slovak) * New translations strings.xml (Slovak) * New translations strings.xml (Lithuanian) * New translations strings.xml (Lithuanian) * New translations exam.xml (Lithuanian) * New translations strings.xml (Lithuanian) --- plugins/aps/src/main/res/values-lt-rLT/strings.xml | 1 + plugins/aps/src/main/res/values-ru-rRU/strings.xml | 1 + plugins/aps/src/main/res/values-sk-rSK/strings.xml | 1 + plugins/constraints/src/main/res/values-lt-rLT/exam.xml | 1 + plugins/constraints/src/main/res/values-ru-rRU/exam.xml | 1 + plugins/constraints/src/main/res/values-sk-rSK/exam.xml | 1 + pump/medtrum/src/main/res/values-lt-rLT/strings.xml | 1 + pump/medtrum/src/main/res/values-ru-rRU/strings.xml | 3 +++ pump/medtrum/src/main/res/values-sk-rSK/strings.xml | 1 + wear/src/main/res/values-lt-rLT/strings.xml | 3 +++ wear/src/main/res/values-ru-rRU/strings.xml | 3 +++ wear/src/main/res/values-sk-rSK/strings.xml | 3 +++ 12 files changed, 20 insertions(+) diff --git a/plugins/aps/src/main/res/values-lt-rLT/strings.xml b/plugins/aps/src/main/res/values-lt-rLT/strings.xml index 5ff94077e3..0d6379ab16 100644 --- a/plugins/aps/src/main/res/values-lt-rLT/strings.xml +++ b/plugins/aps/src/main/res/values-lt-rLT/strings.xml @@ -83,6 +83,7 @@ SMB išjungti nustatymuose NDM nustatymas išjungtas nustatymuose Autosens funkcija išjungta nustatymuose + Autosens neveikia DynISF Ribojamas AIO iki %1$.1f V dėl %2$s Maksimali reikšmė nustatymuose diff --git a/plugins/aps/src/main/res/values-ru-rRU/strings.xml b/plugins/aps/src/main/res/values-ru-rRU/strings.xml index 29406218f9..4c19f9fedd 100644 --- a/plugins/aps/src/main/res/values-ru-rRU/strings.xml +++ b/plugins/aps/src/main/res/values-ru-rRU/strings.xml @@ -83,6 +83,7 @@ Супер микро болюс SMB отключен в настройках Непредвиденный прием пищи UAM отключен в настройках Автоматический подбор чувствительности Autosens отключен в настройках + Autosens отключён в DynISF Ограничение активного инсулина IOB до %1$.1f ед. из-за %2$s максимальное значение в настройках diff --git a/plugins/aps/src/main/res/values-sk-rSK/strings.xml b/plugins/aps/src/main/res/values-sk-rSK/strings.xml index f504160375..ee7b42745a 100644 --- a/plugins/aps/src/main/res/values-sk-rSK/strings.xml +++ b/plugins/aps/src/main/res/values-sk-rSK/strings.xml @@ -83,6 +83,7 @@ SMB zakázané v nastaveniach UAM zakázané v nastaveniach Automatická detekcia citlivosti zakázaná v nastaveniach + Autosens zakázaný v DynISF IOB obmedzený na %1$.1f JI: %2$s maximálna hodnota v nastaveniach diff --git a/plugins/constraints/src/main/res/values-lt-rLT/exam.xml b/plugins/constraints/src/main/res/values-lt-rLT/exam.xml index 5cc8201c2f..5ad84e1365 100644 --- a/plugins/constraints/src/main/res/values-lt-rLT/exam.xml +++ b/plugins/constraints/src/main/res/values-lt-rLT/exam.xml @@ -148,6 +148,7 @@ Nustačius 150% profilį, sistemos apskaičiuotas angliavandenių įsisavinimo laikas pailgėja Nustačius 150% profilį, sistemos apskaičiuotas angliavandenių įsisavinimo laikas sutrumpėja Nustačius 150% profilį, sistemos apskaičiuotas angliavandenių įsisavinimo laikas nepakinta + https://wiki.aaps.app/en/latest/Usage/COB-calculation.html#how-does-aaps-calculate-the-cob-value AIO keičia nustatyta laikina valandinė bazė. Padidinta laikina bazė nebus nustatyta, jei glikemija yra žemiau numatyto tikslo. Jei ilgą laiką stebima neigiama AIO reikšmė ir nėra fizinio aktyvumo, tai rodo, kad Jūsų nustatymai yra per „agresyvūs“ ir Jums reikia mažiau insulino. diff --git a/plugins/constraints/src/main/res/values-ru-rRU/exam.xml b/plugins/constraints/src/main/res/values-ru-rRU/exam.xml index 8df6e9504a..56244ff327 100644 --- a/plugins/constraints/src/main/res/values-ru-rRU/exam.xml +++ b/plugins/constraints/src/main/res/values-ru-rRU/exam.xml @@ -148,6 +148,7 @@ Установка профиля на 150% увеличит расчетное время усвоения углеводов Установка профиля на 150% уменьшит расчетное время усвоения углеводов Установка профиля на 150% не повлияет на расчетное время усвоения углеводов + https://wiki.aaps.app/en/latest/Usage/COB-calculation.html#how-does-aaps-calculate-the-cob-value На величину IOB влияют устанавливаемые ВБС. Высокая ВБС не будет применяться, если уровень сахара в крови ниже целевого. Отрицательный IOB в течение длительного периода при отсутствии физнагрузки указывает на то, что ваш профиль завышен и требуется снизить кол-во инсулина в настройках. diff --git a/plugins/constraints/src/main/res/values-sk-rSK/exam.xml b/plugins/constraints/src/main/res/values-sk-rSK/exam.xml index 9bb5b627a1..104796b05e 100644 --- a/plugins/constraints/src/main/res/values-sk-rSK/exam.xml +++ b/plugins/constraints/src/main/res/values-sk-rSK/exam.xml @@ -148,6 +148,7 @@ Nastavenie profilu na 150% spôsobí, že vypočítaná doba absorbcie sacharidov bude dlhšia Nastavenie profilu na 150% spôsobí, že vypočítaná doba absorbcie sacharidov bude kratšia Nastavenie profilu na 150% neovplyvní vypočítanú absorbciu sacharidov + https://wiki.aaps.app/cs/latest/Usage/COB-calculation.html#how-does-aaps-calculate-the-cob-value Hodnota IOB je ovplyvnená vydanými dočasnými bazálmi. Vysoký dočasný bazál nebude spustený, pokiaľ je Vaša glykémia nižšia, ako cieľ. Negatívne IOB po značnú dobu bez cvičenia naznačuje, že váš profil je príliš \"silný\" a vo vašom profile je potrebného menej inzulínu. diff --git a/pump/medtrum/src/main/res/values-lt-rLT/strings.xml b/pump/medtrum/src/main/res/values-lt-rLT/strings.xml index 98952d7733..da7983f437 100644 --- a/pump/medtrum/src/main/res/values-lt-rLT/strings.xml +++ b/pump/medtrum/src/main/res/values-lt-rLT/strings.xml @@ -70,6 +70,7 @@ Įjungiama Netikėta būsena: %1$s Nepasirinktas profilis. Pasirinkite profilį ir bandykite dar kartą. + Nežinomas SN. Įveskite pompos pagrindo serijos numerį nustatymuose ir bandykite vėl. Pompos pagrindo SN: %1$X Nėra aktyvaus rezervuaro. Spauskite Kitas ir pradėkite aktyvavimą. Neprijunkite pagrindo prie rezervuaro iki kito žingsnio! diff --git a/pump/medtrum/src/main/res/values-ru-rRU/strings.xml b/pump/medtrum/src/main/res/values-ru-rRU/strings.xml index ea45cc70b4..533755408c 100644 --- a/pump/medtrum/src/main/res/values-ru-rRU/strings.xml +++ b/pump/medtrum/src/main/res/values-ru-rRU/strings.xml @@ -39,6 +39,8 @@ Приостановка на низкой ГК Приостановка на низкой ГК 2 Автоматическая приостановка + почасовой максимальный приостановлен + суточный максимальный приостановлен Приостановлено На паузе Окклюзия @@ -68,6 +70,7 @@ Выполняется активация Непредвиденное состояние: %1$s Профиль не выбран. Выберите профиль и повторите попытку. + Серийный номер не известен. Введите серийный номер помпы в настройках и повторите попытку. Серийный номер основания: %1$X Активный патч отсутствует. Нажмите Далее для начала процесса активации. Не соединяйте основание и патч до следующего шага! diff --git a/pump/medtrum/src/main/res/values-sk-rSK/strings.xml b/pump/medtrum/src/main/res/values-sk-rSK/strings.xml index 53c6a82b5d..45ced610f5 100644 --- a/pump/medtrum/src/main/res/values-sk-rSK/strings.xml +++ b/pump/medtrum/src/main/res/values-sk-rSK/strings.xml @@ -70,6 +70,7 @@ Aktivácia prebieha Neočakávaný stav: %1$s Žiadny vybraný profil. Prosím vyberte si profil a skúste to znovu. + Nie je zadané žiadne sériové číslo. Zadajte sériové číslo pumpy v nastaveniach a skúste to znova. Sériové číslo základne pumpy: %1$X Žiadny aktívny Patch. Stlačte Ďalšia pre zahájenie aktivačného procesu. Základňa by nemala byť pripojená ku kanyle až do dalšieho kroku! diff --git a/wear/src/main/res/values-lt-rLT/strings.xml b/wear/src/main/res/values-lt-rLT/strings.xml index 54727ea9ae..9be89fde50 100644 --- a/wear/src/main/res/values-lt-rLT/strings.xml +++ b/wear/src/main/res/values-lt-rLT/strings.xml @@ -44,6 +44,9 @@ Rodyti GĮ Rodyti krypties rodyklę Laikas nuo pask. vertės + Rodyti LB + Rodyti bolusus & SMB + Rodyti tinklelį Tamsus Paryškinti valandines bazes Rodyti prognozes diff --git a/wear/src/main/res/values-ru-rRU/strings.xml b/wear/src/main/res/values-ru-rRU/strings.xml index 00028b1cd3..a42b881664 100644 --- a/wear/src/main/res/values-ru-rRU/strings.xml +++ b/wear/src/main/res/values-ru-rRU/strings.xml @@ -44,6 +44,9 @@ Отображать ГКИ (BGI) Показывать стрелку тренда Показывать ретро события + Показывать ВБС + Показывать болюс & СМБ + Показывать сетку Тёмная Выделить базалы Показывать прогноз diff --git a/wear/src/main/res/values-sk-rSK/strings.xml b/wear/src/main/res/values-sk-rSK/strings.xml index 27a7110aad..79ccfa3c62 100644 --- a/wear/src/main/res/values-sk-rSK/strings.xml +++ b/wear/src/main/res/values-sk-rSK/strings.xml @@ -44,6 +44,9 @@ Zobraziť BGI Zobrazovať trendovú šípku Zobraziť aktualizované pred + Zobraziť dočasný bazál + Zobraziť Bolus & SMB + Zobraziť mriežku Tmavý Zvýrazniť bazály Zobraziť predikcie From bface2a24dddcf82ac06388e18ad947be8029f5c Mon Sep 17 00:00:00 2001 From: jbr7rr <> Date: Sun, 8 Oct 2023 08:41:38 +0200 Subject: [PATCH 065/127] Medtrum: Patch expiration default to true --- pump/medtrum/src/main/res/xml/pref_medtrum_pump.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pump/medtrum/src/main/res/xml/pref_medtrum_pump.xml b/pump/medtrum/src/main/res/xml/pref_medtrum_pump.xml index 3e929bdcbb..b27de7bd1e 100644 --- a/pump/medtrum/src/main/res/xml/pref_medtrum_pump.xml +++ b/pump/medtrum/src/main/res/xml/pref_medtrum_pump.xml @@ -14,7 +14,7 @@ android:title="@string/sn_input_title" /> From 5945aa40ab989b374529d11f3b84268f384c3ec0 Mon Sep 17 00:00:00 2001 From: jbr7rr <> Date: Sun, 8 Oct 2023 11:33:40 +0200 Subject: [PATCH 066/127] Medtrum: Do not spam event bus on bolus progress --- .../pump/medtrum/services/MedtrumService.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt index 91057b7aaf..ca6d0207aa 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt @@ -420,6 +420,7 @@ class MedtrumService : DaggerService(), BLECommCallback { var communicationLost = false var connectionRetryCounter = 0 var checkTime = medtrumPump.bolusProgressLastTimeStamp + var lastSentBolusAmount: Double? = null while (!medtrumPump.bolusStopped && !medtrumPump.bolusDone && !communicationLost) { SystemClock.sleep(100) @@ -436,10 +437,15 @@ class MedtrumService : DaggerService(), BLECommCallback { disconnect("Communication stopped") } } else { - bolusingEvent.t = medtrumPump.bolusingTreatment - bolusingEvent.status = rh.gs(info.nightscout.pump.common.R.string.bolus_delivered_so_far, medtrumPump.bolusingTreatment?.insulin, medtrumPump.bolusAmountToBeDelivered) - bolusingEvent.percent = round((medtrumPump.bolusingTreatment?.insulin?.div(medtrumPump.bolusAmountToBeDelivered) ?: 0.0) * 100).toInt() - 1 - rxBus.send(bolusingEvent) + val currentBolusAmount = medtrumPump.bolusingTreatment?.insulin + + if (currentBolusAmount != null && currentBolusAmount != lastSentBolusAmount) { + bolusingEvent.t = medtrumPump.bolusingTreatment + bolusingEvent.status = rh.gs(info.nightscout.pump.common.R.string.bolus_delivered_so_far, medtrumPump.bolusingTreatment?.insulin, medtrumPump.bolusAmountToBeDelivered) + bolusingEvent.percent = round(currentBolusAmount.div(medtrumPump.bolusAmountToBeDelivered) * 100).toInt() - 1 + rxBus.send(bolusingEvent) + lastSentBolusAmount = currentBolusAmount + } } } From ccb7961e50dc84494e7c2d912904846f7333948d Mon Sep 17 00:00:00 2001 From: jbr7rr <> Date: Sun, 8 Oct 2023 12:16:09 +0200 Subject: [PATCH 067/127] Medtrum: Option to show notification on non critical pump alerts --- .../interfaces/notifications/Notification.kt | 1 + .../nightscout/pump/medtrum/MedtrumPump.kt | 9 +++++ .../comm/packets/NotificationPacket.kt | 6 +++- .../pump/medtrum/services/MedtrumService.kt | 33 ++++++++++++++++--- pump/medtrum/src/main/res/values/strings.xml | 4 +++ .../src/main/res/xml/pref_medtrum_pump.xml | 6 ++++ 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/notifications/Notification.kt b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/notifications/Notification.kt index ba138abaf8..f9eb549c7b 100644 --- a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/notifications/Notification.kt +++ b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/notifications/Notification.kt @@ -138,6 +138,7 @@ open class Notification { const val PUMP_SETTINGS_FAILED = 84 const val PUMP_TIMEZONE_UPDATE_FAILED = 85 const val BLUETOOTH_NOT_SUPPORTED = 86 + const val PUMP_WARNING = 87 const val USER_MESSAGE = 1000 diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt index 48cba7b7a9..4a7f99e566 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt @@ -71,6 +71,15 @@ class MedtrumPump @Inject constructor( _activeAlarms = value } + // New pump warnings + private val _pumpWarning = MutableStateFlow(AlarmState.NONE) + val pumpWarningFlow: StateFlow = _pumpWarning + var pumpWarning: AlarmState + get() = _pumpWarning.value + set(value) { + _pumpWarning.value = value + } + // Prime progress as state flow private val _primeProgress = MutableStateFlow(0) val primeProgressFlow: StateFlow = _primeProgress diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacket.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacket.kt index cc3d1c9178..32ed8e39d6 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacket.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacket.kt @@ -200,7 +200,11 @@ class NotificationPacket(val injector: HasAndroidInjector) { val alarmState = AlarmState.values()[i] if ((alarmFlags shr i) and 1 != 0) { // If the alarm bit is set, add the corresponding alarm to activeAlarms - medtrumPump.addAlarm(alarmState) + if (!medtrumPump.activeAlarms.contains(alarmState)) { + aapsLogger.debug(LTag.PUMPCOMM, "Adding alarm $alarmState to active alarms") + medtrumPump.addAlarm(alarmState) + medtrumPump.pumpWarning = alarmState + } } else if (medtrumPump.activeAlarms.contains(alarmState)) { // If the alarm bit is not set, and the corresponding alarm is in activeAlarms, remove it medtrumPump.removeAlarm(alarmState) diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt index ca6d0207aa..d60ab4936d 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt @@ -164,6 +164,11 @@ class MedtrumService : DaggerService(), BLECommCallback { handleConnectionStateChange(connectionState) } } + scope.launch { + medtrumPump.pumpWarningFlow.collect { pumpWarning -> + notifyPumpWarning(pumpWarning) + } + } } override fun onDestroy() { @@ -583,6 +588,7 @@ class MedtrumService : DaggerService(), BLECommCallback { when (state) { MedtrumPumpState.NONE, MedtrumPumpState.STOPPED -> { + rxBus.send(EventDismissNotification(Notification.PUMP_WARNING)) rxBus.send(EventDismissNotification(Notification.PUMP_ERROR)) rxBus.send(EventDismissNotification(Notification.PUMP_SUSPENDED)) uiInteraction.addNotification( @@ -631,20 +637,22 @@ class MedtrumService : DaggerService(), BLECommCallback { } MedtrumPumpState.HOURLY_MAX_SUSPENDED -> { - uiInteraction.addNotification( + uiInteraction.addNotificationWithSound( Notification.PUMP_SUSPENDED, rh.gs(R.string.pump_is_suspended_hour_max), - Notification.NORMAL, + Notification.URGENT, + app.aaps.core.ui.R.raw.alarm ) // Pump will report proper TBR for this from loadEvents() commandQueue.loadEvents(null) } MedtrumPumpState.DAILY_MAX_SUSPENDED -> { - uiInteraction.addNotification( + uiInteraction.addNotificationWithSound( Notification.PUMP_SUSPENDED, rh.gs(R.string.pump_is_suspended_day_max), - Notification.NORMAL, + Notification.URGENT, + app.aaps.core.ui.R.raw.alarm ) // Pump will report proper TBR for this from loadEvents() commandQueue.loadEvents(null) @@ -689,6 +697,23 @@ class MedtrumService : DaggerService(), BLECommCallback { } } + private fun notifyPumpWarning(alarmState: AlarmState) { + // Notification on pump warning + if (sp.getBoolean(R.string.key_pump_warning_notification, true) && alarmState != AlarmState.NONE) { + uiInteraction.addNotification( + Notification.PUMP_WARNING, + rh.gs(R.string.pump_warning, medtrumPump.alarmStateToString(alarmState)), + Notification.ANNOUNCEMENT, + ) + pumpSync.insertAnnouncement( + medtrumPump.alarmStateToString(alarmState), + null, + medtrumPump.pumpType(), + medtrumPump.pumpSN.toString(radix = 16) + ) + } + } + /** BLECommCallbacks */ override fun onBLEConnected() { aapsLogger.debug(LTag.PUMPCOMM, "<<<<< onBLEConnected") diff --git a/pump/medtrum/src/main/res/values/strings.xml b/pump/medtrum/src/main/res/values/strings.xml index 147c018513..b508b7150d 100644 --- a/pump/medtrum/src/main/res/values/strings.xml +++ b/pump/medtrum/src/main/res/values/strings.xml @@ -4,6 +4,7 @@ sn_input alarm_setting patch_expiration + pump_warning_notification hourly_max_insulin daily_max_insulin @@ -30,6 +31,7 @@ Pump integration for Medtrum Nano and Medtrum 300U Medtrum pump settings Pump error: %1$s !! + Pump warning: %1$s Pump is suspended Pump is suspended due to hourly max insulin exceeded Pump is suspended due to daily max insulin exceeded @@ -138,6 +140,8 @@ Pump untested: %1$d! Please contact us at discord or github for support Alarm Settings Select your preferred pump alarm settings. + Notification on pump warning + Show notification on non critical pump warnings: low battery, low reservoir (20 units) and expires soon. Recommended to leave enabled when pump alarms are set to silent. Patch Expiration When enabled, the patch will expire after 3 days, with a grace period of 8 hours after that. Hourly Maximum Insulin diff --git a/pump/medtrum/src/main/res/xml/pref_medtrum_pump.xml b/pump/medtrum/src/main/res/xml/pref_medtrum_pump.xml index b27de7bd1e..4e4ff321ba 100644 --- a/pump/medtrum/src/main/res/xml/pref_medtrum_pump.xml +++ b/pump/medtrum/src/main/res/xml/pref_medtrum_pump.xml @@ -27,6 +27,12 @@ android:entries="@array/alarmSettings" android:entryValues="@array/alarmSettingsValues" /> + + Date: Sun, 8 Oct 2023 19:49:40 +0200 Subject: [PATCH 068/127] Medtrum: Do not clearAlarms on going to ACTIVE --- .../info/nightscout/pump/medtrum/services/MedtrumService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt index d60ab4936d..c04f5e9f1d 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt @@ -322,6 +322,7 @@ class MedtrumService : DaggerService(), BLECommCallback { } // Resume suspended pump if (result) result = sendPacketAndGetResponse(ResumePumpPacket(injector)) + if (result) medtrumPump.clearAlarmState() } return result } @@ -619,7 +620,6 @@ class MedtrumService : DaggerService(), BLECommCallback { MedtrumPumpState.ACTIVE_ALT -> { rxBus.send(EventDismissNotification(Notification.PATCH_NOT_ACTIVE)) rxBus.send(EventDismissNotification(Notification.PUMP_SUSPENDED)) - medtrumPump.clearAlarmState() } MedtrumPumpState.LOW_BG_SUSPENDED, From 4d7897dacee0a459f54bd376122f67ea5d84acc6 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 16:37:51 -0700 Subject: [PATCH 069/127] Rewrites MedtrumPumpTest with matchers Issue #2745 --- .../pump/medtrum/MedtrumPumpTest.kt | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) 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 a59124713a..5ba7ff5227 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 @@ -7,10 +7,10 @@ import app.aaps.core.interfaces.pump.PumpSync import app.aaps.core.interfaces.pump.defs.PumpType import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress import app.aaps.core.interfaces.utils.T +import com.google.common.truth.Truth.assertThat import info.nightscout.pump.medtrum.comm.enums.BasalType import info.nightscout.pump.medtrum.util.MedtrumSnUtil import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito import org.mockito.Mockito.mock @@ -43,7 +43,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) - Assertions.assertEquals(expectedByteArray.contentToString(), result?.contentToString()) + assertThat(result!!.contentToString()).isEqualTo(expectedByteArray.contentToString()) } @Test fun buildMedtrumProfileArrayGiveProfileWhenValuesTooHighThenReturnNull() { @@ -60,7 +60,7 @@ class MedtrumPumpTest : MedtrumTestBase() { val result = medtrumPump.buildMedtrumProfileArray(profile) // Expected values - Assertions.assertNull(result) + assertThat(result).isNull() } @Test fun getCurrentHourlyBasalFromMedtrumProfileArrayGivenProfileWhenValuesSetThenReturnCorrectValue() { @@ -88,28 +88,28 @@ class MedtrumPumpTest : MedtrumTestBase() { val zonedDateTime0399 = localDate.atTime(localTime0399).atZone(ZoneId.systemDefault()) val time0399 = zonedDateTime0399.toInstant().toEpochMilli() val result = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray!!, time0399) - Assertions.assertEquals(2.1, result, 0.01) + assertThat(result).isWithin(0.01).of(2.1) // 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) - Assertions.assertEquals(1.7, result1, 0.01) + assertThat(result1).isWithin(0.01).of(1.7) // 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) - Assertions.assertEquals(2.0, result2, 0.01) + assertThat(result2).isWithin(0.01).of(2.0) // 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) - Assertions.assertEquals(2.1, result3, 0.01) + assertThat(result3).isWithin(0.01).of(2.1) } @Test fun handleBolusStatusUpdateWhenCalledExpectNewData() { @@ -124,9 +124,9 @@ class MedtrumPumpTest : MedtrumTestBase() { medtrumPump.handleBolusStatusUpdate(bolusType, bolusCompleted, amount) // Expected values - Assertions.assertEquals(bolusCompleted, medtrumPump.bolusDone) - Assertions.assertEquals(amount, medtrumPump.bolusAmountDeliveredFlow.value, 0.01) - Assertions.assertEquals(amount, medtrumPump.bolusingTreatment!!.insulin, 0.01) + assertThat(medtrumPump.bolusDone).isEqualTo(bolusCompleted) + assertThat(medtrumPump.bolusAmountDeliveredFlow.value).isWithin(0.01).of(amount) + assertThat(medtrumPump.bolusingTreatment!!.insulin).isWithin(0.01).of(amount) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndTemporaryBasalInfoThenExpectNewData() { @@ -174,12 +174,12 @@ class MedtrumPumpTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndSameExpectedTemporaryBasalInfoThenExpectNoPumpSync() { @@ -223,12 +223,12 @@ class MedtrumPumpTest : MedtrumTestBase() { ) // Check that other fields in medtrumPump are updated - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndNoTemporaryBasalInfoThenExpectNewData() { @@ -274,12 +274,12 @@ class MedtrumPumpTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsRelativeTempAndTemporaryBasalInfoThenExpectNewData() { @@ -329,12 +329,12 @@ class MedtrumPumpTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsSuspendedThenExpectNewData() { @@ -378,12 +378,12 @@ class MedtrumPumpTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsATypeIsSuspendedAndSameExpectedTemporaryBasalInfoThenExpectNoPumpSync() { @@ -424,12 +424,12 @@ class MedtrumPumpTest : MedtrumTestBase() { anyOrNull() ) - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsSuspendedAndNewerFakeTBRThenExpectInvalidateAndNewData() { @@ -475,12 +475,12 @@ class MedtrumPumpTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsNoneAndThenExpectFakeTBR() { @@ -520,12 +520,12 @@ class MedtrumPumpTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsStandardAndTempBasalExpectedThenExpectSyncStop() { @@ -564,12 +564,12 @@ class MedtrumPumpTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleBasalStatusUpdateWhenBasalTypeIsStandardAndNoTempBasalExpectedThenExpectNoSyncStop() { @@ -605,12 +605,12 @@ class MedtrumPumpTest : MedtrumTestBase() { anyOrNull() ) - Assertions.assertEquals(basalType, medtrumPump.lastBasalType) - Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01) - Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence) - Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId) - Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(basalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime) } @Test fun handleNewPatchCalledWhenCalledExpectNewDataPresent() { @@ -626,10 +626,10 @@ class MedtrumPumpTest : MedtrumTestBase() { medtrumPump.handleNewPatch(newPatchId, newSequenceNumber, newStartTime) // Expected values - Assertions.assertEquals(newPatchId, medtrumPump.patchId) - Assertions.assertEquals(newSequenceNumber, medtrumPump.currentSequenceNumber) - Assertions.assertEquals(newStartTime, medtrumPump.patchStartTime) - Assertions.assertEquals(1, medtrumPump.syncedSequenceNumber) + assertThat(medtrumPump.patchId).isEqualTo(newPatchId) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(newSequenceNumber) + assertThat(medtrumPump.patchStartTime).isEqualTo(newStartTime) + assertThat(medtrumPump.syncedSequenceNumber).isEqualTo(1) } @Test fun handleStopStatusUpdateWhenSequenceThenExpectUpdate() { @@ -644,8 +644,8 @@ class MedtrumPumpTest : MedtrumTestBase() { medtrumPump.handleStopStatusUpdate(sequence, patchId) // Expected values - Assertions.assertEquals(patchId, medtrumPump.lastStopPatchId) - Assertions.assertEquals(sequence, medtrumPump.currentSequenceNumber) + assertThat(medtrumPump.lastStopPatchId).isEqualTo(patchId) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(sequence) } @Test fun setFakeTBRIfNotSetWhenNoFakeTBRAlreadyRunningExpectPumpSync() { From 4653541a7b3a1ac308c868b7877ef4d2702451e2 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 16:39:34 -0700 Subject: [PATCH 070/127] Rewrites CryptTest with matchers Also renames "expect" to "expected" since "expect" is a newer kotlin keyword. Issue #2745 --- .../nightscout/pump/medtrum/encryption/CryptTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 2871bdfd14..2ef0ead2c6 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,6 +1,6 @@ package info.nightscout.pump.medtrum.encryption -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class CryptTest { @@ -10,9 +10,9 @@ class CryptTest { val crypt = Crypt() val input = 2859923929 - val expect = 3364239851 + val expected = 3364239851L val output: Long = crypt.keyGen(input) - Assertions.assertEquals(expect, output) + assertThat(output).isEqualTo(expected) } @Test @@ -20,8 +20,8 @@ class CryptTest { val crypt = Crypt() val input = 2859923929 - val expect: Long = 126009121 + val expected = 126009121L val output: Long = crypt.simpleDecrypt(input) - Assertions.assertEquals(expect, output) + assertThat(output).isEqualTo(expected) } } From 82731361c6b66f4f558fca988c7756908b6064bf Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 16:42:05 -0700 Subject: [PATCH 071/127] Rewrites WriteCommandPacketsTest with matchers Issue #2745 --- .../medtrum/comm/WriteCommandPacketsTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 52e62336e3..848a54140e 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,6 +1,6 @@ package info.nightscout.pump.medtrum.comm -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class WriteCommandPacketsTest { @@ -8,20 +8,20 @@ class WriteCommandPacketsTest { @Test fun given14LongCommandExpectOnePacket() { val input = byteArrayOf(5, 2, 0, 0, 0, 0, -21, 57, -122, -56) - val expect = byteArrayOf(14, 5, 0, 0, 2, 0, 0, 0, 0, -21, 57, -122, -56, -93, 0) + val expected = byteArrayOf(14, 5, 0, 0, 2, 0, 0, 0, 0, -21, 57, -122, -56, -93, 0) val sequence = 0 val cmdPackets = WriteCommandPackets(input, sequence) val output = cmdPackets.getNextPacket() - Assertions.assertEquals(expect.contentToString(), output.contentToString()) + assertThat(output.contentToString()).isEqualTo(expected.contentToString()) } @Test fun given41LongCommandExpectThreePackets() { val input = byteArrayOf(18, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -20, 36, 2, 100, -123, 2) - val expect1 = byteArrayOf(41, 18, 0, 1, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, -121) - val expect2 = byteArrayOf(41, 18, 0, 2, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -3) - val expect3 = byteArrayOf(41, 18, 0, 3, -20, 36, 2, 100, -123, 2, -125, -89) + val expected1 = byteArrayOf(41, 18, 0, 1, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, -121) + val expected2 = byteArrayOf(41, 18, 0, 2, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -3) + val expected3 = byteArrayOf(41, 18, 0, 3, -20, 36, 2, 100, -123, 2, -125, -89) val sequence = 0 val cmdPackets = WriteCommandPackets(input, sequence) @@ -31,10 +31,10 @@ class WriteCommandPacketsTest { val output4 = cmdPackets.getNextPacket() - 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()) + assertThat(output1.contentToString()).isEqualTo(expected1.contentToString()) + assertThat(output2.contentToString()).isEqualTo(expected2.contentToString()) + assertThat(output3.contentToString()).isEqualTo(expected3.contentToString()) + assertThat(output4).isNull() + assertThat(cmdPackets.allPacketsConsumed()).isTrue() } } From b83e19ea6acb35bf208691c105b564b03bf55ddb Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 16:44:57 -0700 Subject: [PATCH 072/127] Rewrites ActivatePacketTest with matchers Issue #2745 --- .../comm/packets/ActivatePacketTest.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) 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 3b67e573f8..a1816946bf 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 @@ -2,10 +2,10 @@ package info.nightscout.pump.medtrum.comm.packets import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import com.google.common.truth.Truth.assertThat 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 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) - Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) + assertThat(result.contentToString()).isEqualTo(expectedByteArray.contentToString()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -64,15 +64,15 @@ class ActivatePacketTest : MedtrumTestBase() { val expectedBasalPatchId = 41L val expectedBasalStart = 1675605528000L - 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) + assertThat(result).isTrue() + assertThat(medtrumPump.patchId).isEqualTo(expectedPatchId) + assertThat(medtrumPump.lastTimeReceivedFromPump).isEqualTo(expectedTime) + assertThat(medtrumPump.lastBasalType).isEqualTo(expectedBasalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(expectedBasalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(expectedBasalSequence) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedBasalPatchId) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedBasalStart) + assertThat(medtrumPump.actualBasalProfile).isEqualTo(basalProfile) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -84,6 +84,6 @@ class ActivatePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertFalse(result) + assertThat(result).isFalse() } } From c95654c0ac96a1de73ccce1ceee6acfc6129d50b Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 16:45:18 -0700 Subject: [PATCH 073/127] Rewrites AuthorizePacketTest with matchers Issue #2745 --- .../medtrum/comm/packets/AuthorizePacketTest.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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 0244392562..99e2aee435 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 @@ -1,11 +1,11 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector 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 class AuthorizePacketTest : MedtrumTestBase() { @@ -37,8 +37,7 @@ class AuthorizePacketTest : MedtrumTestBase() { val key = 3364239851 val type = 2 val expectedByteArray = byteArrayOf(opCode.toByte()) + type.toByte() + medtrumPump.patchSessionToken.toByteArray(4) + key.toByteArray(4) - Assertions.assertEquals(10, result.size) - Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) + assertThat(result).asList().containsExactlyElementsIn(expectedByteArray.toList()).inOrder() } @Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() { @@ -57,10 +56,10 @@ class AuthorizePacketTest : MedtrumTestBase() { // Expected values val swString = "$swVerX.$swVerY.$swVerZ" - Assertions.assertTrue(result) - Assertions.assertFalse(packet.failed) - Assertions.assertEquals(deviceType, medtrumPump.deviceType) - Assertions.assertEquals(swString, medtrumPump.swVersion) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() + assertThat(medtrumPump.deviceType).isEqualTo(deviceType) + assertThat(medtrumPump.swVersion).isEqualTo(swString) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -75,7 +74,7 @@ class AuthorizePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertFalse(result) - Assertions.assertTrue(packet.failed) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } } From b1a2d2064640cd1b367eb6b2b48a68bfd5a02607 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 16:46:55 -0700 Subject: [PATCH 074/127] Rewrites CancelBolusPacketTest with matchers Issue #2745 --- .../pump/medtrum/comm/packets/CancelBolusPacketTest.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 1c0bb47b11..e3dde0798d 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 @@ -1,9 +1,9 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class CancelBolusPacketTest : MedtrumTestBase() { @@ -27,8 +27,6 @@ class CancelBolusPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - val expectedByteArray = byteArrayOf(opCode.toByte()) + 1.toByte() - Assertions.assertEquals(2, result.size) - Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) + assertThat(result).asList().containsExactly(opCode.toByte(), 1.toByte()).inOrder() } } From 9cb7bed31a800b0c8c64c20d0dd36e0beb1dae73 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 16:47:00 -0700 Subject: [PATCH 075/127] Rewrites ClearPumpAlarmPacketTest with matchers Issue #2745 --- .../pump/medtrum/comm/packets/ClearPumpAlarmPacketTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 056cd200f4..6f7faebfa1 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 @@ -1,10 +1,10 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class ClearPumpAlarmPacketTest : MedtrumTestBase() { @@ -29,8 +29,8 @@ class ClearPumpAlarmPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(3, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) - Assertions.assertEquals(clearCode, result.copyOfRange(1, 3).toInt()) + assertThat(result).hasLength(3) + assertThat(result[0]).isEqualTo(opCode.toByte()) + assertThat(result.copyOfRange(1, 3).toInt()).isEqualTo(clearCode) } } From d39a23977d77564683b66dc120630850ce90fd75 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 16:54:40 -0700 Subject: [PATCH 076/127] Rewrites CancelTempBasalPacketTest with matchers Issue #2745 --- .../comm/packets/CancelTempBasalPacketTest.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 ee4f252f65..8c151959bf 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 @@ -1,10 +1,10 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class CancelTempBasalPacketTest : MedtrumTestBase() { @@ -30,8 +30,7 @@ class CancelTempBasalPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(1, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) + assertThat(result).asList().containsExactly(opCode.toByte()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -49,12 +48,12 @@ class CancelTempBasalPacketTest : MedtrumTestBase() { val expectedStartTime = 1679575392000L val expectedPatchId = 146L - 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) + assertThat(result).isTrue() + assertThat(medtrumPump.lastBasalType).isEqualTo(expectedBasalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(expectedBasalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(expectedBasalSequence) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedStartTime) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedPatchId) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -66,7 +65,7 @@ class CancelTempBasalPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertFalse(result) - Assertions.assertTrue(packet.failed) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } } From 3e8455ad2e1a8aa296c68e166c4f784e1a148396 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:01:20 -0700 Subject: [PATCH 077/127] Rewrites GetDeviceTypePacketTest with matchers Issue #2745 --- .../comm/packets/GetDeviceTypePacketTest.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 c3e37cf08e..f683e87a3c 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 @@ -1,10 +1,10 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class GetDeviceTypePacketTest : MedtrumTestBase() { @@ -28,8 +28,7 @@ class GetDeviceTypePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(1, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) + assertThat(result).asList().containsExactly(opCode.toByte()) } @Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() { @@ -45,10 +44,10 @@ class GetDeviceTypePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) - Assertions.assertEquals(deviceType, packet.deviceType) - Assertions.assertEquals(deviceSN, packet.deviceSN) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() + assertThat(packet.deviceType).isEqualTo(deviceType) + assertThat(packet.deviceSN).isEqualTo(deviceSN) } @@ -65,9 +64,9 @@ class GetDeviceTypePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response.sliceArray(0..response.size - 2)) // Expected values - Assertions.assertEquals(false, result) - Assertions.assertEquals(true, packet.failed) - Assertions.assertEquals(0, packet.deviceType) - Assertions.assertEquals(0, packet.deviceSN) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() + assertThat(packet.deviceType).isEqualTo(0) + assertThat(packet.deviceSN).isEqualTo(0) } } From 568b6cbcc5027a92942b83b5ea777cdb2f0e0af4 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:03:28 -0700 Subject: [PATCH 078/127] Rewrites GetRecordPacketTest with matchers Issue #2745 --- .../comm/packets/GetRecordPacketTest.kt | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) 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 3b062a2770..97815fb03b 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 @@ -4,10 +4,10 @@ import app.aaps.core.interfaces.pump.DetailedBolusInfo import app.aaps.core.interfaces.pump.DetailedBolusInfoStorage import app.aaps.core.interfaces.pump.PumpSync import app.aaps.core.interfaces.utils.T +import com.google.common.truth.Truth.assertThat 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.mockito.Mock import org.mockito.Mockito @@ -42,7 +42,7 @@ class GetRecordPacketTest : MedtrumTestBase() { // Expected values val expected = byteArrayOf(99, 4, 0, -110, 0) - Assertions.assertEquals(expected.contentToString(), result.contentToString()) + assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder() } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -54,8 +54,8 @@ class GetRecordPacketTest : MedtrumTestBase() { val result = packet.handleResponse(data) // Expected values - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -67,8 +67,8 @@ class GetRecordPacketTest : MedtrumTestBase() { val result = packet.handleResponse(data) // Expected values - Assertions.assertEquals(false, result) - Assertions.assertEquals(true, packet.failed) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } @Test fun handleResponseGivenBolusRecordWhenAndDetailedBolusInfoPresentThenExpectPumpSyncWithTempId() { @@ -100,10 +100,10 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) - Assertions.assertEquals(timestamp, medtrumPump.lastBolusTime) - Assertions.assertEquals(amount, medtrumPump.lastBolusAmount, 0.01) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() + assertThat(medtrumPump.lastBolusTime).isEqualTo(timestamp) + assertThat(medtrumPump.lastBolusAmount).isWithin(0.01).of(amount) } @Test fun handleResponseGivenBolusRecordWhenAndNoDetailedBolusInfoPresentThenExpectPumpSyncWithPumpId() { @@ -129,10 +129,10 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) - Assertions.assertEquals(timestamp, medtrumPump.lastBolusTime) - Assertions.assertEquals(amount, medtrumPump.lastBolusAmount, 0.01) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() + assertThat(medtrumPump.lastBolusTime).isEqualTo(timestamp) + assertThat(medtrumPump.lastBolusAmount).isWithin(0.01).of(amount) } @Test fun handleResponseGivenExtendedBolusRecordThenExpectPumpSyncWithPumpId() { @@ -157,8 +157,8 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenComboBolusRecordWhenAndNoDetailedBolusInfoPresentThenExpectPumpSyncWithPumpId() { @@ -195,8 +195,8 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenBasalRecordWhenAbsoluteTempThenExpectPumpSync() { @@ -223,8 +223,8 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenBasalRecordWhenRelativeTempThenExpectPumpSync() { @@ -251,8 +251,8 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenBasalRecordWhenSuspendThenExpectPumpSync() { @@ -279,8 +279,8 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenBasalRecordWhenStandardAndSuspendEndReasonThenExpectPumpSync() { @@ -315,8 +315,8 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenBasalRecordWhenTempAndSuspendEndReasonThenExpectPumpSync() { @@ -351,8 +351,8 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenBasalRecordWhenStandardAndSuspendEndReasonAndNewerExistingTBRThenExpectNoPumpSync() { @@ -391,8 +391,8 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenTDDRecordThenExpectPumpSync() { @@ -421,7 +421,7 @@ class GetRecordPacketTest : MedtrumTestBase() { pumpSerial = medtrumPump.pumpSN.toString(radix = 16) ) - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } } From 764ae29e56c01f5e762d1e42162aa0286b5a0f5e Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:18:53 -0700 Subject: [PATCH 079/127] Rewrites GetTimePacketTest with matchers Issue #2745 --- .../medtrum/comm/packets/GetTimePacketTest.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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 de947a2514..5e2ef9cd84 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 @@ -1,11 +1,11 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector 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 class GetTimePacketTest : MedtrumTestBase() { @@ -30,8 +30,7 @@ class GetTimePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(1, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) + assertThat(result).asList().containsExactly(opCode.toByte()) } @Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() { @@ -46,9 +45,9 @@ class GetTimePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) - Assertions.assertEquals(MedtrumTimeUtil().convertPumpTimeToSystemTimeMillis(time), medtrumPump.lastTimeReceivedFromPump) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() + assertThat(medtrumPump.lastTimeReceivedFromPump).isEqualTo(MedtrumTimeUtil().convertPumpTimeToSystemTimeMillis(time)) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -63,8 +62,8 @@ class GetTimePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response.sliceArray(0..response.size - 2)) // Expected values - Assertions.assertEquals(false, result) - Assertions.assertEquals(true, packet.failed) - Assertions.assertEquals(0, medtrumPump.lastTimeReceivedFromPump) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() + assertThat(medtrumPump.lastTimeReceivedFromPump).isEqualTo(0) } } From ed726a1d29b5fb6129f2126c2c35a3e594d6c8ff Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:21:55 -0700 Subject: [PATCH 080/127] Rewrites MedtrumPacketTest with matchers Issue #2745 --- .../medtrum/comm/packets/MedtrumPacketTest.kt | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) 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 0469575c65..20a762d437 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 @@ -1,10 +1,10 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class MedtrumPacketTest : MedtrumTestBase() { @@ -29,8 +29,7 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(result.size, 1) - Assertions.assertEquals(result[0], opCode.toByte()) + assertThat(result).asList().containsExactly(opCode.toByte()) } @Test fun handleResponseGivenResponseWhenOpcodeIsCorrectThenResultTrue() { @@ -45,8 +44,8 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(result, true) - Assertions.assertEquals(packet.failed, false) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenResponseWhenOpcodeIsIncorrectThenResultFalse() { @@ -61,8 +60,8 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(result, false) - Assertions.assertEquals(packet.failed, true) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } @Test fun handleResponseGivenResponseWhenResponseCodeIsWaitingThenResultFalse() { @@ -77,8 +76,8 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(result, false) - Assertions.assertEquals(packet.failed, false) + assertThat(result).isFalse() + assertThat(packet.failed).isFalse() } @Test fun handleResponseGivenResponseWhenResponseCodeIsErrorThenResultFalse() { @@ -93,8 +92,8 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(false, result) - Assertions.assertEquals(true, packet.failed) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -108,7 +107,7 @@ class MedtrumPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(false, result) - Assertions.assertEquals(true, packet.failed) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } } From 8b85e00953ff3647f81250b556020124079d411f Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:25:32 -0700 Subject: [PATCH 081/127] Rewrites NotificationPacketTest with matchers Issue #2745 --- .../comm/packets/NotificationPacketTest.kt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) 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 7e17be2c76..90664ee302 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 @@ -1,12 +1,12 @@ package info.nightscout.pump.medtrum.comm.packets import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.pump.medtrum.MedtrumTestBase import info.nightscout.pump.medtrum.comm.enums.BasalType import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class NotificationPacketTest : MedtrumTestBase() { @@ -30,7 +30,7 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(byteArrayOf(state)) // Expected values - Assertions.assertEquals(medtrumPump.pumpState, MedtrumPumpState.fromByte(state)) + assertThat(MedtrumPumpState.fromByte(state)).isEqualTo(medtrumPump.pumpState) } @Test fun handleNotificationGivenBasalDataThenDataSaved() { @@ -41,12 +41,12 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(data) // Expected values - 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) + assertThat(medtrumPump.lastBasalType).isEqualTo(BasalType.ABSOLUTE_TEMP) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(0.85) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(25) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(14) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(1685126612000) + assertThat(medtrumPump.reservoir).isWithin(0.01).of(186.80) } @Test fun handleNotificationGivenSequenceAndOtherDataThenDataSaved() { @@ -57,7 +57,7 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(data) // Expected values - Assertions.assertEquals(167, medtrumPump.currentSequenceNumber) + assertThat(medtrumPump.currentSequenceNumber).isEqualTo(167) } @Test fun handleNotificationGivenBolusInProgressThenDataSaved() { @@ -69,9 +69,9 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(data) // Expected values - Assertions.assertEquals(false, medtrumPump.bolusDone) - Assertions.assertEquals(0.15, medtrumPump.bolusingTreatment!!.insulin, 0.01) - Assertions.assertEquals(163.5, medtrumPump.reservoir, 0.01) + assertThat(medtrumPump.bolusDone).isFalse() + assertThat(medtrumPump.bolusingTreatment!!.insulin).isWithin(0.01).of(0.15) + assertThat(medtrumPump.reservoir).isWithin(0.01).of(163.5) } @Test fun handleNotificationGivenBolusFinishedThenDataSaved() { @@ -83,8 +83,8 @@ class NotificationPacketTest : MedtrumTestBase() { NotificationPacket(packetInjector).handleNotification(data) // Expected values - Assertions.assertEquals(true, medtrumPump.bolusDone) - Assertions.assertEquals(1.65, medtrumPump.bolusingTreatment!!.insulin, 0.01) - Assertions.assertEquals(161.95, medtrumPump.reservoir, 0.01) + assertThat(medtrumPump.bolusDone).isTrue() + assertThat(medtrumPump.bolusingTreatment!!.insulin).isWithin(0.01).of(1.65) + assertThat(medtrumPump.reservoir).isWithin(0.01).of(161.95) } } From eeb3a84b9cdd396ceeebc710340efa5547aed06b Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:26:57 -0700 Subject: [PATCH 082/127] Rewrites PollPatchPacketTest with matchers Issue #2745 --- .../pump/medtrum/comm/packets/PollPatchPacketTest.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 0a7377989b..d5009d532b 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 @@ -1,9 +1,9 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class PollPatchPacketTest : MedtrumTestBase() { @@ -27,7 +27,6 @@ class PollPatchPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(1, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) + assertThat(result).asList().containsExactly(opCode.toByte()) } } From 7055ced8dbe074f6e9187f5a2a2c43fd21525c53 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:28:25 -0700 Subject: [PATCH 083/127] Rewrites PrimePacketTest with matchers Issue #2745 --- .../nightscout/pump/medtrum/comm/packets/PrimePacketTest.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 1f415ab10a..d3f417fcf5 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 @@ -1,9 +1,9 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class PrimePacketTest : MedtrumTestBase() { @@ -27,7 +27,6 @@ class PrimePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(1, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) + assertThat(result).asList().containsExactly(opCode.toByte()) } } From 59d81e47deb5371eabc52b395c4251b42d82ea8b Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:38:25 -0700 Subject: [PATCH 084/127] Rewrites ReadBolusStatePacketTest with matchers Issue #2745 --- .../comm/packets/ReadBolusStatePacketTest.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 3bde0194a3..06aebf1beb 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 @@ -1,10 +1,10 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class ReadBolusStatePacketTest : MedtrumTestBase() { @@ -31,9 +31,9 @@ class ReadBolusStatePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertTrue(result) - Assertions.assertFalse(packet.failed) - Assertions.assertEquals(bolusData.contentToString(), packet.bolusData.contentToString()) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() + assertThat(packet.bolusData).isEqualTo(bolusData) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -47,8 +47,8 @@ class ReadBolusStatePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(false, result) - Assertions.assertEquals(true, packet.failed) - Assertions.assertEquals(byteArrayOf().contentToString(), packet.bolusData.contentToString()) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() + assertThat(packet.bolusData).isEmpty() } } From 7ebe8e1698cd422998b6ca0ee3117c9ca85db037 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:50:15 -0700 Subject: [PATCH 085/127] Rewrites ResumePumpPacket with matchers Issue #2745 --- .../nightscout/pump/medtrum/comm/packets/ResumePumpPacket.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 5390f5bacc..43d1a2c930 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 @@ -1,9 +1,9 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class ResumePumpPacketTest : MedtrumTestBase() { @@ -27,7 +27,6 @@ class ResumePumpPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(1, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) + assertThat(result).asList().containsExactly(opCode.toByte()) } } From a87ba8b7081634836fc8703707b5b9983ba8ba96 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 17:55:30 -0700 Subject: [PATCH 086/127] Rewrites SetBasalProfilePacketTest with matchers Issue #2745 --- .../comm/packets/SetBasalProfilePacketTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 cd7f592dfd..fadd0fd465 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 @@ -1,10 +1,10 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class SetBasalProfilePacketTest : MedtrumTestBase() { @@ -31,7 +31,7 @@ class SetBasalProfilePacketTest : MedtrumTestBase() { // Expected values val expected = byteArrayOf(opCode.toByte()) + 1.toByte() + basalProfile - Assertions.assertEquals(expected.contentToString(), result.contentToString()) + assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder() } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -50,13 +50,13 @@ class SetBasalProfilePacketTest : MedtrumTestBase() { val expectedStartTime = 1679575392000L val expectedPatchId = 146L - 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) + assertThat(result).isTrue() + assertThat(medtrumPump.lastBasalType).isEqualTo(expectedBasalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(expectedBasalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(expectedBasalSequence) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedStartTime) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedPatchId) + assertThat(medtrumPump.actualBasalProfile).isEqualTo(basalProfile) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -69,7 +69,7 @@ class SetBasalProfilePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertFalse(result) - Assertions.assertTrue(packet.failed) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } } From efcc9baa669ca96cd14a98640ea7a9160bcfd4f0 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:07:12 -0700 Subject: [PATCH 087/127] Rewrites SetBolusMotorPacketTest with matchers Issue #2745 --- .../pump/medtrum/comm/packets/SetBolusMotorPacketTest.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 e6350e383f..3a6cf8ed50 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 @@ -1,9 +1,9 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class SetBolusMotorPacketTest : MedtrumTestBase() { @@ -27,8 +27,6 @@ class SetBolusMotorPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - val expectedByteArray = byteArrayOf(opCode.toByte()) + 0.toByte() - Assertions.assertEquals(2, result.size) - Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) + assertThat(result).asList().containsExactly(opCode.toByte(), 0.toByte()).inOrder() } } From 8f34ca5d89a743a1c612620e5255b0ae0994bf35 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:12:06 -0700 Subject: [PATCH 088/127] Rewrites SetBolusPacketTest with matchers Issue #2745 --- .../pump/medtrum/comm/packets/SetBolusPacketTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 b622345911..7cca16d361 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 @@ -1,9 +1,9 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class SetBolusPacketTest : MedtrumTestBase() { @@ -28,6 +28,6 @@ class SetBolusPacketTest : MedtrumTestBase() { // Expected values val expected = byteArrayOf(19, 1, 47, 0, 0) - Assertions.assertEquals(expected.contentToString(), result.contentToString()) + assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder() } } From 5bfedf055c35959de660aa364d284edcab338e49 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:13:21 -0700 Subject: [PATCH 089/127] Rewrites SetPatchPacketTest with matchers Issue #2745 --- .../pump/medtrum/comm/packets/SetPatchPacketTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 924f3f129d..cc2daf2b48 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 @@ -1,10 +1,10 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 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) - Assertions.assertEquals(expected.contentToString(), result.contentToString()) + assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder() } } From b560313e755b47ce59dbdba877d13f5de5a82dbd Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:16:12 -0700 Subject: [PATCH 090/127] Rewrites SetTempBasalPacketTest with matchers Issue #2745 --- .../comm/packets/SetTempBasalPacketTest.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 ee1aee300f..96c66c4109 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 @@ -1,10 +1,10 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class SetTempBasalPacketTest : MedtrumTestBase() { @@ -31,7 +31,7 @@ class SetTempBasalPacketTest : MedtrumTestBase() { // Expected values val expected = byteArrayOf(24, 6, 25, 0, 60, 0) - Assertions.assertEquals(expected.contentToString(), result.contentToString()) + assertThat(result.contentToString()).isEqualTo(expected.contentToString()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -52,12 +52,12 @@ class SetTempBasalPacketTest : MedtrumTestBase() { val expectedStartTime = 1679575112000L val expectedPatchId = 146L - 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) + assertThat(result).isTrue() + assertThat(medtrumPump.lastBasalType).isEqualTo(expectedBasalType) + assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(expectedBasalRate) + assertThat(medtrumPump.lastBasalSequence).isEqualTo(expectedBasalSequence) + assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedStartTime) + assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedPatchId) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -72,6 +72,6 @@ class SetTempBasalPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertFalse(result) + assertThat(result).isFalse() } } From 58dd9692de6a3cda80952b47cb997a31a9369ae3 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:17:44 -0700 Subject: [PATCH 091/127] Rewrites SetTimePacketTest with matchers Issue #2745 --- .../pump/medtrum/comm/packets/SetTimePacketTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 7d45db28dc..70abf87455 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 @@ -1,11 +1,11 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector 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 class SetTimePacketTest : MedtrumTestBase() { @@ -30,8 +30,7 @@ class SetTimePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - val expectedByteArray = byteArrayOf(opCode.toByte()) + 2.toByte() + time.toByteArray(4) - Assertions.assertEquals(6, result.size) - Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) + val expected = byteArrayOf(opCode.toByte()) + 2.toByte() + time.toByteArray(4) + assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder() } } From d75bf0e611531f025ae3d2121c3711b93bdaf8e8 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:20:33 -0700 Subject: [PATCH 092/127] Rewrites SetTimeZonePacketTest with matchers Issue #2745 --- .../medtrum/comm/packets/SetTimeZonePacketTest.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 127fac1af8..099a35c9fb 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 @@ -1,11 +1,11 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector 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 class SetTimeZonePacketTest : MedtrumTestBase() { @@ -35,9 +35,8 @@ class SetTimeZonePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - val expectedByteArray = byteArrayOf(opCode.toByte()) + offsetMinutes.toByteArray(2) + time.toByteArray(4) - Assertions.assertEquals(7, result.size) - Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) + val expected = byteArrayOf(opCode.toByte()) + offsetMinutes.toByteArray(2) + time.toByteArray(4) + assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder() } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -50,7 +49,7 @@ class SetTimeZonePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertTrue(result) - Assertions.assertEquals(offsetMinutes, medtrumPump.pumpTimeZoneOffset) + assertThat(result).isTrue() + assertThat(medtrumPump.pumpTimeZoneOffset).isEqualTo(offsetMinutes) } } From d24d97cc4b4a4559f3fa520f9dcf186fb80f84f9 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:22:05 -0700 Subject: [PATCH 093/127] Rewrites StopPatchPacketTest with matchers Issue #2745 --- .../medtrum/comm/packets/StopPatchPacketTest.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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 be58797655..138a0e887c 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 @@ -1,9 +1,9 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class StopPatchPacketTest : MedtrumTestBase() { @@ -28,8 +28,7 @@ class StopPatchPacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(1, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) + assertThat(result).asList().containsExactly(opCode.toByte()) } @Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() { @@ -43,9 +42,9 @@ class StopPatchPacketTest : MedtrumTestBase() { // Expected values val expectedPatchId = 146L val expectedStopSequence = 23 - Assertions.assertTrue(result) - Assertions.assertEquals(expectedPatchId, medtrumPump.lastStopPatchId) - Assertions.assertEquals(expectedStopSequence, medtrumPump.lastStopSequence) + assertThat(result).isTrue() + assertThat(medtrumPump.lastStopPatchId).isEqualTo(expectedPatchId) + assertThat(medtrumPump.lastStopSequence).isEqualTo(expectedStopSequence) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -57,7 +56,7 @@ class StopPatchPacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertFalse(result) - Assertions.assertTrue(packet.failed) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } } From b65512440c3722f72da01f9eafb23d4842c6b819 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:23:16 -0700 Subject: [PATCH 094/127] Rewrites SubscribePacketTest with matchers Issue #2745 --- .../pump/medtrum/comm/packets/SubscribePacketTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 341cc260c9..6753c17a6b 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 @@ -1,10 +1,10 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat 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 class SubscribePacketTest : MedtrumTestBase() { @@ -28,8 +28,7 @@ class SubscribePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - val expectedByteArray = byteArrayOf(opCode.toByte()) + 4095.toByteArray(2) - Assertions.assertEquals(3, result.size) - Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString()) + val expected = byteArrayOf(opCode.toByte()) + 4095.toByteArray(2) + assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder() } } From 270d6fbdd23d1dc94c95f0daf260dc3222f1f276 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:26:14 -0700 Subject: [PATCH 095/127] Rewrites SynchronizePacketTest with matchers Issue #2745 --- .../comm/packets/SynchronizePacketTest.kt | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) 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 7d1d872723..f0db5d533d 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 @@ -1,12 +1,12 @@ package info.nightscout.pump.medtrum.comm.packets +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector 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 class SynchronizePacketTest : MedtrumTestBase() { @@ -35,8 +35,7 @@ class SynchronizePacketTest : MedtrumTestBase() { val result = packet.getRequest() // Expected values - Assertions.assertEquals(1, result.size) - Assertions.assertEquals(opCode.toByte(), result[0]) + assertThat(result).asList().containsExactly(opCode.toByte()) } @Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() { @@ -53,9 +52,9 @@ class SynchronizePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(true, result) - Assertions.assertEquals(false, packet.failed) - Assertions.assertEquals(state, packet.medtrumPump.pumpState.state) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() + assertThat(packet.medtrumPump.pumpState.state).isEqualTo(state) } @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @@ -71,13 +70,13 @@ class SynchronizePacketTest : MedtrumTestBase() { val result = packet.handleResponse(response) // Expected values - Assertions.assertEquals(false, result) - Assertions.assertEquals(true, packet.failed) + assertThat(result).isFalse() + assertThat(packet.failed).isTrue() } @Test fun handleResponseContainingSyncDataThenDataSaved() { // Inputs - val data = + val byteData = byteArrayOf( 47, 3, @@ -130,21 +129,21 @@ class SynchronizePacketTest : MedtrumTestBase() { // Call val packet = SynchronizePacket(packetInjector) - val result = packet.handleResponse(data) + val result = packet.handleResponse(byteData) // Expected values - 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) + assertThat(result).isTrue() + assertThat(packet.failed).isFalse() + assertThat(packet.medtrumPump.pumpState).isEqualTo(MedtrumPumpState.ACTIVE) + assertThat(packet.medtrumPump.lastBasalType).isEqualTo(BasalType.ABSOLUTE_TEMP) + assertThat(packet.medtrumPump.lastBasalRate).isWithin(0.01).of(0.85) + assertThat(packet.medtrumPump.lastBasalSequence).isEqualTo(25) + assertThat(packet.medtrumPump.lastBasalPatchId).isEqualTo(14) + assertThat(packet.medtrumPump.lastBasalStartTime).isEqualTo(1685126612000) + assertThat(packet.medtrumPump.patchAge).isEqualTo(8123) + assertThat(packet.medtrumPump.reservoir).isWithin(0.01).of(186.80) + assertThat(packet.medtrumPump.patchStartTime).isEqualTo(1685120120000) + assertThat(packet.medtrumPump.batteryVoltage_A).isWithin(0.01).of(5.96875) + assertThat(packet.medtrumPump.batteryVoltage_B).isWithin(0.01).of(2.8125) } } From feb75829ee429398b1b8251e93fdb33f928ea339 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:44:26 -0700 Subject: [PATCH 096/127] Rewrites FunctionsTest with matchers Issue #2745 --- .../pump/omnipod/dash/util/FunctionsTest.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt index 52ebcf240b..f6bb6ceb46 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt @@ -1,10 +1,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.util import app.aaps.core.interfaces.profile.Profile +import com.google.common.truth.Truth.assertThat import app.aaps.core.interfaces.profile.Profile.ProfileValue import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito import org.mockito.Mockito.`when` @@ -25,19 +25,19 @@ class FunctionsTest { val basalProgram: BasalProgram = mapProfileToBasalProgram(profile) val entries: List = basalProgram.segments - Assertions.assertEquals(3, entries.size) + assertThat(entries).hasSize(3) val entry1: BasalProgram.Segment = entries[0] - Assertions.assertEquals(0.toShort(), entry1.startSlotIndex) - Assertions.assertEquals(50, entry1.basalRateInHundredthUnitsPerHour) - Assertions.assertEquals(10.toShort(), entry1.endSlotIndex) + assertThat(entry1.startSlotIndex).isEqualTo(0.toShort()) + assertThat(entry1.basalRateInHundredthUnitsPerHour).isEqualTo(50) + assertThat(entry1.endSlotIndex).isEqualTo(10.toShort()) val entry2: BasalProgram.Segment = entries[1] - Assertions.assertEquals(10.toShort(), entry2.startSlotIndex) - Assertions.assertEquals(100, entry2.basalRateInHundredthUnitsPerHour) - Assertions.assertEquals(28.toShort(), entry2.endSlotIndex) + assertThat(entry2.startSlotIndex).isEqualTo(10.toShort()) + assertThat(entry2.basalRateInHundredthUnitsPerHour).isEqualTo(100) + assertThat(entry2.endSlotIndex).isEqualTo(28.toShort()) val entry3: BasalProgram.Segment = entries[2] - Assertions.assertEquals(28.toShort(), entry3.startSlotIndex) - Assertions.assertEquals(305, entry3.basalRateInHundredthUnitsPerHour) - Assertions.assertEquals(48.toShort(), entry3.endSlotIndex) + assertThat(entry3.startSlotIndex).isEqualTo(28.toShort()) + assertThat(entry3.basalRateInHundredthUnitsPerHour).isEqualTo(305) + assertThat(entry3.endSlotIndex).isEqualTo(48.toShort()) } @Test fun invalidProfileZeroEntries() { @@ -104,6 +104,6 @@ class FunctionsTest { val basalProgram: BasalProgram = mapProfileToBasalProgram(profile) val basalProgramElement: BasalProgram.Segment = basalProgram.segments[0] - Assertions.assertEquals(5, basalProgramElement.basalRateInHundredthUnitsPerHour) + assertThat(basalProgramElement.basalRateInHundredthUnitsPerHour).isEqualTo(5) } } From d71805b85b00717c4c1fedf2ea92f3e40e244e42 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:46:40 -0700 Subject: [PATCH 097/127] Rewrites EnDecryptTest with matchers Issue #2745 --- .../omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt index fac539d635..eac55c8d88 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt @@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecry import app.aaps.core.utils.toHex import app.aaps.shared.tests.AAPSLoggerTest +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.spongycastle.util.encoders.Hex @@ -32,7 +32,7 @@ import org.spongycastle.util.encoders.Hex val msg = MessagePacket.parse(encryptedMessage) val decryptedMsg = enDecrypt.decrypt(msg) - Assertions.assertEquals(decrypted.toHex(), decryptedMsg.payload.toHex()) + assertThat(decryptedMsg.payload.toHex()).isEqualTo(decrypted.toHex()) } @Test @@ -56,6 +56,6 @@ import org.spongycastle.util.encoders.Hex val encrypted = enDecrypt.encrypt(msg) - Assertions.assertEquals(encryptedMessage.toHex(), encrypted.asByteArray().toHex()) + assertThat(encrypted.asByteArray().toHex()).isEqualTo(encryptedMessage.toHex()) } } From fe14ef27b22ae5cea63157b2633b856bfe031c63 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:50:39 -0700 Subject: [PATCH 098/127] Rewrites KeyExchangeTest with matchers Issue #2745 --- .../omnipod/dash/driver/comm/pair/KeyExchangeTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt index e8a36c089c..0d73b2ce5c 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt @@ -4,9 +4,9 @@ import app.aaps.core.interfaces.configuration.Config import app.aaps.core.utils.toHex import app.aaps.shared.tests.AAPSLoggerTest import app.aaps.shared.tests.TestBase +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mock @@ -20,7 +20,7 @@ class KeyExchangeTest : TestBase() { private val keyGenerator = X25519KeyGenerator() private val keyGeneratorSpy: X25519KeyGenerator = spy(keyGenerator) - private var randomByteGenerator: RandomByteGenerator = mock(RandomByteGenerator::class.java) + private var randomByteGenerator = mock() @Mock lateinit var config: Config @@ -43,9 +43,9 @@ class KeyExchangeTest : TestBase() { val podPublicKey = Hex.decode("2fe57da347cd62431528daac5fbb290730fff684afc4cfc2ed90995f58cb3b74") val podNonce = Hex.decode("00000000000000000000000000000000") ke.updatePodPublicData(podPublicKey + podNonce) - Assertions.assertEquals(ke.pdmPublic.toHex(), "f2b6940243aba536a66e19fb9a39e37f1e76a1cd50ab59b3e05313b4fc93975e") - Assertions.assertEquals(ke.pdmConf.toHex(), "5fc3b4da865e838ceaf1e9e8bb85d1ac") + assertThat("f2b6940243aba536a66e19fb9a39e37f1e76a1cd50ab59b3e05313b4fc93975e").isEqualTo(ke.pdmPublic.toHex()) + assertThat("5fc3b4da865e838ceaf1e9e8bb85d1ac").isEqualTo(ke.pdmConf.toHex()) ke.validatePodConf(Hex.decode("af4f10db5f96e5d9cd6cfc1f54f4a92f")) - Assertions.assertEquals(ke.ltk.toHex(), "341e16d13f1cbf73b19d1c2964fee02b") + assertThat("341e16d13f1cbf73b19d1c2964fee02b").isEqualTo(ke.ltk.toHex()) } } From 3ea240f4db2bf7f422d511dc1a072887df1218b1 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:53:33 -0700 Subject: [PATCH 099/127] Rewrites EapMessageTest with matchers Issue #2745 --- .../pump/omnipod/dash/driver/comm/session/EapMessageTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessageTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessageTest.kt index a17c03a276..92cd2282b3 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessageTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessageTest.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session import app.aaps.core.utils.toHex import app.aaps.shared.tests.AAPSLoggerTest -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test import org.spongycastle.util.encoders.Hex @@ -14,6 +14,6 @@ class EapMessageTest { Hex.decode("01bd0038170100000205000000c55c78e8d3b9b9e935860a7259f6c001050000c2cd1248451103bd77a6c7ef88c441ba7e0200006cff5d18") val eapMsg = EapMessage.parse(aapsLogger, payload) val back = eapMsg.toByteArray() - Assertions.assertEquals(back.toHex(), payload.toHex()) + assertThat(payload.toHex()).isEqualTo(back.toHex()) } } From 6bc5adfe5215bdff7265731eb9a28c4e1a64ed6a Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 18:57:21 -0700 Subject: [PATCH 100/127] Rewrites MilenageTest with matchers Issue #2745 --- .../dash/driver/comm/session/MilenageTest.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/MilenageTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/MilenageTest.kt index 65152a5f36..847ce37927 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/MilenageTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/MilenageTest.kt @@ -4,7 +4,7 @@ import app.aaps.core.interfaces.configuration.Config import app.aaps.core.utils.toHex import app.aaps.shared.tests.AAPSLoggerTest import app.aaps.shared.tests.TestBase -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test import org.mockito.Mock import org.spongycastle.util.encoders.Hex @@ -22,9 +22,9 @@ class MilenageTest : TestBase() { sqn = byteArrayOf(0, 0, 0, 0, 0, 2), randParam = Hex.decode("c2cd1248451103bd77a6c7ef88c441ba") ) - Assertions.assertEquals(m.res.toHex(), "a40bc6d13861447e") - Assertions.assertEquals(m.ck.toHex(), "55799fd26664cbf6e476525e2dee52c6") - Assertions.assertEquals(m.autn.toHex(), "00c55c78e8d3b9b9e935860a7259f6c0") + assertThat(m.res.toHex()).isEqualTo("a40bc6d13861447e") + assertThat(m.ck.toHex()).isEqualTo("55799fd26664cbf6e476525e2dee52c6") + assertThat(m.autn.toHex()).isEqualTo("00c55c78e8d3b9b9e935860a7259f6c0") } @Test fun testMilenage2() { @@ -36,9 +36,9 @@ class MilenageTest : TestBase() { sqn = byteArrayOf(0, 0, 0, 0, 0, 2), // 1 + 1 randParam = Hex.decode("4fc01ac1a94376ae3e052339c07d9e1f") ) - Assertions.assertEquals(m.res.toHex(), "ec549e00fa668a19") - Assertions.assertEquals(m.ck.toHex(), "ee3dac761fe358a9f476cc5ee81aa3e9") - Assertions.assertEquals(m.autn.toHex(), "a3e7a71430c8b9b95245b33b3bd679c4") + assertThat(m.res.toHex()).isEqualTo("ec549e00fa668a19") + assertThat(m.ck.toHex()).isEqualTo("ee3dac761fe358a9f476cc5ee81aa3e9") + assertThat(m.autn.toHex()).isEqualTo("a3e7a71430c8b9b95245b33b3bd679c4") } @Test fun testMilenageIncrementedSQN() { @@ -51,9 +51,9 @@ class MilenageTest : TestBase() { sqn = byteArrayOf(0, 0, 0, 0, 0x01, 0x5e), randParam = Hex.decode("d71cc44820e5419f42c62ae97c035988") ) - Assertions.assertEquals(m.res.toHex(), "5f807a379a5c5d30") - Assertions.assertEquals(m.ck.toHex(), "8dd4b3ceb849a01766e37f9d86045c39") - Assertions.assertEquals(m.autn.toHex(), "0e0264d056fcb9b9752227365a090955") + assertThat(m.res.toHex()).isEqualTo("5f807a379a5c5d30") + assertThat(m.ck.toHex()).isEqualTo("8dd4b3ceb849a01766e37f9d86045c39") + assertThat(m.autn.toHex()).isEqualTo("0e0264d056fcb9b9752227365a090955") } @Test fun testMileageSynchronization() { @@ -67,7 +67,7 @@ class MilenageTest : TestBase() { randParam = Hex.decode("396707041ca3a5931fc0e52d2d7b9ecf"), amf = byteArrayOf(0, 0), ) - Assertions.assertEquals(m.receivedMacS.toHex(), m.macS.toHex()) - Assertions.assertEquals(m.sqn.toHex(), m.synchronizationSqn.toHex()) + assertThat(m.receivedMacS.toHex()).isEqualTo(m.macS.toHex()) + assertThat(m.sqn.toHex()).isEqualTo(m.synchronizationSqn.toHex()) } } From 23a97d1dc58ff67d39500c1674e9ea2dc463e090 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 19:00:47 -0700 Subject: [PATCH 101/127] Rewrites MessagePacketTest with matchers Issue #2745 --- .../driver/comm/message/MessagePacketTest.kt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt index 51a93579db..9df69de86d 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import app.aaps.core.utils.toHex +import com.google.common.truth.Truth.assertThat import com.google.crypto.tink.subtle.Hex import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class MessagePacketTest { @@ -16,19 +16,19 @@ class MessagePacketTest { @Test fun testParseMessagePacket() { val msg = MessagePacket.parse(Hex.decode(payload)) - Assertions.assertEquals(msg.type, MessageType.ENCRYPTED) - Assertions.assertEquals(msg.source, Id.fromLong(136326824)) - Assertions.assertEquals(msg.destination, Id.fromLong(136326825)) - Assertions.assertEquals(msg.sequenceNumber, 7.toByte()) - Assertions.assertEquals(msg.ackNumber, 0.toByte()) - Assertions.assertEquals(msg.eqos, 1.toShort()) - Assertions.assertEquals(msg.priority, false) - Assertions.assertEquals(msg.lastMessage, false) - Assertions.assertEquals(msg.gateway, false) - Assertions.assertEquals(msg.sas, true) - Assertions.assertEquals(msg.tfs, false) - Assertions.assertEquals(msg.version, 0.toShort()) - Assertions.assertEquals(msg.payload.toHex(), payload.substring(32, payload.length)) + assertThat(msg.type).isEqualTo(MessageType.ENCRYPTED) + assertThat(msg.source).isEqualTo(Id.fromLong(136326824)) + assertThat(msg.destination).isEqualTo(Id.fromLong(136326825)) + assertThat(msg.sequenceNumber).isEqualTo(7.toByte()) + assertThat(msg.ackNumber).isEqualTo(0.toByte()) + assertThat(msg.eqos).isEqualTo(1.toShort()) + assertThat(msg.priority).isFalse() + assertThat(msg.lastMessage).isFalse() + assertThat(msg.gateway).isFalse() + assertThat(msg.sas).isTrue() + assertThat(msg.tfs).isFalse() + assertThat(msg.version).isEqualTo(0.toShort()) + assertThat(payload.substring(32, payload.length)).isEqualTo(msg.payload.toHex()) } @Test fun testSerializeMessagePacket() { @@ -46,6 +46,6 @@ class MessagePacketTest { tfs = false, payload = Hex.decode(payload.substring(32, payload.length)) ) - Assertions.assertEquals(msg.asByteArray().toHex(), payload) + assertThat(msg.asByteArray().toHex()).isEqualTo(payload) } } From b8ddafe22059ca490fbb414082c01282e73f7360 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 19:05:49 -0700 Subject: [PATCH 102/127] Rewrites PayloadJoinerTest with matchers Issue #2745 --- .../omnipod/dash/driver/comm/message/PayloadJoinerTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadJoinerTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadJoinerTest.kt index 983cfdb72f..c534618a2c 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadJoinerTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadJoinerTest.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import app.aaps.core.utils.toHex +import com.google.common.truth.Truth.assertThat import com.google.crypto.tink.subtle.Hex import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadJoiner -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class PayloadJoinerTest { @@ -14,7 +14,7 @@ class PayloadJoinerTest { val payload = "54,57,10,23,03,00,00,c0,ff,ff,ff,fe,08,20,2e,a8,50,30,3d,00,01,a5".replace(",", "") val joiner = PayloadJoiner(f1) joiner.accumulate(f2) - val actual = joiner.finalize() - Assertions.assertEquals(payload, actual.toHex()) + val result = joiner.finalize() + assertThat(result.toHex()).isEqualTo(payload) } } From 22b6f75444d9e0576aacc2e0676e4a7e233e722b Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 19:08:06 -0700 Subject: [PATCH 103/127] Rewrites PayloadSplitJoinTest with matchers Issue #2745 --- .../omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt index e37800a571..90b676a649 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import app.aaps.core.utils.toHex +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadJoiner import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import java.util.Random @@ -22,7 +22,7 @@ class PayloadSplitJoinTest { joiner.accumulate(p.toByteArray()) } val got = joiner.finalize() - Assertions.assertEquals(got.toHex(), payload.toHex()) + assertThat(got.toHex()).isEqualTo(payload.toHex()) } } } From 5d4c0f72430341d16e5eaf3c4ac9bc78e9a03356 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 19:14:54 -0700 Subject: [PATCH 104/127] Rewrites StringLengthPrefixEncodingTest with matchers Issue #2745 --- .../driver/comm/message/StringLengthPrefixEncodingTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt index 6379eaa702..005c0337d2 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt @@ -1,8 +1,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import app.aaps.core.utils.toHex +import com.google.common.truth.Truth.assertThat import com.google.crypto.tink.subtle.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class StringLengthPrefixEncodingTest { @@ -12,12 +12,12 @@ class StringLengthPrefixEncodingTest { @Test fun testFormatKeysP0() { val payload = StringLengthPrefixEncoding.formatKeys(arrayOf("P0="), arrayOf(p0Content)) - Assertions.assertEquals(p0Payload.toHex(), payload.toHex()) + assertThat(p0Payload.toHex()).isEqualTo(payload.toHex()) } @Test fun testParseKeysP0() { val parsed = StringLengthPrefixEncoding.parseKeys(arrayOf("P0="), p0Payload) - Assertions.assertEquals(parsed.size, 1) - Assertions.assertEquals(parsed[0].toHex(), p0Content.toHex()) + assertThat(parsed).hasLength(1) + assertThat(parsed[0].toHex()).isEqualTo(p0Content.toHex()) } } From 8af75ade2a39c77d1da2b3f797915bf950cd8d3e Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:16:21 -0700 Subject: [PATCH 105/127] Rewrites AlarmStatusResponseTest with matchers Issue #2745 --- .../pod/response/AlarmStatusResponseTest.kt | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt index 605d7043e9..9428a081f2 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt @@ -1,44 +1,44 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class AlarmStatusResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("021602080100000501BD00000003FF01950000000000670A") val response = AlarmStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(ResponseType.StatusResponseType.ALARM_STATUS, response.statusResponseType) - Assertions.assertEquals(ResponseType.StatusResponseType.ALARM_STATUS.value, response.additionalStatusResponseType) - Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus) - Assertions.assertEquals(0.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(5.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(445.toShort(), response.totalPulsesDelivered) - Assertions.assertEquals(AlarmType.NONE, response.alarmType) - Assertions.assertEquals(0.toShort(), response.alarmTime) - Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(405.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertFalse(response.occlusionAlarm) - Assertions.assertFalse(response.pulseInfoInvalid) - Assertions.assertEquals(PodStatus.UNINITIALIZED, response.podStatusWhenAlarmOccurred) - Assertions.assertFalse(response.immediateBolusWhenAlarmOccurred) - Assertions.assertEquals(0x00.toByte(), response.occlusionType) - Assertions.assertFalse(response.occurredWhenFetchingImmediateBolusActiveInformation) - Assertions.assertEquals(0.toShort(), response.rssi) - Assertions.assertEquals(0.toShort(), response.receiverLowerGain) - Assertions.assertEquals(PodStatus.UNINITIALIZED, response.podStatusWhenAlarmOccurred2) - Assertions.assertEquals(26378.toShort(), response.returnAddressOfPodAlarmHandlerCaller) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.ADDITIONAL_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.ADDITIONAL_STATUS_RESPONSE.value) + assertThat(response.statusResponseType).isEqualTo(ResponseType.StatusResponseType.ALARM_STATUS) + assertThat(response.additionalStatusResponseType).isEqualTo(ResponseType.StatusResponseType.ALARM_STATUS.value) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE) + assertThat(response.bolusPulsesRemaining).isEqualTo(0.toShort()) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(5.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(445.toShort()) + assertThat(response.alarmType).isEqualTo(AlarmType.NONE) + assertThat(response.alarmTime).isEqualTo(0.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort()) + assertThat(response.minutesSinceActivation).isEqualTo(405.toShort()) + assertThat(response.activeAlerts.size).isEqualTo(0) + assertThat(response.occlusionAlarm).isFalse() + assertThat(response.pulseInfoInvalid).isFalse() + assertThat(response.podStatusWhenAlarmOccurred).isEqualTo(PodStatus.UNINITIALIZED) + assertThat(response.immediateBolusWhenAlarmOccurred).isFalse() + assertThat(response.occlusionType).isEqualTo(0x00.toByte()) + assertThat(response.occurredWhenFetchingImmediateBolusActiveInformation).isFalse() + assertThat(response.rssi).isEqualTo(0.toShort()) + assertThat(response.receiverLowerGain).isEqualTo(0.toShort()) + assertThat(response.podStatusWhenAlarmOccurred2).isEqualTo(PodStatus.UNINITIALIZED) + assertThat(response.returnAddressOfPodAlarmHandlerCaller).isEqualTo(26378.toShort()) } } From 6785f1a11dfeef017181003dba6a9fff1f90d5f5 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:25:32 -0700 Subject: [PATCH 106/127] Rewrites DefaultStatusResponseTest with matchers Issue #2745 --- .../pod/response/DefaultStatusResponseTest.kt | 154 +++++++++--------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt index 9d847eefe6..200567566c 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt @@ -1,30 +1,30 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class DefaultStatusResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("1D1800A02800000463FF") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus) - Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(320.toShort(), response.totalPulsesDelivered) - Assertions.assertEquals(5.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(0.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertEquals(280.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()) + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME) + assertThat(response.totalPulsesDelivered).isEqualTo(320.toShort()) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(5.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(0.toShort()) + assertThat(response.activeAlerts).isEmpty() + assertThat(response.minutesSinceActivation).isEqualTo(280.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort()) } /** @@ -49,21 +49,21 @@ class DefaultStatusResponseTest { Alert 7 is InActive Occlusion alert active false */ - @Test @Throws(DecoderException::class) fun testValidResponseBelowMin() { + @Test fun testValidResponseBelowMin() { val encoded = Hex.decodeHex("1D1905281000004387D3039A") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus) - Assertions.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(2.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(0.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertEquals(4321.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(979.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(2640.toShort(), response.totalPulsesDelivered) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_BELOW_MIN_VOLUME) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(2.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(0.toShort()) + assertThat(response.activeAlerts).isEmpty() + assertThat(response.minutesSinceActivation).isEqualTo(4321.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(979.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(2640.toShort()) } /** @@ -88,21 +88,21 @@ class DefaultStatusResponseTest { Alert 7 is InActive Occlusion alert active false */ - @Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining() { + @Test fun testValidResponseBolusPulsesRemaining() { val encoded = Hex.decodeHex("1D180519C00E0039A7FF8085") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.deliveryStatus) - Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(8.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(14.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertEquals(3689.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(2611.toShort(), response.totalPulsesDelivered) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.BASAL_ACTIVE) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(8.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(14.toShort()) + assertThat(response.activeAlerts).isEmpty() + assertThat(response.minutesSinceActivation).isEqualTo(3689.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(2611.toShort()) } /** response (hex) 1D990714201F0042ED8801DE @@ -118,21 +118,21 @@ class DefaultStatusResponseTest { Full reservoir pulses remaining: 392 Time since activation: 4283 */ - @Test @Throws(DecoderException::class) fun testValidResponseReservoirPulsesRemaining() { + @Test fun testValidResponseReservoirPulsesRemaining() { val encoded = Hex.decodeHex("1D990714201F0042ED8801DE") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.UNKNOWN, response.deliveryStatus) // Extended bolus active - Assertions.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(4.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(31.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) - Assertions.assertEquals(4283.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(392.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(3624.toShort(), response.totalPulsesDelivered) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.UNKNOWN) // Extended bolus active + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_BELOW_MIN_VOLUME) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(4.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(31.toShort()) + assertThat(response.activeAlerts).isEmpty() + assertThat(response.minutesSinceActivation).isEqualTo(4283.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(392.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(3624.toShort()) } /** response (hex) 1d68002601f400002bff0368 @@ -148,13 +148,13 @@ class DefaultStatusResponseTest { Full reservoir pulses remaining: 392 Time since activation: 4283 */ - @Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining3() { + @Test fun testValidResponseBolusPulsesRemaining3() { val encoded = Hex.decodeHex("1d68002601f400002bff0368") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(500.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.bolusPulsesRemaining).isEqualTo(500.toShort()) + assertThat(response.activeAlerts).isEmpty() } /** response (hex) 1d28002e91e400002fff8256 @@ -170,13 +170,13 @@ class DefaultStatusResponseTest { Full reservoir pulses remaining: 392 Time since activation: 4283 */ - @Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining4() { + @Test fun testValidResponseBolusPulsesRemaining4() { val encoded = Hex.decodeHex("1d28002e91e400002fff8256") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(484.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(0, response.activeAlerts.size) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.bolusPulsesRemaining).isEqualTo(484.toShort()) + assertThat(response.activeAlerts).isEmpty() } /* @@ -200,21 +200,21 @@ class DefaultStatusResponseTest { Alert 7 is Active Occlusion alert active false */ - @Test @Throws(DecoderException::class) fun testValidResponseActiveAlert1() { + @Test fun testValidResponseActiveAlert1() { val encoded = Hex.decodeHex("1D980559C820404393FF83AA") val response = DefaultStatusResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.messageType) - Assertions.assertEquals(DeliveryStatus.UNKNOWN, response.deliveryStatus) - Assertions.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(9.toShort(), response.sequenceNumberOfLastProgrammingCommand) - Assertions.assertEquals(32.toShort(), response.bolusPulsesRemaining) - Assertions.assertEquals(1, response.activeAlerts.size) - Assertions.assertEquals(4324.toShort(), response.minutesSinceActivation) - Assertions.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) - Assertions.assertEquals(2739.toShort(), response.totalPulsesDelivered) - Assertions.assertEquals(true, response.activeAlerts.contains(AlertType.EXPIRATION)) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.DEFAULT_STATUS_RESPONSE.value) + assertThat(response.deliveryStatus).isEqualTo(DeliveryStatus.UNKNOWN) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_ABOVE_MIN_VOLUME) + assertThat(response.sequenceNumberOfLastProgrammingCommand).isEqualTo(9.toShort()) + assertThat(response.bolusPulsesRemaining).isEqualTo(32.toShort()) + assertThat(response.activeAlerts).hasSize(1) + assertThat(response.minutesSinceActivation).isEqualTo(4324.toShort()) + assertThat(response.reservoirPulsesRemaining).isEqualTo(1023.toShort()) + assertThat(response.totalPulsesDelivered).isEqualTo(2739.toShort()) + assertThat(response.activeAlerts.contains(AlertType.EXPIRATION)).isTrue() } } From 25112828a2065bf42f6242de8620d8375d012ee8 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:26:44 -0700 Subject: [PATCH 107/127] Rewrites NakResponseTest with matchers Issue #2745 --- .../driver/pod/response/NakResponseTest.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt index 86e2d7e28e..53c19b63fa 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt @@ -1,26 +1,26 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.NakErrorType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class NakResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("0603070009") val response = NakResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.NAK_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.NAK_RESPONSE.value, response.messageType) - Assertions.assertEquals(NakErrorType.ILLEGAL_PARAM, response.nakErrorType) - Assertions.assertEquals(AlarmType.NONE, response.alarmType) - Assertions.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus) - Assertions.assertEquals(0x00.toShort(), response.securityNakSyncCount) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.NAK_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.NAK_RESPONSE.value) + assertThat(response.nakErrorType).isEqualTo(NakErrorType.ILLEGAL_PARAM) + assertThat(response.alarmType).isEqualTo(AlarmType.NONE) + assertThat(response.podStatus).isEqualTo(PodStatus.RUNNING_BELOW_MIN_VOLUME) + assertThat(response.securityNakSyncCount).isEqualTo(0x00.toShort()) } } From 18cf56e2678f1bcf1f857cb6983f62a0fad9da80 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:31:11 -0700 Subject: [PATCH 108/127] Rewrites SetUniqueIdResponseTest with matchers Issue #2745 --- .../pod/response/SetUniqueIdResponseTest.kt | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt index 10460252df..99015de4f7 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt @@ -1,39 +1,39 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class SetUniqueIdResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("011B13881008340A50040A00010300040308146CC1000954D402420001") val response = SetUniqueIdResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, response.activationResponseType) - Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.messageType) - Assertions.assertEquals(27.toShort(), response.messageLength) - Assertions.assertEquals(5000.toShort(), response.pulseVolumeInTenThousandthMicroLiter) - Assertions.assertEquals(16.toShort(), response.pumpRate) - Assertions.assertEquals(8.toShort(), response.primePumpRate) - Assertions.assertEquals(52.toShort(), response.numberOfEngagingClutchDrivePulses) - Assertions.assertEquals(10.toShort(), response.numberOfPrimePulses) - Assertions.assertEquals(80.toShort(), response.podExpirationTimeInHours) - Assertions.assertEquals(4.toShort(), response.firmwareVersionMajor) - Assertions.assertEquals(10.toShort(), response.firmwareVersionMinor) - Assertions.assertEquals(0.toShort(), response.firmwareVersionInterim) - Assertions.assertEquals(1.toShort(), response.bleVersionMajor) - Assertions.assertEquals(3.toShort(), response.bleVersionMinor) - Assertions.assertEquals(0.toShort(), response.bleVersionInterim) - Assertions.assertEquals(4.toShort(), response.productId) - Assertions.assertEquals(PodStatus.UID_SET, response.podStatus) - Assertions.assertEquals(135556289L, response.lotNumber) - Assertions.assertEquals(611540L, response.podSequenceNumber) - Assertions.assertEquals(37879809L, response.uniqueIdReceivedInCommand) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.ACTIVATION_RESPONSE) + assertThat(response.activationResponseType).isEqualTo(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.ACTIVATION_RESPONSE.value) + assertThat(response.messageLength).isEqualTo(27.toShort()) + assertThat(response.pulseVolumeInTenThousandthMicroLiter).isEqualTo(5000.toShort()) + assertThat(response.pumpRate).isEqualTo(16.toShort()) + assertThat(response.primePumpRate).isEqualTo(8.toShort()) + assertThat(response.numberOfEngagingClutchDrivePulses).isEqualTo(52.toShort()) + assertThat(response.numberOfPrimePulses).isEqualTo(10.toShort()) + assertThat(response.podExpirationTimeInHours).isEqualTo(80.toShort()) + assertThat(response.firmwareVersionMajor).isEqualTo(4.toShort()) + assertThat(response.firmwareVersionMinor).isEqualTo(10.toShort()) + assertThat(response.firmwareVersionInterim).isEqualTo(0.toShort()) + assertThat(response.bleVersionMajor).isEqualTo(1.toShort()) + assertThat(response.bleVersionMinor).isEqualTo(3.toShort()) + assertThat(response.bleVersionInterim).isEqualTo(0.toShort()) + assertThat(response.productId).isEqualTo(4.toShort()) + assertThat(response.podStatus).isEqualTo(PodStatus.UID_SET) + assertThat(response.lotNumber).isEqualTo(135556289L) + assertThat(response.podSequenceNumber).isEqualTo(611540L) + assertThat(response.uniqueIdReceivedInCommand).isEqualTo(37879809L) } } From f85953694bef442ad70db8e5e54214a19fc3bc02 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:32:56 -0700 Subject: [PATCH 109/127] Rewrites VersionResponseTest with matchers Issue #2745 --- .../pod/response/VersionResponseTest.kt | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt index 7cc313a5bc..aa79c8afd9 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt @@ -1,35 +1,35 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class VersionResponseTest { - @Test @Throws(DecoderException::class) fun testValidResponse() { + @Test fun testValidResponse() { val encoded = Hex.decodeHex("0115040A00010300040208146CC1000954D400FFFFFFFF") val response = VersionResponse(encoded) - Assertions.assertArrayEquals(encoded, response.encoded) - Assertions.assertNotSame(encoded, response.encoded) - Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType) - Assertions.assertEquals(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE, response.activationResponseType) - Assertions.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.messageType) - Assertions.assertEquals(21.toShort(), response.messageLength) - Assertions.assertEquals(4.toShort(), response.firmwareVersionMajor) - Assertions.assertEquals(10.toShort(), response.firmwareVersionMinor) - Assertions.assertEquals(0.toShort(), response.firmwareVersionInterim) - Assertions.assertEquals(1.toShort(), response.bleVersionMajor) - Assertions.assertEquals(3.toShort(), response.bleVersionMinor) - Assertions.assertEquals(0.toShort(), response.bleVersionInterim) - Assertions.assertEquals(4.toShort(), response.productId) - Assertions.assertEquals(PodStatus.FILLED, response.podStatus) - Assertions.assertEquals(135556289L, response.lotNumber) - Assertions.assertEquals(611540L, response.podSequenceNumber) - Assertions.assertEquals(0.toByte(), response.rssi) - Assertions.assertEquals(0.toByte(), response.receiverLowerGain) - Assertions.assertEquals(4294967295L, response.uniqueIdReceivedInCommand) + assertThat(response.encoded).asList().containsExactlyElementsIn(encoded.asList()).inOrder() + assertThat(response.encoded).isNotSameInstanceAs(encoded) + assertThat(response.responseType).isEqualTo(ResponseType.ACTIVATION_RESPONSE) + assertThat(response.activationResponseType).isEqualTo(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE) + assertThat(response.messageType).isEqualTo(ResponseType.ACTIVATION_RESPONSE.value) + assertThat(response.messageLength).isEqualTo(21.toShort()) + assertThat(response.firmwareVersionMajor).isEqualTo(4.toShort()) + assertThat(response.firmwareVersionMinor).isEqualTo(10.toShort()) + assertThat(response.firmwareVersionInterim).isEqualTo(0.toShort()) + assertThat(response.bleVersionMajor).isEqualTo(1.toShort()) + assertThat(response.bleVersionMinor).isEqualTo(3.toShort()) + assertThat(response.bleVersionInterim).isEqualTo(0.toShort()) + assertThat(response.productId).isEqualTo(4.toShort()) + assertThat(response.podStatus).isEqualTo(PodStatus.FILLED) + assertThat(response.lotNumber).isEqualTo(135556289L) + assertThat(response.podSequenceNumber).isEqualTo(611540L) + assertThat(response.rssi).isEqualTo(0.toByte()) + assertThat(response.receiverLowerGain).isEqualTo(0.toByte()) + assertThat(response.uniqueIdReceivedInCommand).isEqualTo(4294967295L) } } From 3566c64ca891e2385997fdc779e2d5da77d5a81d Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:36:46 -0700 Subject: [PATCH 110/127] Rewrites GetStatusCommandTest with matchers Issue #2745 --- .../dash/driver/pod/command/GetStatusCommandTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt index d149f51161..33195bfa8b 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class GetStatusCommandTest { - @Test @Throws(DecoderException::class) fun testGetDefaultStatusResponse() { + @Test fun testGetDefaultStatusResponse() { val encoded = GetStatusCommand.Builder() .setUniqueId(37879810) .setSequenceNumber(15.toShort()) @@ -16,6 +15,6 @@ class GetStatusCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("024200023C030E0100024C"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200023C030E0100024C").asList()).inOrder() } } From d44367a17049874488975e65fe0901a1dea483a2 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:42:55 -0700 Subject: [PATCH 111/127] Rewrites DeactivateCommandTest with matchers Issue #2745 --- .../dash/driver/pod/command/DeactivateCommandTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt index 1c74df813f..db10dc0d41 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt @@ -1,13 +1,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command -import org.apache.commons.codec.DecoderException +import com.google.common.truth.Truth.assertThat import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class DeactivateCommandTest { - @Test @Throws(DecoderException::class) fun testEncoding() { + @Test fun testEncoding() { val encoded = DeactivateCommand.Builder() .setUniqueId(37879809) .setSequenceNumber(5.toShort()) @@ -15,6 +14,6 @@ class DeactivateCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000114061C04494E532E001C"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000114061C04494E532E001C").asList()).inOrder() } } From 77964df4aeb0097991fa4243dee4f166170c8bfd Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:43:09 -0700 Subject: [PATCH 112/127] Rewrites GetVersionCommandTest with matchers Issue #2745 --- .../dash/driver/pod/command/GetVersionCommandTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt index d3f66e68c0..dd7ab87763 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt @@ -1,19 +1,18 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command -import org.apache.commons.codec.DecoderException +import com.google.common.truth.Truth.assertThat import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class GetVersionCommandTest { - @Test @Throws(DecoderException::class) fun testEncoding() { + @Test fun testEncoding() { val encoded = GetVersionCommand.Builder() .setSequenceNumber(0.toShort()) .setUniqueId(GetVersionCommand.DEFAULT_UNIQUE_ID) .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2").asList()).inOrder() } } From 9840cf81c878a8ca3e4aaf9792d6020cd6623ef9 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:49:20 -0700 Subject: [PATCH 113/127] Rewrites ProgramBasalCommandTest with matchers Issue #2745 --- .../pod/command/ProgramBasalCommandTest.kt | 44 +++++-------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt index b988e45e4f..09c6feaade 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt @@ -1,17 +1,16 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import java.util.Date @Suppress("DEPRECATION") class ProgramBasalCommandTest { - @Test @Throws(DecoderException::class) fun testProgramBasalCommand() { + @Test fun testProgramBasalCommand() { val segments = listOf( BasalProgram.Segment(0.toShort(), 48.toShort(), 300) ) @@ -28,13 +27,10 @@ class ProgramBasalCommandTest { .build() .encoded - Assertions.assertArrayEquals( - Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C"), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testProgramBasalCommandWithExtraAlternateSegmentPulse() { + @Test fun testProgramBasalCommandWithExtraAlternateSegmentPulse() { val segments = listOf( BasalProgram.Segment(0.toShort(), 48.toShort(), 5) ) @@ -51,13 +47,10 @@ class ProgramBasalCommandTest { .build() .encoded - Assertions.assertArrayEquals( - Hex.decodeHex("0000109130241a12494e532e0000c52e0f700000f800f800f800130e0000000707fcad8000f015752a00033b"), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0000109130241a12494e532e0000c52e0f700000f800f800f800130e0000000707fcad8000f015752a00033b").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testProgramBasalCommandAllSegments() { + @Test fun testProgramBasalCommandAllSegments() { val segments = mutableListOf() for (segment in 0..23) { val rate = when (segment) { @@ -95,15 +88,10 @@ class ProgramBasalCommandTest { val expected = "0000000508C41A28494E532E00018B16273000032000300130023003300430053006300730083009200A100B100C180D1398400B005E009E22E80002EB49D200000A15752A0000140ABA9500001E07270E000028055D4A800032044AA200003C0393870000460310BCDB005002AEA540005A02625A00006402255100006E01F360E8007801C9C380008201A68D13008C01885E6D0096016E360000A0015752A000AA0143209600B401312D0000BE01211D2800C80112A88000DC00F9B07400F000E4E1C0010E00CB73558158".lowercase() - Assertions.assertArrayEquals( - Hex.decodeHex( - expected - ), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex(expected).asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testProgramBasalCommandHighRates() { + @Test fun testProgramBasalCommandHighRates() { val segments = listOf( BasalProgram.Segment(0.toShort(), 2.toShort(), 300), BasalProgram.Segment(2.toShort(), 4.toShort(), 290), @@ -140,15 +128,10 @@ class ProgramBasalCommandTest { val expected = "000000051C981A2C494E532E00046D162178000B101E101D101C101B101A301938173816101458123810380E300D180B100A180613684008013F008954400258005B8D800244005EB5B002300062179B021C0065B9AA02080069A34403E8006DDD0003AC0074E0360384007A12000190008954400456009476C1029400A675A2024400BD6B61020800D3468900E600EED54D00C80112A880008201A68D13809b" - Assertions.assertArrayEquals( - Hex.decodeHex( - expected - ), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex(expected).asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testProgramBasalCommandDifferentInterval() { + @Test fun testProgramBasalCommandDifferentInterval() { val segments = listOf( BasalProgram.Segment(0.toShort(), 2.toShort(), 50), BasalProgram.Segment(2.toShort(), 6.toShort(), 75), @@ -177,11 +160,6 @@ class ProgramBasalCommandTest { val expected = "0000000528581A1C494E532E00038E161E50000E100538075000780DB01B701D58091801133840040A100032DC82006402255100012C016E36000006EB49D200043800CB73550CA80065B9AA0910005EB5B0023A01211D28001E07270E000065" - Assertions.assertArrayEquals( - Hex.decodeHex( - expected - ), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex(expected).asList()).inOrder() } } From f111f7f0918ba987bd9c12cd0f4ebbf040786c22 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:49:30 -0700 Subject: [PATCH 114/127] Rewrites ProgramAlertsCommandTest with matchers Issue #2745 --- .../pod/command/ProgramAlertsCommandTest.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt index 2497e8c74b..c77469c636 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt @@ -1,18 +1,17 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTrigger import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ProgramAlertsCommandTest { - @Test @Throws(DecoderException::class) fun testExpirationAlerts() { + @Test fun testExpirationAlerts() { val configurations: MutableList = ArrayList() configurations.add( AlertConfiguration( @@ -46,10 +45,10 @@ class ProgramAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testLowReservoirAlert() { + @Test fun testLowReservoirAlert() { val configurations: MutableList = ArrayList() configurations.add( AlertConfiguration( @@ -71,10 +70,10 @@ class ProgramAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testUserExpirationAlert() { + @Test fun testUserExpirationAlert() { val configurations: MutableList = ArrayList() configurations.add( AlertConfiguration( @@ -96,10 +95,10 @@ class ProgramAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testLumpOfCoalAlert() { + @Test fun testLumpOfCoalAlert() { val configurations: MutableList = ArrayList() configurations.add( AlertConfiguration( @@ -122,6 +121,6 @@ class ProgramAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("02420003280C190A494E532E7837000508020356"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("02420003280C190A494E532E7837000508020356").asList()).inOrder() } } From 2929fd957f932ea39656073e516a142c8db81062 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 20:50:28 -0700 Subject: [PATCH 115/127] Rewrites ProgramBeepsCommandTest with matchers Issue #2745 --- .../dash/driver/pod/command/ProgramBeepsCommandTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt index 6695c10155..9bc59e20bc 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt @@ -1,15 +1,14 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ProgramBeepsCommandTest { - @Test @Throws(DecoderException::class) fun testPlayTestBeep() { + @Test fun testPlayTestBeep() { val encoded = ProgramBeepsCommand.Builder() .setUniqueId(37879810) .setSequenceNumber(11.toShort()) @@ -20,6 +19,6 @@ class ProgramBeepsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("024200022C061E0402000000800F"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200022C061E0402000000800F").asList()).inOrder() } } From 249106cf6af151a49068e726173623ba2833b7dc Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 21:00:32 -0700 Subject: [PATCH 116/127] Rewrites ProgramBolusCommandTest with matchers Issue #2745 --- .../dash/driver/pod/command/ProgramBolusCommandTest.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt index 2bca8a864b..16d1268792 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ProgramBolusCommandTest { - @Test @Throws(DecoderException::class) fun testProgramBolusCommand() { + @Test fun testProgramBolusCommand() { val encoded = ProgramBolusCommand.Builder() .setNumberOfUnits(5.0) .setProgramReminder(ProgramReminder(false, true, 0.toByte())) @@ -19,9 +18,6 @@ class ProgramBolusCommandTest { .build() .encoded - Assertions.assertArrayEquals( - Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6"), - encoded - ) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6").asList()).inOrder() } } From a4fb17e53c7d7bdeec426cf69fcadb0cf7da2f5a Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 21:00:39 -0700 Subject: [PATCH 117/127] Rewrites ProgramTempBasalCommandTest with matchers Issue #2745 --- .../command/ProgramTempBasalCommandTest.kt | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt index a5222f611f..c0e9593c1a 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt @@ -1,14 +1,14 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class ProgramTempBasalCommandTest { - @Test @Throws(DecoderException::class) fun testExtraAlternateSegmentPulseTempBasal() { + @Test fun testExtraAlternateSegmentPulseTempBasal() { val command = ProgramTempBasalCommand.Builder() .setUniqueId(37879809) .setNonce(1229869870) @@ -18,13 +18,10 @@ class ProgramTempBasalCommandTest { .setProgramReminder(ProgramReminder(atStart = false, atEnd = true, atInterval = 0.toByte())) .build() - Assertions.assertArrayEquals( - Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6"), - command.encoded - ) + assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testZeroTempBasal() { + @Test fun testZeroTempBasal() { val command = ProgramTempBasalCommand.Builder() .setUniqueId(37879809) .setNonce(1229869870) @@ -34,13 +31,10 @@ class ProgramTempBasalCommandTest { .setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte())) .build() - Assertions.assertArrayEquals( - Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000A6B49D20001E3"), - command.encoded - ) + assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000A6B49D20001E3").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testZeroTempBasalShort() { + @Test fun testZeroTempBasalShort() { val command = ProgramTempBasalCommand.Builder() .setUniqueId(37879809) .setNonce(1229869870) @@ -50,13 +44,10 @@ class ProgramTempBasalCommandTest { .setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte())) .build() - Assertions.assertArrayEquals( - Hex.decodeHex("024200011C201A0E494E532E01007901384000000000160EC00000016B49D2000001EB49D200815B"), - command.encoded - ) + assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200011C201A0E494E532E01007901384000000000160EC00000016B49D2000001EB49D200815B").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testZeroTempBasalVeryLong() { + @Test fun testZeroTempBasalVeryLong() { val command = ProgramTempBasalCommand.Builder() .setUniqueId(37879809) .setNonce(1229869870) @@ -66,9 +57,6 @@ class ProgramTempBasalCommandTest { .setProgramReminder(ProgramReminder(atStart = true, atEnd = true, atInterval = 0.toByte())) .build() - Assertions.assertArrayEquals( - Hex.decodeHex("024200011C221A10494E532E0100901838400000F0007000160EC00000186B49D20000186B49D2000132"), - command.encoded - ) + assertThat(command.encoded).asList().containsExactlyElementsIn(Hex.decodeHex("024200011C221A10494E532E0100901838400000F0007000160EC00000186B49D20000186B49D2000132").asList()).inOrder() } } From 124e27b449ebba80750593daebd937ac325a2111 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 21:00:44 -0700 Subject: [PATCH 118/127] Rewrites SetUniqueIdCommandTest with matchers Issue #2745 --- .../dash/driver/pod/command/SetUniqueIdCommandTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt index b47b52aa41..1dbdfbc75d 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command -import org.apache.commons.codec.DecoderException +import com.google.common.truth.Truth.assertThat import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import java.util.Date class SetUniqueIdCommandTest { - @Test @Throws(DecoderException::class) fun testEncoding() { + @Test fun testEncoding() { @Suppress("DEPRECATION") val encoded = SetUniqueIdCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(6.toShort()) @@ -18,6 +17,6 @@ class SetUniqueIdCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344").asList()).inOrder() } } From 1d3c697caa001b06401f3d2595cd4c78cfab3084 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 21:00:48 -0700 Subject: [PATCH 119/127] Rewrites SilenceAlertsCommandTest with matchers Issue #2745 --- .../dash/driver/pod/command/SilenceAlertsCommandTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt index 64884e99dc..8360adddba 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt @@ -1,15 +1,14 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import java.util.EnumSet class SilenceAlertsCommandTest { - @Test @Throws(DecoderException::class) fun testSilenceLowReservoirAlert() { + @Test fun testSilenceLowReservoirAlert() { val encoded = SilenceAlertsCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(1.toShort()) @@ -18,7 +17,7 @@ class SilenceAlertsCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000304071105494E532E1081CE"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000304071105494E532E1081CE").asList()).inOrder() } // TODO capture more silence alerts commands From 5139242bc144437cfc03609af3f711fedcc77c27 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 21:00:52 -0700 Subject: [PATCH 120/127] Rewrites StopDeliveryCommandTest with matchers Issue #2745 --- .../driver/pod/command/StopDeliveryCommandTest.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt index e0dac98b34..01ce8b0000 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class StopDeliveryCommandTest { - @Test @Throws(DecoderException::class) fun testStopTempBasal() { + @Test fun testStopTempBasal() { val encoded = StopDeliveryCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(0.toShort()) @@ -18,10 +17,10 @@ class StopDeliveryCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000300071F05494E532E6201B1"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000300071F05494E532E6201B1").asList()).inOrder() } - @Test @Throws(DecoderException::class) fun testSuspendDelivery() { + @Test fun testSuspendDelivery() { val encoded = StopDeliveryCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(2.toShort()) @@ -31,7 +30,7 @@ class StopDeliveryCommandTest { .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000308071F05494E532E078287"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000308071F05494E532E078287").asList()).inOrder() } // TODO test cancel bolus From f26aba03e5f73dd44de602ebda66e4ef8c367769 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 21:00:56 -0700 Subject: [PATCH 121/127] Rewrites SuspendDeliveryCommandTest with matchers Issue #2745 --- .../dash/driver/pod/command/SuspendDeliveryCommandTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommandTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommandTest.kt index ba53dc84b2..8787f2a0f1 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommandTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SuspendDeliveryCommandTest.kt @@ -1,14 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType -import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class SuspendDeliveryCommandTest { - @Test @Throws(DecoderException::class) fun testSuspendDelivery() { + @Test fun testSuspendDelivery() { val encoded = SuspendDeliveryCommand.Builder() .setUniqueId(37879811) .setSequenceNumber(0.toShort()) @@ -16,6 +15,6 @@ class SuspendDeliveryCommandTest { .setBeepType(BeepType.LONG_SINGLE_BEEP) .build() .encoded - Assertions.assertArrayEquals(Hex.decodeHex("0242000300131f05494e532e67190a494e532e680000140302811f"), encoded) + assertThat(encoded).asList().containsExactlyElementsIn(Hex.decodeHex("0242000300131f05494e532e67190a494e532e680000140302811f").asList()).inOrder() } } From e7455366ed41660164977772f685cc3683480405 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 08:21:37 +0000 Subject: [PATCH 122/127] chore(deps): bump org.mockito:mockito-junit-jupiter from 5.5.0 to 5.6.0 Bumps [org.mockito:mockito-junit-jupiter](https://github.com/mockito/mockito) from 5.5.0 to 5.6.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.5.0...v5.6.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-junit-jupiter dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d01c614d33..062178e7fd 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ buildscript { junit_version = '4.13.2' junit_jupiter_version = '5.10.0' - mockito_version = '5.5.0' + mockito_version = '5.6.0' dexmaker_version = '1.2' retrofit2_version = '2.9.0' okhttp3_version = '4.11.0' From 5e6b74cc37f59334cb70a5f27c195d986d58a9b0 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 9 Oct 2023 13:00:57 +0200 Subject: [PATCH 123/127] New Crowdin updates (#2879) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations exam.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Romanian) * New translations strings.xml (French) * New translations strings.xml (Spanish) * New translations strings.xml (Bulgarian) * New translations strings.xml (Catalan) * New translations strings.xml (Czech) * New translations strings.xml (Danish) * New translations strings.xml (German) * New translations strings.xml (Greek) * New translations strings.xml (Hebrew) * New translations strings.xml (Hungarian) * New translations strings.xml (Italian) * New translations strings.xml (Korean) * New translations strings.xml (Lithuanian) * New translations strings.xml (Dutch) * New translations strings.xml (Polish) * New translations strings.xml (Portuguese) * New translations strings.xml (Russian) * New translations strings.xml (Slovak) * New translations strings.xml (Swedish) * New translations strings.xml (Turkish) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Portuguese, Brazilian) * New translations strings.xml (Croatian) * New translations strings.xml (Norwegian Bokmal) * Update source file strings.xml --- core/ui/src/main/res/values-nb-rNO/strings.xml | 8 ++++---- .../src/main/res/values-nb-rNO/exam.xml | 6 +++--- .../main/src/main/res/values-nb-rNO/strings.xml | 16 ++++++++-------- wear/src/main/res/values-bg-rBG/strings.xml | 5 ----- wear/src/main/res/values-ca-rES/strings.xml | 3 --- wear/src/main/res/values-cs-rCZ/strings.xml | 5 ----- wear/src/main/res/values-da-rDK/strings.xml | 5 ----- wear/src/main/res/values-de-rDE/strings.xml | 5 ----- wear/src/main/res/values-el-rGR/strings.xml | 5 ----- wear/src/main/res/values-es-rES/strings.xml | 5 ----- wear/src/main/res/values-fr-rFR/strings.xml | 5 ----- wear/src/main/res/values-hr-rHR/strings.xml | 3 --- wear/src/main/res/values-hu-rHU/strings.xml | 2 -- wear/src/main/res/values-it-rIT/strings.xml | 5 ----- wear/src/main/res/values-iw-rIL/strings.xml | 5 ----- wear/src/main/res/values-ko-rKR/strings.xml | 5 ----- wear/src/main/res/values-lt-rLT/strings.xml | 5 ----- wear/src/main/res/values-nb-rNO/strings.xml | 7 +------ wear/src/main/res/values-nl-rNL/strings.xml | 5 ----- wear/src/main/res/values-pl-rPL/strings.xml | 5 ----- wear/src/main/res/values-pt-rBR/strings.xml | 5 ----- wear/src/main/res/values-pt-rPT/strings.xml | 5 ----- wear/src/main/res/values-ro-rRO/strings.xml | 5 ----- wear/src/main/res/values-ru-rRU/strings.xml | 5 ----- wear/src/main/res/values-sk-rSK/strings.xml | 5 ----- wear/src/main/res/values-sv-rSE/strings.xml | 5 ----- wear/src/main/res/values-tr-rTR/strings.xml | 5 ----- wear/src/main/res/values-zh-rCN/strings.xml | 3 --- 28 files changed, 16 insertions(+), 132 deletions(-) diff --git a/core/ui/src/main/res/values-nb-rNO/strings.xml b/core/ui/src/main/res/values-nb-rNO/strings.xml index 5c7ae8153d..bf26537a71 100644 --- a/core/ui/src/main/res/values-nb-rNO/strings.xml +++ b/core/ui/src/main/res/values-nb-rNO/strings.xml @@ -61,7 +61,7 @@ Opplæringsmål Vennligst vent… Stopp - Karbo + Karbohydrater Ugyldig profil! INGEN PROFIL VALGT ]]> @@ -73,7 +73,7 @@ Basal Målverdi Insulinets virkningstid (DIA) - Insulin- til karbohydratfaktor + Insulin-karbohydratfaktor (IK) Insulin sensitivitetsfaktor (ISF) Basalrate Blodsukkermål @@ -146,7 +146,7 @@ Er du sikker på at du vil fjerne %1$d elementer Behandling Opprett ny profil fra denne profilen? - Innstillinger for veiviser + Innstillinger for boluskalkulator 15 min trend COB Bolus IOB @@ -223,7 +223,7 @@ Midlertidig BS-mål Midlertidig målverdi Avbryt midl. mål - Bolusassistent + Boluskalkulator Finger Sensor Manuell diff --git a/plugins/constraints/src/main/res/values-nb-rNO/exam.xml b/plugins/constraints/src/main/res/values-nb-rNO/exam.xml index 21bb5132ca..8da0332af8 100644 --- a/plugins/constraints/src/main/res/values-nb-rNO/exam.xml +++ b/plugins/constraints/src/main/res/values-nb-rNO/exam.xml @@ -190,20 +190,20 @@ IK vil være forskjellig hvis du regner en skive brød som 10g eller 12g. IK faktor betyr: Hvor mange brødenheter som dekkes av 1E insulin? https://wiki.aaps.app/en/latest/Getting-Started/FAQ.html#insulin-to-carb-ratio-ic-g-u - Profil bytte + Profilbytte Når du spesifiserer et profilbytte på 90%, hvilke svar er korrekte? Basaldoser vil være 10% lavere. ISF verdien vil være 10% høyere. Verdien av KH ratio vil være 10 % lavere. ISF og KH ratio er uendret. https://wiki.aaps.app/en/latest/Usage/Profiles.html#profile-switch - Profil bytte + Profilbytte Når du spesifiserer et profilbytte på 120%, hvilke svar er korrekte? Blodsukkermålet vil være 20% høyere. Basaldoser vil være 20% høyere. Blodsukkermålet vil være uforandret. ISF vil være 20% høyere. - Profil bytte + Profilbytte Hvis du står opp 2 timer tidligere enn vanlig, hvordan forteller du AndroidAPS om endringen i døgnrytmen din? Gjør et profilbytte med en tidsforskyvning på 2 Gjør et profilbytte med en tidsforskyvning på -2 diff --git a/plugins/main/src/main/res/values-nb-rNO/strings.xml b/plugins/main/src/main/res/values-nb-rNO/strings.xml index 19baf4f493..c7afc82c6d 100644 --- a/plugins/main/src/main/res/values-nb-rNO/strings.xml +++ b/plugins/main/src/main/res/values-nb-rNO/strings.xml @@ -225,13 +225,13 @@ Andre økning hurtigknapp for karbohydrater Tredje økning hurtigknapp for karbohydrater CGM - Standard midl. mål - spise snart varighet - spise snart målverdi - varighet for aktivitet - målverdi ved aktivitet - hypo varighet - hypo målverdi + Standard midlertidig BS-mål + Spise snart varighet (min) + Spise snart målverdi + Aktivitet varighet (min) + Aktivitet målverdi + Hypo varighet (min) + Hypo målverdi Standardverdier for påfyll/prime Knapp 1 Knapp 2 @@ -307,7 +307,7 @@ Klokkeinnstillinger Kontroller fra klokke Sett midl. mål og angi behandlinger fra klokken. - Beregninger inkludert i resultatet fra veiviseren: + Beregninger inkludert i resultatet fra kalkulator: Generelle innstillinger Varsle ved SMB Vis SMB på klokken som en standard bolus. diff --git a/wear/src/main/res/values-bg-rBG/strings.xml b/wear/src/main/res/values-bg-rBG/strings.xml index 2f2e4b0ebb..eeca18334c 100644 --- a/wear/src/main/res/values-bg-rBG/strings.xml +++ b/wear/src/main/res/values-bg-rBG/strings.xml @@ -8,8 +8,6 @@ AAPS(без Графика) AAPS(Кръгъл) AAPS(v2) - AAPS(Самолет) - AAPS(Steampunk) AAPS (DigitalStyle) AAPS(Персонализиран) AAPS(Действия) @@ -53,7 +51,6 @@ Десничар Левичар Модерен - Делта грануларност (Steampunk) Ниска Средна Висока @@ -176,8 +173,6 @@ Няма налични данни Нарастване Намаляване - В - Н средно --Е --гр diff --git a/wear/src/main/res/values-ca-rES/strings.xml b/wear/src/main/res/values-ca-rES/strings.xml index 85a00336f7..bfe951dbce 100644 --- a/wear/src/main/res/values-ca-rES/strings.xml +++ b/wear/src/main/res/values-ca-rES/strings.xml @@ -7,8 +7,6 @@ AAPS(GrafGrossa) AAPS(NoGraf) AAPS(Cercle) - AAPS(Cockpit) - AAPS(Steampunk) AAPS(DigitalStyle) Cap dada! Dades antigues! @@ -44,7 +42,6 @@ Ràpid dreta Ràpid esquerra Dispers modern - Granularitat delta (Steampunk) Baix Mig Alt diff --git a/wear/src/main/res/values-cs-rCZ/strings.xml b/wear/src/main/res/values-cs-rCZ/strings.xml index d2103d8074..ff0f4e4dfb 100644 --- a/wear/src/main/res/values-cs-rCZ/strings.xml +++ b/wear/src/main/res/values-cs-rCZ/strings.xml @@ -8,8 +8,6 @@ AAPS(BezGrafu) AAPS(Kruhový) AAPS(v2) - AAPS(Kokpit) - AAPS (Steampunk) AAPS (DigitalStyle) AAPS (vlastní) AAPS(Akce) @@ -62,7 +60,6 @@ Rychle zprava Rychle zleva Modern Sparse - Míra podrobnosti delty (Steampunk) Nízká Střední Vysoká @@ -185,8 +182,6 @@ Žádná data k dispozici zvýšení snížení - V - N prům --U --g diff --git a/wear/src/main/res/values-da-rDK/strings.xml b/wear/src/main/res/values-da-rDK/strings.xml index 8b1d49d32e..3dc905dda5 100644 --- a/wear/src/main/res/values-da-rDK/strings.xml +++ b/wear/src/main/res/values-da-rDK/strings.xml @@ -8,8 +8,6 @@ AAPS(IngenGraf) AAPS(Cirkel) AAPS(v2) - AAPS(Cockpit) - AAPS(Steampunk) AAPS (DigitalStil) AAPS(Brugerdefineret) AAPS (Handlinger) @@ -60,7 +58,6 @@ Hurtigt højre Hurtig venstre Moderne spreder - Delta Granularitet (Steampunk) Lav Medium Høj @@ -183,8 +180,6 @@ Ingen data tilgængelig forøgelse formindskelse - H - L gns. --IE --g diff --git a/wear/src/main/res/values-de-rDE/strings.xml b/wear/src/main/res/values-de-rDE/strings.xml index 3e71e6e871..ea613f1c35 100644 --- a/wear/src/main/res/values-de-rDE/strings.xml +++ b/wear/src/main/res/values-de-rDE/strings.xml @@ -8,8 +8,6 @@ AAPS(KeinGraph) AAPS(Kreis) AAPS(v2) - AAPS(Cockpit) - AAPS(Steampunk) AAPS(DigitalStyle) AAPS(Custom) AAPS(Aktionen) @@ -53,7 +51,6 @@ Schnell rechts Schnell links Modern Sparse - Genauigkeit (Steampunk) Niedrig Mittel Hoch @@ -176,8 +173,6 @@ Keine Daten vorhanden erhöhen verringern - H - L Ø --IE --g diff --git a/wear/src/main/res/values-el-rGR/strings.xml b/wear/src/main/res/values-el-rGR/strings.xml index 95bc53a56d..52efac981f 100644 --- a/wear/src/main/res/values-el-rGR/strings.xml +++ b/wear/src/main/res/values-el-rGR/strings.xml @@ -8,8 +8,6 @@ AAPS(χωρίς_γράφημα) AAPS(Κυκλικό) AAPS(v2) - AAPS(Πιλοτήριο) - AAPS(Steampunk) AAPS(ψηφιακό) AAPS(προσαρμοσμένα_χαρακτηριστικά) AAPS( Ενέργειες) @@ -59,7 +57,6 @@ Γρήγορα δεξιά Γρήγορα αριστερά Σύγχρονο Sparse - Διαφορά Βαθμού Λεπτομέρειας (Steampunk) Χαμηλή Μέσο Υψηλό @@ -182,8 +179,6 @@ Δεν υπάρχουν διαθέσιμα δεδομένα αύξηση μείωση - H - L μέσος --U --g diff --git a/wear/src/main/res/values-es-rES/strings.xml b/wear/src/main/res/values-es-rES/strings.xml index 16d9723927..d7dd4c9ac3 100644 --- a/wear/src/main/res/values-es-rES/strings.xml +++ b/wear/src/main/res/values-es-rES/strings.xml @@ -8,8 +8,6 @@ AAPS (SinGráfico) AAPS (Círculo) AAPS(v2) - AAPS(Cockpit) - AAPS(Steampunk) AAPS (Digital) AAPS(personalizado) AAPS(Acciones) @@ -62,7 +60,6 @@ Rápido a la derecha Rápido a la izquierda Disperso moderno - Granularidad delta (Steampunk) Bajo Medio Alto @@ -185,8 +182,6 @@ No hay datos disponibles incremento decremento - A - B media --U --g diff --git a/wear/src/main/res/values-fr-rFR/strings.xml b/wear/src/main/res/values-fr-rFR/strings.xml index a06d81f46a..3c0669aac0 100644 --- a/wear/src/main/res/values-fr-rFR/strings.xml +++ b/wear/src/main/res/values-fr-rFR/strings.xml @@ -8,8 +8,6 @@ AAPS (SansGraph) AAPS (Cercle) AAPS (v2) - AAPS (Cockpit) - AAPS (Steampunk) AAPS (Digital) AAPS(perso) AAPS (Actions) @@ -62,7 +60,6 @@ Droitier Gaucher Moderne - Précision Delta (Steampunk) Faible Moyen Élevé @@ -185,8 +182,6 @@ Aucune donnée disponible augmenter diminuer - H - B moy --U --g diff --git a/wear/src/main/res/values-hr-rHR/strings.xml b/wear/src/main/res/values-hr-rHR/strings.xml index 7cbbee1c5a..9d657e0902 100644 --- a/wear/src/main/res/values-hr-rHR/strings.xml +++ b/wear/src/main/res/values-hr-rHR/strings.xml @@ -8,7 +8,6 @@ AAPS(Bez grafa) AAPS(Kružni) AAPS(v2) - AAPS(Cockpit) Nisko Visoko Kalkulator @@ -31,8 +30,6 @@ Otkaži povećanje smanjenje - H - L prosječno U --g diff --git a/wear/src/main/res/values-hu-rHU/strings.xml b/wear/src/main/res/values-hu-rHU/strings.xml index 20664f080f..42b5f8da0f 100644 --- a/wear/src/main/res/values-hu-rHU/strings.xml +++ b/wear/src/main/res/values-hu-rHU/strings.xml @@ -7,8 +7,6 @@ AAPS(NagyGrafikon) AAPS(NincsGrafikon) AAPS(Kör) - AAPS(Pilótafülke) - AAPS(Steampunk) AAPS(Digitális) Nincs adat! Régi adat! diff --git a/wear/src/main/res/values-it-rIT/strings.xml b/wear/src/main/res/values-it-rIT/strings.xml index 61a9158f1f..bd62bf02ab 100644 --- a/wear/src/main/res/values-it-rIT/strings.xml +++ b/wear/src/main/res/values-it-rIT/strings.xml @@ -8,8 +8,6 @@ AAPS(NoChart) AAPS(Circle) AAPS(v2) - AAPS(Cockpit) - AAPS(Steampunk) AAPS(DigitalStyle) AAPS(Personalizzato) AAPS(azioni) @@ -59,7 +57,6 @@ Quick righty Quick lefty Modern Sparse - Delta Granularity (Steampunk) Basso Medio Alto @@ -182,8 +179,6 @@ Nessun dato disponibile incremento decremento - H - L media --U --g diff --git a/wear/src/main/res/values-iw-rIL/strings.xml b/wear/src/main/res/values-iw-rIL/strings.xml index bc4359285f..f967777df3 100644 --- a/wear/src/main/res/values-iw-rIL/strings.xml +++ b/wear/src/main/res/values-iw-rIL/strings.xml @@ -8,8 +8,6 @@ AAPS (ללא תרשים) AAPS (עיגול) AAPS (v2) - AAPS (תא טייס) - AAPS (סטימפאנק) AAPS (דיגיטלי) AAPS (פעולות) AAPS (מטרה זמנית) @@ -54,7 +52,6 @@ ימני מהיר שמאלי מהיר מינימלי מודרני - מפורט (סטימפאנק) נמוך בינוני גבוה @@ -176,8 +173,6 @@ אין נתונים זמינים תוספת הפחתה - גב\' - נמ\' ממוצע -- יח\' -- גר\' diff --git a/wear/src/main/res/values-ko-rKR/strings.xml b/wear/src/main/res/values-ko-rKR/strings.xml index e0268f71a5..fd4d545f9e 100644 --- a/wear/src/main/res/values-ko-rKR/strings.xml +++ b/wear/src/main/res/values-ko-rKR/strings.xml @@ -8,8 +8,6 @@ AAPS(차트없음) AAPS(원형) AAPS(v2) - AAPS(조종석) - AAPS(스팀펑크) AAPS(디지털방식) AAPS(Custom) AAPS(Actions) @@ -53,7 +51,6 @@ 오른손잡이 왼손잡이 모던스타일 - 증분 밀도(스팀펑크) @@ -176,8 +173,6 @@ 사용할 수 있는 데이터 없음 증가 감소 - H - L 평균 --U --g diff --git a/wear/src/main/res/values-lt-rLT/strings.xml b/wear/src/main/res/values-lt-rLT/strings.xml index 9be89fde50..4fe153c042 100644 --- a/wear/src/main/res/values-lt-rLT/strings.xml +++ b/wear/src/main/res/values-lt-rLT/strings.xml @@ -8,8 +8,6 @@ AAPS(BeGrafiko) AAPS(Apvalus) AAPS(v2) - AAPS(Cockpit) - AAPS(Steampunk) AAPS(DigitalStyle) AAPS(suasmeninta) AAPS(Veiksmai) @@ -62,7 +60,6 @@ Greitai dešinėn Greitai kairėn Minimalistinis - Detalus pokytis (Steampunk) Žemas Vidutinis Aukštas @@ -185,8 +182,6 @@ Nėra duomenų didėjimas mažėjimas - H - L vid. --v --g diff --git a/wear/src/main/res/values-nb-rNO/strings.xml b/wear/src/main/res/values-nb-rNO/strings.xml index 5165e2eaa1..19a7d80008 100644 --- a/wear/src/main/res/values-nb-rNO/strings.xml +++ b/wear/src/main/res/values-nb-rNO/strings.xml @@ -8,8 +8,6 @@ AAPS (ingen graf) AAPS (sirkel) AAPS(v2) - AAPS(Cockpit) - AAPS(Steampunk) AAPS(Digitalstil) AAPS(Tilpasset) AAPS(Actions) @@ -62,7 +60,6 @@ Raskt høyre Raskt venstre Modern Sparse - Deltagranularitet (Steampunk) Lav Middels Høy @@ -174,7 +171,7 @@ Under lading Alltid På modus Alltid på under lading - Spising + Spise snart Hypo Aktivitet Manuell @@ -185,8 +182,6 @@ Ingen data tilgjengelig økning reduksjon - H - L snitt --E --g diff --git a/wear/src/main/res/values-nl-rNL/strings.xml b/wear/src/main/res/values-nl-rNL/strings.xml index 6ae34ecb6d..704466c59a 100644 --- a/wear/src/main/res/values-nl-rNL/strings.xml +++ b/wear/src/main/res/values-nl-rNL/strings.xml @@ -8,8 +8,6 @@ AAPS(GeenGrafiek) AAPS(Cirkel) AAPS(v2) - AAPS(Cockpit) - AAPS(Steampunk) AAPS(DigitaleStijl) AAPS(Custom) AAPS(Acties) @@ -62,7 +60,6 @@ Snel rechts Snel links Modern spaarzaam - Delta schaalverdeling (Steampunk) Laag Middel Hoog @@ -185,8 +182,6 @@ Geen data beschikbaar verhoog verlaag - H - L gem --E --g diff --git a/wear/src/main/res/values-pl-rPL/strings.xml b/wear/src/main/res/values-pl-rPL/strings.xml index a66313e1cf..2eb5cd5f3b 100644 --- a/wear/src/main/res/values-pl-rPL/strings.xml +++ b/wear/src/main/res/values-pl-rPL/strings.xml @@ -8,8 +8,6 @@ AAPS(BezWykresu) AAPS(Koło) AAPS(v2) - AAPS(Kokpit) - AAPS(Steampunk) AAPS(StylCyfrowy) AAPS(niestandardowy) AAPS(Ustawienia) @@ -62,7 +60,6 @@ Szybki prawy Szybki lewy Minimalistyczny - Granularność Delty (Steampunk) Niska Średnia Wysoka @@ -185,8 +182,6 @@ Brak dostępnych danych zwiększenie zmniejszenie - W - N śr --U --g diff --git a/wear/src/main/res/values-pt-rBR/strings.xml b/wear/src/main/res/values-pt-rBR/strings.xml index 672219eec4..a30c53b003 100644 --- a/wear/src/main/res/values-pt-rBR/strings.xml +++ b/wear/src/main/res/values-pt-rBR/strings.xml @@ -8,8 +8,6 @@ AAPS(SemGraf) AAPS(Círculo) AAPS(v2) - AAPS(Cockpit) - AAPS(Steampunk) AAPS(DigitalStyle) AAPS(Ações) AAPS(Meta Temporária) @@ -48,7 +46,6 @@ Rápido Direito Rápido Esquerdo Moderno Esparso - Delta Granularidade (Steampunk) Baixo Médio Alto @@ -170,8 +167,6 @@ Sem dados disponíveis incremento diminuição - H - L média --U --g diff --git a/wear/src/main/res/values-pt-rPT/strings.xml b/wear/src/main/res/values-pt-rPT/strings.xml index 469c1dc139..41bc5307b5 100644 --- a/wear/src/main/res/values-pt-rPT/strings.xml +++ b/wear/src/main/res/values-pt-rPT/strings.xml @@ -8,8 +8,6 @@ AAPS(SemGraf) AAPS(Círculo) AAPS(v2) - AAPS(Cockpit) - AAPS(Steampunk) AAPS(DigitalStyle) AAPS(personalizado) AAPS(Ações) @@ -58,7 +56,6 @@ Rápido Direito Rápido Esquerdo Moderno Esparso - Delta Granularidade (Steampunk) Baixo Médio Alto @@ -181,8 +178,6 @@ Dados indisponíveis aumentar diminuir - H - L média --U --g diff --git a/wear/src/main/res/values-ro-rRO/strings.xml b/wear/src/main/res/values-ro-rRO/strings.xml index 43e2c50004..0fd9642499 100644 --- a/wear/src/main/res/values-ro-rRO/strings.xml +++ b/wear/src/main/res/values-ro-rRO/strings.xml @@ -8,8 +8,6 @@ AAPS(FărăGrafic) AAPS(Cerc) AAPS(v2) - AAPS(Panou) - AAPS (Steampunk) AAPS (DigitalStyle) AAPS (Personalizat) AAPS(Acțiuni) @@ -62,7 +60,6 @@ Drepta rapid Stânga rapid Distanță modernă - Granularitate Delta (Steampunk) Mic Mediu Mare @@ -185,8 +182,6 @@ Nu există date disponibile creștere scădere - H - L med. --U --g diff --git a/wear/src/main/res/values-ru-rRU/strings.xml b/wear/src/main/res/values-ru-rRU/strings.xml index a42b881664..b1adbce79f 100644 --- a/wear/src/main/res/values-ru-rRU/strings.xml +++ b/wear/src/main/res/values-ru-rRU/strings.xml @@ -8,8 +8,6 @@ AAPS (Без графика) AAPS (круглый) AAPS(v2) - AAPS (кабина пилота) - AAPS (Стимпанк) AAPS (ЦифровойСтиль) AAPS (настраиваемый) AAPS (Действия) @@ -62,7 +60,6 @@ Быстрый правосторонний Быстрый левосторонний Современный разреженный - Дельта детально (Стимпанк) Низкий Средний Высокий @@ -185,8 +182,6 @@ Нет данных приращение декремент - В - Н сред --ед --г diff --git a/wear/src/main/res/values-sk-rSK/strings.xml b/wear/src/main/res/values-sk-rSK/strings.xml index 79ccfa3c62..86bdf56cb4 100644 --- a/wear/src/main/res/values-sk-rSK/strings.xml +++ b/wear/src/main/res/values-sk-rSK/strings.xml @@ -8,8 +8,6 @@ AAPS(ŽiadnyGraf) AAPS(Kruhový) AAPS(v2) - AAPS(Kokpit) - AAPS (Steampunk) AAPS (DigitalStyle) AAPS (vlastný) AAPS (Akcie) @@ -62,7 +60,6 @@ Rýchlo vpravo Rýchlo vľavo Modern Sparse - Presnosť (Steampunk) Nízka Stredná Vysoká @@ -185,8 +182,6 @@ Žiadne údaje nie sú k dispozícii prírastok zníženie - H - L priemer --JI --g diff --git a/wear/src/main/res/values-sv-rSE/strings.xml b/wear/src/main/res/values-sv-rSE/strings.xml index bcebeaa52f..022ee17421 100644 --- a/wear/src/main/res/values-sv-rSE/strings.xml +++ b/wear/src/main/res/values-sv-rSE/strings.xml @@ -8,8 +8,6 @@ AAPS (NoChart) AAPS (Circle) AAPS(v2) - AAPS (Cockpit) - AAPS (Steampunk) AAPS (DigitalStyle) AAPS (anpassad) AAPS(Åtgärder) @@ -53,7 +51,6 @@ Snabb höger Snabb vänster Modern Sparse - Precision för skillnad (Steampunk) Låg Mellan Hög @@ -176,8 +173,6 @@ Ingen data tillgänglig öka minska - H - L medel --U --g diff --git a/wear/src/main/res/values-tr-rTR/strings.xml b/wear/src/main/res/values-tr-rTR/strings.xml index 3e2be2dd4e..5e2e96c084 100644 --- a/wear/src/main/res/values-tr-rTR/strings.xml +++ b/wear/src/main/res/values-tr-rTR/strings.xml @@ -8,8 +8,6 @@ AAPS(GrafikYok) AAPS(Daire) AAPS (v2) - AAPS(Cockpit) - AAPS (Steampunk) AAPS(DijitalStil) AAPS(Özel) AAPS(Eylemler) @@ -62,7 +60,6 @@ Hızlı Sağ Hızlı Sol Modern Seyrek - Delta Tanecikliliği (Steampunk) Düşük Orta Yüksek @@ -185,8 +182,6 @@ Veri yok artış azalma - Y - D ort --Ü --g diff --git a/wear/src/main/res/values-zh-rCN/strings.xml b/wear/src/main/res/values-zh-rCN/strings.xml index 9c857fb1a9..1d8d4093ae 100644 --- a/wear/src/main/res/values-zh-rCN/strings.xml +++ b/wear/src/main/res/values-zh-rCN/strings.xml @@ -8,8 +8,6 @@ AAPS(无图) AAPS(圆形) AAPS(v2) - AAPS(驾驶) - AAPS(机械) AAPS(数字风格) AAPS(操作) AAPS(临时目标) @@ -48,7 +46,6 @@ 快速右对齐 快速左对齐 现代场景 - 变化量详细程度 (Steampunk) 中等 From 543c8c7f7345b6ce5bbc6b96a37597fe8eb30030 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 10 Oct 2023 22:23:57 +0200 Subject: [PATCH 124/127] New Crowdin updates (#2889) * Update source file strings.xml * New translations strings.xml (Czech) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Romanian) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Polish) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Spanish) * New translations strings.xml (Dutch) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations strings.xml (Norwegian Bokmal) * New translations objectives.xml (Norwegian Bokmal) --- app/src/main/res/values-nb-rNO/strings.xml | 2 +- .../src/main/res/values-nb-rNO/strings.xml | 2 +- .../ui/src/main/res/values-nb-rNO/strings.xml | 18 ++++---- .../src/main/res/values-nb-rNO/strings.xml | 4 +- .../src/main/res/values-nb-rNO/strings.xml | 6 +-- .../src/main/res/values-nb-rNO/objectives.xml | 4 +- .../src/main/res/values-nb-rNO/strings.xml | 2 +- .../src/main/res/values-nb-rNO/strings.xml | 42 +++++++++---------- .../src/main/res/values-nb-rNO/strings.xml | 2 +- .../src/main/res/values-nb-rNO/strings.xml | 2 +- .../src/main/res/values-nb-rNO/strings.xml | 18 ++++---- .../src/main/res/values-nb-rNO/strings.xml | 4 +- .../src/main/res/values-nb-rNO/strings.xml | 2 +- .../src/main/res/values-nb-rNO/strings.xml | 2 +- .../src/main/res/values-cs-rCZ/strings.xml | 3 ++ .../src/main/res/values-es-rES/strings.xml | 3 ++ .../src/main/res/values-nb-rNO/strings.xml | 3 ++ .../src/main/res/values-nl-rNL/strings.xml | 2 + .../src/main/res/values-pl-rPL/strings.xml | 3 ++ .../src/main/res/values-ro-rRO/strings.xml | 3 ++ .../src/main/res/values-nb-rNO/strings.xml | 6 +-- .../src/main/res/values-nb-rNO/strings.xml | 4 +- ui/src/main/res/values-nb-rNO/strings.xml | 24 +++++------ wear/src/main/res/values-nb-rNO/strings.xml | 4 +- 24 files changed, 91 insertions(+), 74 deletions(-) diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 807084700e..f02eea5d08 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -9,7 +9,7 @@ Delta Profil Lagre - Les inn profil på nytt + Last inn profil på nytt Korreksjon (FARLIG Å DEAKTIVERE) Kun NS opplasting Kun NS opplasting (deaktivert sync). Ikke effektiv på SGV med mindre en lokal kilde som xDrip+ er valgt. Ikke effektiv på Profiler mens NS-Profiler brukes.\n!!! ADVARSEL !!! Deaktivering av dette alternativet kan føre til funksjonsfeil og overdosering av insulin hvis noen av dine komponenter (AAPS, NS, xDrip+) er feil konfigurert. Observer at data som vises i AAPS samsvarer med pumpestatus! diff --git a/core/interfaces/src/main/res/values-nb-rNO/strings.xml b/core/interfaces/src/main/res/values-nb-rNO/strings.xml index 47694ea69b..f0d8eeb0e6 100644 --- a/core/interfaces/src/main/res/values-nb-rNO/strings.xml +++ b/core/interfaces/src/main/res/values-nb-rNO/strings.xml @@ -54,7 +54,7 @@ Vis basalrate Vis loop status Vis BS - Vis BS + Vis BGI Vis retningspil Vis tid siden Vis ukenummer diff --git a/core/ui/src/main/res/values-nb-rNO/strings.xml b/core/ui/src/main/res/values-nb-rNO/strings.xml index bf26537a71..1612d72d0a 100644 --- a/core/ui/src/main/res/values-nb-rNO/strings.xml +++ b/core/ui/src/main/res/values-nb-rNO/strings.xml @@ -61,7 +61,7 @@ Opplæringsmål Vennligst vent… Stopp - Karbohydrater + Karbo Ugyldig profil! INGEN PROFIL VALGT ]]> @@ -146,7 +146,7 @@ Er du sikker på at du vil fjerne %1$d elementer Behandling Opprett ny profil fra denne profilen? - Innstillinger for boluskalkulator + Kalkulatorinnstillinger 15 min trend COB Bolus IOB @@ -155,7 +155,7 @@ Login Prime/fylling Insulin - Avbryt temp target + Avbryt midlertidig målverdi Lukket Loop Åpen Loop Stopp ved lavt BS @@ -220,7 +220,7 @@ Karbo-korreksjon OpenAPS Offline Bytte pumpebatteri - Midlertidig BS-mål + Midlertidig mål Midlertidig målverdi Avbryt midl. mål Boluskalkulator @@ -453,10 +453,10 @@ INFO Bolusveiviser - Du har høyt blodsukker. I stedet for å spise nå er det bedre å utsette det til du har et lavere blodsukker. Ønsker du å sette en korreksjons bolus nå og få en påminnelse om når det er på tide å spise? I dette tilfellet vil ingen karbohydrater registreres nå, og du må bruke måltidsveiviseren igjen når vi gir deg en påminnelse. + Du har høyt blodsukker. I stedet for å spise nå er det bedre å utsette det til du har et lavere blodsukker. Ønsker du å sette en korreksjonsbolus nå og få en påminnelse om når det er på tide å spise? I dette tilfellet vil ingen karbohydrater registreres nå, og du må bruke boluskalkulatoren igjen når vi gir deg en påminnelse. COB vs IOB !! Advarsel: Oppdaget treg absorpsjon av karbohydrater: %2$d%% av tiden. Dobbeltsjekk din beregning. COB kan være misvisende og du risikerer å få for mye insulin !!]]> - Doser denne delen av resultatet fra bolusveiviseren [%] + Doser denne delen av resultatet fra boluskalkulatoren [%] Terskel for gammel BS-verdi [min] Bolus begrensning brukt: %1$.2f E til %2$.2f E Bolus vil bare bli loggført (ikke levert av pumpe) @@ -478,7 +478,7 @@ TempT: %1$s %1$s til %2$s Ingen pumpe tilgjengelig! - Hurtigveiviser + Hurtigknapp Barn Tenåring @@ -486,8 +486,8 @@ Insulinresistent voksen Graviditet Velg pasienttype for oppsett av sikkerhetsgrenser - Maks tillat bolus [U] - Maks tillat karbo [g] + Maks tillatt bolus [U] + Maks tillatt karbohydrater [g] Pasienttype Lås opp innstillinger diff --git a/plugins/automation/src/main/res/values-nb-rNO/strings.xml b/plugins/automation/src/main/res/values-nb-rNO/strings.xml index b3c069256f..0b67c24fef 100644 --- a/plugins/automation/src/main/res/values-nb-rNO/strings.xml +++ b/plugins/automation/src/main/res/values-nb-rNO/strings.xml @@ -113,7 +113,7 @@ Legg til regel Stopp prosessering - Nå må du spise!\nBruk bolusveiviser og gjør beregning på nytt. - Tid for bolus!\nStart bolusveiviser og gjør beregning på nytt. + Nå må du spise!\nBruk boluskalkulator og gjør beregning på nytt. + Tid for bolus!\nStart boluskalkulator og gjør beregning på nytt. Feil under innstilling av fremtidig alarm diff --git a/plugins/configuration/src/main/res/values-nb-rNO/strings.xml b/plugins/configuration/src/main/res/values-nb-rNO/strings.xml index c99a9a9e89..3a00df1b2a 100644 --- a/plugins/configuration/src/main/res/values-nb-rNO/strings.xml +++ b/plugins/configuration/src/main/res/values-nb-rNO/strings.xml @@ -45,8 +45,8 @@ Start første læringsmål RileyLink status: Les status - Data valg - Innlesing av fabrikkinstillinger + Datavalg + Innlesing av fabrikkinnstillinger Tillat automatisk rapportering av appkrasj og bruksdata til utviklerne via fabrioc.io-tjenesten. Denne e-postadressen vedlegges krasjrapporter slik at vi kan kontakte deg i akutte tilfeller. Det er valgfritt. Identifikasjon (e-post, Facebook eller Discord nick osv.) @@ -81,7 +81,7 @@ Brukes for innstilling av aktive plugins Varsel: Hvis du aktiverer og kobler til en pumpe, så vil AndroidAPS kopiere basalinnstillinger fra din profil over til pumpen og overskrive verdiene som er lagret i pumpen. Sjekk at du har riktige basalverdier i AndroidAPS. Hvis du ikke er sikker eller ikke ønsker å overskrive basalverdiene i pumpen, trykk avbryt og koble til pumpen senere. åpne innstillinger - NSClient-versjonen samsvarer ikke med AAPS-versjonen. Vennligst oppdater. + AAPSClient-versjonen samsvarer ikke med AAPS-versjonen. Vennligst oppdater. Innstillinger Du må angi et hovedpassord som vil bli brukt til å kryptere dine eksporterte innstillinger. Husk dette! diff --git a/plugins/constraints/src/main/res/values-nb-rNO/objectives.xml b/plugins/constraints/src/main/res/values-nb-rNO/objectives.xml index 957e9d4277..291f461957 100644 --- a/plugins/constraints/src/main/res/values-nb-rNO/objectives.xml +++ b/plugins/constraints/src/main/res/values-nb-rNO/objectives.xml @@ -9,7 +9,7 @@ Kontroller at BS er tilgjengelig i Nightscout og at insulindata fra pumpen lastes opp Du har gjort et grunnleggende oppsett av AAPS økosystem. Nightscout (NS) er ikke nødvendig for at AAPS skal kunne kjøres, men det er svært nyttig for å lage rapporter eller gi innsyn i dine data. Det er ikke nødvendig å være tilkoblet NS hele tiden hvis du bruker NS kun for deg selv. Du kan lage innstillinger for å laste opp dine data til NS når du er tilkoblet hjemme wifi og spare batteri. Starter med åpen loop - Kjør i \"Åpen Loop\" modus i noen dager og aktiver flere temp basaler. Konfigurer og aktiver flere midlertidige og default temp BS mål (f.eks. for Aktivitet eller Hypo behandling) + Kjør i \"Åpen Loop\"-modus i noen dager og aktiver flere midlertidige basaler. Konfigurer og aktiver flere midlertidige mål og standard midlertidige mål (f.eks. for Aktivitet og Hypo) Åpen loop kan brukes til anbefalinger hvis du ikke har en kompatibel pumpe eller hvis du ikke er klar til å kjøre i lukket loop. Forstå din åpen loop, inkludert den temp basal anbefalingen Ut ifra hva du har erfart og lært, avgjør hva din max basal skal være og still den inn i både pumpen og AAPS innstillinger @@ -42,7 +42,7 @@ Angi profil 90% for 10 min (langt-trykk på profilnavn i Oversikt) Simuler dusjing. Frakoble pumpen i 1t (langt trykk på Åpen Loop) ... og koble til igjen på samme måte - Opprett egendefinerte midlertidige BS mål med 10 min varighet (langt-trykk på gjeldende mål) + Opprett egendefinerte midlertidige mål med 10 min varighet (langt-trykk på gjeldende mål) I Konfigurasjonsverktøyet aktiverer du Hendelser plugin, og gjør det synlig og viser innholdet fra menyen i øverste linje Vis innholdet i Loop plugin Test skaleringsfunksjonen ved et langt trykk på BS grafen diff --git a/plugins/constraints/src/main/res/values-nb-rNO/strings.xml b/plugins/constraints/src/main/res/values-nb-rNO/strings.xml index 06ff898466..7e56ad8011 100644 --- a/plugins/constraints/src/main/res/values-nb-rNO/strings.xml +++ b/plugins/constraints/src/main/res/values-nb-rNO/strings.xml @@ -45,7 +45,7 @@ Lukket loop aktivert MÅL Opplæringsprogram - Ønsker du å starte læringsmåletpå nytt? Du vil miste fullførte trinn. + Ønsker du å starte læringsmålet på nytt? Du vil miste fullførte trinn. Neste Forrige Nullstille ferdig-status diff --git a/plugins/main/src/main/res/values-nb-rNO/strings.xml b/plugins/main/src/main/res/values-nb-rNO/strings.xml index c7afc82c6d..6632e8430a 100644 --- a/plugins/main/src/main/res/values-nb-rNO/strings.xml +++ b/plugins/main/src/main/res/values-nb-rNO/strings.xml @@ -137,10 +137,10 @@ Slette gjeldende profil? Enheter: Mangler profilnavn - Feil i IK faktoren + Feil i IK-faktoren Feil i basalverdiene Feil i BS målverdier - Feil i IF verdien + Feil i ISF-verdien Noen av profilnavnene inneholder punktum.\nDette støttes ikke av NS.\nProfilen er ikke lastet opp til NS. Ugyldig profil %1$s ikke akseptert fra NS Visning @@ -212,20 +212,20 @@ OpenAPS Opplaster BS data status - Innstillinger for hurtigveiviser + Innstillinger for hurtigknapp Hold skjermen påslått Forhindre Android fra å slå av skjermen. Mobilen vil bruke mye batteri hvis den ikke kobles til strømledning. Behandlinger Antall karbohydrater som skal legges til når knappen trykkes Mengde insulin som skal legges til når knappen trykkes - Første økning hurtigknapp for insulin - Andre økning hurtigknapp for insulin - Tredje økning hurtigknapp for insulin - Første økning hurtigknapp for karbohydrater - Andre økning hurtigknapp for karbohydrater - Tredje økning hurtigknapp for karbohydrater + Første økning knapp for insulin + Andre økning knapp for insulin + Tredje økning knapp for insulin + Første økning knapp for karbohydrater + Andre økning knapp for karbohydrater + Tredje økning knapp for karbohydrater CGM - Standard midlertidig BS-mål + Standard midlertidig mål Spise snart varighet (min) Spise snart målverdi Aktivitet varighet (min) @@ -241,23 +241,23 @@ Lav verdi Høy verdi Korte navn i menyfaner - Vis merknadsfelt i dialogvindu for behandlinger + Vis merknadsfelt i dialogvindu for boluskalkulator Bolusveiviser utfører beregninger, men bare denne del av beregnet insulin leveres. Nyttig ved bruk av SMB-algoritmen. Gi full bolus (100 %) dersom blodsukker er eldre enn - Aktiver boluskalkulator - Bruk en påminnelse om å spise senere isetdet for beregnet av kalkulator når blodsukker er høyt (\"pre-bolus\") + Aktiver bolusveileder + Bruk en påminnelse om å spise senere istedet for boluskalkulatorens resultat når blodsukker er høyt (\"pre-bolus\") Aktiver superbolus i veiviser - Aktiver superbolus-funksjonen i veiviseren. Ikke aktiver denne før du vet hvordan den fungerer. DEN KAN LEDE TIL EN OVERDOSERING AV INSULIN HVIS DEN BRUKES UKRITISK! + Aktiver superbolus-funksjonen i boluskalkulatoren. Ikke aktiver denne før du vet hvordan den fungerer. DEN KAN LEDE TIL EN OVERDOSERING AV INSULIN HVIS DEN BRUKES UKRITISK! Aktiver boluspåminnelse - Bruk påminnelse for å sette bolusdosen senere med veiviseren («post bolus») + Bruk en påminnelse for å sette bolusdosen senere med boluskalkulatoren («post bolus») Kjør %s? Prognoser Behandlinger Puls Avvikskurve - Aktivitet - Blodsukkerpåvirkning + Insulinaktivitet + BS-påvirkning (BGI) Sensitivitet Avvik Aktive KH (COB) @@ -274,7 +274,7 @@ BEH HR SENS - Graf skala + Graf-skala Graf Opprinnelig visningstema @@ -291,9 +291,9 @@ (Ingen klokke tilkoblet) Pumpestatus Loopstatus - Kalkulator hurtigveiviser:\nInsulin: %1$.2fE\nKarbo: %2$dg - Den valgte hurtigveiviseren er ikke tilgjengelig lenger, oppdater klokkeurskive - Hurtigveiviser: %1$s\ninsulin: %2$.2fE\nKarbo: %3$dg + Boluskalkulator:\nInsulin: %1$.2fE\nKarbo: %2$dg + Den valgte hurtigknappen er ikke lenger tilgjengelig, oppdater klokkeflis + Hurtigknapp: %1$s\ninsulin: %2$.2fE\nKarbo: %3$dg Ukjent forhåndsinnstilling midl. mål: %1$s Avbryt gjeldende midl. mål? Forskjellige enheter brukt på klokke og telefon! diff --git a/plugins/smoothing/src/main/res/values-nb-rNO/strings.xml b/plugins/smoothing/src/main/res/values-nb-rNO/strings.xml index 2ce352518a..f24cdc1d85 100644 --- a/plugins/smoothing/src/main/res/values-nb-rNO/strings.xml +++ b/plugins/smoothing/src/main/res/values-nb-rNO/strings.xml @@ -2,7 +2,7 @@ UTJEVNING Eksponentiell utjevning - "Andre algoritme for eksponentiell utjevning" + "Andre ordens algoritme for eksponentiell utjevning" Gjennomsnittlig utjevning "Gjennomsnittlig utjevnings-algoritme, nyeste verdi påvirkes ikke" Ingen utjevning diff --git a/plugins/source/src/main/res/values-nb-rNO/strings.xml b/plugins/source/src/main/res/values-nb-rNO/strings.xml index c719e2ad6b..1d8deba163 100644 --- a/plugins/source/src/main/res/values-nb-rNO/strings.xml +++ b/plugins/source/src/main/res/values-nb-rNO/strings.xml @@ -34,6 +34,6 @@ I xDrip+, velg 640G/Eversens som datakilde Innstillinger for opplasting av BS Logg sensorbytte til NS - Opprett hendelse \"Senso bytte\" automatisk i NS ved start av sensoren + Opprett hendelse \"Sensor bytte\" automatisk i NS ved start av sensoren retning diff --git a/plugins/sync/src/main/res/values-nb-rNO/strings.xml b/plugins/sync/src/main/res/values-nb-rNO/strings.xml index f432e0bfa6..e91f3141de 100644 --- a/plugins/sync/src/main/res/values-nb-rNO/strings.xml +++ b/plugins/sync/src/main/res/values-nb-rNO/strings.xml @@ -13,8 +13,8 @@ Opprett varslinger hvis det er nødvendig med karbohydrater Opprett varslinger i Nightscout ved feil eller meldinger (også synlig i Careportal under Behandlinger) Opprett Nightscout-meldinger ved behov for karbohydrater - Synkroniserer dine data med Nightscout - Synkroniserer dataene dine med Nightscout med v3 API + Synkroniserer dine data med Nightscout v1 API + Synkroniserer dine data med Nightscout v3 API Blokkert på grunn av ladealternativer Blokkert på grunn av tilkoblingsalternativer Versjonen av Nightscout støttes ikke @@ -51,20 +51,20 @@ Last opp data til NS Hent lagrede profiler Synkroniser profiler fra NS profileditor - Motta midlertidige BS-mål - Aksepter midlertidige mål angitt med NS eller NSClient + Motta midlertidige mål + Aksepter midlertidige mål angitt med NS eller AAPSClient Motta profilbytter Aksepter profilbytter som er angitt via NS eller NSClient Motta APS offline hendelser - Aksepter APS offline hendelser lagt inn gjennom NS eller NSClient + Aksepter APS offline hendelser lagt inn gjennom NS eller AAPSClient Motta TBR og EB Godta TBR og EB beregninger fra tilleggsmodul Motta insulin - Aksepter insulin angitt via NS eller NSClient (enhetene er ikke dosert, kun beregnet mot IOB) + Aksepter insulin angitt via NS eller AAPSClient (enhetene er ikke dosert, kun beregnet mot IOB) Motta karbohydrater - Aksepter karbohydrater angitt med NS eller NSClient + Aksepter karbohydrater angitt med NS eller AAPSClient Motta behandlingshendelser - Godta behandlingshendelser (kanyle, insulin, batteribytte osv.) som er lagt inn gjennom NS eller NSClient + Godta behandlingshendelser (kanyle, insulin, batteribytte osv.) som er lagt inn gjennom NS eller AAPSClient Motta/tilbakefyll CGM data Aksepter CGM data fra NS Reduser opplastingshastighet @@ -76,7 +76,7 @@ Logg app-start til NS Kopiere NS innstillinger (hvis de eksisterer)? Koble til websockets - Aktivering vetyr: hurtigere oppdateringer, mottak av alarmer og kunngjøringer og høyere batteriforbruk som ligner v1. Alle andre opplastere til NS må bruke v3 protokoll. + Aktivering betyr: hurtigere oppdateringer, mottak av alarmer og kunngjøringer og høyere batteriforbruk som ligner v1 API. Alle andre opplastere til NS må bruke v3 API. Ditt Tidepool brukernavn, normalt din e-postadresse Brukernavn for innlogging diff --git a/pump/diaconn/src/main/res/values-nb-rNO/strings.xml b/pump/diaconn/src/main/res/values-nb-rNO/strings.xml index e3ee2e76e9..23b32d57b3 100644 --- a/pump/diaconn/src/main/res/values-nb-rNO/strings.xml +++ b/pump/diaconn/src/main/res/values-nb-rNO/strings.xml @@ -3,7 +3,7 @@ Slett sammenkobling Ingen enheter er tilgjengelige Diaconn pumpe sammenkobling - Pumpe feil + Pumpefeil Alarmer Basal timer Boluser @@ -33,7 +33,7 @@ Diaconn G8 Diaconn G8 Max bolus nådd - Kommando feil + Kommandofeil Hastighetsfeil Insulingrense nådd Forespurt: %1$.2fE Levert: %2$.2fE Feilkode: %3$s diff --git a/pump/eopatch/src/main/res/values-nb-rNO/strings.xml b/pump/eopatch/src/main/res/values-nb-rNO/strings.xml index 79d285475f..4f4d1f0686 100644 --- a/pump/eopatch/src/main/res/values-nb-rNO/strings.xml +++ b/pump/eopatch/src/main/res/values-nb-rNO/strings.xml @@ -86,7 +86,7 @@ Kontrollerer Patch kommunikasjon… Flytt smartenheten din nærmere Patch. Gå til en annen lokasjon og prøv på nytt. - Kommunikasjons feil + Kommunikasjonsfeil Kommunikasjon vellykket Sammenkoblet med Patch. Avbryt paringen diff --git a/pump/medtronic/src/main/res/values-nb-rNO/strings.xml b/pump/medtronic/src/main/res/values-nb-rNO/strings.xml index fa3221b358..7a7ffa8595 100644 --- a/pump/medtronic/src/main/res/values-nb-rNO/strings.xml +++ b/pump/medtronic/src/main/res/values-nb-rNO/strings.xml @@ -73,7 +73,7 @@ Angi basal profil Henter Temp Basal Angi Temp Basal - Avbryt temp basal + Avbryt midlertidig basal Angi Bolus Oppdater status insulinvolum Pumpe utilgjengelig diff --git a/pump/medtrum/src/main/res/values-cs-rCZ/strings.xml b/pump/medtrum/src/main/res/values-cs-rCZ/strings.xml index 2fd23c2faf..3bd036a325 100644 --- a/pump/medtrum/src/main/res/values-cs-rCZ/strings.xml +++ b/pump/medtrum/src/main/res/values-cs-rCZ/strings.xml @@ -6,6 +6,7 @@ Integrace pumpy pro Medtrum Nano a Medtrum 300U Nastavení pumpy Medtrum Chyba pumpy: %1$s!! + Varování pumpy: %1$s Pumpa je pozastavena Pumpa je pozastavena kvůli překročení maximálního množství inzulínu za hodinu Pumpa je pozastavena kvůli překročení maximálního množství inzulínu za den @@ -106,6 +107,8 @@ Nevyzkoušená pumpa: %1$d! Kontaktujte nás na Discordu nebo Githubu, kde získáte podporu. Nastavení alarmů Vyberte preferované nastavení alarmů. + Oznámení o varování pumpy + Zobrazit upozornění na nekritická varování pumpy: vybitá baterie, téměř prázdný zásobník (20 jednotek) a brzy dojde inzulin. Doporučeno ponechat zapnuté, když jsou výstrahy pumpy nastaveny na ticho. Vypršení platnosti Patche Pokud je povoleno, Patch vyprší po 3 dnech s maximální dobou odkladu 8 hodin. Hodinové maximum inzulínu diff --git a/pump/medtrum/src/main/res/values-es-rES/strings.xml b/pump/medtrum/src/main/res/values-es-rES/strings.xml index 8a99c08eff..50534174b7 100644 --- a/pump/medtrum/src/main/res/values-es-rES/strings.xml +++ b/pump/medtrum/src/main/res/values-es-rES/strings.xml @@ -6,6 +6,7 @@ Integración de bombas de insulina Medtrum Nano y Medtrum 300U Ajustes de la bomba Medtrum Error de bomba: %1$s !! + Advertencia de la bomba: %1$s Bomba suspendida Bomba suspendida por superarse el máximo de insulina por hora Bomba suspendida por superar el máximo diario de insulina @@ -106,6 +107,8 @@ Bomba no probada: %1$d! Por favor, contacta con nosotros en Discord o GitHub para obtener soporte Ajustes de las alarmas Selecciona los ajustes de la alarma de la bomba que prefieras. + Notificación sobre advertencia de la bomba + Mostrar notificación en advertencias de la bomba no críticas: batería baja, reserva baja (20 unidades) y próxima a caducar. Se recomienda dejarlo habilitado cuando las alarmas de la bomba estén configuradas en silencio. Caducidad del parche Cuando está activado, el parche caducará a los 3 días, con un periodo de gracia de 8 horas adicionales Insulina máxima por hora diff --git a/pump/medtrum/src/main/res/values-nb-rNO/strings.xml b/pump/medtrum/src/main/res/values-nb-rNO/strings.xml index 99d7018610..b2f4013796 100644 --- a/pump/medtrum/src/main/res/values-nb-rNO/strings.xml +++ b/pump/medtrum/src/main/res/values-nb-rNO/strings.xml @@ -6,6 +6,7 @@ Pumpeintegrasjon for Medtrum Nano og Medtrum 300U Medtrum pumpeinnstillinger Pumpefeil: %1$s!! + Pumpeadvarsel: %1$s Pumpen er pauset Pumpe er pauset fordi maksimal insulinleveranse per time er overskredet Pumpe er pauset fordi maksimal insulinleveranse per dag er overskredet @@ -106,6 +107,8 @@ Pumpe ikke testet: %1$d! Kontakt oss på discord eller github for støtte Alarminnstillinger Velg dine foretrukne alarminnstillinger. + Varsel om pumpeadvarsel + Vis varsel om ikke-kritisk pumpeadvarsel: lavt batteri, lavt reservoar (20 enheter) og utløper snart. Anbefales og la være aktivert når pumpealarmer er satt til stillemodus. Patch utløpsdato Når aktivert vil plasteret utløpe etter 3 dager, med en nådeperiode på 8 timer etter det. Maksimal insulin per time diff --git a/pump/medtrum/src/main/res/values-nl-rNL/strings.xml b/pump/medtrum/src/main/res/values-nl-rNL/strings.xml index aaaff5addd..a55cf9a280 100644 --- a/pump/medtrum/src/main/res/values-nl-rNL/strings.xml +++ b/pump/medtrum/src/main/res/values-nl-rNL/strings.xml @@ -6,6 +6,7 @@ Pomp integratie voor Medtrum Nano en Medtrum 300U Medtrum pomp instellingen Pomp fout: %1$s!! + Pomp waarschuwing: %1$s Pomp is onderbroken Pomp is onderbroken als gevolg van overschrijding max insuline per uur Pomp is onderbroken als gevolg van overschrijding max insuline per dag @@ -106,6 +107,7 @@ Pomp niet getest, %1$d! Neem contact met ons op via discord of github voor ondersteuning Alarminstellingen Selecteer uw gewenste alarminstellingen voor de pomp. + Notificatie bij pomp waarschuwing Patch vervalt Wanneer ingeschakeld, zal de patch na 3 dagen verlopen met een extra periode van 8 uur coulance. Maximale insuline per uur diff --git a/pump/medtrum/src/main/res/values-pl-rPL/strings.xml b/pump/medtrum/src/main/res/values-pl-rPL/strings.xml index e1038fb4f1..ddccc09c6d 100644 --- a/pump/medtrum/src/main/res/values-pl-rPL/strings.xml +++ b/pump/medtrum/src/main/res/values-pl-rPL/strings.xml @@ -6,6 +6,7 @@ Integracja z pompami Medtrum Nano i Medtrum 300U Ustawienia pompy Medtrum Błąd pompy: %1$s!! + Ostrzeżenie pompy: %1$s Pompa jest wstrzymana Pompa jest wstrzymana z powodu przekroczenia maksymalnej godzinowej dawki insuliny Pompa jest wstrzymana z powodu przekroczenia maksymalnej dziennej dawki insuliny @@ -106,6 +107,8 @@ Pompa nieprzetestowana: %1$d! Skontaktuj się z nami na Discordzie lub github, aby uzyskać wsparcie Ustawienia alarmu Wybierz preferowaną konfigurację alarmu pompy. + Powiadomienie o ostrzeżeniu pompy + Pokaż powiadomienia o niekrytycznych ostrzeżeniach pompy takich jak: niski poziom baterii, niski poziom zbiornika (20 jednostek) i wkrótce wygasa. Zalecane zostawianie włączonych powiadomień, gdy alarmy pompy są wyciszone. Wygaśnięcie Patcha Po uruchomieniu Patch wygaśnie po 3 dniach, z dodatkowym 8 godzinowym okresem karencji. Maksymalna Insulina w godzinę diff --git a/pump/medtrum/src/main/res/values-ro-rRO/strings.xml b/pump/medtrum/src/main/res/values-ro-rRO/strings.xml index 47001e16b9..1b55a6cc25 100644 --- a/pump/medtrum/src/main/res/values-ro-rRO/strings.xml +++ b/pump/medtrum/src/main/res/values-ro-rRO/strings.xml @@ -6,6 +6,7 @@ Integrarea pompei pentru Medtrum Nano și Medtrum 300U Setări pompă Medtrum Eroare pompă: %1$s!! + Avertizare pompă: %1$s Pompă suspendată Pompă suspendată din cauza depăşirii valorii maxime a insulinei pe oră Pompă suspendată din cauza depăşirii valorii maxime zilnice a insulinei @@ -106,6 +107,8 @@ Pompă netestată: %1$d! Te rugăm să ne contactezi pe discord sau github pentru suport. Setări alarmă Selectează setările preferate pentru alarma pompei. + Notificare la avertizarea pompei + Arată notificare cu privire la avertismentele non-critice ale pompei: baterie scăzută, rezervor redus (20 de unități) și expiră în curând. Se recomandă să lăsaţi activat când alarmele pompei sunt setate la silențios. Patch Expirare Când este activat, patchul va expira după 3 zile, cu o perioadă de graţie de 8 ore după expirare. Insulină maximă pe oră diff --git a/pump/omnipod-common/src/main/res/values-nb-rNO/strings.xml b/pump/omnipod-common/src/main/res/values-nb-rNO/strings.xml index 43dfaccd4f..ebd443fd13 100644 --- a/pump/omnipod-common/src/main/res/values-nb-rNO/strings.xml +++ b/pump/omnipod-common/src/main/res/values-nb-rNO/strings.xml @@ -2,7 +2,7 @@ - Pod administrasjon + Pod-administrasjon Handlinger Verktøy Aktiver Pod @@ -105,10 +105,10 @@ DST/Tidssone-deteksjon aktivert Utløpspåminnelse aktivert Når aktivert, vil Pod\'en pipe når tidspunktet er nådd - Påminelse før utløp (72 timer) + Påminnelse før utløp (72 timer) Utløpspåminnelse aktivert Når aktivert, vil Pod\'en pipe når tidspunktet er nådd og en time før nedstenging - Påminelse før utløp (80 timer) + Påminnelse før utløp (80 timer) Varsel om lavt reservoar aktivert Antall enheter Demp Pod-varsler automatisk diff --git a/pump/rileylink/src/main/res/values-nb-rNO/strings.xml b/pump/rileylink/src/main/res/values-nb-rNO/strings.xml index c2a43ee706..eba97aad46 100644 --- a/pump/rileylink/src/main/res/values-nb-rNO/strings.xml +++ b/pump/rileylink/src/main/res/values-nb-rNO/strings.xml @@ -27,7 +27,7 @@ Batterinivå: %1$d%% Tilkoblingsstatus: - Tilkoblings feil: + Tilkoblingsfeil: Enhet Enhets type: Konfigurert enhetsmodell: @@ -42,7 +42,7 @@ %1$.2f MHz Bluetooth initialiserer… - Bluetooth feil + Bluetoothfeil Bluetooth klar Ikke startet RileyLink initialisering… diff --git a/ui/src/main/res/values-nb-rNO/strings.xml b/ui/src/main/res/values-nb-rNO/strings.xml index 2c74e6897f..09efac2ec8 100644 --- a/ui/src/main/res/values-nb-rNO/strings.xml +++ b/ui/src/main/res/values-nb-rNO/strings.xml @@ -4,9 +4,9 @@ Karbohydrat-begrensning utført TT Dialog avbrutt - Start TT for trening - Start TT for spise snart - Start TT for hypoglykemi + Start midlertidig mål for Aktivitet + Start midlertidig mål for Spise snart + Start midlertidig mål for Hypo Tids- forskyvning min Påminnelse om å gi bolus senere @@ -130,27 +130,27 @@ kun på klokke kun på telefon - Innstillinger for hurtigveiviser + Innstillinger for hurtigknapp Knappetekst: Karbo: Gyldig: Legg til Rediger Vis oppføring på enhet: - BS beregning - Bolus IOB beregning - Basal IOB beregning - Trendberegning - Superbolus beregning + BS-beregning + Bolus IOB-beregning + Basal IOB-beregning + Trend-beregning + Superbolus-beregning Prosent Alt Telefon Klokke Bare positive Bare negative - COB beregning - Beregning av midl. mål - Prosent beregning + COB-beregning + Beregning av midlertidig mål + Prosent-beregning Standardverdi håndtering av dra-og-slipp diff --git a/wear/src/main/res/values-nb-rNO/strings.xml b/wear/src/main/res/values-nb-rNO/strings.xml index 19a7d80008..426e56cc75 100644 --- a/wear/src/main/res/values-nb-rNO/strings.xml +++ b/wear/src/main/res/values-nb-rNO/strings.xml @@ -12,7 +12,7 @@ AAPS(Tilpasset) AAPS(Actions) AAPS(Midl. Mål) - AAPS(Quick Wizard) + AAPS(Hurtigknapp) Ingen data! Gamle data! Siden %1$s @@ -95,7 +95,7 @@ XL Varighet Midl. mål forespurt - Quick Wizard forespurt + Hurtigknapp forespurt Behandling forespurt Bolus forespurt Beregning forespurt From ae3b66d5c0cc8c454669134e358f95ef1665cbcc Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 10 Oct 2023 23:14:02 +0200 Subject: [PATCH 125/127] Wear: handle QuickWizard as BolusWizard --- .../main/general/wear/wearintegration/DataHandlerMobile.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataHandlerMobile.kt b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataHandlerMobile.kt index c45bd99c33..c55939ecbc 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataHandlerMobile.kt +++ b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/wear/wearintegration/DataHandlerMobile.kt @@ -495,11 +495,12 @@ class DataHandlerMobile @Inject constructor( val message = rh.gs(R.string.quick_wizard_message, quickWizardEntry.buttonText(), wizard.calculatedTotalInsulin, quickWizardEntry.carbs()) + "\n_____________\n" + wizard.explainShort() + lastBolusWizard = wizard rxBus.send( EventMobileToWear( EventData.ConfirmAction( rh.gs(app.aaps.core.ui.R.string.confirm).uppercase(), message, - returnCommand = EventData.ActionBolusConfirmed(insulinAfterConstraints, carbsAfterConstraints) + returnCommand = EventData.ActionWizardConfirmed(wizard.timeStamp) ) ) ) From 7df80eebe0d7c14c803a8375c39f00c2c49c61f5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 10 Oct 2023 23:19:34 +0200 Subject: [PATCH 126/127] More detailed info on clearing database --- .../app/aaps/database/impl/AppRepository.kt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/database/impl/src/main/java/app/aaps/database/impl/AppRepository.kt b/database/impl/src/main/java/app/aaps/database/impl/AppRepository.kt index 0e82476a24..c5cb3fbcd4 100644 --- a/database/impl/src/main/java/app/aaps/database/impl/AppRepository.kt +++ b/database/impl/src/main/java/app/aaps/database/impl/AppRepository.kt @@ -105,23 +105,23 @@ import kotlin.math.roundToInt removed.add(Pair("HeartRate", database.heartRateDao.deleteOlderThan(than))) if (deleteTrackedChanges) { - removed.add(Pair("GlucoseValue", database.glucoseValueDao.deleteTrackedChanges())) - removed.add(Pair("TherapyEvent", database.therapyEventDao.deleteTrackedChanges())) - removed.add(Pair("TemporaryBasal", database.temporaryBasalDao.deleteTrackedChanges())) - removed.add(Pair("Bolus", database.bolusDao.deleteTrackedChanges())) - removed.add(Pair("ExtendedBolus", database.extendedBolusDao.deleteTrackedChanges())) - removed.add(Pair("MultiWaveBolus", database.multiwaveBolusLinkDao.deleteTrackedChanges())) - // keep TDD removed.add(Pair("TotalDailyDose", database.totalDailyDoseDao.deleteTrackedChanges())) - removed.add(Pair("Carbs", database.carbsDao.deleteTrackedChanges())) - removed.add(Pair("TemporaryTarget", database.temporaryTargetDao.deleteTrackedChanges())) - removed.add(Pair("ApsResultLink", database.apsResultLinkDao.deleteTrackedChanges())) - removed.add(Pair("BolusCalculatorResult", database.bolusCalculatorResultDao.deleteTrackedChanges())) - removed.add(Pair("EffectiveProfileSwitch", database.effectiveProfileSwitchDao.deleteTrackedChanges())) - removed.add(Pair("ProfileSwitch", database.profileSwitchDao.deleteTrackedChanges())) - removed.add(Pair("ApsResult", database.apsResultDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES GlucoseValue", database.glucoseValueDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES TherapyEvent", database.therapyEventDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES TemporaryBasal", database.temporaryBasalDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES Bolus", database.bolusDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES ExtendedBolus", database.extendedBolusDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES MultiWaveBolus", database.multiwaveBolusLinkDao.deleteTrackedChanges())) + // keep TDD removed.add(Pair("CHANGES TotalDailyDose", database.totalDailyDoseDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES Carbs", database.carbsDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES TemporaryTarget", database.temporaryTargetDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES ApsResultLink", database.apsResultLinkDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES BolusCalculatorResult", database.bolusCalculatorResultDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES EffectiveProfileSwitch", database.effectiveProfileSwitchDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES ProfileSwitch", database.profileSwitchDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES ApsResult", database.apsResultDao.deleteTrackedChanges())) // keep food database.foodDao.deleteHistory() - removed.add(Pair("OfflineEvent", database.offlineEventDao.deleteTrackedChanges())) - removed.add(Pair("HeartRate", database.heartRateDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES OfflineEvent", database.offlineEventDao.deleteTrackedChanges())) + removed.add(Pair("CHANGES HeartRate", database.heartRateDao.deleteTrackedChanges())) } val ret = StringBuilder() removed From 0caded7bbb2c09036f4dc20a80b04634eb275441 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 10 Oct 2023 23:32:23 +0200 Subject: [PATCH 127/127] Xdrip: check for running sync --- .../sync/xdrip/DataSyncSelectorXdripImpl.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/xdrip/DataSyncSelectorXdripImpl.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/xdrip/DataSyncSelectorXdripImpl.kt index 315a5e9957..5153dd95bf 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/xdrip/DataSyncSelectorXdripImpl.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/xdrip/DataSyncSelectorXdripImpl.kt @@ -4,6 +4,9 @@ import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.plugin.ActivePlugin import app.aaps.core.interfaces.profile.ProfileFunction +import app.aaps.core.interfaces.rx.bus.RxBus +import app.aaps.core.interfaces.rx.events.EventNSClientNewLog +import app.aaps.core.interfaces.rx.events.EventXdripNewLog import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sync.DataSyncSelector import app.aaps.core.interfaces.sync.DataSyncSelectorXdrip @@ -25,7 +28,8 @@ class DataSyncSelectorXdripImpl @Inject constructor( private val profileFunction: ProfileFunction, private val activePlugin: ActivePlugin, private val xdripBroadcast: Lazy, - private val appRepository: AppRepository + private val appRepository: AppRepository, + private val rxBus: RxBus ) : DataSyncSelectorXdrip { class QueueCounter( @@ -72,7 +76,17 @@ class DataSyncSelectorXdripImpl @Inject constructor( override fun queueSize(): Long = queueCounter.size() + private var running = false + private val sync = Any() + override suspend fun doUpload() { + synchronized(sync) { + if (running) { + rxBus.send(EventXdripNewLog("RUN", "Already running")) + return + } + running = true + } if (isEnabled) { processChangedGlucoseValues() processChangedBoluses() @@ -96,6 +110,7 @@ class DataSyncSelectorXdripImpl @Inject constructor( // not supported at the moment //processChangedProfileStore() } + running = false } override fun resetToNextFullSync() {