From 518f2836507a95c8224fb178333d4e7f3d7b5458 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 21 Nov 2021 19:32:52 +0100 Subject: [PATCH 1/6] Add string Command Queue --- .../androidaps/queue/commands/CommandBolus.kt | 4 ++-- .../commands/CommandCancelExtendedBolus.kt | 3 ++- .../queue/commands/CommandCancelTempBasal.kt | 3 ++- .../queue/commands/CommandExtendedBolus.kt | 3 ++- .../CommandInsightSetTBROverNotification.kt | 3 ++- .../queue/commands/CommandLoadEvents.kt | 3 ++- .../queue/commands/CommandLoadHistory.kt | 3 ++- .../queue/commands/CommandLoadTDDs.kt | 3 ++- .../queue/commands/CommandSMBBolus.kt | 2 +- .../queue/commands/CommandSetProfile.kt | 2 +- .../queue/commands/CommandSetUserSettings.kt | 3 ++- .../queue/commands/CommandStartPump.kt | 3 ++- .../queue/commands/CommandStopPump.kt | 3 ++- .../queue/commands/CommandTempBasalAbsolute.kt | 3 ++- .../queue/commands/CommandTempBasalPercent.kt | 3 ++- core/src/main/res/values/strings.xml | 18 ++++++++++++++++-- 16 files changed, 44 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.kt index 0de6850a6d..68d26d57c8 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.kt @@ -32,7 +32,7 @@ class CommandBolus( } override fun status(): String { - return (if (detailedBolusInfo.insulin > 0) "BOLUS " + rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin) else "") + - if (detailedBolusInfo.carbs > 0) "CARBS " + rh.gs(R.string.format_carbs, detailedBolusInfo.carbs.toInt()) else "" + return (if (detailedBolusInfo.insulin > 0) rh.gs(R.string.bolus_u_min, detailedBolusInfo.insulin) else "") + + if (detailedBolusInfo.carbs > 0) rh.gs(R.string.carbs_g, detailedBolusInfo.carbs.toInt()) else "" } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.kt index c15d0e7914..a2053c1f45 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.queue.Callback @@ -19,5 +20,5 @@ class CommandCancelExtendedBolus constructor( callback?.result(r)?.run() } - override fun status(): String = "CANCEL EXTENDEDBOLUS" + override fun status(): String = rh.gs(R.string.uel_cancel_extended_bolus) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.kt index 79835a9ecd..2f27ec33f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.queue.Callback @@ -20,5 +21,5 @@ class CommandCancelTempBasal( callback?.result(r)?.run() } - override fun status(): String = "CANCEL TEMPBASAL" + override fun status(): String = rh.gs(R.string.uel_accepts_temp_basal) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.kt index c1c67bfac4..e0fe72e4cc 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.queue.Callback @@ -21,5 +22,5 @@ class CommandExtendedBolus constructor( callback?.result(r)?.run() } - override fun status(): String = "EXTENDEDBOLUS $insulin U $durationInMinutes min" + override fun status(): String = rh.gs(R.string.extended_bolus_u_min, insulin, durationInMinutes) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandInsightSetTBROverNotification.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandInsightSetTBROverNotification.kt index ab8b8bd3e2..695f097004 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandInsightSetTBROverNotification.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandInsightSetTBROverNotification.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.queue.Callback @@ -23,5 +24,5 @@ class CommandInsightSetTBROverNotification constructor( } @Suppress("SpellCheckingInspection") - override fun status(): String = "INSIGHTSETTBROVERNOTIFICATION" + override fun status(): String = rh.gs(R.string.insight_set_tbr_over_notification) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.kt index 58a0570eaf..886027428b 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.Dana import info.nightscout.androidaps.interfaces.Diaconn @@ -32,5 +33,5 @@ class CommandLoadEvents( } } - override fun status(): String = "LOAD EVENTS" + override fun status(): String = rh.gs(R.string.load_events) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.kt index 3ff9c133c1..dd0694741e 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.Dana import info.nightscout.androidaps.interfaces.Diaconn @@ -33,5 +34,5 @@ class CommandLoadHistory( } } - override fun status(): String = "LOAD HISTORY $type" + override fun status(): String = rh.gs(R.string.load_history, type.toInt()) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.kt index a38ab32962..3513e1efff 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.queue.Callback @@ -20,5 +21,5 @@ class CommandLoadTDDs( callback?.result(r)?.run() } - override fun status(): String = "LOAD TDDs" + override fun status(): String = rh.gs(R.string.load_tdds) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt index 6fc51058b7..e5ace367c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt @@ -37,5 +37,5 @@ class CommandSMBBolus( callback?.result(r)?.run() } - override fun status(): String = "SMB BOLUS ${rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin)}" + override fun status(): String = rh.gs(R.string.smb_bolus_u, detailedBolusInfo.insulin) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.kt index fdf3fb28fa..5eaca9aa0a 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.kt @@ -45,5 +45,5 @@ class CommandSetProfile constructor( } } - override fun status(): String = "SET PROFILE" + override fun status(): String = rh.gs(R.string.set_profile) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.kt index 7460529e67..c0fd30e315 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.Dana import info.nightscout.androidaps.interfaces.Diaconn @@ -30,5 +31,5 @@ class CommandSetUserSettings( } } - override fun status(): String = "SET USER SETTINGS" + override fun status(): String = rh.gs(R.string.set_user_settings) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandStartPump.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandStartPump.kt index 8987208bab..8444f5bc90 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandStartPump.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandStartPump.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.queue.Callback @@ -21,5 +22,5 @@ class CommandStartPump( } } - override fun status(): String = "START PUMP" + override fun status(): String = rh.gs(R.string.start_pump) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandStopPump.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandStopPump.kt index 894573f435..3568d2656e 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandStopPump.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandStopPump.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.queue.Callback @@ -21,5 +22,5 @@ class CommandStopPump( } } - override fun status(): String = "STOP PUMP" + override fun status(): String = rh.gs(R.string.stop_pump) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.kt index 647a6feee6..b87496af59 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.PumpSync @@ -26,5 +27,5 @@ class CommandTempBasalAbsolute( callback?.result(r)?.run() } - override fun status(): String = "TEMP BASAL $absoluteRate U/h $durationInMinutes min" + override fun status(): String = rh.gs(R.string.temp_basal_absolute, absoluteRate, durationInMinutes) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.kt index d4b559edd6..6b198cb40c 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.PumpSync @@ -30,5 +31,5 @@ class CommandTempBasalPercent( callback?.result(r)?.run() } - override fun status(): String = "TEMP BASAL $percent% $durationInMinutes min" + override fun status(): String = rh.gs(R.string.temp_basal_percent, percent, durationInMinutes) } \ No newline at end of file diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 209944b186..ab9c924cb5 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -504,7 +504,22 @@ Basal value NSClient version doesn\'t match to AndroidAPS. Please update. - + + BOLUS %1$.2f U + CARBS %1$d g + EXTENDED BOLUS %1$.2f U %2$d min + LOAD EVENTS + LOAD HISTORY %1$d + LOAD TDDs + SET PROFILE + SET USER SETTINGS + SMB BOLUS %1$.2f U + START PUMP + STOP PUMP + TEMP BASAL %1$.2f U/h %2$d min + TEMP BASAL %1$d% %2$d min + INSIGHT SET TBR OVER NOTIFICATION + READSTATUS %1$s KeepAlive. Status outdated. KeepAlive. Basal outdated. SMS @@ -520,7 +535,6 @@ Bolus OK Pump paired Insight Refresh Button - READSTATUS %1$s %1$d day From bbab3b0c9d88b4f49aa21719aa868849a6f82289 Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 22 Nov 2021 23:57:52 +0100 Subject: [PATCH 2/6] Fix Tests --- .../general/smsCommunicator/SmsCommunicatorPluginTest.kt | 2 ++ .../info/nightscout/androidaps/queue/QueueThreadTest.kt | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index 0aa864c7cf..6dc184e56b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -227,6 +227,8 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { `when`(rh.gs(R.string.smscommunicator_code_from_authenticator_for)).thenReturn("from Authenticator app for: %1\$s followed by PIN") `when`(rh.gs(R.string.patient_name_default)).thenReturn("User") `when`(rh.gs(R.string.invalidprofile)).thenReturn("Invalid profile !!!") + `when`(rh.gs(R.string.sms)).thenReturn("SMS") + `when`(rh.gs(ArgumentMatchers.eq(R.string.bolus_u_min), ArgumentMatchers.any())).thenAnswer { i: InvocationOnMock -> "BOLUS " + i.arguments[1] + " U" } `when`(rh.gsNotLocalised(R.string.loopsuspended)).thenReturn("Loop suspended") `when`(rh.gsNotLocalised(R.string.smscommunicator_stoppedsms)).thenReturn("SMS Remote Service stopped. To reactivate it, use AAPS on master smartphone.") `when`(rh.gsNotLocalised(R.string.profileswitchcreated)).thenReturn("Profile switch created") diff --git a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt index 9c6688791d..d2a2d3fac5 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt @@ -4,6 +4,7 @@ import android.content.Context import android.os.PowerManager import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.database.AppRepository @@ -21,8 +22,10 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Assert import org.junit.Before import org.junit.Test +import org.mockito.ArgumentMatchers import org.mockito.Mock import org.mockito.Mockito +import org.mockito.invocation.InvocationOnMock class QueueThreadTest : TestBaseWithProfile() { @@ -41,6 +44,7 @@ class QueueThreadTest : TestBaseWithProfile() { } if (it is CommandTempBasalAbsolute) { it.activePlugin = activePlugin + it.rh = rh } } } @@ -75,6 +79,8 @@ class QueueThreadTest : TestBaseWithProfile() { val percentageConstraint = Constraint(0) Mockito.`when`(constraintChecker.applyBasalPercentConstraints(anyObject(), anyObject())) .thenReturn(percentageConstraint) + Mockito.`when`(rh.gs(ArgumentMatchers.eq(R.string.temp_basal_absolute), ArgumentMatchers.anyDouble(), ArgumentMatchers.anyInt())).thenReturn("TEMP BASAL %1\$.2f U/h %2\$d min").thenAnswer { + i: InvocationOnMock -> "TEMP BASAL " + i.arguments[1] + " U/h " + i.arguments[2] + "min" } sut = QueueThread(commandQueue, context, aapsLogger, rxBus, activePlugin, rh, sp) } From 7c7bece171963f8b8c10abe5bfff81c97606b76a Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 23 Nov 2021 00:12:19 +0100 Subject: [PATCH 3/6] Remove unnecessary string --- .../plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index 6dc184e56b..d71447e89c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -228,7 +228,6 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { `when`(rh.gs(R.string.patient_name_default)).thenReturn("User") `when`(rh.gs(R.string.invalidprofile)).thenReturn("Invalid profile !!!") `when`(rh.gs(R.string.sms)).thenReturn("SMS") - `when`(rh.gs(ArgumentMatchers.eq(R.string.bolus_u_min), ArgumentMatchers.any())).thenAnswer { i: InvocationOnMock -> "BOLUS " + i.arguments[1] + " U" } `when`(rh.gsNotLocalised(R.string.loopsuspended)).thenReturn("Loop suspended") `when`(rh.gsNotLocalised(R.string.smscommunicator_stoppedsms)).thenReturn("SMS Remote Service stopped. To reactivate it, use AAPS on master smartphone.") `when`(rh.gsNotLocalised(R.string.profileswitchcreated)).thenReturn("Profile switch created") From 4bbd3128919d4b0955aa266479750f1be8b5417d Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 23 Nov 2021 00:14:22 +0100 Subject: [PATCH 4/6] Simplify Mock --- .../java/info/nightscout/androidaps/queue/QueueThreadTest.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt index d2a2d3fac5..6f45105592 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt @@ -79,8 +79,7 @@ class QueueThreadTest : TestBaseWithProfile() { val percentageConstraint = Constraint(0) Mockito.`when`(constraintChecker.applyBasalPercentConstraints(anyObject(), anyObject())) .thenReturn(percentageConstraint) - Mockito.`when`(rh.gs(ArgumentMatchers.eq(R.string.temp_basal_absolute), ArgumentMatchers.anyDouble(), ArgumentMatchers.anyInt())).thenReturn("TEMP BASAL %1\$.2f U/h %2\$d min").thenAnswer { - i: InvocationOnMock -> "TEMP BASAL " + i.arguments[1] + " U/h " + i.arguments[2] + "min" } + Mockito.`when`(rh.gs(ArgumentMatchers.eq(R.string.temp_basal_absolute), ArgumentMatchers.anyDouble(), ArgumentMatchers.anyInt())).thenReturn("TEMP BASAL %1\$.2f U/h %2\$d min") sut = QueueThread(commandQueue, context, aapsLogger, rxBus, activePlugin, rh, sp) } From 6042adbca520bcb209f30679609f6f832519b0e5 Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 23 Nov 2021 00:19:31 +0100 Subject: [PATCH 5/6] Remove unused import and simplify a bit more --- .../java/info/nightscout/androidaps/queue/QueueThreadTest.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt index 6f45105592..6281c576a3 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt @@ -25,7 +25,6 @@ import org.junit.Test import org.mockito.ArgumentMatchers import org.mockito.Mock import org.mockito.Mockito -import org.mockito.invocation.InvocationOnMock class QueueThreadTest : TestBaseWithProfile() { @@ -79,7 +78,7 @@ class QueueThreadTest : TestBaseWithProfile() { val percentageConstraint = Constraint(0) Mockito.`when`(constraintChecker.applyBasalPercentConstraints(anyObject(), anyObject())) .thenReturn(percentageConstraint) - Mockito.`when`(rh.gs(ArgumentMatchers.eq(R.string.temp_basal_absolute), ArgumentMatchers.anyDouble(), ArgumentMatchers.anyInt())).thenReturn("TEMP BASAL %1\$.2f U/h %2\$d min") + Mockito.`when`(rh.gs(ArgumentMatchers.eq(R.string.temp_basal_absolute), anyObject(), anyObject())).thenReturn("TEMP BASAL %1\$.2f U/h %2\$d min") sut = QueueThread(commandQueue, context, aapsLogger, rxBus, activePlugin, rh, sp) } From 7225df34818328116ce20728eeae1e4abdf67a4a Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 23 Nov 2021 20:22:04 +0100 Subject: [PATCH 6/6] Fix Crash (wrong format) --- core/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index ab9c924cb5..f3b3eac818 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -517,7 +517,7 @@ START PUMP STOP PUMP TEMP BASAL %1$.2f U/h %2$d min - TEMP BASAL %1$d% %2$d min + TEMP BASAL %1$d%% %2$d min INSIGHT SET TBR OVER NOTIFICATION READSTATUS %1$s KeepAlive. Status outdated.