Merge branch 'dev' into refactor
This commit is contained in:
commit
34b26b194f
|
@ -2,6 +2,7 @@ package info.nightscout.plugins.aps.loop
|
||||||
|
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
@ -24,7 +25,6 @@ import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -72,28 +72,28 @@ class LoopPluginTest : TestBase() {
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
||||||
val pumpDescription = PumpDescription()
|
val pumpDescription = PumpDescription()
|
||||||
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
|
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
|
||||||
Assertions.assertEquals(LoopFragment::class.java.name, loopPlugin.pluginDescription.fragmentClass)
|
assertThat(loopPlugin.pluginDescription.fragmentClass).isEqualTo(LoopFragment::class.java.name)
|
||||||
Assertions.assertEquals(PluginType.LOOP, loopPlugin.getType())
|
assertThat(loopPlugin.getType()).isEqualTo(PluginType.LOOP)
|
||||||
Assertions.assertEquals("Loop", loopPlugin.name)
|
assertThat(loopPlugin.name).isEqualTo("Loop")
|
||||||
Assertions.assertEquals("LOOP", loopPlugin.nameShort)
|
assertThat(loopPlugin.nameShort).isEqualTo("LOOP")
|
||||||
Assertions.assertEquals(true, loopPlugin.hasFragment())
|
assertThat(loopPlugin.hasFragment()).isTrue()
|
||||||
Assertions.assertEquals(true, loopPlugin.showInList(PluginType.LOOP))
|
assertThat(loopPlugin.showInList(PluginType.LOOP)).isTrue()
|
||||||
Assertions.assertEquals(info.nightscout.plugins.aps.R.xml.pref_loop.toLong(), loopPlugin.preferencesId.toLong())
|
assertThat(loopPlugin.preferencesId.toLong()).isEqualTo(info.nightscout.plugins.aps.R.xml.pref_loop.toLong())
|
||||||
|
|
||||||
// Plugin is disabled by default
|
// Plugin is disabled by default
|
||||||
Assertions.assertEquals(false, loopPlugin.isEnabled())
|
assertThat(loopPlugin.isEnabled()).isFalse()
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
||||||
Assertions.assertEquals(true, loopPlugin.isEnabled())
|
assertThat(loopPlugin.isEnabled()).isTrue()
|
||||||
|
|
||||||
// No temp basal capable pump should disable plugin
|
// No temp basal capable pump should disable plugin
|
||||||
virtualPumpPlugin.pumpDescription.isTempBasalCapable = false
|
virtualPumpPlugin.pumpDescription.isTempBasalCapable = false
|
||||||
Assertions.assertEquals(false, loopPlugin.isEnabled())
|
assertThat(loopPlugin.isEnabled()).isFalse()
|
||||||
virtualPumpPlugin.pumpDescription.isTempBasalCapable = true
|
virtualPumpPlugin.pumpDescription.isTempBasalCapable = true
|
||||||
|
|
||||||
// Fragment is hidden by default
|
// Fragment is hidden by default
|
||||||
Assertions.assertEquals(false, loopPlugin.isFragmentVisible())
|
assertThat(loopPlugin.isFragmentVisible()).isFalse()
|
||||||
loopPlugin.setFragmentVisible(PluginType.LOOP, true)
|
loopPlugin.setFragmentVisible(PluginType.LOOP, true)
|
||||||
Assertions.assertEquals(true, loopPlugin.isFragmentVisible())
|
assertThat(loopPlugin.isFragmentVisible()).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *********** not working
|
/* *********** not working
|
||||||
|
@ -116,7 +116,7 @@ class LoopPluginTest : TestBase() {
|
||||||
MockedLoopPlugin mockedLoopPlugin = new MockedLoopPlugin();
|
MockedLoopPlugin mockedLoopPlugin = new MockedLoopPlugin();
|
||||||
Treatment t = new Treatment();
|
Treatment t = new Treatment();
|
||||||
bus.post(new EventTreatmentChange(t));
|
bus.post(new EventTreatmentChange(t));
|
||||||
Assertions.assertEquals(true, mockedLoopPlugin.invokeCalled);
|
assertThat(mockedLoopPlugin.invokeCalled).isTrue();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.general.maintenance
|
package info.nightscout.plugins.general.maintenance
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.configuration.maintenance.MaintenancePlugin
|
import info.nightscout.configuration.maintenance.MaintenancePlugin
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
|
@ -10,7 +11,6 @@ import info.nightscout.interfaces.nsclient.NSSettingsStatus
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -40,11 +40,12 @@ class MaintenancePluginTest : TestBase() {
|
||||||
|
|
||||||
@Test fun logFilesTest() {
|
@Test fun logFilesTest() {
|
||||||
var logs = sut.getLogFiles(2)
|
var logs = sut.getLogFiles(2)
|
||||||
Assertions.assertEquals(2, logs.size)
|
assertThat(logs.map { it.name }).containsExactly(
|
||||||
Assertions.assertEquals("AndroidAPS.log", logs[0].name)
|
"AndroidAPS.log",
|
||||||
Assertions.assertEquals("AndroidAPS.2018-01-03_01-01-00.1.zip", logs[1].name)
|
"AndroidAPS.2018-01-03_01-01-00.1.zip",
|
||||||
|
).inOrder()
|
||||||
logs = sut.getLogFiles(10)
|
logs = sut.getLogFiles(10)
|
||||||
Assertions.assertEquals(4, logs.size)
|
assertThat(logs).hasSize(4)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -53,7 +54,7 @@ class MaintenancePluginTest : TestBase() {
|
||||||
val name = "AndroidAPS.log.zip"
|
val name = "AndroidAPS.log.zip"
|
||||||
var zipFile = File("build/$name")
|
var zipFile = File("build/$name")
|
||||||
zipFile = sut.zipLogs(zipFile, logs)
|
zipFile = sut.zipLogs(zipFile, logs)
|
||||||
Assertions.assertTrue(zipFile.exists())
|
assertThat(zipFile.exists()).isTrue()
|
||||||
Assertions.assertTrue(zipFile.isFile)
|
assertThat(zipFile.isFile).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.plugins.sensitivity
|
package info.nightscout.plugins.sensitivity
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.interfaces.aps.AutosensDataStore
|
import info.nightscout.interfaces.aps.AutosensDataStore
|
||||||
|
@ -12,7 +13,6 @@ import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ class AbstractSensitivityPluginTest : TestBase() {
|
||||||
fun fillResultTest() {
|
fun fillResultTest() {
|
||||||
val sut = SensitivityTestClass(pluginDescription, aapsLogger, rh, sp)
|
val sut = SensitivityTestClass(pluginDescription, aapsLogger, rh, sp)
|
||||||
var ar = sut.fillResult(1.0, 1.0, "1", "1.2", "1", 12, 0.7, 1.2)
|
var ar = sut.fillResult(1.0, 1.0, "1", "1.2", "1", 12, 0.7, 1.2)
|
||||||
Assertions.assertEquals(1.0, ar.ratio, 0.01)
|
assertThat(ar.ratio).isWithin(0.01).of(1.0)
|
||||||
ar = sut.fillResult(1.2, 1.0, "1", "1.2", "1", 40, 0.7, 1.2)
|
ar = sut.fillResult(1.2, 1.0, "1", "1.2", "1", 40, 0.7, 1.2)
|
||||||
Assertions.assertEquals(1.16, ar.ratio, 0.01)
|
assertThat(ar.ratio).isWithin(0.01).of(1.16)
|
||||||
ar = sut.fillResult(1.2, 1.0, "1", "1.2", "1", 50, 0.7, 1.2)
|
ar = sut.fillResult(1.2, 1.0, "1", "1.2", "1", 50, 0.7, 1.2)
|
||||||
Assertions.assertEquals(1.2, ar.ratio, 0.01)
|
assertThat(ar.ratio).isWithin(0.01).of(1.2)
|
||||||
ar = sut.fillResult(1.2, 1.0, "1", "1.2", "1", 50, 0.7, 1.1)
|
ar = sut.fillResult(1.2, 1.0, "1", "1.2", "1", 50, 0.7, 1.1)
|
||||||
Assertions.assertEquals(1.1, ar.ratio, 0.01)
|
assertThat(ar.ratio).isWithin(0.01).of(1.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.pump
|
package info.nightscout.pump
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.core.pump.toHtml
|
import info.nightscout.core.pump.toHtml
|
||||||
|
@ -8,7 +9,6 @@ import info.nightscout.plugins.aps.loop.extensions.json
|
||||||
import info.nightscout.pump.virtual.extensions.toText
|
import info.nightscout.pump.virtual.extensions.toText
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
@ -42,132 +42,132 @@ class PumpEnactResultTest : TestBaseWithProfile() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.success(true)
|
per.success(true)
|
||||||
Assertions.assertEquals(true, per.success)
|
assertThat(per.success).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun enactedTest() {
|
@Test fun enactedTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.enacted(true)
|
per.enacted(true)
|
||||||
Assertions.assertEquals(true, per.enacted)
|
assertThat(per.enacted).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun commentTest() {
|
@Test fun commentTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.comment("SomeComment")
|
per.comment("SomeComment")
|
||||||
Assertions.assertEquals("SomeComment", per.comment)
|
assertThat(per.comment).isEqualTo("SomeComment")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun durationTest() {
|
@Test fun durationTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.duration(10)
|
per.duration(10)
|
||||||
Assertions.assertEquals(10, per.duration.toLong())
|
assertThat(per.duration.toLong()).isEqualTo(10L)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun absoluteTest() {
|
@Test fun absoluteTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.absolute(11.0)
|
per.absolute(11.0)
|
||||||
Assertions.assertEquals(11.0, per.absolute, 0.01)
|
assertThat(per.absolute).isWithin(0.01).of(11.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun percentTest() {
|
@Test fun percentTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.percent(10)
|
per.percent(10)
|
||||||
Assertions.assertEquals(10, per.percent)
|
assertThat(per.percent).isEqualTo(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun isPercentTest() {
|
@Test fun isPercentTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.isPercent(true)
|
per.isPercent(true)
|
||||||
Assertions.assertEquals(true, per.isPercent)
|
assertThat(per.isPercent).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun isTempCancelTest() {
|
@Test fun isTempCancelTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.isTempCancel(true)
|
per.isTempCancel(true)
|
||||||
Assertions.assertEquals(true, per.isTempCancel)
|
assertThat(per.isTempCancel).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun bolusDeliveredTest() {
|
@Test fun bolusDeliveredTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.bolusDelivered(11.0)
|
per.bolusDelivered(11.0)
|
||||||
Assertions.assertEquals(11.0, per.bolusDelivered, 0.01)
|
assertThat(per.bolusDelivered).isWithin(0.01).of(11.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun queuedTest() {
|
@Test fun queuedTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.queued(true)
|
per.queued(true)
|
||||||
Assertions.assertEquals(true, per.queued)
|
assertThat(per.queued).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun toStringTest() {
|
@Test fun toStringTest() {
|
||||||
var per = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
var per = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
||||||
Assertions.assertEquals(
|
assertThat(per.toText(rh)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Enacted: true
|
Enacted: true
|
||||||
Comment: AAA
|
Comment: AAA
|
||||||
Insulin: 10.0 U
|
Insulin: 10.0 U
|
||||||
""".trimIndent(), per.toText(rh)
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
||||||
Assertions.assertEquals(
|
assertThat(per.toText(rh)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Enacted: true
|
Enacted: true
|
||||||
Comment: AAA
|
Comment: AAA
|
||||||
Cancel temp basal
|
Cancel temp basal
|
||||||
""".trimIndent(), per.toText(rh)
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
||||||
Assertions.assertEquals(
|
assertThat(per.toText(rh)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Enacted: true
|
Enacted: true
|
||||||
Comment: AAA
|
Comment: AAA
|
||||||
Duration: 20 min
|
Duration: 20 min
|
||||||
Percent: 90%
|
Percent: 90%
|
||||||
""".trimIndent(), per.toText(rh)
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
||||||
Assertions.assertEquals(
|
assertThat(per.toText(rh)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Enacted: true
|
Enacted: true
|
||||||
Comment: AAA
|
Comment: AAA
|
||||||
Duration: 30 min
|
Duration: 30 min
|
||||||
Absolute: 1.0 U/h
|
Absolute: 1.0 U/h
|
||||||
""".trimIndent(), per.toText(rh)
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
per = PumpEnactResult(injector).enacted(false).comment("AAA")
|
per = PumpEnactResult(injector).enacted(false).comment("AAA")
|
||||||
Assertions.assertEquals(
|
assertThat(per.toText(rh)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Comment: AAA
|
Comment: AAA
|
||||||
""".trimIndent(), per.toText(rh)
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun toHtmlTest() {
|
@Test fun toHtmlTest() {
|
||||||
|
|
||||||
var per: PumpEnactResult = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
var per: PumpEnactResult = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
||||||
Assertions.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>SMB</b>: 10.0 U", per.toHtml(rh, decimalFormatter))
|
assertThat(per.toHtml(rh, decimalFormatter)).isEqualTo("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>SMB</b>: 10.0 U")
|
||||||
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
||||||
Assertions.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br>Cancel temp basal", per.toHtml(rh, decimalFormatter))
|
assertThat(per.toHtml(rh, decimalFormatter)).isEqualTo("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br>Cancel temp basal")
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
||||||
Assertions.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 20 min<br><b>Percent</b>: 90%", per.toHtml(rh, decimalFormatter))
|
assertThat(per.toHtml(rh, decimalFormatter)).isEqualTo("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 20 min<br><b>Percent</b>: 90%")
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
||||||
Assertions.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 30 min<br><b>Absolute</b>: 1.00 U/h", per.toHtml(rh, decimalFormatter))
|
assertThat(per.toHtml(rh, decimalFormatter)).isEqualTo("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 30 min<br><b>Absolute</b>: 1.00 U/h")
|
||||||
per = PumpEnactResult(injector).enacted(false).comment("AAA")
|
per = PumpEnactResult(injector).enacted(false).comment("AAA")
|
||||||
Assertions.assertEquals("<b>Success</b>: false<br><b>Comment</b>: AAA", per.toHtml(rh, decimalFormatter))
|
assertThat(per.toHtml(rh, decimalFormatter)).isEqualTo("<b>Success</b>: false<br><b>Comment</b>: AAA")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun jsonTest() {
|
@Test fun jsonTest() {
|
||||||
|
@ -175,15 +175,15 @@ class PumpEnactResultTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
var per: PumpEnactResult = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
var per: PumpEnactResult = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
||||||
o = per.json(validProfile.getBasal())
|
o = per.json(validProfile.getBasal())
|
||||||
JSONAssert.assertEquals("{\"smb\":10}", o, false)
|
JSONAssert.assertEquals("""{"smb":10}""", o, false)
|
||||||
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
||||||
o = per.json(validProfile.getBasal())
|
o = per.json(validProfile.getBasal())
|
||||||
JSONAssert.assertEquals("{\"rate\":0,\"duration\":0}", o, false)
|
JSONAssert.assertEquals("""{"rate":0,"duration":0}""", o, false)
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
||||||
o = per.json(validProfile.getBasal())
|
o = per.json(validProfile.getBasal())
|
||||||
JSONAssert.assertEquals("{\"rate\":0.9,\"duration\":20}", o, false)
|
JSONAssert.assertEquals("""{"rate":0.9,"duration":20}""", o, false)
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
||||||
o = per.json(validProfile.getBasal())
|
o = per.json(validProfile.getBasal())
|
||||||
JSONAssert.assertEquals("{\"rate\":1,\"duration\":30}", o, false)
|
JSONAssert.assertEquals("""{"rate":1,"duration":30}""", o, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,2 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources></resources>
|
<resources>
|
||||||
|
<string name="format_carbs">%1$d g</string>
|
||||||
|
</resources>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<string name="bolus_delivered_successfully">Bolo %1$.2fU entregado correctamente</string>
|
<string name="bolus_delivered_successfully">Bolo %1$.2fU entregado correctamente</string>
|
||||||
<string name="no_valid_basal_rate">Tasa basal no válida leída en la bomba</string>
|
<string name="no_valid_basal_rate">Tasa basal no válida leída en la bomba</string>
|
||||||
<string name="limiting_iob">Limitando IOB a %1$.1f U debido a %2$s</string>
|
<string name="limiting_iob">Limitando IOB a %1$.1f U debido a %2$s</string>
|
||||||
<string name="loop_disabled">LAZO DESACTIVADO POR RESTRICCIONES</string>
|
<string name="loop_disabled">BUCLE DESACTIVADO POR RESTRICCIONES</string>
|
||||||
<string name="event_type">Tipo de evento</string>
|
<string name="event_type">Tipo de evento</string>
|
||||||
<string name="reload">Recargar</string>
|
<string name="reload">Recargar</string>
|
||||||
<string name="mgdl">mg/dl</string>
|
<string name="mgdl">mg/dl</string>
|
||||||
|
@ -86,11 +86,11 @@
|
||||||
<string name="pump_time_updated">Hora actualizada en la bomba</string>
|
<string name="pump_time_updated">Hora actualizada en la bomba</string>
|
||||||
<string name="exit">Salir</string>
|
<string name="exit">Salir</string>
|
||||||
<string name="removerecord">Eliminar registro</string>
|
<string name="removerecord">Eliminar registro</string>
|
||||||
<string name="loopisdisabled">Lazo desactivado</string>
|
<string name="loopisdisabled">Bucle desactivado</string>
|
||||||
<string name="alarm">Alarma</string>
|
<string name="alarm">Alarma</string>
|
||||||
<string name="disableloop">Desactivar lazo</string>
|
<string name="disableloop">Desactivar bucle</string>
|
||||||
<string name="enableloop">Activar lazo</string>
|
<string name="enableloop">Activar bucle</string>
|
||||||
<string name="resumeloop">Reanudar el lazo</string>
|
<string name="resumeloop">Reanudar el bucle</string>
|
||||||
<string name="suspendloop">Suspender lazo</string>
|
<string name="suspendloop">Suspender lazo</string>
|
||||||
<string name="duration_min_label">Duración [min]</string>
|
<string name="duration_min_label">Duración [min]</string>
|
||||||
<string name="notification">Notificación</string>
|
<string name="notification">Notificación</string>
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
<string name="shortgramm">g</string>
|
<string name="shortgramm">g</string>
|
||||||
<string name="pumpsuspended">Bomba parada</string>
|
<string name="pumpsuspended">Bomba parada</string>
|
||||||
<string name="notconfigured">Sin configurar</string>
|
<string name="notconfigured">Sin configurar</string>
|
||||||
<string name="loopsuspended">Lazo suspendido</string>
|
<string name="loopsuspended">Bucle suspendido</string>
|
||||||
<string name="trend_arrow">Flecha de tendencia</string>
|
<string name="trend_arrow">Flecha de tendencia</string>
|
||||||
<string name="a11y_autosens_label">Auto sens</string>
|
<string name="a11y_autosens_label">Auto sens</string>
|
||||||
<string name="required">req</string>
|
<string name="required">req</string>
|
||||||
|
@ -156,8 +156,8 @@
|
||||||
<string name="prime_fill">Cebar/Llenar</string>
|
<string name="prime_fill">Cebar/Llenar</string>
|
||||||
<string name="overview_insulin_label">Insulina</string>
|
<string name="overview_insulin_label">Insulina</string>
|
||||||
<string name="stoptemptarget">Detener objetivo temporal</string>
|
<string name="stoptemptarget">Detener objetivo temporal</string>
|
||||||
<string name="closedloop">Lazo cerrado</string>
|
<string name="closedloop">Bucle cerrado</string>
|
||||||
<string name="openloop">Lazo abierto</string>
|
<string name="openloop">Bucle abierto</string>
|
||||||
<string name="lowglucosesuspend">Suspensión por glucosa baja (LGS)</string>
|
<string name="lowglucosesuspend">Suspensión por glucosa baja (LGS)</string>
|
||||||
<string name="dia">DIA</string>
|
<string name="dia">DIA</string>
|
||||||
<string name="ic_short">IC</string>
|
<string name="ic_short">IC</string>
|
||||||
|
@ -165,7 +165,7 @@
|
||||||
<string name="canceling_tbr_failed">Error cancelando la basal temporal</string>
|
<string name="canceling_tbr_failed">Error cancelando la basal temporal</string>
|
||||||
<string name="canceling_eb_failed">Error cancelando el bolo extendido</string>
|
<string name="canceling_eb_failed">Error cancelando el bolo extendido</string>
|
||||||
<string name="virtualpump_uploadstatus_title">Subir estado de la bomba a NS o Tidepool</string>
|
<string name="virtualpump_uploadstatus_title">Subir estado de la bomba a NS o Tidepool</string>
|
||||||
<string name="suspendloop_label">Desactiva/suspende el lazo</string>
|
<string name="suspendloop_label">Desactiva/suspende el bucle</string>
|
||||||
<string name="iob_label">Insulina a bordo (IOB)</string>
|
<string name="iob_label">Insulina a bordo (IOB)</string>
|
||||||
<!-- Protection-->
|
<!-- Protection-->
|
||||||
<string name="wrongpassword">Contraseña incorrecta</string>
|
<string name="wrongpassword">Contraseña incorrecta</string>
|
||||||
|
@ -234,7 +234,7 @@
|
||||||
<string name="wear">Reloj</string>
|
<string name="wear">Reloj</string>
|
||||||
<string name="automation">Automatización</string>
|
<string name="automation">Automatización</string>
|
||||||
<string name="custom">Personalizado</string>
|
<string name="custom">Personalizado</string>
|
||||||
<string name="loop">Lazo</string>
|
<string name="loop">Bucle</string>
|
||||||
<string name="ns">NS</string>
|
<string name="ns">NS</string>
|
||||||
<string name="record">Registro</string>
|
<string name="record">Registro</string>
|
||||||
<!-- Command-->
|
<!-- Command-->
|
||||||
|
@ -278,11 +278,11 @@
|
||||||
<string name="uel_store_profile">GUARDAR PERFIL</string>
|
<string name="uel_store_profile">GUARDAR PERFIL</string>
|
||||||
<string name="uel_profile_switch">CAMBIO DE PERFIL</string>
|
<string name="uel_profile_switch">CAMBIO DE PERFIL</string>
|
||||||
<string name="uel_profile_switch_cloned">CAMBIO DE PERFIL CLONADO</string>
|
<string name="uel_profile_switch_cloned">CAMBIO DE PERFIL CLONADO</string>
|
||||||
<string name="uel_closed_loop_mode">MODO LAZO CERRADO</string>
|
<string name="uel_closed_loop_mode">MODO BUCLE CERRADO</string>
|
||||||
<string name="uel_lgs_loop_mode">MODO LAZO LGS</string>
|
<string name="uel_lgs_loop_mode">MODO BUCLE LGS</string>
|
||||||
<string name="uel_open_loop_mode">MODO LAZO ABIERTO</string>
|
<string name="uel_open_loop_mode">MODO BUCLE ABIERTO</string>
|
||||||
<string name="uel_loop_disabled">LAZO DESACTIVADO</string>
|
<string name="uel_loop_disabled">BUCLE DESACTIVADO</string>
|
||||||
<string name="uel_loop_enabled">LAZO ACTIVADO</string>
|
<string name="uel_loop_enabled">BUCLE ACTIVADO</string>
|
||||||
<string name="uel_reconnect">RECONECTAR</string>
|
<string name="uel_reconnect">RECONECTAR</string>
|
||||||
<string name="uel_disconnect">DESCONECTAR</string>
|
<string name="uel_disconnect">DESCONECTAR</string>
|
||||||
<string name="uel_resume">REANUDAR</string>
|
<string name="uel_resume">REANUDAR</string>
|
||||||
|
@ -353,8 +353,8 @@
|
||||||
<string name="ue_action">Acción</string>
|
<string name="ue_action">Acción</string>
|
||||||
<string name="ue_timestamp">Fecha y hora</string>
|
<string name="ue_timestamp">Fecha y hora</string>
|
||||||
<string name="ue_none">Sin Unidad</string>
|
<string name="ue_none">Sin Unidad</string>
|
||||||
<string name="uel_loop_change">LAZO CAMBIADO</string>
|
<string name="uel_loop_change">BUCLE CAMBIADO</string>
|
||||||
<string name="uel_loop_removed">LAZO ELIMINADO</string>
|
<string name="uel_loop_removed">BUCLE ELIMINADO</string>
|
||||||
<string name="uel_other">OTROS</string>
|
<string name="uel_other">OTROS</string>
|
||||||
<!-- HardLimits -->
|
<!-- HardLimits -->
|
||||||
<string name="profile_low_target">Perfil de objetivo bajo</string>
|
<string name="profile_low_target">Perfil de objetivo bajo</string>
|
||||||
|
|
|
@ -581,6 +581,22 @@
|
||||||
<string name="cleanup_db_confirm_sync">Voulez-vous nettoyer la base de données ?\nCela supprimera les modifications suivies et les données historiques de plus de 3 mois.\nCela accélérera la synchronisation complète de manière spectaculaire.</string>
|
<string name="cleanup_db_confirm_sync">Voulez-vous nettoyer la base de données ?\nCela supprimera les modifications suivies et les données historiques de plus de 3 mois.\nCela accélérera la synchronisation complète de manière spectaculaire.</string>
|
||||||
<string name="cleared_entries">Entrées effacées</string>
|
<string name="cleared_entries">Entrées effacées</string>
|
||||||
<!-- Weekday-->
|
<!-- Weekday-->
|
||||||
|
<string name="weekday_sunday_short">Dim</string>
|
||||||
|
<string name="weekday_saturday_short">Sam</string>
|
||||||
|
<string name="weekday_friday_short">Ven</string>
|
||||||
|
<string name="weekday_thursday_short">Jeu</string>
|
||||||
|
<string name="weekday_wednesday_short">Mer</string>
|
||||||
|
<string name="weekday_tuesday_short">Mar</string>
|
||||||
|
<string name="weekday_monday_short">Lun</string>
|
||||||
<!-- WeekdayPicker -->
|
<!-- WeekdayPicker -->
|
||||||
|
<string name="monday_short">L</string>
|
||||||
|
<string name="tuesday_short">M</string>
|
||||||
|
<string name="wednesday_short">M</string>
|
||||||
|
<string name="thursday_short">J</string>
|
||||||
|
<string name="friday_short">V</string>
|
||||||
|
<string name="saturday_short">S</string>
|
||||||
|
<string name="sunday_short">D</string>
|
||||||
<!-- DecimalFormatterImpl -->
|
<!-- DecimalFormatterImpl -->
|
||||||
|
<string name="format_insulin_units1">%1$.1f U</string>
|
||||||
|
<string name="format_insulin_units">%1$.2f U</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -581,6 +581,22 @@
|
||||||
<string name="cleanup_db_confirm_sync">Wil je de database opschonen?\nHet zal bijgehouden wijzigingen en historische gegevens ouder dan 3 maanden verwijderen.\nDit zal de volledige synchronisatie drastisch versnellen.</string>
|
<string name="cleanup_db_confirm_sync">Wil je de database opschonen?\nHet zal bijgehouden wijzigingen en historische gegevens ouder dan 3 maanden verwijderen.\nDit zal de volledige synchronisatie drastisch versnellen.</string>
|
||||||
<string name="cleared_entries">Invoer gewist</string>
|
<string name="cleared_entries">Invoer gewist</string>
|
||||||
<!-- Weekday-->
|
<!-- Weekday-->
|
||||||
|
<string name="weekday_sunday_short">Zo</string>
|
||||||
|
<string name="weekday_saturday_short">Za</string>
|
||||||
|
<string name="weekday_friday_short">Vr</string>
|
||||||
|
<string name="weekday_thursday_short">Do</string>
|
||||||
|
<string name="weekday_wednesday_short">Wo</string>
|
||||||
|
<string name="weekday_tuesday_short">Di</string>
|
||||||
|
<string name="weekday_monday_short">Ma</string>
|
||||||
<!-- WeekdayPicker -->
|
<!-- WeekdayPicker -->
|
||||||
|
<string name="monday_short">M</string>
|
||||||
|
<string name="tuesday_short">D</string>
|
||||||
|
<string name="wednesday_short">W</string>
|
||||||
|
<string name="thursday_short">D</string>
|
||||||
|
<string name="friday_short">V</string>
|
||||||
|
<string name="saturday_short">Z</string>
|
||||||
|
<string name="sunday_short">Z</string>
|
||||||
<!-- DecimalFormatterImpl -->
|
<!-- DecimalFormatterImpl -->
|
||||||
|
<string name="format_insulin_units1">%1$.1f E</string>
|
||||||
|
<string name="format_insulin_units">%1$.2f E</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -581,6 +581,22 @@
|
||||||
<string name="cleanup_db_confirm_sync">Vil du rydde opp i databasen?\nDet vil fjerne sporede endringer og historiske data eldre enn 3 måneder.\nÅ gjøre dette vil øke hastigheten på synkronisering betydelig.</string>
|
<string name="cleanup_db_confirm_sync">Vil du rydde opp i databasen?\nDet vil fjerne sporede endringer og historiske data eldre enn 3 måneder.\nÅ gjøre dette vil øke hastigheten på synkronisering betydelig.</string>
|
||||||
<string name="cleared_entries">Fjernet oppføringer</string>
|
<string name="cleared_entries">Fjernet oppføringer</string>
|
||||||
<!-- Weekday-->
|
<!-- Weekday-->
|
||||||
|
<string name="weekday_sunday_short">Søn</string>
|
||||||
|
<string name="weekday_saturday_short">Lør</string>
|
||||||
|
<string name="weekday_friday_short">Fre</string>
|
||||||
|
<string name="weekday_thursday_short">Tor</string>
|
||||||
|
<string name="weekday_wednesday_short">Ons</string>
|
||||||
|
<string name="weekday_tuesday_short">Tir</string>
|
||||||
|
<string name="weekday_monday_short">Man</string>
|
||||||
<!-- WeekdayPicker -->
|
<!-- WeekdayPicker -->
|
||||||
|
<string name="monday_short">M</string>
|
||||||
|
<string name="tuesday_short">Ti</string>
|
||||||
|
<string name="wednesday_short">O</string>
|
||||||
|
<string name="thursday_short">To</string>
|
||||||
|
<string name="friday_short">F</string>
|
||||||
|
<string name="saturday_short">L</string>
|
||||||
|
<string name="sunday_short">S</string>
|
||||||
<!-- DecimalFormatterImpl -->
|
<!-- DecimalFormatterImpl -->
|
||||||
|
<string name="format_insulin_units1">%1$.1f E</string>
|
||||||
|
<string name="format_insulin_units">%1$.2f E</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.implementation.iob
|
package info.nightscout.implementation.iob
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.core.iob.asRounded
|
import info.nightscout.core.iob.asRounded
|
||||||
import info.nightscout.core.iob.log
|
import info.nightscout.core.iob.log
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
|
@ -9,7 +10,6 @@ import info.nightscout.interfaces.iob.InMemoryGlucoseValue
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
import info.nightscout.shared.utils.T
|
import info.nightscout.shared.utils.T
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -30,22 +30,22 @@ class GlucoseStatusTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Test fun toStringShouldBeOverloaded() {
|
@Test fun toStringShouldBeOverloaded() {
|
||||||
val glucoseStatus = GlucoseStatus(glucose = 0.0, noise = 0.0, delta = 0.0, shortAvgDelta = 0.0, longAvgDelta = 0.0, date = 0)
|
val glucoseStatus = GlucoseStatus(glucose = 0.0, noise = 0.0, delta = 0.0, shortAvgDelta = 0.0, longAvgDelta = 0.0, date = 0)
|
||||||
Assertions.assertEquals(true, glucoseStatus.log(decimalFormatter).contains("Delta"))
|
assertThat(glucoseStatus.log(decimalFormatter)).contains("Delta")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun roundTest() {
|
@Test fun roundTest() {
|
||||||
val glucoseStatus = GlucoseStatus(glucose = 100.11111, noise = 0.0, delta = 0.0, shortAvgDelta = 0.0, longAvgDelta = 0.0, date = 0)
|
val glucoseStatus = GlucoseStatus(glucose = 100.11111, noise = 0.0, delta = 0.0, shortAvgDelta = 0.0, longAvgDelta = 0.0, date = 0)
|
||||||
Assertions.assertEquals(100.1, glucoseStatus.asRounded().glucose, 0.0001)
|
assertThat(glucoseStatus.asRounded().glucose).isWithin(0.0001).of(100.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun calculateValidGlucoseStatus() {
|
@Test fun calculateValidGlucoseStatus() {
|
||||||
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateValidBgData())
|
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateValidBgData())
|
||||||
val glucoseStatus = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).glucoseStatusData!!
|
val glucoseStatus = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).glucoseStatusData!!
|
||||||
Assertions.assertEquals(214.0, glucoseStatus.glucose, 0.001)
|
assertThat(glucoseStatus.glucose).isWithin(0.001).of(214.0)
|
||||||
Assertions.assertEquals(-2.0, glucoseStatus.delta, 0.001)
|
assertThat(glucoseStatus.delta).isWithin(0.001).of(-2.0)
|
||||||
Assertions.assertEquals(-2.5, glucoseStatus.shortAvgDelta, 0.001) // -2 -2.5 -3 deltas are relative to current value
|
assertThat(glucoseStatus.shortAvgDelta).isWithin(0.001).of(-2.5) // -2 -2.5 -3 deltas are relative to current value
|
||||||
Assertions.assertEquals(-2.0, glucoseStatus.longAvgDelta, 0.001) // -2 -2 -2 -2
|
assertThat(glucoseStatus.longAvgDelta).isWithin(0.001).of(-2.0) // -2 -2 -2 -2
|
||||||
Assertions.assertEquals(1514766900000L, glucoseStatus.date) // latest date
|
assertThat(glucoseStatus.date).isEqualTo(1514766900000L) // latest date
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Not testing anymore, not valid for bucketed data
|
Not testing anymore, not valid for bucketed data
|
||||||
|
@ -53,11 +53,11 @@ class GlucoseStatusTest : TestBaseWithProfile() {
|
||||||
@Test fun calculateMostRecentGlucoseStatus() {
|
@Test fun calculateMostRecentGlucoseStatus() {
|
||||||
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateMostRecentBgData())
|
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateMostRecentBgData())
|
||||||
val glucoseStatus: GlucoseStatus = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!!
|
val glucoseStatus: GlucoseStatus = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!!
|
||||||
Assertions.assertEquals(215.0, glucoseStatus.glucose, 0.001) // (214+216) / 2
|
assertThat(glucoseStatus.glucose).isWithin(0.001).of(215.0) // (214+216) / 2
|
||||||
Assertions.assertEquals(-1.0, glucoseStatus.delta, 0.001)
|
assertThat(glucoseStatus.delta).isWithin(0.001).of(-1.0)
|
||||||
Assertions.assertEquals(-1.0, glucoseStatus.shortAvgDelta, 0.001)
|
assertThat(glucoseStatus.shortAvgDelta).isWithin(0.001).of(-1.0)
|
||||||
Assertions.assertEquals(0.0, glucoseStatus.longAvgDelta, 0.001)
|
assertThat( glucoseStatus.longAvgDelta).isWithin(0.001).of(0.0)
|
||||||
Assertions.assertEquals(1514766900000L, glucoseStatus.date) // latest date, even when averaging
|
assertThat(glucoseStatus.date).isEqualTo(1514766900000L) // latest date, even when averaging
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateMostRecentBgData(): MutableList<InMemoryGlucoseValue> {
|
private fun generateMostRecentBgData(): MutableList<InMemoryGlucoseValue> {
|
||||||
|
@ -72,33 +72,33 @@ class GlucoseStatusTest : TestBaseWithProfile() {
|
||||||
@Test fun oneRecordShouldProduceZeroDeltas() {
|
@Test fun oneRecordShouldProduceZeroDeltas() {
|
||||||
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateOneCurrentRecordBgData())
|
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateOneCurrentRecordBgData())
|
||||||
val glucoseStatus: GlucoseStatus = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).glucoseStatusData!!
|
val glucoseStatus: GlucoseStatus = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).glucoseStatusData!!
|
||||||
Assertions.assertEquals(214.0, glucoseStatus.glucose, 0.001)
|
assertThat(glucoseStatus.glucose).isWithin(0.001).of(214.0)
|
||||||
Assertions.assertEquals(0.0, glucoseStatus.delta, 0.001)
|
assertThat(glucoseStatus.delta).isWithin(0.001).of(0.0)
|
||||||
Assertions.assertEquals(0.0, glucoseStatus.shortAvgDelta, 0.001) // -2 -2.5 -3 deltas are relative to current value
|
assertThat(glucoseStatus.shortAvgDelta).isWithin(0.001).of(0.0) // -2 -2.5 -3 deltas are relative to current value
|
||||||
Assertions.assertEquals(0.0, glucoseStatus.longAvgDelta, 0.001) // -2 -2 -2 -2
|
assertThat(glucoseStatus.longAvgDelta).isWithin(0.001).of(0.0) // -2 -2 -2 -2
|
||||||
Assertions.assertEquals(1514766900000L, glucoseStatus.date) // latest date
|
assertThat(glucoseStatus.date).isEqualTo(1514766900000L) // latest date
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun insufficientDataShouldReturnNull() {
|
@Test fun insufficientDataShouldReturnNull() {
|
||||||
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateInsufficientBgData())
|
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateInsufficientBgData())
|
||||||
val glucoseStatus: GlucoseStatus? = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).glucoseStatusData
|
val glucoseStatus: GlucoseStatus? = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).glucoseStatusData
|
||||||
Assertions.assertEquals(null, glucoseStatus)
|
assertThat(glucoseStatus).isNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun oldDataShouldReturnNull() {
|
@Test fun oldDataShouldReturnNull() {
|
||||||
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateOldBgData())
|
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateOldBgData())
|
||||||
val glucoseStatus: GlucoseStatus? = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).glucoseStatusData
|
val glucoseStatus: GlucoseStatus? = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).glucoseStatusData
|
||||||
Assertions.assertEquals(null, glucoseStatus)
|
assertThat(glucoseStatus).isNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun returnOldDataIfAllowed() {
|
@Test fun returnOldDataIfAllowed() {
|
||||||
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateOldBgData())
|
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateOldBgData())
|
||||||
val glucoseStatus: GlucoseStatus? = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).getGlucoseStatusData(true)
|
val glucoseStatus: GlucoseStatus? = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil, decimalFormatter).getGlucoseStatusData(true)
|
||||||
Assertions.assertNotEquals(null, glucoseStatus)
|
assertThat(glucoseStatus).isNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun averageShouldNotFailOnEmptyArray() {
|
@Test fun averageShouldNotFailOnEmptyArray() {
|
||||||
Assertions.assertEquals(0.0, GlucoseStatusProviderImpl.average(ArrayList()), 0.001)
|
assertThat(GlucoseStatusProviderImpl.average(ArrayList())).isWithin(0.001).of(0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -107,11 +107,11 @@ class GlucoseStatusTest : TestBaseWithProfile() {
|
||||||
@Test fun calculateGlucoseStatusForLibreTestBgData() {
|
@Test fun calculateGlucoseStatusForLibreTestBgData() {
|
||||||
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateLibreTestData())
|
Mockito.`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateLibreTestData())
|
||||||
val glucoseStatus: GlucoseStatus = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!!
|
val glucoseStatus: GlucoseStatus = GlucoseStatusProviderImpl(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!!
|
||||||
Assertions.assertEquals(100.0, glucoseStatus.glucose, 0.001) //
|
assertThat(glucoseStatus.glucose).isWithin(0.001).of(100.0)
|
||||||
Assertions.assertEquals(-10.0, glucoseStatus.delta, 0.001)
|
assertThat(glucoseStatus.delta).isWithin(0.001).of(-10.0)
|
||||||
Assertions.assertEquals(-10.0, glucoseStatus.shortAvgDelta, 0.001)
|
assertThat(glucoseStatus.shortAvgDelta).isWithin(0.001).of(-10.0)
|
||||||
Assertions.assertEquals(-10.0, glucoseStatus.longAvgDelta, 0.001)
|
assertThat(glucoseStatus.longAvgDelta).isWithin(0.001).of(-10.0)
|
||||||
Assertions.assertEquals(1514766900000L, glucoseStatus.date) // latest date
|
assertThat(glucoseStatus.date).isEqualTo(1514766900000L) // latest date
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateLibreTestData(): MutableList<InMemoryGlucoseValue> {
|
private fun generateLibreTestData(): MutableList<InMemoryGlucoseValue> {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.implementation.overview
|
package info.nightscout.implementation.overview
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.ValueWrapper
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
|
@ -10,7 +11,6 @@ import info.nightscout.interfaces.profile.DefaultValueHelper
|
||||||
import info.nightscout.shared.utils.T
|
import info.nightscout.shared.utils.T
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import io.reactivex.rxjava3.core.Single
|
import io.reactivex.rxjava3.core.Single
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -43,23 +43,23 @@ class OverviewDataImplTest : TestBaseWithProfile() {
|
||||||
// no data
|
// no data
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Absent()))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Absent()))
|
||||||
Assertions.assertNull(sut.lastBg(autosensDataStore))
|
assertThat(sut.lastBg(autosensDataStore)).isNull()
|
||||||
Assertions.assertFalse(sut.isLow(autosensDataStore))
|
assertThat(sut.isLow(autosensDataStore)).isFalse()
|
||||||
Assertions.assertFalse(sut.isHigh(autosensDataStore))
|
assertThat(sut.isHigh(autosensDataStore)).isFalse()
|
||||||
|
|
||||||
// no bucketed but in db
|
// no bucketed but in db
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
||||||
Assertions.assertEquals(200.0, sut.lastBg(autosensDataStore)?.value)
|
assertThat(sut.lastBg(autosensDataStore)?.value).isEqualTo(200.0)
|
||||||
Assertions.assertFalse(sut.isLow(autosensDataStore))
|
assertThat(sut.isLow(autosensDataStore)).isFalse()
|
||||||
Assertions.assertTrue(sut.isHigh(autosensDataStore))
|
assertThat(sut.isHigh(autosensDataStore)).isTrue()
|
||||||
|
|
||||||
// in bucketed
|
// in bucketed
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(bucketedData)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(bucketedData)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
||||||
Assertions.assertEquals(70.0, sut.lastBg(autosensDataStore)?.value)
|
assertThat(sut.lastBg(autosensDataStore)?.value).isEqualTo(70.0)
|
||||||
Assertions.assertTrue(sut.isLow(autosensDataStore))
|
assertThat(sut.isLow(autosensDataStore)).isTrue()
|
||||||
Assertions.assertFalse(sut.isHigh(autosensDataStore))
|
assertThat(sut.isHigh(autosensDataStore)).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -68,13 +68,13 @@ class OverviewDataImplTest : TestBaseWithProfile() {
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
||||||
Mockito.`when`(dateUtil.now()).thenReturn(time + T.mins(1).msecs())
|
Mockito.`when`(dateUtil.now()).thenReturn(time + T.mins(1).msecs())
|
||||||
Assertions.assertTrue(sut.isActualBg(autosensDataStore))
|
assertThat(sut.isActualBg(autosensDataStore)).isTrue()
|
||||||
Mockito.`when`(dateUtil.now()).thenReturn(time + T.mins(9).msecs() + 1)
|
Mockito.`when`(dateUtil.now()).thenReturn(time + T.mins(9).msecs() + 1)
|
||||||
Assertions.assertFalse(sut.isActualBg(autosensDataStore))
|
assertThat(sut.isActualBg(autosensDataStore)).isFalse()
|
||||||
|
|
||||||
// no data
|
// no data
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Absent()))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Absent()))
|
||||||
Assertions.assertFalse(sut.isActualBg(autosensDataStore))
|
assertThat(sut.isActualBg(autosensDataStore)).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,47 +1,47 @@
|
||||||
package info.nightscout.implementation.profile
|
package info.nightscout.implementation.profile
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.interfaces.profile.PureProfile
|
import info.nightscout.interfaces.profile.PureProfile
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
internal class ProfileStoreTest : TestBaseWithProfile() {
|
internal class ProfileStoreTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getStartDateTest() {
|
fun getStartDateTest() {
|
||||||
Assertions.assertEquals(0, getValidProfileStore().getStartDate())
|
assertThat(getValidProfileStore().getStartDate()).isEqualTo(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getDefaultProfileTest() {
|
fun getDefaultProfileTest() {
|
||||||
Assertions.assertTrue(getValidProfileStore().getDefaultProfile() is PureProfile)
|
assertThat(getValidProfileStore().getDefaultProfile()).isInstanceOf(PureProfile::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getDefaultProfileJsonTest() {
|
fun getDefaultProfileJsonTest() {
|
||||||
Assertions.assertTrue(getValidProfileStore().getDefaultProfileJson()?.has("dia") ?: false)
|
assertThat(getValidProfileStore().getDefaultProfileJson()?.has("dia")).isTrue()
|
||||||
Assertions.assertEquals(null, getInvalidProfileStore2().getDefaultProfileJson())
|
assertThat(getInvalidProfileStore2().getDefaultProfileJson()).isNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getDefaultProfileNameTest() {
|
fun getDefaultProfileNameTest() {
|
||||||
Assertions.assertEquals(TESTPROFILENAME, getValidProfileStore().getDefaultProfileName())
|
assertThat(getValidProfileStore().getDefaultProfileName()).isEqualTo(TESTPROFILENAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getProfileListTest() {
|
fun getProfileListTest() {
|
||||||
Assertions.assertEquals(1, getValidProfileStore().getProfileList().size)
|
assertThat(getValidProfileStore().getProfileList()).hasSize(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getSpecificProfileTest() {
|
fun getSpecificProfileTest() {
|
||||||
Assertions.assertTrue(getValidProfileStore().getSpecificProfile(TESTPROFILENAME) is PureProfile)
|
assertThat(getValidProfileStore().getSpecificProfile(TESTPROFILENAME)).isInstanceOf(PureProfile::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allProfilesValidTest() {
|
fun allProfilesValidTest() {
|
||||||
Assertions.assertTrue(getValidProfileStore().allProfilesValid)
|
assertThat(getValidProfileStore().allProfilesValid).isTrue()
|
||||||
Assertions.assertFalse(getInvalidProfileStore1().allProfilesValid)
|
assertThat(getInvalidProfileStore1().allProfilesValid).isFalse()
|
||||||
Assertions.assertFalse(getInvalidProfileStore2().allProfilesValid)
|
assertThat(getInvalidProfileStore2().allProfilesValid).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.implementation.profile
|
package info.nightscout.implementation.profile
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
import info.nightscout.implementation.utils.DecimalFormatterImpl
|
import info.nightscout.implementation.utils.DecimalFormatterImpl
|
||||||
import info.nightscout.interfaces.GlucoseUnit
|
import info.nightscout.interfaces.GlucoseUnit
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -29,19 +29,19 @@ class ProfileUtilImplTest : TestBase() {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun toUnitsString() {
|
fun toUnitsString() {
|
||||||
Assertions.assertEquals("100", sut.fromMgdlToStringInUnits(glucoseValue.value, GlucoseUnit.MGDL))
|
assertThat(sut.fromMgdlToStringInUnits(glucoseValue.value, GlucoseUnit.MGDL)).isEqualTo("100")
|
||||||
Assertions.assertEquals("5.6", sut.fromMgdlToStringInUnits(glucoseValue.value, GlucoseUnit.MMOL))
|
assertThat(sut.fromMgdlToStringInUnits(glucoseValue.value, GlucoseUnit.MMOL)).isEqualTo("5.6")
|
||||||
Assertions.assertEquals(0.1, sut.convertToMgdl(0.1, GlucoseUnit.MGDL), 0.01)
|
assertThat(sut.convertToMgdl(0.1, GlucoseUnit.MGDL)).isWithin(0.01).of(0.1)
|
||||||
Assertions.assertEquals(18.0, sut.convertToMgdl(1.0, GlucoseUnit.MMOL), 0.01)
|
assertThat(sut.convertToMgdl(1.0, GlucoseUnit.MMOL)).isWithin(0.01).of(18.0)
|
||||||
Assertions.assertEquals(1.0, sut.convertToMmol(18.0, GlucoseUnit.MGDL), 0.01)
|
assertThat(sut.convertToMmol(18.0, GlucoseUnit.MGDL)).isWithin(0.01).of(1.0)
|
||||||
Assertions.assertEquals(18.0, sut.convertToMmol(18.0, GlucoseUnit.MMOL), 0.01)
|
assertThat(sut.convertToMmol(18.0, GlucoseUnit.MMOL)).isWithin(0.01).of(18.0)
|
||||||
Assertions.assertEquals(18.0, sut.fromMgdlToUnits(18.0, GlucoseUnit.MGDL), 0.01)
|
assertThat(sut.fromMgdlToUnits(18.0, GlucoseUnit.MGDL)).isWithin(0.01).of(18.0)
|
||||||
Assertions.assertEquals(1.0, sut.fromMgdlToUnits(18.0, GlucoseUnit.MMOL), 0.01)
|
assertThat(sut.fromMgdlToUnits(18.0, GlucoseUnit.MMOL)).isWithin(0.01).of(1.0)
|
||||||
Assertions.assertEquals(18.0, sut.fromMgdlToUnits(18.0, GlucoseUnit.MGDL), 0.01)
|
assertThat(sut.fromMgdlToUnits(18.0, GlucoseUnit.MGDL)).isWithin(0.01).of(18.0)
|
||||||
Assertions.assertEquals(1.0, sut.fromMgdlToUnits(18.0, GlucoseUnit.MMOL), 0.01)
|
assertThat(sut.fromMgdlToUnits(18.0, GlucoseUnit.MMOL)).isWithin(0.01).of(1.0)
|
||||||
Assertions.assertEquals("18", sut.fromMgdlToStringInUnits(18.0, GlucoseUnit.MGDL))
|
assertThat(sut.fromMgdlToStringInUnits(18.0, GlucoseUnit.MGDL)).isEqualTo("18")
|
||||||
Assertions.assertEquals("1.0", sut.fromMgdlToStringInUnits(18.0, GlucoseUnit.MMOL).replace(",", "."))
|
assertThat(sut.fromMgdlToStringInUnits(18.0, GlucoseUnit.MMOL).replace(",", ".")).isEqualTo("1.0")
|
||||||
Assertions.assertEquals("5 - 6", sut.toTargetRangeString(5.0, 6.0, GlucoseUnit.MGDL, GlucoseUnit.MGDL))
|
assertThat(sut.toTargetRangeString(5.0, 6.0, GlucoseUnit.MGDL, GlucoseUnit.MGDL)).isEqualTo("5 - 6")
|
||||||
Assertions.assertEquals("4", sut.toTargetRangeString(4.0, 4.0, GlucoseUnit.MGDL, GlucoseUnit.MGDL))
|
assertThat(sut.toTargetRangeString(4.0, 4.0, GlucoseUnit.MGDL, GlucoseUnit.MGDL)).isEqualTo("4")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.implementation.pump
|
package info.nightscout.implementation.pump
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -47,9 +47,9 @@ class DetailedBolusInfoStorageTest : TestBase() {
|
||||||
@Test
|
@Test
|
||||||
fun add() {
|
fun add() {
|
||||||
detailedBolusInfoStorage.store.clear()
|
detailedBolusInfoStorage.store.clear()
|
||||||
Assertions.assertEquals(0, detailedBolusInfoStorage.store.size)
|
assertThat(detailedBolusInfoStorage.store).isEmpty()
|
||||||
detailedBolusInfoStorage.add(info1)
|
detailedBolusInfoStorage.add(info1)
|
||||||
Assertions.assertEquals(1, detailedBolusInfoStorage.store.size)
|
assertThat(detailedBolusInfoStorage.store).hasSize(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -58,38 +58,38 @@ class DetailedBolusInfoStorageTest : TestBase() {
|
||||||
// Look for exact bolus
|
// Look for exact bolus
|
||||||
setUp()
|
setUp()
|
||||||
var d: DetailedBolusInfo? = detailedBolusInfoStorage.findDetailedBolusInfo(1000000, 4.0)
|
var d: DetailedBolusInfo? = detailedBolusInfoStorage.findDetailedBolusInfo(1000000, 4.0)
|
||||||
Assertions.assertEquals(4.0, d!!.insulin, 0.01)
|
assertThat(d!!.insulin).isWithin(0.01).of(4.0)
|
||||||
Assertions.assertEquals(2, detailedBolusInfoStorage.store.size)
|
assertThat(detailedBolusInfoStorage.store).hasSize(2)
|
||||||
// Look for exact bolus
|
// Look for exact bolus
|
||||||
setUp()
|
setUp()
|
||||||
d = detailedBolusInfoStorage.findDetailedBolusInfo(1000000, 3.0)
|
d = detailedBolusInfoStorage.findDetailedBolusInfo(1000000, 3.0)
|
||||||
Assertions.assertEquals(3.0, d!!.insulin, 0.01)
|
assertThat(d!!.insulin).isWithin(0.01).of(3.0)
|
||||||
Assertions.assertEquals(2, detailedBolusInfoStorage.store.size)
|
assertThat(detailedBolusInfoStorage.store).hasSize(2)
|
||||||
// With less insulin (bolus not delivered completely). Should return first one matching date
|
// With less insulin (bolus not delivered completely). Should return first one matching date
|
||||||
setUp()
|
setUp()
|
||||||
d = detailedBolusInfoStorage.findDetailedBolusInfo(1000500, 2.0)
|
d = detailedBolusInfoStorage.findDetailedBolusInfo(1000500, 2.0)
|
||||||
Assertions.assertEquals(3.0, d!!.insulin, 0.01)
|
assertThat(d!!.insulin).isWithin(0.01).of(3.0)
|
||||||
Assertions.assertEquals(2, detailedBolusInfoStorage.store.size)
|
assertThat(detailedBolusInfoStorage.store).hasSize(2)
|
||||||
// With less insulin (bolus not delivered completely). Should return first one matching date
|
// With less insulin (bolus not delivered completely). Should return first one matching date
|
||||||
setUp()
|
setUp()
|
||||||
d = detailedBolusInfoStorage.findDetailedBolusInfo(1000500, 3.5)
|
d = detailedBolusInfoStorage.findDetailedBolusInfo(1000500, 3.5)
|
||||||
Assertions.assertEquals(4.0, d!!.insulin, 0.01)
|
assertThat(d!!.insulin).isWithin(0.01).of(4.0)
|
||||||
Assertions.assertEquals(2, detailedBolusInfoStorage.store.size)
|
assertThat(detailedBolusInfoStorage.store).hasSize(2)
|
||||||
// With more insulin should return null
|
// With more insulin should return null
|
||||||
setUp()
|
setUp()
|
||||||
d = detailedBolusInfoStorage.findDetailedBolusInfo(1000500, 4.5)
|
d = detailedBolusInfoStorage.findDetailedBolusInfo(1000500, 4.5)
|
||||||
Assertions.assertNull(d)
|
assertThat(d).isNull()
|
||||||
Assertions.assertEquals(3, detailedBolusInfoStorage.store.size)
|
assertThat(detailedBolusInfoStorage.store).hasSize(3)
|
||||||
// With more than one minute off should return null
|
// With more than one minute off should return null
|
||||||
setUp()
|
setUp()
|
||||||
d = detailedBolusInfoStorage.findDetailedBolusInfo(1070000, 4.0)
|
d = detailedBolusInfoStorage.findDetailedBolusInfo(1070000, 4.0)
|
||||||
Assertions.assertNull(d)
|
assertThat(d).isNull()
|
||||||
Assertions.assertEquals(3, detailedBolusInfoStorage.store.size)
|
assertThat(detailedBolusInfoStorage.store).hasSize(3)
|
||||||
// Use last, if bolus size is the same
|
// Use last, if bolus size is the same
|
||||||
// setUp()
|
// setUp()
|
||||||
// d = detailedBolusInfoStorage.findDetailedBolusInfo(1070000, 5.0)
|
// d = detailedBolusInfoStorage.findDetailedBolusInfo(1070000, 5.0)
|
||||||
// assertEquals(5.0, d!!.insulin, 0.01)
|
// assertThat( d!!.insulin).isWithin(0.01).of(5.0)
|
||||||
// assertEquals(2, detailedBolusInfoStorage.store.size)
|
// assertThat(detailedBolusInfoStorage.store).hasSize(2)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.implementation.pump
|
package info.nightscout.implementation.pump
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ class TemporaryBasalStorageTest : TestBase() {
|
||||||
@Test
|
@Test
|
||||||
fun add() {
|
fun add() {
|
||||||
temporaryBasalStorage.store.clear()
|
temporaryBasalStorage.store.clear()
|
||||||
Assertions.assertEquals(0, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).isEmpty()
|
||||||
temporaryBasalStorage.add(info1)
|
temporaryBasalStorage.add(info1)
|
||||||
Assertions.assertEquals(1, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -40,38 +40,38 @@ class TemporaryBasalStorageTest : TestBase() {
|
||||||
// Look for exact bolus
|
// Look for exact bolus
|
||||||
setUp()
|
setUp()
|
||||||
var d = temporaryBasalStorage.findTemporaryBasal(1000000, 4.0)
|
var d = temporaryBasalStorage.findTemporaryBasal(1000000, 4.0)
|
||||||
Assertions.assertEquals(4.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(4.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
// Look for exact bolus
|
// Look for exact bolus
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1000000, 3.0)
|
d = temporaryBasalStorage.findTemporaryBasal(1000000, 3.0)
|
||||||
Assertions.assertEquals(3.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(3.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
// With less rate (bolus not delivered completely). Should return first one matching date
|
// With less rate (bolus not delivered completely). Should return first one matching date
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1000500, 2.0)
|
d = temporaryBasalStorage.findTemporaryBasal(1000500, 2.0)
|
||||||
Assertions.assertEquals(3.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(3.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
// With less rate (bolus not delivered completely). Should return first one matching date
|
// With less rate (bolus not delivered completely). Should return first one matching date
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1000500, 3.5)
|
d = temporaryBasalStorage.findTemporaryBasal(1000500, 3.5)
|
||||||
Assertions.assertEquals(4.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(4.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
// With more rate should return null
|
// With more rate should return null
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1000500, 4.5)
|
d = temporaryBasalStorage.findTemporaryBasal(1000500, 4.5)
|
||||||
Assertions.assertNull(d)
|
assertThat(d).isNull()
|
||||||
Assertions.assertEquals(3, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(3)
|
||||||
// With more than one minute off should return null
|
// With more than one minute off should return null
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1070000, 4.0)
|
d = temporaryBasalStorage.findTemporaryBasal(1070000, 4.0)
|
||||||
Assertions.assertNull(d)
|
assertThat(d).isNull()
|
||||||
Assertions.assertEquals(3, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(3)
|
||||||
// Use last, if bolus size is the same
|
// Use last, if bolus size is the same
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1070000, 5.0)
|
d = temporaryBasalStorage.findTemporaryBasal(1070000, 5.0)
|
||||||
Assertions.assertEquals(5.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(5.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.implementation.queue
|
package info.nightscout.implementation.queue
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
@ -38,7 +39,6 @@ import info.nightscout.shared.utils.DateUtil
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import info.nightscout.sharedtests.TestPumpPlugin
|
import info.nightscout.sharedtests.TestPumpPlugin
|
||||||
import io.reactivex.rxjava3.core.Single
|
import io.reactivex.rxjava3.core.Single
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -172,121 +172,121 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
|
||||||
commandQueue.handler = handler
|
commandQueue.handler = handler
|
||||||
|
|
||||||
// start with empty queue
|
// start with empty queue
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// add bolus command
|
// add bolus command
|
||||||
commandQueue.bolus(DetailedBolusInfo(), null)
|
commandQueue.bolus(DetailedBolusInfo(), null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
|
|
||||||
commandQueue.waitForFinishedThread()
|
commandQueue.waitForFinishedThread()
|
||||||
Thread.sleep(1000)
|
Thread.sleep(1000)
|
||||||
|
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun doTests() {
|
fun doTests() {
|
||||||
|
|
||||||
// start with empty queue
|
// start with empty queue
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// add bolus command
|
// add bolus command
|
||||||
commandQueue.bolus(DetailedBolusInfo(), null)
|
commandQueue.bolus(DetailedBolusInfo(), null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
|
|
||||||
// add READSTATUS
|
// add READSTATUS
|
||||||
commandQueue.readStatus("anyString", null)
|
commandQueue.readStatus("anyString", null)
|
||||||
Assertions.assertEquals(2, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(2)
|
||||||
|
|
||||||
// adding another bolus should remove the first one (size still == 2)
|
// adding another bolus should remove the first one (size still == 2)
|
||||||
commandQueue.bolus(DetailedBolusInfo(), null)
|
commandQueue.bolus(DetailedBolusInfo(), null)
|
||||||
Assertions.assertEquals(2, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(2)
|
||||||
|
|
||||||
// clear the queue should reset size
|
// clear the queue should reset size
|
||||||
commandQueue.clear()
|
commandQueue.clear()
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// add tempbasal
|
// add tempbasal
|
||||||
commandQueue.tempBasalAbsolute(0.0, 30, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
commandQueue.tempBasalAbsolute(0.0, 30, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
|
|
||||||
// add tempbasal percent. it should replace previous TEMPBASAL
|
// add tempbasal percent. it should replace previous TEMPBASAL
|
||||||
commandQueue.tempBasalPercent(0, 30, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
commandQueue.tempBasalPercent(0, 30, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
|
|
||||||
// cancel tempbasal it should replace previous TEMPBASAL
|
// cancel tempbasal it should replace previous TEMPBASAL
|
||||||
commandQueue.cancelTempBasal(false, null)
|
commandQueue.cancelTempBasal(false, null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
|
|
||||||
// add extended bolus
|
// add extended bolus
|
||||||
commandQueue.extendedBolus(1.0, 30, null)
|
commandQueue.extendedBolus(1.0, 30, null)
|
||||||
Assertions.assertEquals(2, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(2)
|
||||||
|
|
||||||
// add extended should remove previous extended setting
|
// add extended should remove previous extended setting
|
||||||
commandQueue.extendedBolus(1.0, 30, null)
|
commandQueue.extendedBolus(1.0, 30, null)
|
||||||
Assertions.assertEquals(2, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(2)
|
||||||
|
|
||||||
// cancel extended bolus should replace previous extended
|
// cancel extended bolus should replace previous extended
|
||||||
commandQueue.cancelExtended(null)
|
commandQueue.cancelExtended(null)
|
||||||
Assertions.assertEquals(2, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(2)
|
||||||
|
|
||||||
// add setProfile
|
// add setProfile
|
||||||
// TODO: this crash the test
|
// TODO: this crash the test
|
||||||
// commandQueue.setProfile(validProfile, null)
|
// commandQueue.setProfile(validProfile, null)
|
||||||
// Assertions.assertEquals(3, commandQueue.size())
|
// assertThat(commandQueue.size()).isEqualTo(3)
|
||||||
|
|
||||||
// add loadHistory
|
// add loadHistory
|
||||||
commandQueue.loadHistory(0.toByte(), null)
|
commandQueue.loadHistory(0.toByte(), null)
|
||||||
Assertions.assertEquals(3, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(3)
|
||||||
|
|
||||||
// add loadEvents
|
// add loadEvents
|
||||||
commandQueue.loadEvents(null)
|
commandQueue.loadEvents(null)
|
||||||
Assertions.assertEquals(4, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(4)
|
||||||
|
|
||||||
// add clearAlarms
|
// add clearAlarms
|
||||||
commandQueue.clearAlarms(null)
|
commandQueue.clearAlarms(null)
|
||||||
Assertions.assertEquals(5, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(5)
|
||||||
|
|
||||||
// add deactivate
|
// add deactivate
|
||||||
commandQueue.deactivate(null)
|
commandQueue.deactivate(null)
|
||||||
Assertions.assertEquals(6, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(6)
|
||||||
|
|
||||||
// add updateTime
|
// add updateTime
|
||||||
commandQueue.updateTime(null)
|
commandQueue.updateTime(null)
|
||||||
Assertions.assertEquals(7, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(7)
|
||||||
|
|
||||||
commandQueue.clear()
|
commandQueue.clear()
|
||||||
commandQueue.tempBasalAbsolute(0.0, 30, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
commandQueue.tempBasalAbsolute(0.0, 30, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
||||||
commandQueue.pickup()
|
commandQueue.pickup()
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
Assertions.assertNotNull(commandQueue.performing)
|
assertThat(commandQueue.performing).isNotNull()
|
||||||
Assertions.assertEquals(Command.CommandType.TEMPBASAL, commandQueue.performing?.commandType)
|
assertThat(commandQueue.performing?.commandType).isEqualTo(Command.CommandType.TEMPBASAL)
|
||||||
commandQueue.resetPerforming()
|
commandQueue.resetPerforming()
|
||||||
Assertions.assertNull(commandQueue.performing)
|
assertThat(commandQueue.performing).isNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun callingCancelAllBolusesClearsQueue() {
|
fun callingCancelAllBolusesClearsQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
val smb = DetailedBolusInfo()
|
val smb = DetailedBolusInfo()
|
||||||
smb.lastKnownBolusTime = System.currentTimeMillis()
|
smb.lastKnownBolusTime = System.currentTimeMillis()
|
||||||
smb.bolusType = DetailedBolusInfo.BolusType.SMB
|
smb.bolusType = DetailedBolusInfo.BolusType.SMB
|
||||||
commandQueue.bolus(smb, null)
|
commandQueue.bolus(smb, null)
|
||||||
commandQueue.bolus(DetailedBolusInfo(), null)
|
commandQueue.bolus(DetailedBolusInfo(), null)
|
||||||
Assertions.assertEquals(2, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(2)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.cancelAllBoluses(null)
|
commandQueue.cancelAllBoluses(null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun smbIsRejectedIfABolusIsQueued() {
|
fun smbIsRejectedIfABolusIsQueued() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.bolus(DetailedBolusInfo(), null)
|
commandQueue.bolus(DetailedBolusInfo(), null)
|
||||||
|
@ -295,14 +295,14 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
|
||||||
val queued: Boolean = commandQueue.bolus(smb, null)
|
val queued: Boolean = commandQueue.bolus(smb, null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertFalse(queued)
|
assertThat(queued).isFalse()
|
||||||
Assertions.assertEquals(commandQueue.size(), 1)
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun smbIsRejectedIfLastKnownBolusIsOutdated() {
|
fun smbIsRejectedIfLastKnownBolusIsOutdated() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val bolus = DetailedBolusInfo()
|
val bolus = DetailedBolusInfo()
|
||||||
|
@ -311,14 +311,14 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
|
||||||
val queued: Boolean = commandQueue.bolus(bolus, null)
|
val queued: Boolean = commandQueue.bolus(bolus, null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertFalse(queued)
|
assertThat(queued).isFalse()
|
||||||
Assertions.assertEquals(commandQueue.size(), 0)
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isCustomCommandRunning() {
|
fun isCustomCommandRunning() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val queued1 = commandQueue.customCommand(CustomCommand1(), null)
|
val queued1 = commandQueue.customCommand(CustomCommand1(), null)
|
||||||
|
@ -326,249 +326,249 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
|
||||||
commandQueue.pickup()
|
commandQueue.pickup()
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(queued1)
|
assertThat(queued1).isTrue()
|
||||||
Assertions.assertTrue(queued2)
|
assertThat(queued2).isTrue()
|
||||||
Assertions.assertTrue(commandQueue.isCustomCommandInQueue(CustomCommand1::class.java))
|
assertThat(commandQueue.isCustomCommandInQueue(CustomCommand1::class.java)).isTrue()
|
||||||
Assertions.assertTrue(commandQueue.isCustomCommandInQueue(CustomCommand2::class.java))
|
assertThat(commandQueue.isCustomCommandInQueue(CustomCommand2::class.java)).isTrue()
|
||||||
Assertions.assertFalse(commandQueue.isCustomCommandInQueue(CustomCommand3::class.java))
|
assertThat(commandQueue.isCustomCommandInQueue(CustomCommand3::class.java)).isFalse()
|
||||||
|
|
||||||
Assertions.assertTrue(commandQueue.isCustomCommandRunning(CustomCommand1::class.java))
|
assertThat(commandQueue.isCustomCommandRunning(CustomCommand1::class.java)).isTrue()
|
||||||
Assertions.assertFalse(commandQueue.isCustomCommandRunning(CustomCommand2::class.java))
|
assertThat(commandQueue.isCustomCommandRunning(CustomCommand2::class.java)).isFalse()
|
||||||
Assertions.assertFalse(commandQueue.isCustomCommandRunning(CustomCommand3::class.java))
|
assertThat(commandQueue.isCustomCommandRunning(CustomCommand3::class.java)).isFalse()
|
||||||
|
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isSetUserOptionsCommandInQueue() {
|
fun isSetUserOptionsCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.setUserOptions(null)
|
commandQueue.setUserOptions(null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.SET_USER_SETTINGS))
|
assertThat(commandQueue.isLastScheduled(Command.CommandType.SET_USER_SETTINGS)).isTrue()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
// next should be ignored
|
// next should be ignored
|
||||||
commandQueue.setUserOptions(null)
|
commandQueue.setUserOptions(null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isLoadEventsCommandInQueue() {
|
fun isLoadEventsCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.loadEvents(null)
|
commandQueue.loadEvents(null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.LOAD_EVENTS))
|
assertThat(commandQueue.isLastScheduled(Command.CommandType.LOAD_EVENTS)).isTrue()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
// next should be ignored
|
// next should be ignored
|
||||||
commandQueue.loadEvents(null)
|
commandQueue.loadEvents(null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isClearAlarmsCommandInQueue() {
|
fun isClearAlarmsCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.clearAlarms(null)
|
commandQueue.clearAlarms(null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.CLEAR_ALARMS))
|
assertThat(commandQueue.isLastScheduled(Command.CommandType.CLEAR_ALARMS)).isTrue()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
// next should be ignored
|
// next should be ignored
|
||||||
commandQueue.clearAlarms(null)
|
commandQueue.clearAlarms(null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isDeactivateCommandInQueue() {
|
fun isDeactivateCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.deactivate(null)
|
commandQueue.deactivate(null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.DEACTIVATE))
|
assertThat(commandQueue.isLastScheduled(Command.CommandType.DEACTIVATE)).isTrue()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
// next should be ignored
|
// next should be ignored
|
||||||
commandQueue.deactivate(null)
|
commandQueue.deactivate(null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isUpdateTimeCommandInQueue() {
|
fun isUpdateTimeCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.updateTime(null)
|
commandQueue.updateTime(null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.UPDATE_TIME))
|
assertThat(commandQueue.isLastScheduled(Command.CommandType.UPDATE_TIME)).isTrue()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
// next should be ignored
|
// next should be ignored
|
||||||
commandQueue.updateTime(null)
|
commandQueue.updateTime(null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isLoadTDDsCommandInQueue() {
|
fun isLoadTDDsCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.loadTDDs(null)
|
commandQueue.loadTDDs(null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
// next should be ignored
|
// next should be ignored
|
||||||
commandQueue.loadTDDs(null)
|
commandQueue.loadTDDs(null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isLoadHistoryCommandInQueue() {
|
fun isLoadHistoryCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.loadHistory(0, null)
|
commandQueue.loadHistory(0, null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.LOAD_HISTORY))
|
assertThat(commandQueue.isLastScheduled(Command.CommandType.LOAD_HISTORY)).isTrue()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
// next should be ignored
|
// next should be ignored
|
||||||
commandQueue.loadHistory(0, null)
|
commandQueue.loadHistory(0, null)
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isProfileSetCommandInQueue() {
|
fun isProfileSetCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
testPumpPlugin.isProfileSet = true
|
testPumpPlugin.isProfileSet = true
|
||||||
commandQueue.setProfile(validProfile, false, object : Callback() {
|
commandQueue.setProfile(validProfile, false, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
Assertions.assertTrue(result.success)
|
assertThat(result.success).isTrue()
|
||||||
Assertions.assertFalse(result.enacted)
|
assertThat(result.enacted).isFalse()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// then
|
// then
|
||||||
// the same profile -> ignore
|
// the same profile -> ignore
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
// different should be added
|
// different should be added
|
||||||
testPumpPlugin.isProfileSet = false
|
testPumpPlugin.isProfileSet = false
|
||||||
commandQueue.setProfile(validProfile, false, object : Callback() {
|
commandQueue.setProfile(validProfile, false, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
Assertions.assertTrue(result.success)
|
assertThat(result.success).isTrue()
|
||||||
Assertions.assertTrue(result.enacted)
|
assertThat(result.enacted).isTrue()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
// next should be ignored
|
// next should be ignored
|
||||||
commandQueue.setProfile(validProfile, false, object : Callback() {
|
commandQueue.setProfile(validProfile, false, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
Assertions.assertTrue(result.success)
|
assertThat(result.success).isTrue()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
testPumpPlugin.isProfileSet = true
|
testPumpPlugin.isProfileSet = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isStopCommandInQueue() {
|
fun isStopCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.stopPump(null)
|
commandQueue.stopPump(null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.STOP_PUMP))
|
assertThat(commandQueue.isLastScheduled(Command.CommandType.STOP_PUMP)).isTrue()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isStarCommandInQueue() {
|
fun isStarCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.startPump(null)
|
commandQueue.startPump(null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.START_PUMP))
|
assertThat(commandQueue.isLastScheduled(Command.CommandType.START_PUMP)).isTrue()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isSetTbrNotificationCommandInQueue() {
|
fun isSetTbrNotificationCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.setTBROverNotification(null, true)
|
commandQueue.setTBROverNotification(null, true)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.INSIGHT_SET_TBR_OVER_ALARM))
|
assertThat(commandQueue.isLastScheduled(Command.CommandType.INSIGHT_SET_TBR_OVER_ALARM)).isTrue()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun differentCustomCommandsAllowed() {
|
fun differentCustomCommandsAllowed() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val queued1 = commandQueue.customCommand(CustomCommand1(), null)
|
val queued1 = commandQueue.customCommand(CustomCommand1(), null)
|
||||||
val queued2 = commandQueue.customCommand(CustomCommand2(), null)
|
val queued2 = commandQueue.customCommand(CustomCommand2(), null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(queued1)
|
assertThat(queued1).isTrue()
|
||||||
Assertions.assertTrue(queued2)
|
assertThat(queued2).isTrue()
|
||||||
Assertions.assertEquals(2, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun sameCustomCommandNotAllowed() {
|
fun sameCustomCommandNotAllowed() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val queued1 = commandQueue.customCommand(CustomCommand1(), null)
|
val queued1 = commandQueue.customCommand(CustomCommand1(), null)
|
||||||
val queued2 = commandQueue.customCommand(CustomCommand1(), null)
|
val queued2 = commandQueue.customCommand(CustomCommand1(), null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(queued1)
|
assertThat(queued1).isTrue()
|
||||||
Assertions.assertFalse(queued2)
|
assertThat(queued2).isFalse()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun readStatusTwiceIsNotAllowed() {
|
fun readStatusTwiceIsNotAllowed() {
|
||||||
// given
|
// given
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val queued1 = commandQueue.readStatus("1", null)
|
val queued1 = commandQueue.readStatus("1", null)
|
||||||
val queued2 = commandQueue.readStatus("2", null)
|
val queued2 = commandQueue.readStatus("2", null)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assertions.assertTrue(queued1)
|
assertThat(queued1).isTrue()
|
||||||
Assertions.assertFalse(queued2)
|
assertThat(queued2).isFalse()
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(1)
|
||||||
Assertions.assertTrue(commandQueue.statusInQueue())
|
assertThat(commandQueue.statusInQueue()).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CustomCommand1 : CustomCommand {
|
private class CustomCommand1 : CustomCommand {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.implementation.queue
|
package info.nightscout.implementation.queue
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
|
@ -16,7 +17,6 @@ import info.nightscout.interfaces.queue.Command
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import info.nightscout.sharedtests.TestPumpPlugin
|
import info.nightscout.sharedtests.TestPumpPlugin
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.ArgumentMatchers
|
import org.mockito.ArgumentMatchers
|
||||||
|
@ -87,6 +87,6 @@ class QueueThreadTest : TestBaseWithProfile() {
|
||||||
commandQueue.tempBasalAbsolute(2.0, 60, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
commandQueue.tempBasalAbsolute(2.0, 60, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
||||||
@Suppress("CallToThreadRun")
|
@Suppress("CallToThreadRun")
|
||||||
sut.run()
|
sut.run()
|
||||||
Assertions.assertEquals(0, commandQueue.size())
|
assertThat(commandQueue.size()).isEqualTo(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.implementation.utils
|
package info.nightscout.implementation.utils
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.interfaces.utils.DecimalFormatter
|
import info.nightscout.interfaces.utils.DecimalFormatter
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -20,22 +20,22 @@ class DecimalFormatterTest : TestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun to0DecimalTest() {
|
@Test fun to0DecimalTest() {
|
||||||
Assertions.assertEquals("1", sut.to0Decimal(1.33).replace(",", "."))
|
assertThat(sut.to0Decimal(1.33).replace(",", ".")).isEqualTo("1")
|
||||||
Assertions.assertEquals("1U", sut.to0Decimal(1.33, "U").replace(",", "."))
|
assertThat(sut.to0Decimal(1.33, "U").replace(",", ".")).isEqualTo("1U")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun to1DecimalTest() {
|
@Test fun to1DecimalTest() {
|
||||||
Assertions.assertEquals("1.3", sut.to1Decimal(1.33).replace(",", "."))
|
assertThat(sut.to1Decimal(1.33).replace(",", ".")).isEqualTo("1.3")
|
||||||
Assertions.assertEquals("1.3U", sut.to1Decimal(1.33, "U").replace(",", "."))
|
assertThat(sut.to1Decimal(1.33, "U").replace(",", ".")).isEqualTo("1.3U")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun to2DecimalTest() {
|
@Test fun to2DecimalTest() {
|
||||||
Assertions.assertEquals("1.33", sut.to2Decimal(1.3333).replace(",", "."))
|
assertThat(sut.to2Decimal(1.3333).replace(",", ".")).isEqualTo("1.33")
|
||||||
Assertions.assertEquals("1.33U", sut.to2Decimal(1.3333, "U").replace(",", "."))
|
assertThat(sut.to2Decimal(1.3333, "U").replace(",", ".")).isEqualTo("1.33U")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun to3DecimalTest() {
|
@Test fun to3DecimalTest() {
|
||||||
Assertions.assertEquals("1.333", sut.to3Decimal(1.3333).replace(",", "."))
|
assertThat(sut.to3Decimal(1.3333).replace(",", ".")).isEqualTo("1.333")
|
||||||
Assertions.assertEquals("1.333U", sut.to3Decimal(1.3333, "U").replace(",", "."))
|
assertThat(sut.to3Decimal(1.3333, "U").replace(",", ".")).isEqualTo("1.333U")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -114,4 +114,5 @@
|
||||||
<string name="loop_smb_set_by_pump_label">SMB défini par la pompe</string>
|
<string name="loop_smb_set_by_pump_label">SMB défini par la pompe</string>
|
||||||
<string name="loop_open_mode_min_change">Changement minimum [%]</string>
|
<string name="loop_open_mode_min_change">Changement minimum [%]</string>
|
||||||
<string name="loop_open_mode_min_change_summary" formatted="false">Le fonctionnement de la Boucle demandera une confirmation uniquement si le changement est supérieur à cette valeur en %. Par défaut, la valeur est 20%</string>
|
<string name="loop_open_mode_min_change_summary" formatted="false">Le fonctionnement de la Boucle demandera une confirmation uniquement si le changement est supérieur à cette valeur en %. Par défaut, la valeur est 20%</string>
|
||||||
|
<string name="fallback_smb_no_tdd">Revenir à SMB. Pas assez de données DTQ.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -68,8 +68,8 @@
|
||||||
<string name="configbuilder_sync">Sincronización</string>
|
<string name="configbuilder_sync">Sincronización</string>
|
||||||
<string name="configbuilder_sync_description">Subida de datos y sincronización de plugins</string>
|
<string name="configbuilder_sync_description">Subida de datos y sincronización de plugins</string>
|
||||||
<string name="configbuilder_constraints_description">¿Qué restricciones se aplican?</string>
|
<string name="configbuilder_constraints_description">¿Qué restricciones se aplican?</string>
|
||||||
<string name="configbuilder_loop">Lazo</string>
|
<string name="configbuilder_loop">Bucle</string>
|
||||||
<string name="configbuilder_loop_description">Usa esto para habilitar la integración de lazo de AAPS</string>
|
<string name="configbuilder_loop_description">Usa esto para habilitar la integración de bucle de AAPS.</string>
|
||||||
<string name="configbuilder_insulin_description">¿Qué tipo de insulina estás utilizando?</string>
|
<string name="configbuilder_insulin_description">¿Qué tipo de insulina estás utilizando?</string>
|
||||||
<string name="configbuilder_bgsource">Origen de Glucosa</string>
|
<string name="configbuilder_bgsource">Origen de Glucosa</string>
|
||||||
<string name="configbuilder_bgsource_description">¿Desde dónde debería obtener AAPS los datos?</string>
|
<string name="configbuilder_bgsource_description">¿Desde dónde debería obtener AAPS los datos?</string>
|
||||||
|
|
|
@ -158,4 +158,14 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S
|
||||||
<!-- Permissions -->
|
<!-- Permissions -->
|
||||||
<string name="alert_dialog_storage_permission_text">Veuillez redémarrer votre téléphone ou redémarrer AAPS à partir des Paramètres du système\nsinon AAPS ne sera pas connecté aux journaux (important pour suivre et vérifier que les algorithmes fonctionnent correctement)!</string>
|
<string name="alert_dialog_storage_permission_text">Veuillez redémarrer votre téléphone ou redémarrer AAPS à partir des Paramètres du système\nsinon AAPS ne sera pas connecté aux journaux (important pour suivre et vérifier que les algorithmes fonctionnent correctement)!</string>
|
||||||
<!-- Maintenance -->
|
<!-- Maintenance -->
|
||||||
|
<string name="metadata_label_format">Format de fichier</string>
|
||||||
|
<string name="metadata_label_created_at">Créé le</string>
|
||||||
|
<string name="metadata_label_aaps_version">Version d\'AAPS</string>
|
||||||
|
<string name="metadata_label_aaps_flavour">Version de construction</string>
|
||||||
|
<string name="metadata_label_device_name">Export du nom du patient de l\'appareil</string>
|
||||||
|
<string name="metadata_label_device_model">Export du modèle de l\'appareil</string>
|
||||||
|
<string name="metadata_label_encryption">Cryptage du fichier</string>
|
||||||
|
<string name="metadata_format_new">Nouveau format chiffré</string>
|
||||||
|
<string name="metadata_format_debug">Nouveau format de débogage (non crypté)</string>
|
||||||
|
<string name="metadata_format_other">Format d\'export inconnu</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -157,4 +157,14 @@
|
||||||
<!-- Permissions -->
|
<!-- Permissions -->
|
||||||
<string name="alert_dialog_storage_permission_text">Herstart je telefoon of herstart AndroidAPS vanuit de systeem instellingen a. u. b. \nanders zal AndroidAPS geen log mogelijkheid hebben (Dit is belangrijk om te controleren of de algoritmes correct werken)!</string>
|
<string name="alert_dialog_storage_permission_text">Herstart je telefoon of herstart AndroidAPS vanuit de systeem instellingen a. u. b. \nanders zal AndroidAPS geen log mogelijkheid hebben (Dit is belangrijk om te controleren of de algoritmes correct werken)!</string>
|
||||||
<!-- Maintenance -->
|
<!-- Maintenance -->
|
||||||
|
<string name="metadata_label_format">Bestandsformaat</string>
|
||||||
|
<string name="metadata_label_created_at">Gemaakt op</string>
|
||||||
|
<string name="metadata_label_aaps_version">AAPS versie</string>
|
||||||
|
<string name="metadata_label_aaps_flavour">Build variant</string>
|
||||||
|
<string name="metadata_label_device_name">Patiëntnaam van exporterend apparaat</string>
|
||||||
|
<string name="metadata_label_device_model">Modelnaam/nr van exporterend apparaat</string>
|
||||||
|
<string name="metadata_label_encryption">Bestandsversleuteling</string>
|
||||||
|
<string name="metadata_format_new">Nieuwe versleutelde indeling</string>
|
||||||
|
<string name="metadata_format_debug">Nieuwe debug indeling (onversleuteld)</string>
|
||||||
|
<string name="metadata_format_other">Onbekende export indeling</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -157,4 +157,14 @@
|
||||||
<!-- Permissions -->
|
<!-- Permissions -->
|
||||||
<string name="alert_dialog_storage_permission_text">Vennligst start mobilen på nytt eller restart AAPS fra Innstillinger \nellers vil ikke AAPS ha aktivert loggføring (viktig for å spore og kontrollere at algoritmene fungerer riktig)!</string>
|
<string name="alert_dialog_storage_permission_text">Vennligst start mobilen på nytt eller restart AAPS fra Innstillinger \nellers vil ikke AAPS ha aktivert loggføring (viktig for å spore og kontrollere at algoritmene fungerer riktig)!</string>
|
||||||
<!-- Maintenance -->
|
<!-- Maintenance -->
|
||||||
|
<string name="metadata_label_format">Filformat</string>
|
||||||
|
<string name="metadata_label_created_at">Opprettet den</string>
|
||||||
|
<string name="metadata_label_aaps_version">AAPS versjon</string>
|
||||||
|
<string name="metadata_label_aaps_flavour">Byggvariant</string>
|
||||||
|
<string name="metadata_label_device_name">Exporterer enhetens pasientnavn</string>
|
||||||
|
<string name="metadata_label_device_model">Eksporterer enhetsmodell</string>
|
||||||
|
<string name="metadata_label_encryption">Filkryptering</string>
|
||||||
|
<string name="metadata_format_new">Nytt krypteringsformat</string>
|
||||||
|
<string name="metadata_format_debug">Nytt feilsøkingsformat (ukryptert)</string>
|
||||||
|
<string name="metadata_format_other">Ukjent eksportformat</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<string name="dia_profile">Debes establecer el valor de DAI en tu perfil.</string>
|
<string name="dia_profile">Debes establecer el valor de DAI en tu perfil.</string>
|
||||||
<string name="dia_minimumis5h">El valor mínimo permitido es de 5 horas.</string>
|
<string name="dia_minimumis5h">El valor mínimo permitido es de 5 horas.</string>
|
||||||
<string name="dia_hint1">https://wiki.aaps.app/en/latest/Configuration/Config-Builder.html#insulin</string>
|
<string name="dia_hint1">https://wiki.aaps.app/en/latest/Configuration/Config-Builder.html#insulin</string>
|
||||||
<string name="dia_meaningisequaltodiapump">Si usted está satisfecho de que el valor para DIA que utilizó en su bomba antes de que AAPS funcionara bien, no hay necesidad de cambiar esto cuando comience a hacer bucle.</string>
|
<string name="dia_meaningisequaltodiapump">Si usted está satisfecho de que el valor para DIA que utilizó en su bomba antes de que AAPS funcionara bien, no hay necesidad de cambiar esto cuando comience usar el bucle cerrado.</string>
|
||||||
<string name="dia_valuemustbedetermined">Deberás determinar por ti mismo el valor apropiado para DAI.</string>
|
<string name="dia_valuemustbedetermined">Deberás determinar por ti mismo el valor apropiado para DAI.</string>
|
||||||
<string name="hypott_label">Objetivo temporal ante Hipoglucemia</string>
|
<string name="hypott_label">Objetivo temporal ante Hipoglucemia</string>
|
||||||
<string name="hypott_whenhypott">¿Cuál es la razón principal para establecer un objetivo temporal por hipoglucemia?</string>
|
<string name="hypott_whenhypott">¿Cuál es la razón principal para establecer un objetivo temporal por hipoglucemia?</string>
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<!-- Pump History -->
|
<!-- Pump History -->
|
||||||
<string name="pump_history_type">Tipo:</string>
|
<string name="pump_history_type">Tipo:</string>
|
||||||
<!-- PumpDeviceState -->
|
<!-- PumpDeviceState -->
|
||||||
<string name="pump_status_never_contacted">Nunca contactado</string>
|
<string name="pump_status_never_contacted">Nunca conectado</string>
|
||||||
<string name="pump_status_sleeping">En reposo</string>
|
<string name="pump_status_sleeping">En reposo</string>
|
||||||
<string name="pump_status_waking_up">Iniciando</string>
|
<string name="pump_status_waking_up">Iniciando</string>
|
||||||
<string name="pump_status_active">Activo</string>
|
<string name="pump_status_active">Activo</string>
|
||||||
|
|
|
@ -65,6 +65,14 @@
|
||||||
<!-- Pump History -->
|
<!-- Pump History -->
|
||||||
<string name="pump_history_type">Type :</string>
|
<string name="pump_history_type">Type :</string>
|
||||||
<!-- PumpDeviceState -->
|
<!-- PumpDeviceState -->
|
||||||
|
<string name="pump_status_never_contacted">Jamais contacté</string>
|
||||||
|
<string name="pump_status_sleeping">En veille</string>
|
||||||
|
<string name="pump_status_waking_up">Réveil en cours</string>
|
||||||
|
<string name="pump_status_active">Actif</string>
|
||||||
|
<string name="pump_status_error_comm">Erreur de communication</string>
|
||||||
|
<string name="pump_status_timeout_comm">Délai de communication dépassé</string>
|
||||||
|
<string name="pump_status_pump_unreachable">Pompe hors de portée</string>
|
||||||
|
<string name="pump_status_invalid_config">Configuration invalide</string>
|
||||||
<plurals name="duration_days">
|
<plurals name="duration_days">
|
||||||
<item quantity="one">%1$d jour</item>
|
<item quantity="one">%1$d jour</item>
|
||||||
<item quantity="other">%1$d jours</item>
|
<item quantity="other">%1$d jours</item>
|
||||||
|
|
|
@ -65,6 +65,14 @@
|
||||||
<!-- Pump History -->
|
<!-- Pump History -->
|
||||||
<string name="pump_history_type">Type:</string>
|
<string name="pump_history_type">Type:</string>
|
||||||
<!-- PumpDeviceState -->
|
<!-- PumpDeviceState -->
|
||||||
|
<string name="pump_status_never_contacted">Nooit verbonden</string>
|
||||||
|
<string name="pump_status_sleeping">Slapend</string>
|
||||||
|
<string name="pump_status_waking_up">Actief worden</string>
|
||||||
|
<string name="pump_status_active">Actief</string>
|
||||||
|
<string name="pump_status_error_comm">Communicatiefout</string>
|
||||||
|
<string name="pump_status_timeout_comm">Time-out bij communicatie</string>
|
||||||
|
<string name="pump_status_pump_unreachable">Pomp niet bereikbaar</string>
|
||||||
|
<string name="pump_status_invalid_config">Ongeldige configuratie</string>
|
||||||
<plurals name="duration_days">
|
<plurals name="duration_days">
|
||||||
<item quantity="one">%1$d dag</item>
|
<item quantity="one">%1$d dag</item>
|
||||||
<item quantity="other">%1$d dagen</item>
|
<item quantity="other">%1$d dagen</item>
|
||||||
|
|
|
@ -65,6 +65,14 @@
|
||||||
<!-- Pump History -->
|
<!-- Pump History -->
|
||||||
<string name="pump_history_type">Type:</string>
|
<string name="pump_history_type">Type:</string>
|
||||||
<!-- PumpDeviceState -->
|
<!-- PumpDeviceState -->
|
||||||
|
<string name="pump_status_never_contacted">Aldri tilkoblet</string>
|
||||||
|
<string name="pump_status_sleeping">Hvilemodus</string>
|
||||||
|
<string name="pump_status_waking_up">Våkner opp</string>
|
||||||
|
<string name="pump_status_active">Aktiv</string>
|
||||||
|
<string name="pump_status_error_comm">Feil med kommunikasjon</string>
|
||||||
|
<string name="pump_status_timeout_comm">Tidsavbrudd ved kommunikasjon</string>
|
||||||
|
<string name="pump_status_pump_unreachable">Pumpe er utilgjengelig</string>
|
||||||
|
<string name="pump_status_invalid_config">Ugyldig konfigurasjon</string>
|
||||||
<plurals name="duration_days">
|
<plurals name="duration_days">
|
||||||
<item quantity="one">%1$d dag</item>
|
<item quantity="one">%1$d dag</item>
|
||||||
<item quantity="other">%1$d dager</item>
|
<item quantity="other">%1$d dager</item>
|
||||||
|
|
|
@ -65,6 +65,14 @@
|
||||||
<!-- Pump History -->
|
<!-- Pump History -->
|
||||||
<string name="pump_history_type">Typ:</string>
|
<string name="pump_history_type">Typ:</string>
|
||||||
<!-- PumpDeviceState -->
|
<!-- PumpDeviceState -->
|
||||||
|
<string name="pump_status_never_contacted">Nikdy nepripojené</string>
|
||||||
|
<string name="pump_status_sleeping">Spiaca</string>
|
||||||
|
<string name="pump_status_waking_up">Prebúdzanie</string>
|
||||||
|
<string name="pump_status_active">Aktívna</string>
|
||||||
|
<string name="pump_status_error_comm">Chyba komunikácie</string>
|
||||||
|
<string name="pump_status_timeout_comm">Uplynul časový limit komunikácie</string>
|
||||||
|
<string name="pump_status_pump_unreachable">Pumpa nedostupná</string>
|
||||||
|
<string name="pump_status_invalid_config">Neplatná konfigurácia</string>
|
||||||
<plurals name="duration_days">
|
<plurals name="duration_days">
|
||||||
<item quantity="one">%1$d deň</item>
|
<item quantity="one">%1$d deň</item>
|
||||||
<item quantity="few">%1$d dní</item>
|
<item quantity="few">%1$d dní</item>
|
||||||
|
|
|
@ -9,4 +9,5 @@
|
||||||
<string name="virtual_pump_label">POMPE VIRTUELLE</string>
|
<string name="virtual_pump_label">POMPE VIRTUELLE</string>
|
||||||
<string name="virtualpump_settings">Paramètres pompe virtuelle</string>
|
<string name="virtualpump_settings">Paramètres pompe virtuelle</string>
|
||||||
<!-- PumpType-->
|
<!-- PumpType-->
|
||||||
|
<string name="def_extended_note">* Uniquement les valeurs unitaires sont acceptées. Les plages pour les basal/bolus ne sont pas supportées par les pompes virtuelles.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -9,4 +9,5 @@
|
||||||
<string name="virtual_pump_label">VIRTUELE POMP</string>
|
<string name="virtual_pump_label">VIRTUELE POMP</string>
|
||||||
<string name="virtualpump_settings">Virtuele pomp instellingen</string>
|
<string name="virtualpump_settings">Virtuele pomp instellingen</string>
|
||||||
<!-- PumpType-->
|
<!-- PumpType-->
|
||||||
|
<string name="def_extended_note">* Alleen absolute waardes (geen van-tot bereik) worden ondersteund voor basaal / bolus in virtuele pomp.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -9,4 +9,5 @@
|
||||||
<string name="virtual_pump_label">VIRTUELL PUMPE</string>
|
<string name="virtual_pump_label">VIRTUELL PUMPE</string>
|
||||||
<string name="virtualpump_settings">Innstillinger for virtuell pumpe</string>
|
<string name="virtualpump_settings">Innstillinger for virtuell pumpe</string>
|
||||||
<!-- PumpType-->
|
<!-- PumpType-->
|
||||||
|
<string name="def_extended_note">* Bare konkrete verdier støttes som granularitet for basal/bolus i virtuell pumpe, ingen verdiområder.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.ui.defaultProfile
|
package info.nightscout.ui.defaultProfile
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.core.profile.ProfileSealed
|
import info.nightscout.core.profile.ProfileSealed
|
||||||
import info.nightscout.interfaces.GlucoseUnit
|
import info.nightscout.interfaces.GlucoseUnit
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DefaultProfileTest : TestBaseWithProfile() {
|
class DefaultProfileTest : TestBaseWithProfile() {
|
||||||
|
@ -12,18 +12,18 @@ class DefaultProfileTest : TestBaseWithProfile() {
|
||||||
fun profile() {
|
fun profile() {
|
||||||
val dp = DefaultProfile(dateUtil, profileUtil).profile(5, 5.1 / 0.3, 0.0, GlucoseUnit.MMOL)
|
val dp = DefaultProfile(dateUtil, profileUtil).profile(5, 5.1 / 0.3, 0.0, GlucoseUnit.MMOL)
|
||||||
var p = ProfileSealed.Pure(dp!!)
|
var p = ProfileSealed.Pure(dp!!)
|
||||||
Assertions.assertEquals(0.150, p.getBasalTimeFromMidnight(0), 0.001)
|
assertThat(p.getBasalTimeFromMidnight(0)).isWithin(0.001).of(0.150)
|
||||||
Assertions.assertEquals(15.0, p.getIcTimeFromMidnight(0), 0.001)
|
assertThat(p.getIcTimeFromMidnight(0)).isWithin(0.001).of(15.0)
|
||||||
Assertions.assertEquals(11.8, p.getIsfTimeFromMidnight(0), 0.001)
|
assertThat(p.getIsfTimeFromMidnight(0)).isWithin(0.001).of(11.8)
|
||||||
|
|
||||||
p = ProfileSealed.Pure(DefaultProfile(dateUtil, profileUtil).profile(7, 10.0 / 0.4, 0.0, GlucoseUnit.MMOL)!!)
|
p = ProfileSealed.Pure(DefaultProfile(dateUtil, profileUtil).profile(7, 10.0 / 0.4, 0.0, GlucoseUnit.MMOL)!!)
|
||||||
Assertions.assertEquals(0.350, p.getBasalTimeFromMidnight(0), 0.001)
|
assertThat(p.getBasalTimeFromMidnight(0)).isWithin(0.001).of(0.350)
|
||||||
Assertions.assertEquals(15.0, p.getIcTimeFromMidnight(0), 0.001)
|
assertThat(p.getIcTimeFromMidnight(0)).isWithin(0.001).of(15.0)
|
||||||
Assertions.assertEquals(6.8, p.getIsfTimeFromMidnight(0), 0.001)
|
assertThat(p.getIsfTimeFromMidnight(0)).isWithin(0.001).of(6.8)
|
||||||
|
|
||||||
p = ProfileSealed.Pure(DefaultProfile(dateUtil, profileUtil).profile(12, 25.0 / 0.5, 0.0, GlucoseUnit.MMOL)!!)
|
p = ProfileSealed.Pure(DefaultProfile(dateUtil, profileUtil).profile(12, 25.0 / 0.5, 0.0, GlucoseUnit.MMOL)!!)
|
||||||
Assertions.assertEquals(0.80, p.getBasalTimeFromMidnight(0), 0.001)
|
assertThat(p.getBasalTimeFromMidnight(0)).isWithin(0.001).of(0.80)
|
||||||
Assertions.assertEquals(10.0, p.getIcTimeFromMidnight(0), 0.001)
|
assertThat(p.getIcTimeFromMidnight(0)).isWithin(0.001).of(10.0)
|
||||||
Assertions.assertEquals(2.2, p.getIsfTimeFromMidnight(0), 0.001)
|
assertThat(p.getIsfTimeFromMidnight(0)).isWithin(0.001).of(2.2)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue