Merge remote-tracking branch 'Nightscout/dev' into wear/new_custom_watchface

This commit is contained in:
Philoul 2023-10-11 08:38:10 +02:00
commit 40632d463c
179 changed files with 1389 additions and 1533 deletions

View file

@ -9,7 +9,7 @@
<string name="delta">Delta</string>
<string name="profile_label">Profil</string>
<string name="save">Lagre</string>
<string name="reloadprofile">Les inn profil på nytt</string>
<string name="reloadprofile">Last inn profil på nytt</string>
<string name="correctionbous">Korreksjon</string>
<string name="ns_upload_only">(FARLIG Å DEAKTIVERE) Kun NS opplasting</string>
<string name="ns_upload_only_summary">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!</string>

View file

@ -11,15 +11,15 @@ 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'
activity_version = '1.8.0'
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'
material_version = '1.10.0'
gridlayout_version = '1.0.0'
constraintlayout_version = '2.1.4'
preferencektx_version = '1.2.1'
@ -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'

View file

@ -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

View file

@ -54,7 +54,7 @@
<string name="pref_show_basal_rate">Vis basalrate</string>
<string name="pref_show_loop_status">Vis loop status</string>
<string name="pref_show_bg">Vis BS</string>
<string name="pref_show_bgi">Vis BS</string>
<string name="pref_show_bgi">Vis BGI</string>
<string name="pref_show_direction_arrow">Vis retningspil</string>
<string name="pref_show_ago">Vis tid siden</string>
<string name="pref_show_week_number">Vis ukenummer</string>

View file

@ -64,7 +64,7 @@
<string name="carbs">Karbo</string>
<string name="invalid_profile">Ugyldig profil!</string>
<string name="no_profile_set">INGEN PROFIL VALGT</string>
<string name="active"><![CDATA[<Active>]]></string>
<string name="active"><![CDATA[<Aktiv>]]></string>
<string name="date">Dato</string>
<string name="units_label">Enheter</string>
<string name="dia_label">DIA</string>
@ -73,7 +73,7 @@
<string name="basal_label">Basal</string>
<string name="target_label">Målverdi</string>
<string name="dia_long_label">Insulinets virkningstid (DIA)</string>
<string name="ic_long_label">Insulin- til karbohydratfaktor</string>
<string name="ic_long_label">Insulin-karbohydratfaktor (IK)</string>
<string name="isf_long_label">Insulin sensitivitetsfaktor (ISF)</string>
<string name="basal_long_label">Basalrate</string>
<string name="target_long_label">Blodsukkermål</string>
@ -136,7 +136,7 @@
<string name="a11y_low">lavt</string>
<string name="average">Gjennomsnitt</string>
<string name="tir">TIR</string>
<string name="none"><![CDATA[<none>]]></string>
<string name="none"><![CDATA[<ingen>]]></string>
<string name="remove_label">FJERN</string>
<string name="activate_profile">Aktiver profil</string>
<string name="reset">tilbakestill</string>
@ -146,7 +146,7 @@
<string name="confirm_remove_multiple_items">Er du sikker på at du vil fjerne %1$d elementer</string>
<string name="overview_treatment_label">Behandling</string>
<string name="copytolocalprofile">Opprett ny profil fra denne profilen?</string>
<string name="wear_wizard_settings">Innstillinger for veiviser</string>
<string name="wear_wizard_settings">Kalkulatorinnstillinger</string>
<string name="bg_trend_label">15 min trend</string>
<string name="treatments_wizard_cob_label">COB</string>
<string name="bolus_iob_label">Bolus IOB</string>
@ -155,7 +155,7 @@
<string name="login">Login</string>
<string name="prime_fill">Prime/fylling</string>
<string name="overview_insulin_label">Insulin</string>
<string name="stoptemptarget">Avbryt temp target</string>
<string name="stoptemptarget">Avbryt midlertidig målverdi</string>
<string name="closedloop">Lukket Loop</string>
<string name="openloop">Åpen Loop</string>
<string name="lowglucosesuspend">Stopp ved lavt BS</string>
@ -220,10 +220,10 @@
<string name="careportal_carbscorrection">Karbo-korreksjon</string>
<string name="careportal_openapsoffline">OpenAPS Offline</string>
<string name="pump_battery_change">Bytte pumpebatteri</string>
<string name="temporary_target">Midlertidig BS-mål</string>
<string name="temporary_target">Midlertidig mål</string>
<string name="careportal_temporarytargetvalue">Midlertidig målverdi</string>
<string name="careportal_temporarytargetcancel">Avbryt midl. mål</string>
<string name="boluswizard">Bolusassistent</string>
<string name="boluswizard">Boluskalkulator</string>
<string name="glucosetype_finger">Finger</string>
<string name="glucosetype_sensor">Sensor</string>
<string name="manual">Manuell</string>
@ -453,10 +453,10 @@
<string name="info">INFO</string>
<!-- BolusWizard -->
<string name="bolus_advisor">Bolusveiviser</string>
<string name="bolus_advisor_message">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.</string>
<string name="bolus_advisor_message">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.</string>
<string name="cobvsiob">COB vs IOB</string>
<string name="slowabsorptiondetected"><![CDATA[<font color=\'%1$s\'>!! 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 !!</font>]]></string>
<string name="partialboluswizard">Doser denne delen av resultatet fra bolusveiviseren [%]</string>
<string name="partialboluswizard">Doser denne delen av resultatet fra boluskalkulatoren [%]</string>
<string name="partialboluswizard_reset_time">Terskel for gammel BS-verdi [min]</string>
<string name="bolus_constraint_applied_warn">Bolus begrensning brukt: %1$.2f E til %2$.2f E</string>
<string name="bolus_recorded_only">Bolus vil bare bli loggført (ikke levert av pumpe)</string>
@ -478,7 +478,7 @@
<string name="wizard_explain_tt">TempT: %1$s</string>
<string name="wizard_explain_tt_to">%1$s til %2$s</string>
<string name="wizard_pump_not_available">Ingen pumpe tilgjengelig!</string>
<string name="quickwizard">Hurtigveiviser</string>
<string name="quickwizard">Hurtigknapp</string>
<!-- Preferences-->
<string name="child">Barn</string>
<string name="teenage">Tenåring</string>
@ -486,8 +486,8 @@
<string name="resistant_adult">Insulinresistent voksen</string>
<string name="pregnant">Graviditet</string>
<string name="patient_age_summary">Velg pasienttype for oppsett av sikkerhetsgrenser</string>
<string name="max_bolus_title">Maks tillat bolus [U]</string>
<string name="max_carbs_title">Maks tillat karbo [g]</string>
<string name="max_bolus_title">Maks tillatt bolus [U]</string>
<string name="max_carbs_title">Maks tillatt karbohydrater [g]</string>
<string name="patient_type">Pasienttype</string>
<!-- Protection-->
<string name="unlock_settings">Lås opp innstillinger</string>

View file

@ -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

View file

@ -83,6 +83,7 @@
<string name="smb_disabled_in_preferences">SMB išjungti nustatymuose</string>
<string name="uam_disabled_in_preferences">NDM nustatymas išjungtas nustatymuose</string>
<string name="autosens_disabled_in_preferences">Autosens funkcija išjungta nustatymuose</string>
<string name="autosens_disabled_in_dyn_isf">Autosens neveikia DynISF</string>
<!-- Verify if needed in safety-->
<string name="limiting_iob">Ribojamas AIO iki %1$.1f V dėl %2$s</string>
<string name="maxvalueinpreferences">Maksimali reikšmė nustatymuose</string>

View file

@ -83,6 +83,7 @@
<string name="smb_disabled_in_preferences">Супер микро болюс SMB отключен в настройках</string>
<string name="uam_disabled_in_preferences">Непредвиденный прием пищи UAM отключен в настройках</string>
<string name="autosens_disabled_in_preferences">Автоматический подбор чувствительности Autosens отключен в настройках</string>
<string name="autosens_disabled_in_dyn_isf">Autosens отключён в DynISF</string>
<!-- Verify if needed in safety-->
<string name="limiting_iob">Ограничение активного инсулина IOB до %1$.1f ед. из-за %2$s</string>
<string name="maxvalueinpreferences">максимальное значение в настройках</string>

View file

@ -83,6 +83,7 @@
<string name="smb_disabled_in_preferences">SMB zakázané v nastaveniach</string>
<string name="uam_disabled_in_preferences">UAM zakázané v nastaveniach</string>
<string name="autosens_disabled_in_preferences">Automatická detekcia citlivosti zakázaná v nastaveniach</string>
<string name="autosens_disabled_in_dyn_isf">Autosens zakázaný v DynISF</string>
<!-- Verify if needed in safety-->
<string name="limiting_iob">IOB obmedzený na %1$.1f JI: %2$s</string>
<string name="maxvalueinpreferences">maximálna hodnota v nastaveniach</string>

View file

@ -113,7 +113,7 @@
<string name="add_automation">Legg til regel</string>
<string name="stop_processing">Stopp prosessering</string>
<!-- Reminders-->
<string name="time_to_eat">Nå må du spise!\nBruk bolusveiviser og gjør beregning på nytt.</string>
<string name="time_to_bolus">Tid for bolus!\nStart bolusveiviser og gjør beregning på nytt.</string>
<string name="time_to_eat">Nå må du spise!\nBruk boluskalkulator og gjør beregning på nytt.</string>
<string name="time_to_bolus">Tid for bolus!\nStart boluskalkulator og gjør beregning på nytt.</string>
<string name="error_setting_reminder">Feil under innstilling av fremtidig alarm</string>
</resources>

View file

@ -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()
}
}

View file

@ -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)
}
}
}

View file

@ -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())
}
}
}

View file

@ -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)
}
}
}

View file

@ -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")
}
}
}

View file

@ -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)
}
}
}

View file

@ -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<ActionDummy>(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<ActionDummy>(action)
action = ActionDummy(injector).instantiate(JSONObject("{\"type\":\"ActionDummy\"}"))
Assertions.assertTrue(action is ActionDummy)
action = ActionDummy(injector).instantiate(JSONObject("""{"type":"ActionDummy"}"""))
assertIs<ActionDummy>(action)
}
}
}

View file

@ -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())
}
}
}

View file

@ -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")
}
}
}

View file

@ -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)
}
}
}

View file

@ -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()
}
}
}

View file

@ -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")
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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")
}
}
}

View file

@ -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<Transaction<InsertAndCancelCurrentTemporaryTargetTransaction.TransactionResult>>())
}
@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)
}
}
}

View file

@ -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()
}
})
}
}
}

View file

@ -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<Transaction<CancelCurrentTemporaryTargetIfAnyTransaction.TransactionResult>>()))
}
@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()
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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<Int?>(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<Int?>(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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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")
}
}
}

View file

@ -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")
}
}
}

View file

@ -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)
}
}
}

View file

@ -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<InputInsulin>(l.element)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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")
}
}
}

View file

@ -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)
}
}
private fun generateAutosensData() = AutosensDataObject(injector)
}

View file

@ -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)
}
}
}

View file

@ -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
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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<TriggerDummy>(trigger)
trigger = TriggerDummy(injector).instantiate(JSONObject("{\"data\":{},\"type\":\"app.aaps.plugins.automation.triggers.TriggerDummy\"}"))
Assertions.assertTrue(trigger is TriggerDummy)
assertIs<TriggerDummy>(trigger)
trigger = TriggerDummy(injector).instantiate(JSONObject("{\"data\":{},\"type\":\"TriggerDummy\"}"))
Assertions.assertTrue(trigger is TriggerDummy)
assertIs<TriggerDummy>(trigger)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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
}
}
}

View file

@ -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
}
}
}

View file

@ -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
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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
}
}
}

View file

@ -45,8 +45,8 @@
<string name="startobjective">Start første læringsmål</string>
<string name="setupwizard_pump_riley_link_status">RileyLink status:</string>
<string name="readstatus">Les status</string>
<string name="data_choices">Data valg</string>
<string name="fabric_upload">Innlesing av fabrikkinstillinger</string>
<string name="data_choices">Datavalg</string>
<string name="fabric_upload">Innlesing av fabrikkinnstillinger</string>
<string name="allow_automated_crash_reporting">Tillat automatisk rapportering av appkrasj og bruksdata til utviklerne via fabrioc.io-tjenesten.</string>
<string name="summary_email_for_crash_report">Denne e-postadressen vedlegges krasjrapporter slik at vi kan kontakte deg i akutte tilfeller. Det er valgfritt.</string>
<string name="identification">Identifikasjon (e-post, Facebook eller Discord nick osv.)</string>
@ -81,7 +81,7 @@
<string name="description_config_builder">Brukes for innstilling av aktive plugins</string>
<string name="allow_hardware_pump_text">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.</string>
<string name="a11y_open_settings">åpne innstillinger</string>
<string name="nsclient_version_does_not_match">NSClient-versjonen samsvarer ikke med AAPS-versjonen. Vennligst oppdater.</string>
<string name="nsclient_version_does_not_match">AAPSClient-versjonen samsvarer ikke med AAPS-versjonen. Vennligst oppdater.</string>
<!--ImportExport-->
<string name="nav_preferences">Innstillinger</string>
<string name="password_preferences_encrypt_prompt">Du må angi et hovedpassord som vil bli brukt til å kryptere dine eksporterte innstillinger. Husk dette!</string>

View file

@ -148,6 +148,7 @@
<string name="cob3_longer">Nustačius 150% profilį, sistemos apskaičiuotas angliavandenių įsisavinimo laikas pailgėja</string>
<string name="cob3_shorter">Nustačius 150% profilį, sistemos apskaičiuotas angliavandenių įsisavinimo laikas sutrumpėja</string>
<string name="cob3_no_effect">Nustačius 150% profilį, sistemos apskaičiuotas angliavandenių įsisavinimo laikas nepakinta</string>
<string name="cob_hint1">https://wiki.aaps.app/en/latest/Usage/COB-calculation.html#how-does-aaps-calculate-the-cob-value</string>
<string name="iob_value">AIO keičia nustatyta laikina valandinė bazė.</string>
<string name="iob_hightemp">Padidinta laikina bazė nebus nustatyta, jei glikemija yra žemiau numatyto tikslo.</string>
<string name="iob_negiob">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.</string>

View file

@ -190,20 +190,20 @@
<string name="ic_different">IK vil være forskjellig hvis du regner en skive brød som 10g eller 12g.</string>
<string name="ic_meaning">IK faktor betyr: Hvor mange brødenheter som dekkes av 1E insulin?</string>
<string name="ic_hint1">https://wiki.aaps.app/en/latest/Getting-Started/FAQ.html#insulin-to-carb-ratio-ic-g-u</string>
<string name="profileswitch_label">Profil bytte</string>
<string name="profileswitch_label">Profilbytte</string>
<string name="profileswitch_pctwillchange">Når du spesifiserer et profilbytte på 90%, hvilke svar er korrekte?</string>
<string name="profileswitch_basallower">Basaldoser vil være 10% lavere.</string>
<string name="profileswitch_isfhigher">ISF verdien vil være 10% høyere.</string>
<string name="profileswitch_iclower">Verdien av KH ratio vil være 10 % lavere.</string>
<string name="profileswitch_unchanged">ISF og KH ratio er uendret.</string>
<string name="profileswitch_hint1" formatted="false">https://wiki.aaps.app/en/latest/Usage/Profiles.html#profile-switch</string>
<string name="profileswitch2_label">Profil bytte</string>
<string name="profileswitch2_label">Profilbytte</string>
<string name="profileswitch2_pctwillchange">Når du spesifiserer et profilbytte på 120%, hvilke svar er korrekte?</string>
<string name="profileswitch2_bghigher">Blodsukkermålet vil være 20% høyere.</string>
<string name="profileswitch2_basalhigher">Basaldoser vil være 20% høyere.</string>
<string name="profileswitch2_bgunchanged">Blodsukkermålet vil være uforandret.</string>
<string name="profileswitch2_isfhigher">ISF vil være 20% høyere.</string>
<string name="profileswitchtime_label">Profil bytte</string>
<string name="profileswitchtime_label">Profilbytte</string>
<string name="profileswitchtime_iwant">Hvis du står opp 2 timer tidligere enn vanlig, hvordan forteller du AndroidAPS om endringen i døgnrytmen din?</string>
<string name="profileswitchtime_2">Gjør et profilbytte med en tidsforskyvning på 2</string>
<string name="profileswitchtime__2">Gjør et profilbytte med en tidsforskyvning på -2</string>

View file

@ -9,7 +9,7 @@
<string name="objectives_0_gate">Kontroller at BS er tilgjengelig i Nightscout og at insulindata fra pumpen lastes opp</string>
<string name="objectives_0_learned">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.</string>
<string name="objectives_openloop_objective">Starter med åpen loop</string>
<string name="objectives_openloop_gate">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)</string>
<string name="objectives_openloop_gate">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)</string>
<string name="objectives_openloop_learned">Å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.</string>
<string name="objectives_maxbasal_objective">Forstå din åpen loop, inkludert den temp basal anbefalingen</string>
<string name="objectives_maxbasal_gate">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</string>
@ -42,7 +42,7 @@
<string name="objectives_useprofileswitch">Angi profil 90% for 10 min (langt-trykk på profilnavn i Oversikt)</string>
<string name="objectives_usedisconnectpump">Simuler dusjing. Frakoble pumpen i 1t (langt trykk på Åpen Loop)</string>
<string name="objectives_usereconnectpump">... og koble til igjen på samme måte</string>
<string name="objectives_usetemptarget">Opprett egendefinerte midlertidige BS mål med 10 min varighet (langt-trykk på gjeldende mål)</string>
<string name="objectives_usetemptarget">Opprett egendefinerte midlertidige mål med 10 min varighet (langt-trykk på gjeldende mål)</string>
<string name="objectives_useactions">I Konfigurasjonsverktøyet aktiverer du Hendelser plugin, og gjør det synlig og viser innholdet fra menyen i øverste linje</string>
<string name="objectives_useloop">Vis innholdet i Loop plugin</string>
<string name="objectives_usescale">Test skaleringsfunksjonen ved et langt trykk på BS grafen</string>

View file

@ -45,7 +45,7 @@
<string name="closedmodeenabled">Lukket loop aktivert</string>
<string name="objectives_shortname">MÅL</string>
<string name="description_objectives">Opplæringsprogram</string>
<string name="doyouwantresetstart">Ønsker du å starte læringsmåletpå nytt? Du vil miste fullførte trinn.</string>
<string name="doyouwantresetstart">Ønsker du å starte læringsmålet på nytt? Du vil miste fullførte trinn.</string>
<string name="objectives_next_button">Neste</string>
<string name="objectives_previous_button">Forrige</string>
<string name="objectives_button_unfinish">Nullstille ferdig-status</string>

View file

@ -148,6 +148,7 @@
<string name="cob3_longer">Установка профиля на 150% увеличит расчетное время усвоения углеводов</string>
<string name="cob3_shorter">Установка профиля на 150% уменьшит расчетное время усвоения углеводов</string>
<string name="cob3_no_effect">Установка профиля на 150% не повлияет на расчетное время усвоения углеводов</string>
<string name="cob_hint1">https://wiki.aaps.app/en/latest/Usage/COB-calculation.html#how-does-aaps-calculate-the-cob-value</string>
<string name="iob_value">На величину IOB влияют устанавливаемые ВБС.</string>
<string name="iob_hightemp">Высокая ВБС не будет применяться, если уровень сахара в крови ниже целевого.</string>
<string name="iob_negiob">Отрицательный IOB в течение длительного периода при отсутствии физнагрузки указывает на то, что ваш профиль завышен и требуется снизить кол-во инсулина в настройках.</string>

View file

@ -148,6 +148,7 @@
<string name="cob3_longer">Nastavenie profilu na 150% spôsobí, že vypočítaná doba absorbcie sacharidov bude dlhšia</string>
<string name="cob3_shorter">Nastavenie profilu na 150% spôsobí, že vypočítaná doba absorbcie sacharidov bude kratšia</string>
<string name="cob3_no_effect">Nastavenie profilu na 150% neovplyvní vypočítanú absorbciu sacharidov</string>
<string name="cob_hint1">https://wiki.aaps.app/cs/latest/Usage/COB-calculation.html#how-does-aaps-calculate-the-cob-value</string>
<string name="iob_value">Hodnota IOB je ovplyvnená vydanými dočasnými bazálmi.</string>
<string name="iob_hightemp">Vysoký dočasný bazál nebude spustený, pokiaľ je Vaša glykémia nižšia, ako cieľ.</string>
<string name="iob_negiob">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.</string>

View file

@ -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)
)
)
)

View file

@ -137,10 +137,10 @@
<string name="delete_current_profile">Slette gjeldende profil?</string>
<string name="units_colon">Enheter:</string>
<string name="missing_profile_name">Mangler profilnavn</string>
<string name="error_in_ic_values">Feil i IK faktoren</string>
<string name="error_in_ic_values">Feil i IK-faktoren</string>
<string name="error_in_basal_values">Feil i basalverdiene</string>
<string name="error_in_target_values">Feil i BS målverdier</string>
<string name="error_in_isf_values">Feil i IF verdien</string>
<string name="error_in_isf_values">Feil i ISF-verdien</string>
<string name="profile_name_contains_dot">Noen av profilnavnene inneholder punktum.\nDette støttes ikke av NS.\nProfilen er ikke lastet opp til NS.</string>
<string name="invalid_profile_not_accepted">Ugyldig profil %1$s ikke akseptert fra NS</string>
<string name="view">Visning</string>
@ -212,26 +212,26 @@
<string name="openaps">OpenAPS</string>
<string name="uploader">Opplaster</string>
<string name="data_status">BS data status</string>
<string name="quickwizard_settings">Innstillinger for hurtigveiviser</string>
<string name="quickwizard_settings">Innstillinger for hurtigknapp</string>
<string name="keep_screen_on_title">Hold skjermen påslått</string>
<string name="keep_screen_on_summary">Forhindre Android fra å slå av skjermen. Mobilen vil bruke mye batteri hvis den ikke kobles til strømledning.</string>
<string name="treatments">Behandlinger</string>
<string name="carb_increment_button_message">Antall karbohydrater som skal legges til når knappen trykkes</string>
<string name="insulin_increment_button_message">Mengde insulin som skal legges til når knappen trykkes</string>
<string name="firstinsulinincrement">Første økning hurtigknapp for insulin</string>
<string name="secondinsulinincrement">Andre økning hurtigknapp for insulin</string>
<string name="thirdinsulinincrement">Tredje økning hurtigknapp for insulin</string>
<string name="firstcarbsincrement">Første økning hurtigknapp for karbohydrater</string>
<string name="secondcarbsincrement">Andre økning hurtigknapp for karbohydrater</string>
<string name="thirdcarbsincrement">Tredje økning hurtigknapp for karbohydrater</string>
<string name="firstinsulinincrement">Første økning knapp for insulin</string>
<string name="secondinsulinincrement">Andre økning knapp for insulin</string>
<string name="thirdinsulinincrement">Tredje økning knapp for insulin</string>
<string name="firstcarbsincrement">Første økning knapp for karbohydrater</string>
<string name="secondcarbsincrement">Andre økning knapp for karbohydrater</string>
<string name="thirdcarbsincrement">Tredje økning knapp for karbohydrater</string>
<string name="cgm">CGM</string>
<string name="default_temptargets">Standard midl. mål</string>
<string name="eatingsoon_duration">spise snart varighet</string>
<string name="eatingsoon_target">spise snart målverdi</string>
<string name="activity_duration">varighet for aktivitet</string>
<string name="activity_target">målverdi ved aktivitet</string>
<string name="hypo_duration">hypo varighet</string>
<string name="hypo_target">hypo målverdi</string>
<string name="default_temptargets">Standard midlertidig mål</string>
<string name="eatingsoon_duration">Spise snart varighet (min)</string>
<string name="eatingsoon_target">Spise snart målverdi</string>
<string name="activity_duration">Aktivitet varighet (min)</string>
<string name="activity_target">Aktivitet målverdi</string>
<string name="hypo_duration">Hypo varighet (min)</string>
<string name="hypo_target">Hypo målverdi</string>
<string name="fill_bolus_title">Standardverdier for påfyll/prime</string>
<string name="button1">Knapp 1</string>
<string name="button2">Knapp 2</string>
@ -241,23 +241,23 @@
<string name="low_mark">Lav verdi</string>
<string name="high_mark">Høy verdi</string>
<string name="short_tabtitles">Korte navn i menyfaner</string>
<string name="overview_show_notes_field_in_dialogs_title">Vis merknadsfelt i dialogvindu for behandlinger</string>
<string name="overview_show_notes_field_in_dialogs_title">Vis merknadsfelt i dialogvindu for boluskalkulator</string>
<string name="deliverpartofboluswizard">Bolusveiviser utfører beregninger, men bare denne del av beregnet insulin leveres. Nyttig ved bruk av SMB-algoritmen.</string>
<string name="deliver_part_of_boluswizard_reset_time">Gi full bolus (100 %) dersom blodsukker er eldre enn</string>
<string name="enable_bolus_advisor">Aktiver boluskalkulator</string>
<string name="enable_bolus_advisor_summary">Bruk en påminnelse om å spise senere isetdet for beregnet av kalkulator når blodsukker er høyt (\"pre-bolus\")</string>
<string name="enable_bolus_advisor">Aktiver bolusveileder</string>
<string name="enable_bolus_advisor_summary">Bruk en påminnelse om å spise senere istedet for boluskalkulatorens resultat når blodsukker er høyt (\"pre-bolus\")</string>
<string name="enablesuperbolus">Aktiver superbolus i veiviser</string>
<string name="enablesuperbolus_summary">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!</string>
<string name="enablesuperbolus_summary">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!</string>
<string name="enablebolusreminder">Aktiver boluspåminnelse</string>
<string name="enablebolusreminder_summary">Bruk påminnelse for å sette bolusdosen senere med veiviseren («post bolus»)</string>
<string name="enablebolusreminder_summary">Bruk en påminnelse for å sette bolusdosen senere med boluskalkulatoren («post bolus»)</string>
<string name="run_question">Kjør %s?</string>
<!-- OverviewMenu-->
<string name="overview_show_predictions">Prognoser</string>
<string name="overview_show_treatments">Behandlinger</string>
<string name="overview_show_heartRate">Puls</string>
<string name="overview_show_deviation_slope">Avvikskurve</string>
<string name="overview_show_activity">Aktivitet</string>
<string name="overview_show_bgi">Blodsukkerpåvirkning</string>
<string name="overview_show_activity">Insulinaktivitet</string>
<string name="overview_show_bgi">BS-påvirkning (BGI)</string>
<string name="overview_show_sensitivity">Sensitivitet</string>
<string name="overview_show_deviations">Avvik</string>
<string name="overview_show_cob">Aktive KH (COB)</string>
@ -274,7 +274,7 @@
<string name="treatments_shortname">BEH</string>
<string name="heartRate_shortname">HR</string>
<string name="sensitivity_shortname">SENS</string>
<string name="graph_scale">Graf skala</string>
<string name="graph_scale">Graf-skala</string>
<string name="graph_menu_divider_header">Graf</string>
<!-- Skins -->
<string name="classic_description">Opprinnelig visningstema</string>
@ -291,9 +291,9 @@
<string name="no_watch_connected">(Ingen klokke tilkoblet)</string>
<string name="pump_status">Pumpestatus</string>
<string name="loop_status">Loopstatus</string>
<string name="wizard_result">Kalkulator hurtigveiviser:\nInsulin: %1$.2fE\nKarbo: %2$dg</string>
<string name="quick_wizard_not_available">Den valgte hurtigveiviseren er ikke tilgjengelig lenger, oppdater klokkeurskive</string>
<string name="quick_wizard_message">Hurtigveiviser: %1$s\ninsulin: %2$.2fE\nKarbo: %3$dg</string>
<string name="wizard_result">Boluskalkulator:\nInsulin: %1$.2fE\nKarbo: %2$dg</string>
<string name="quick_wizard_not_available">Den valgte hurtigknappen er ikke lenger tilgjengelig, oppdater klokkeflis</string>
<string name="quick_wizard_message">Hurtigknapp: %1$s\ninsulin: %2$.2fE\nKarbo: %3$dg</string>
<string name="wear_action_tempt_preset_error">Ukjent forhåndsinnstilling midl. mål: %1$s</string>
<string name="wear_action_tempt_cancel_message">Avbryt gjeldende midl. mål?</string>
<string name="wear_action_tempt_unit_error">Forskjellige enheter brukt på klokke og telefon!</string>
@ -307,7 +307,7 @@
<string name="wear_settings">Klokkeinnstillinger</string>
<string name="wearcontrol_title">Kontroller fra klokke</string>
<string name="wearcontrol_summary">Sett midl. mål og angi behandlinger fra klokken.</string>
<string name="wear_wizard_settings_summary">Beregninger inkludert i resultatet fra veiviseren:</string>
<string name="wear_wizard_settings_summary">Beregninger inkludert i resultatet fra kalkulator:</string>
<string name="wear_general_settings">Generelle innstillinger</string>
<string name="wear_notifysmb_title">Varsle ved SMB</string>
<string name="wear_notifysmb_summary">Vis SMB på klokken som en standard bolus.</string>
@ -332,7 +332,7 @@
<string name="grams_short">g</string>
<string name="hour_short">t</string>
<string name="no_active_profile">Det er ikke angitt noen aktiv profil!</string>
<string name="profile_message">Profil:\n\nTidsforskyving: %1$d\nProsent: %2$d%%\"</string>
<string name="profile_message">Profil:\n\nTidsforskyving: %1$d\nProsent: %2$d%%</string>
<string name="tdd_line">%1$.2fE %1$.0f%%</string>
<string name="no_profile">Ingen profil valgt</string>
<string name="aps_only">Bare bruk i APS-modus!</string>

View file

@ -2,7 +2,7 @@
<resources>
<string name="smoothing_shortname">UTJEVNING</string>
<string name="exponential_smoothing_name">Eksponentiell utjevning</string>
<string name="description_exponential_smoothing">"Andre algoritme for eksponentiell utjevning"</string>
<string name="description_exponential_smoothing">"Andre ordens algoritme for eksponentiell utjevning"</string>
<string name="avg_smoothing_name">Gjennomsnittlig utjevning</string>
<string name="description_avg_smoothing">"Gjennomsnittlig utjevnings-algoritme, nyeste verdi påvirkes ikke"</string>
<string name="no_smoothing_name">Ingen utjevning</string>

View file

@ -34,6 +34,6 @@
<string name="do_xdrip_upload_summary">I xDrip+, velg 640G/Eversens som datakilde</string>
<string name="bgsource_upload">Innstillinger for opplasting av BS</string>
<string name="dexcom_log_ns_sensor_change_title">Logg sensorbytte til NS</string>
<string name="dexcom_log_ns_sensor_change_summary">Opprett hendelse \"Senso bytte\" automatisk i NS ved start av sensoren</string>
<string name="dexcom_log_ns_sensor_change_summary">Opprett hendelse \"Sensor bytte\" automatisk i NS ved start av sensoren</string>
<string name="direction">retning</string>
</resources>

View file

@ -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<XDripBroadcast>,
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() {

View file

@ -13,8 +13,8 @@
<string name="ns_create_announcements_from_carbs_req_title">Opprett varslinger hvis det er nødvendig med karbohydrater</string>
<string name="ns_create_announcements_from_errors_summary">Opprett varslinger i Nightscout ved feil eller meldinger (også synlig i Careportal under Behandlinger)</string>
<string name="ns_create_announcements_from_carbs_req_summary">Opprett Nightscout-meldinger ved behov for karbohydrater</string>
<string name="description_ns_client">Synkroniserer dine data med Nightscout</string>
<string name="description_ns_client_v3">Synkroniserer dataene dine med Nightscout med v3 API</string>
<string name="description_ns_client">Synkroniserer dine data med Nightscout v1 API</string>
<string name="description_ns_client_v3">Synkroniserer dine data med Nightscout v3 API</string>
<string name="blocked_by_charging">Blokkert på grunn av ladealternativer</string>
<string name="blocked_by_connectivity">Blokkert på grunn av tilkoblingsalternativer</string>
<string name="unsupported_ns_version">Versjonen av Nightscout støttes ikke</string>
@ -51,20 +51,20 @@
<string name="ns_upload">Last opp data til NS</string>
<string name="ns_receive_profile_store">Hent lagrede profiler</string>
<string name="ns_receive_profile_store_summary">Synkroniser profiler fra NS profileditor</string>
<string name="ns_receive_temp_target">Motta midlertidige BS-mål</string>
<string name="ns_receive_temp_target_summary">Aksepter midlertidige mål angitt med NS eller NSClient</string>
<string name="ns_receive_temp_target">Motta midlertidige mål</string>
<string name="ns_receive_temp_target_summary">Aksepter midlertidige mål angitt med NS eller AAPSClient</string>
<string name="ns_receive_profile_switch">Motta profilbytter</string>
<string name="ns_receive_profile_switch_summary">Aksepter profilbytter som er angitt via NS eller NSClient</string>
<string name="ns_receive_offline_event">Motta APS offline hendelser</string>
<string name="ns_receive_offline_event_summary">Aksepter APS offline hendelser lagt inn gjennom NS eller NSClient</string>
<string name="ns_receive_offline_event_summary">Aksepter APS offline hendelser lagt inn gjennom NS eller AAPSClient</string>
<string name="ns_receive_tbr_eb">Motta TBR og EB</string>
<string name="ns_receive_tbr_eb_summary">Godta TBR og EB beregninger fra tilleggsmodul</string>
<string name="ns_receive_insulin">Motta insulin</string>
<string name="ns_receive_insulin_summary">Aksepter insulin angitt via NS eller NSClient (enhetene er ikke dosert, kun beregnet mot IOB)</string>
<string name="ns_receive_insulin_summary">Aksepter insulin angitt via NS eller AAPSClient (enhetene er ikke dosert, kun beregnet mot IOB)</string>
<string name="ns_receive_carbs">Motta karbohydrater</string>
<string name="ns_receive_carbs_summary">Aksepter karbohydrater angitt med NS eller NSClient</string>
<string name="ns_receive_carbs_summary">Aksepter karbohydrater angitt med NS eller AAPSClient</string>
<string name="ns_receive_therapy_events">Motta behandlingshendelser</string>
<string name="ns_receive_therapy_events_summary">Godta behandlingshendelser (kanyle, insulin, batteribytte osv.) som er lagt inn gjennom NS eller NSClient</string>
<string name="ns_receive_therapy_events_summary">Godta behandlingshendelser (kanyle, insulin, batteribytte osv.) som er lagt inn gjennom NS eller AAPSClient</string>
<string name="ns_receive_cgm">Motta/tilbakefyll CGM data</string>
<string name="ns_receive_cgm_summary">Aksepter CGM data fra NS</string>
<string name="ns_sync_slow">Reduser opplastingshastighet</string>
@ -76,7 +76,7 @@
<string name="ns_log_app_started_event">Logg app-start til NS</string>
<string name="copy_existing_values">Kopiere NS innstillinger (hvis de eksisterer)?</string>
<string name="ns_use_ws_title">Koble til websockets</string>
<string name="ns_use_ws_summary">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.</string>
<string name="ns_use_ws_summary">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.</string>
<!-- Tidepool -->
<string name="summary_tidepool_username">Ditt Tidepool brukernavn, normalt din e-postadresse</string>
<string name="title_tidepool_username">Brukernavn for innlogging</string>

View file

@ -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)
}
}
}

View file

@ -3,7 +3,7 @@
<string name="resetpairing">Slett sammenkobling</string>
<string name="diaconn_no_device_available">Ingen enheter er tilgjengelige</string>
<string name="diaconn_pairing">Diaconn pumpe sammenkobling</string>
<string name="pumperror">Pumpe feil</string>
<string name="pumperror">Pumpefeil</string>
<string name="diaconn_g8_history_alarm">Alarmer</string>
<string name="diaconn_g8_history_basalhours">Basal timer</string>
<string name="diaconn_g8_history_bolus">Boluser</string>
@ -33,7 +33,7 @@
<string name="diaconn_g8_pump">Diaconn G8</string>
<string name="diaconn_g8_pump_shortname">Diaconn G8</string>
<string name="maxbolusviolation">Max bolus nådd</string>
<string name="commanderror">Kommando feil</string>
<string name="commanderror">Kommandofeil</string>
<string name="speederror">Hastighetsfeil</string>
<string name="insulinlimitviolation">Insulingrense nådd</string>
<string name="boluserrorcode">Forespurt: %1$.2fE Levert: %2$.2fE Feilkode: %3$s</string>

View file

@ -86,7 +86,7 @@
<string name="patch_communication_check_status_1">Kontrollerer Patch kommunikasjon…</string>
<string name="patch_communication_check_helper_1">Flytt smartenheten din nærmere Patch.</string>
<string name="patch_communication_check_helper_2">Gå til en annen lokasjon og prøv på nytt.</string>
<string name="patch_communication_failed">Kommunikasjons feil</string>
<string name="patch_communication_failed">Kommunikasjonsfeil</string>
<string name="patch_communication_succeed">Kommunikasjon vellykket</string>
<string name="patch_communication_succeed_message">Sammenkoblet med Patch.</string>
<string name="patch_cancel_pairing">Avbryt paringen</string>

View file

@ -73,7 +73,7 @@
<string name="medtronic_cmd_desc_set_basal_profile">Angi basal profil</string>
<string name="medtronic_cmd_desc_get_tbr">Henter Temp Basal</string>
<string name="medtronic_cmd_desc_set_tbr">Angi Temp Basal</string>
<string name="medtronic_cmd_desc_cancel_tbr">Avbryt temp basal</string>
<string name="medtronic_cmd_desc_cancel_tbr">Avbryt midlertidig basal</string>
<string name="medtronic_cmd_desc_set_bolus">Angi Bolus</string>
<string name="medtronic_cmd_desc_get_remaining_insulin">Oppdater status insulinvolum</string>
<string name="medtronic_pump_status_pump_unreachable">Pumpe utilgjengelig</string>

View file

@ -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)

View file

@ -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()
}
}

View file

@ -71,6 +71,15 @@ class MedtrumPump @Inject constructor(
_activeAlarms = value
}
// New pump warnings
private val _pumpWarning = MutableStateFlow(AlarmState.NONE)
val pumpWarningFlow: StateFlow<AlarmState> = _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<Int> = _primeProgress

View file

@ -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)

View file

@ -164,6 +164,11 @@ class MedtrumService : DaggerService(), BLECommCallback {
handleConnectionStateChange(connectionState)
}
}
scope.launch {
medtrumPump.pumpWarningFlow.collect { pumpWarning ->
notifyPumpWarning(pumpWarning)
}
}
}
override fun onDestroy() {
@ -317,6 +322,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
}
// Resume suspended pump
if (result) result = sendPacketAndGetResponse(ResumePumpPacket(injector))
if (result) medtrumPump.clearAlarmState()
}
return result
}
@ -420,6 +426,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 +443,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
}
}
}
@ -577,6 +589,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(
@ -607,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,
@ -625,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)
@ -683,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")

View file

@ -6,6 +6,7 @@
<string name="medtrum_pump_description">Integrace pumpy pro Medtrum Nano a Medtrum 300U</string>
<string name="medtrum_pump_setting">Nastavení pumpy Medtrum</string>
<string name="pump_error">Chyba pumpy: %1$s!! </string>
<string name="pump_warning">Varování pumpy: %1$s </string>
<string name="pump_is_suspended">Pumpa je pozastavena</string>
<string name="pump_is_suspended_hour_max">Pumpa je pozastavena kvůli překročení maximálního množství inzulínu za hodinu</string>
<string name="pump_is_suspended_day_max">Pumpa je pozastavena kvůli překročení maximálního množství inzulínu za den</string>
@ -106,6 +107,8 @@
<string name="pump_unsupported">Nevyzkoušená pumpa: %1$d! Kontaktujte nás na Discordu nebo Githubu, kde získáte podporu.</string>
<string name="alarm_setting_title">Nastavení alarmů</string>
<string name="alarm_setting_summary">Vyberte preferované nastavení alarmů.</string>
<string name="pump_warning_notification_title">Oznámení o varování pumpy</string>
<string name="pump_warning_notification_summary">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.</string>
<string name="patch_expiration_title">Vypršení platnosti Patche</string>
<string name="patch_expiration_summary">Pokud je povoleno, Patch vyprší po 3 dnech s maximální dobou odkladu 8 hodin.</string>
<string name="hourly_max_insulin_title">Hodinové maximum inzulínu</string>

View file

@ -6,6 +6,7 @@
<string name="medtrum_pump_description">Integración de bombas de insulina Medtrum Nano y Medtrum 300U</string>
<string name="medtrum_pump_setting">Ajustes de la bomba Medtrum</string>
<string name="pump_error">Error de bomba: %1$s !! </string>
<string name="pump_warning">Advertencia de la bomba: %1$s</string>
<string name="pump_is_suspended">Bomba suspendida</string>
<string name="pump_is_suspended_hour_max">Bomba suspendida por superarse el máximo de insulina por hora</string>
<string name="pump_is_suspended_day_max">Bomba suspendida por superar el máximo diario de insulina</string>
@ -106,6 +107,8 @@
<string name="pump_unsupported">Bomba no probada: %1$d! Por favor, contacta con nosotros en Discord o GitHub para obtener soporte</string>
<string name="alarm_setting_title">Ajustes de las alarmas</string>
<string name="alarm_setting_summary">Selecciona los ajustes de la alarma de la bomba que prefieras.</string>
<string name="pump_warning_notification_title">Notificación sobre advertencia de la bomba</string>
<string name="pump_warning_notification_summary">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.</string>
<string name="patch_expiration_title">Caducidad del parche</string>
<string name="patch_expiration_summary">Cuando está activado, el parche caducará a los 3 días, con un periodo de gracia de 8 horas adicionales</string>
<string name="hourly_max_insulin_title">Insulina máxima por hora</string>

View file

@ -70,6 +70,7 @@
<string name="step_retry_activation">Įjungiama</string>
<string name="unexpected_state">Netikėta būsena: %1$s</string>
<string name="no_profile_selected">Nepasirinktas profilis. Pasirinkite profilį ir bandykite dar kartą.</string>
<string name="no_sn_in_settings">Nežinomas SN. Įveskite pompos pagrindo serijos numerį nustatymuose ir bandykite vėl.</string>
<string name="base_serial">Pompos pagrindo SN: %1$X</string>
<string name="patch_begin_activation">Nėra aktyvaus rezervuaro. Spauskite <b>Kitas</b> ir pradėkite aktyvavimą.</string>
<string name="patch_not_active_note">Neprijunkite pagrindo prie rezervuaro iki kito žingsnio!</string>

View file

@ -6,6 +6,7 @@
<string name="medtrum_pump_description">Pumpeintegrasjon for Medtrum Nano og Medtrum 300U</string>
<string name="medtrum_pump_setting">Medtrum pumpeinnstillinger</string>
<string name="pump_error">Pumpefeil: %1$s!! </string>
<string name="pump_warning">Pumpeadvarsel: %1$s </string>
<string name="pump_is_suspended">Pumpen er pauset</string>
<string name="pump_is_suspended_hour_max">Pumpe er pauset fordi maksimal insulinleveranse per time er overskredet</string>
<string name="pump_is_suspended_day_max">Pumpe er pauset fordi maksimal insulinleveranse per dag er overskredet</string>
@ -106,6 +107,8 @@
<string name="pump_unsupported">Pumpe ikke testet: %1$d! Kontakt oss på discord eller github for støtte</string>
<string name="alarm_setting_title">Alarminnstillinger</string>
<string name="alarm_setting_summary">Velg dine foretrukne alarminnstillinger.</string>
<string name="pump_warning_notification_title">Varsel om pumpeadvarsel</string>
<string name="pump_warning_notification_summary">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.</string>
<string name="patch_expiration_title">Patch utløpsdato</string>
<string name="patch_expiration_summary">Når aktivert vil plasteret utløpe etter 3 dager, med en nådeperiode på 8 timer etter det.</string>
<string name="hourly_max_insulin_title">Maksimal insulin per time</string>

View file

@ -6,6 +6,7 @@
<string name="medtrum_pump_description">Pomp integratie voor Medtrum Nano en Medtrum 300U</string>
<string name="medtrum_pump_setting">Medtrum pomp instellingen</string>
<string name="pump_error">Pomp fout: %1$s!! </string>
<string name="pump_warning">Pomp waarschuwing: %1$s </string>
<string name="pump_is_suspended">Pomp is onderbroken</string>
<string name="pump_is_suspended_hour_max">Pomp is onderbroken als gevolg van overschrijding max insuline per uur</string>
<string name="pump_is_suspended_day_max">Pomp is onderbroken als gevolg van overschrijding max insuline per dag</string>
@ -106,6 +107,7 @@
<string name="pump_unsupported">Pomp niet getest, %1$d! Neem contact met ons op via discord of github voor ondersteuning</string>
<string name="alarm_setting_title">Alarminstellingen</string>
<string name="alarm_setting_summary">Selecteer uw gewenste alarminstellingen voor de pomp.</string>
<string name="pump_warning_notification_title">Notificatie bij pomp waarschuwing</string>
<string name="patch_expiration_title">Patch vervalt</string>
<string name="patch_expiration_summary">Wanneer ingeschakeld, zal de patch na 3 dagen verlopen met een extra periode van 8 uur coulance.</string>
<string name="hourly_max_insulin_title">Maximale insuline per uur</string>

View file

@ -6,6 +6,7 @@
<string name="medtrum_pump_description">Integracja z pompami Medtrum Nano i Medtrum 300U</string>
<string name="medtrum_pump_setting">Ustawienia pompy Medtrum</string>
<string name="pump_error">Błąd pompy: %1$s!! </string>
<string name="pump_warning">Ostrzeżenie pompy: %1$s </string>
<string name="pump_is_suspended">Pompa jest wstrzymana</string>
<string name="pump_is_suspended_hour_max">Pompa jest wstrzymana z powodu przekroczenia maksymalnej godzinowej dawki insuliny</string>
<string name="pump_is_suspended_day_max">Pompa jest wstrzymana z powodu przekroczenia maksymalnej dziennej dawki insuliny</string>
@ -106,6 +107,8 @@
<string name="pump_unsupported">Pompa nieprzetestowana: %1$d! Skontaktuj się z nami na Discordzie lub github, aby uzyskać wsparcie</string>
<string name="alarm_setting_title">Ustawienia alarmu</string>
<string name="alarm_setting_summary">Wybierz preferowaną konfigurację alarmu pompy.</string>
<string name="pump_warning_notification_title">Powiadomienie o ostrzeżeniu pompy</string>
<string name="pump_warning_notification_summary">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.</string>
<string name="patch_expiration_title">Wygaśnięcie Patcha</string>
<string name="patch_expiration_summary">Po uruchomieniu Patch wygaśnie po 3 dniach, z dodatkowym 8 godzinowym okresem karencji.</string>
<string name="hourly_max_insulin_title">Maksymalna Insulina w godzinę</string>

View file

@ -6,6 +6,7 @@
<string name="medtrum_pump_description">Integrarea pompei pentru Medtrum Nano și Medtrum 300U</string>
<string name="medtrum_pump_setting">Setări pompă Medtrum</string>
<string name="pump_error">Eroare pompă: %1$s!! </string>
<string name="pump_warning">Avertizare pompă: %1$s </string>
<string name="pump_is_suspended">Pompă suspendată</string>
<string name="pump_is_suspended_hour_max">Pompă suspendată din cauza depăşirii valorii maxime a insulinei pe oră</string>
<string name="pump_is_suspended_day_max">Pompă suspendată din cauza depăşirii valorii maxime zilnice a insulinei</string>
@ -106,6 +107,8 @@
<string name="pump_unsupported">Pompă netestată: %1$d! Te rugăm să ne contactezi pe discord sau github pentru suport.</string>
<string name="alarm_setting_title">Setări alarmă</string>
<string name="alarm_setting_summary">Selectează setările preferate pentru alarma pompei.</string>
<string name="pump_warning_notification_title">Notificare la avertizarea pompei</string>
<string name="pump_warning_notification_summary">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.</string>
<string name="patch_expiration_title">Patch Expirare</string>
<string name="patch_expiration_summary">Când este activat, patchul va expira după 3 zile, cu o perioadă de graţie de 8 ore după expirare.</string>
<string name="hourly_max_insulin_title">Insulină maximă pe oră</string>

View file

@ -39,6 +39,8 @@
<string name="alarm_low_bg_suspended">Приостановка на низкой ГК</string>
<string name="alarm_low_bg_suspended2">Приостановка на низкой ГК 2</string>
<string name="alarm_auto_suspended">Автоматическая приостановка</string>
<string name="alarm_hourly_max_suspended">почасовой максимальный приостановлен</string>
<string name="alarm_daily_max_suspended">суточный максимальный приостановлен</string>
<string name="alarm_suspended">Приостановлено</string>
<string name="alarm_paused">На паузе</string>
<string name="alarm_occlusion">Окклюзия</string>
@ -68,6 +70,7 @@
<string name="step_retry_activation">Выполняется активация</string>
<string name="unexpected_state">Непредвиденное состояние: %1$s</string>
<string name="no_profile_selected">Профиль не выбран. Выберите профиль и повторите попытку.</string>
<string name="no_sn_in_settings">Серийный номер не известен. Введите серийный номер помпы в настройках и повторите попытку.</string>
<string name="base_serial">Серийный номер основания: %1$X</string>
<string name="patch_begin_activation">Активный патч отсутствует. Нажмите <b>Далее</b> для начала процесса активации.</string>
<string name="patch_not_active_note">Не соединяйте основание и патч до следующего шага!</string>

View file

@ -70,6 +70,7 @@
<string name="step_retry_activation">Aktivácia prebieha</string>
<string name="unexpected_state">Neočakávaný stav: %1$s</string>
<string name="no_profile_selected">Žiadny vybraný profil. Prosím vyberte si profil a skúste to znovu.</string>
<string name="no_sn_in_settings">Nie je zadané žiadne sériové číslo. Zadajte sériové číslo pumpy v nastaveniach a skúste to znova.</string>
<string name="base_serial">Sériové číslo základne pumpy: %1$X</string>
<string name="patch_begin_activation">Žiadny aktívny Patch. Stlačte <b>Ďalšia</b> pre zahájenie aktivačného procesu.</string>
<string name="patch_not_active_note">Základňa by nemala byť pripojená ku kanyle až do dalšieho kroku!</string>

View file

@ -4,6 +4,7 @@
<string name="key_sn_input" translatable="false">sn_input</string>
<string name="key_alarm_setting" translatable="false">alarm_setting</string>
<string name="key_patch_expiration" translatable="false">patch_expiration</string>
<string name="key_pump_warning_notification" translatable="false">pump_warning_notification</string>
<string name="key_hourly_max_insulin" translatable="false">hourly_max_insulin</string>
<string name="key_daily_max_insulin" translatable="false">daily_max_insulin</string>
@ -30,6 +31,7 @@
<string name="medtrum_pump_description">Pump integration for Medtrum Nano and Medtrum 300U</string>
<string name="medtrum_pump_setting">Medtrum pump settings</string>
<string name="pump_error">Pump error: %1$s !! </string>
<string name="pump_warning">Pump warning: %1$s </string>
<string name="pump_is_suspended">Pump is suspended</string>
<string name="pump_is_suspended_hour_max">Pump is suspended due to hourly max insulin exceeded</string>
<string name="pump_is_suspended_day_max">Pump is suspended due to daily max insulin exceeded</string>
@ -138,6 +140,8 @@
<string name="pump_unsupported">Pump untested: %1$d! Please contact us at discord or github for support</string>
<string name="alarm_setting_title">Alarm Settings</string>
<string name="alarm_setting_summary">Select your preferred pump alarm settings.</string>
<string name="pump_warning_notification_title">Notification on pump warning</string>
<string name="pump_warning_notification_summary">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.</string>
<string name="patch_expiration_title">Patch Expiration</string>
<string name="patch_expiration_summary">When enabled, the patch will expire after 3 days, with a grace period of 8 hours after that.</string>
<string name="hourly_max_insulin_title">Hourly Maximum Insulin</string>

View file

@ -14,7 +14,7 @@
android:title="@string/sn_input_title" />
<SwitchPreference
android:defaultValue="false"
android:defaultValue="true"
android:key="@string/key_patch_expiration"
android:title="@string/patch_expiration_title"
android:summary="@string/patch_expiration_summary" />
@ -27,6 +27,12 @@
android:entries="@array/alarmSettings"
android:entryValues="@array/alarmSettingsValues" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_pump_warning_notification"
android:title="@string/pump_warning_notification_title"
android:summary="@string/pump_warning_notification_summary" />
<app.aaps.core.validators.ValidatingEditTextPreference
android:defaultValue="25"
android:inputType="number"

View file

@ -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() {

View file

@ -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()
}
}

View file

@ -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()
}
}

View file

@ -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()
}
}

View file

@ -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()
}
}

View file

@ -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()
}
}

View file

@ -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)
}
}

View file

@ -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)
}
}

Some files were not shown because too many files have changed in this diff Show more