Merge pull request #2756 from ryanhaining/rewrite_assert_true
Rewrite test files that have assertTrues instead of matchers
This commit is contained in:
commit
307b114947
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.plugins.constraints
|
package info.nightscout.plugins.constraints
|
||||||
|
|
||||||
|
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.androidaps.danar.DanaRPlugin
|
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||||
|
@ -43,7 +44,6 @@ import info.nightscout.pump.danars.DanaRSPlugin
|
||||||
import info.nightscout.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import info.nightscout.source.GlimpPlugin
|
import info.nightscout.source.GlimpPlugin
|
||||||
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
|
||||||
|
@ -237,9 +237,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
comboPlugin.setPluginEnabled(PluginType.PUMP, true)
|
comboPlugin.setPluginEnabled(PluginType.PUMP, true)
|
||||||
comboPlugin.setValidBasalRateProfileSelectedOnPump(false)
|
comboPlugin.setValidBasalRateProfileSelectedOnPump(false)
|
||||||
val c = constraintChecker.isLoopInvocationAllowed()
|
val c = constraintChecker.isLoopInvocationAllowed()
|
||||||
Assertions.assertEquals(true, c.reasonList.size == 2) // Combo & Objectives
|
assertThat(c.reasonList).hasSize(2) // Combo & Objectives
|
||||||
Assertions.assertEquals(true, c.mostLimitedReasonList.size == 2) // Combo & Objectives
|
assertThat(c.mostLimitedReasonList).hasSize(2) // Combo & Objectives
|
||||||
Assertions.assertEquals(java.lang.Boolean.FALSE, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safety & Objectives
|
// Safety & Objectives
|
||||||
|
@ -250,13 +250,13 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0
|
objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0
|
||||||
var c: Constraint<Boolean> = constraintChecker.isClosedLoopAllowed()
|
var c: Constraint<Boolean> = constraintChecker.isClosedLoopAllowed()
|
||||||
aapsLogger.debug("Reason list: " + c.reasonList.toString())
|
aapsLogger.debug("Reason list: " + c.reasonList.toString())
|
||||||
// Assertions.assertTrue(c.reasonList[0].toString().contains("Closed loop is disabled")) // Safety & Objectives
|
// assertThat(c.reasonList[0].toString()).contains("Closed loop is disabled") // Safety & Objectives
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
|
||||||
c = constraintChecker.isClosedLoopAllowed()
|
c = constraintChecker.isClosedLoopAllowed()
|
||||||
Assertions.assertTrue(c.reasonList[0].contains("Closed loop mode disabled in preferences")) // Safety & Objectives
|
assertThat(c.reasonList[0]).contains("Closed loop mode disabled in preferences") // Safety & Objectives
|
||||||
// Assertions.assertEquals(3, c.reasonList.size) // 2x Safety & Objectives
|
// assertThat(c.reasonList).hasThat(3) // 2x Safety & Objectives
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safety & Objectives
|
// Safety & Objectives
|
||||||
|
@ -266,9 +266,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
objectivesPlugin.objectives[Objectives.AUTOSENS_OBJECTIVE].startedOn = 0
|
objectivesPlugin.objectives[Objectives.AUTOSENS_OBJECTIVE].startedOn = 0
|
||||||
`when`(sp.getBoolean(info.nightscout.plugins.aps.R.string.key_openapsama_use_autosens, false)).thenReturn(false)
|
`when`(sp.getBoolean(info.nightscout.plugins.aps.R.string.key_openapsama_use_autosens, false)).thenReturn(false)
|
||||||
val c = constraintChecker.isAutosensModeEnabled()
|
val c = constraintChecker.isAutosensModeEnabled()
|
||||||
Assertions.assertEquals(true, c.reasonList.size == 2) // Safety & Objectives
|
assertThat(c.reasonList).hasSize(2) // Safety & Objectives
|
||||||
Assertions.assertEquals(true, c.mostLimitedReasonList.size == 2) // Safety & Objectives
|
assertThat(c.mostLimitedReasonList).hasSize(2) // Safety & Objectives
|
||||||
Assertions.assertEquals(java.lang.Boolean.FALSE, c.value())
|
assertThat( c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safety
|
// Safety
|
||||||
|
@ -276,9 +276,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
fun isAdvancedFilteringEnabledTest() {
|
fun isAdvancedFilteringEnabledTest() {
|
||||||
`when`(activePlugin.activeBgSource).thenReturn(glimpPlugin)
|
`when`(activePlugin.activeBgSource).thenReturn(glimpPlugin)
|
||||||
val c = constraintChecker.isAdvancedFilteringEnabled()
|
val c = constraintChecker.isAdvancedFilteringEnabled()
|
||||||
Assertions.assertEquals(true, c.reasonList.size == 1) // Safety
|
assertThat(c.reasonList).hasSize(1) // Safety
|
||||||
Assertions.assertEquals(true, c.mostLimitedReasonList.size == 1) // Safety
|
assertThat(c.mostLimitedReasonList).hasSize(1) // Safety
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat( c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SMB should limit
|
// SMB should limit
|
||||||
|
@ -286,7 +286,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
fun isSuperBolusEnabledTest() {
|
fun isSuperBolusEnabledTest() {
|
||||||
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
|
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
|
||||||
val c = constraintChecker.isSuperBolusEnabled()
|
val c = constraintChecker.isSuperBolusEnabled()
|
||||||
Assertions.assertEquals(java.lang.Boolean.FALSE, c.value()) // SMB should limit
|
assertThat( c.value()).isFalse() // SMB should limit
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safety & Objectives
|
// Safety & Objectives
|
||||||
|
@ -298,9 +298,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
|
||||||
// `when`(constraintChecker.isClosedLoopAllowed()).thenReturn(Constraint(true))
|
// `when`(constraintChecker.isClosedLoopAllowed()).thenReturn(Constraint(true))
|
||||||
val c = constraintChecker.isSMBModeEnabled()
|
val c = constraintChecker.isSMBModeEnabled()
|
||||||
Assertions.assertEquals(true, c.reasonList.size == 3) // 2x Safety & Objectives
|
assertThat(c.reasonList).hasSize(3) // 2x Safety & Objectives
|
||||||
Assertions.assertEquals(true, c.mostLimitedReasonList.size == 3) // 2x Safety & Objectives
|
assertThat(c.mostLimitedReasonList).hasSize(3) // 2x Safety & Objectives
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat( c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// applyBasalConstraints tests
|
// applyBasalConstraints tests
|
||||||
|
@ -326,9 +326,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
val d = constraintChecker.getMaxBasalAllowed(validProfile)
|
val d = constraintChecker.getMaxBasalAllowed(validProfile)
|
||||||
Assertions.assertEquals(0.8, d.value(), 0.01)
|
assertThat( d.value()).isWithin( 0.01).of(0.8)
|
||||||
Assertions.assertEquals(3, d.reasonList.size)
|
assertThat(d.reasonList).hasSize(3)
|
||||||
Assertions.assertEquals("DanaR: Limiting max basal rate to 0.80 U/h because of pump limit", d.getMostLimitedReasons(aapsLogger))
|
assertThat(d.getMostLimitedReasons(aapsLogger)).isEqualTo("DanaR: Limiting max basal rate to 0.80 U/h because of pump limit")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -353,9 +353,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
val i = constraintChecker.getMaxBasalPercentAllowed(validProfile)
|
val i = constraintChecker.getMaxBasalPercentAllowed(validProfile)
|
||||||
Assertions.assertEquals(200, i.value())
|
assertThat(i.value()).isEqualTo(200)
|
||||||
Assertions.assertEquals(6, i.reasonList.size)
|
assertThat(i.reasonList).hasSize(6)
|
||||||
Assertions.assertEquals("Safety: Limiting max percent rate to 200% because of pump limit", i.getMostLimitedReasons(aapsLogger))
|
assertThat(i.getMostLimitedReasons(aapsLogger)).isEqualTo("Safety: Limiting max percent rate to 200% because of pump limit")
|
||||||
}
|
}
|
||||||
|
|
||||||
// applyBolusConstraints tests
|
// applyBolusConstraints tests
|
||||||
|
@ -380,9 +380,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
val d = constraintChecker.getMaxBolusAllowed()
|
val d = constraintChecker.getMaxBolusAllowed()
|
||||||
Assertions.assertEquals(3.0, d.value(), 0.01)
|
assertThat( d.value()).isWithin( 0.01).of(3.0)
|
||||||
Assertions.assertEquals(4, d.reasonList.size) // 2x Safety & RS & R
|
assertThat(d.reasonList).hasSize(4) // 2x Safety & RS & R
|
||||||
Assertions.assertEquals("Safety: Limiting bolus to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger))
|
assertThat(d.getMostLimitedReasons(aapsLogger)).isEqualTo("Safety: Limiting bolus to 3.0 U because of max value in preferences")
|
||||||
}
|
}
|
||||||
|
|
||||||
// applyCarbsConstraints tests
|
// applyCarbsConstraints tests
|
||||||
|
@ -393,9 +393,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
val i = constraintChecker.getMaxCarbsAllowed()
|
val i = constraintChecker.getMaxCarbsAllowed()
|
||||||
Assertions.assertEquals(48, i.value())
|
assertThat(i.value()).isEqualTo(48)
|
||||||
Assertions.assertEquals(true, i.reasonList.size == 1)
|
assertThat(i.reasonList).hasSize(1)
|
||||||
Assertions.assertEquals("Safety: Limiting carbs to 48 g because of max value in preferences", i.getMostLimitedReasons(aapsLogger))
|
assertThat(i.getMostLimitedReasons(aapsLogger)).isEqualTo("Safety: Limiting carbs to 48 g because of max value in preferences")
|
||||||
}
|
}
|
||||||
|
|
||||||
// applyMaxIOBConstraints tests
|
// applyMaxIOBConstraints tests
|
||||||
|
@ -410,9 +410,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
val d = constraintChecker.getMaxIOBAllowed()
|
val d = constraintChecker.getMaxIOBAllowed()
|
||||||
Assertions.assertEquals(1.5, d.value(), 0.01)
|
assertThat( d.value()).isWithin( 0.01).of(1.5)
|
||||||
Assertions.assertEquals(2, d.reasonList.size)
|
assertThat(d.reasonList).hasSize(2)
|
||||||
Assertions.assertEquals("OpenAPSAMA: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger))
|
assertThat(d.getMostLimitedReasons(aapsLogger)).isEqualTo("OpenAPSAMA: Limiting IOB to 1.5 U because of max value in preferences")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -426,8 +426,8 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
val d = constraintChecker.getMaxIOBAllowed()
|
val d = constraintChecker.getMaxIOBAllowed()
|
||||||
Assertions.assertEquals(3.0, d.value(), 0.01)
|
assertThat( d.value()).isWithin( 0.01).of(3.0)
|
||||||
Assertions.assertEquals(2, d.reasonList.size)
|
assertThat(d.reasonList).hasSize(2)
|
||||||
Assertions.assertEquals("OpenAPSSMB: Limiting IOB to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger))
|
assertThat(d.getMostLimitedReasons(aapsLogger)).isEqualTo("OpenAPSSMB: Limiting IOB to 3.0 U because of max value in preferences")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.plugins.safety
|
package info.nightscout.plugins.safety
|
||||||
|
|
||||||
|
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.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
|
@ -21,7 +22,6 @@ import info.nightscout.plugins.constraints.safety.SafetyPlugin
|
||||||
import info.nightscout.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import info.nightscout.source.GlimpPlugin
|
import info.nightscout.source.GlimpPlugin
|
||||||
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
|
||||||
|
@ -88,8 +88,8 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
pumpDescription.isTempBasalCapable = false
|
pumpDescription.isTempBasalCapable = false
|
||||||
var c = Constraint(true)
|
var c = Constraint(true)
|
||||||
c = safetyPlugin.isLoopInvocationAllowed(c)
|
c = safetyPlugin.isLoopInvocationAllowed(c)
|
||||||
Assertions.assertEquals("Safety: Pump is not temp basal capable", c.getReasons(aapsLogger))
|
assertThat(c.getReasons(aapsLogger)).isEqualTo("Safety: Pump is not temp basal capable")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -98,8 +98,8 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
`when`(config.isEngineeringModeOrRelease()).thenReturn(false)
|
`when`(config.isEngineeringModeOrRelease()).thenReturn(false)
|
||||||
var c = Constraint(true)
|
var c = Constraint(true)
|
||||||
c = safetyPlugin.isClosedLoopAllowed(c)
|
c = safetyPlugin.isClosedLoopAllowed(c)
|
||||||
Assertions.assertTrue(c.getReasons(aapsLogger).contains("Running dev version. Closed loop is disabled."))
|
assertThat(c.getReasons(aapsLogger)).contains("Running dev version. Closed loop is disabled.")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -107,8 +107,8 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
|
||||||
var c = Constraint(true)
|
var c = Constraint(true)
|
||||||
c = safetyPlugin.isClosedLoopAllowed(c)
|
c = safetyPlugin.isClosedLoopAllowed(c)
|
||||||
Assertions.assertTrue(c.getReasons(aapsLogger).contains("Closed loop mode disabled in preferences"))
|
assertThat(c.getReasons(aapsLogger)).contains("Closed loop mode disabled in preferences")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -117,8 +117,8 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
`when`(constraintChecker.isClosedLoopAllowed(anyObject())).thenReturn(Constraint(true))
|
`when`(constraintChecker.isClosedLoopAllowed(anyObject())).thenReturn(Constraint(true))
|
||||||
var c = Constraint(true)
|
var c = Constraint(true)
|
||||||
c = openAPSSMBPlugin.isSMBModeEnabled(c)
|
c = openAPSSMBPlugin.isSMBModeEnabled(c)
|
||||||
Assertions.assertTrue(c.getReasons(aapsLogger).contains("SMB disabled in preferences"))
|
assertThat(c.getReasons(aapsLogger)).contains("SMB disabled in preferences")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -127,8 +127,8 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
`when`(constraintChecker.isClosedLoopAllowed(anyObject())).thenReturn(Constraint(false))
|
`when`(constraintChecker.isClosedLoopAllowed(anyObject())).thenReturn(Constraint(false))
|
||||||
var c = Constraint(true)
|
var c = Constraint(true)
|
||||||
c = safetyPlugin.isSMBModeEnabled(c)
|
c = safetyPlugin.isSMBModeEnabled(c)
|
||||||
Assertions.assertTrue(c.getReasons(aapsLogger).contains("SMB not allowed in open loop mode"))
|
assertThat(c.getReasons(aapsLogger)).contains("SMB not allowed in open loop mode")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -136,8 +136,8 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
`when`(activePlugin.activeBgSource).thenReturn(glimpPlugin)
|
`when`(activePlugin.activeBgSource).thenReturn(glimpPlugin)
|
||||||
var c = Constraint(true)
|
var c = Constraint(true)
|
||||||
c = safetyPlugin.isAdvancedFilteringEnabled(c)
|
c = safetyPlugin.isAdvancedFilteringEnabled(c)
|
||||||
Assertions.assertEquals("Safety: SMB always and after carbs disabled because active BG source doesn\\'t support advanced filtering", c.getReasons(aapsLogger))
|
assertThat(c.getReasons(aapsLogger)).isEqualTo("Safety: SMB always and after carbs disabled because active BG source doesn\\'t support advanced filtering")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -148,13 +148,12 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
||||||
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
val c = Constraint(Constants.REALLYHIGHBASALRATE)
|
||||||
safetyPlugin.applyBasalConstraints(c, validProfile)
|
safetyPlugin.applyBasalConstraints(c, validProfile)
|
||||||
Assertions.assertEquals(2.0, c.value(), 0.01)
|
assertThat(c.value()).isWithin(0.01).of(2.0)
|
||||||
Assertions.assertEquals(
|
assertThat(c.getReasons(aapsLogger)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
Safety: Limiting max basal rate to 2.00 U/h because of hard limit
|
Safety: Limiting max basal rate to 2.00 U/h because of hard limit
|
||||||
""".trimIndent(), c.getReasons(aapsLogger)
|
""".trimIndent())
|
||||||
)
|
assertThat(c.getMostLimitedReasons(aapsLogger)).isEqualTo("Safety: Limiting max basal rate to 2.00 U/h because of hard limit")
|
||||||
Assertions.assertEquals("Safety: Limiting max basal rate to 2.00 U/h because of hard limit", c.getMostLimitedReasons(aapsLogger))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -162,8 +161,9 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
||||||
val d = Constraint(-0.5)
|
val d = Constraint(-0.5)
|
||||||
safetyPlugin.applyBasalConstraints(d, validProfile)
|
safetyPlugin.applyBasalConstraints(d, validProfile)
|
||||||
Assertions.assertEquals(0.0, d.value(), 0.01)
|
assertThat(d.value()).isWithin(0.01).of(0.0)
|
||||||
Assertions.assertEquals("Safety: Limiting max basal rate to 0.00 U/h because of it must be positive value", d.getReasons(aapsLogger))
|
assertThat(d.getReasons(aapsLogger)).isEqualTo(
|
||||||
|
"Safety: Limiting max basal rate to 0.00 U/h because of it must be positive value")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -175,16 +175,17 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
||||||
val i = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
val i = Constraint(Constants.REALLYHIGHPERCENTBASALRATE)
|
||||||
safetyPlugin.applyBasalPercentConstraints(i, validProfile)
|
safetyPlugin.applyBasalPercentConstraints(i, validProfile)
|
||||||
Assertions.assertEquals(200, i.value())
|
assertThat(i.value()).isEqualTo(200)
|
||||||
Assertions.assertEquals(
|
assertThat(i.getReasons(aapsLogger)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
Safety: Percent rate 1111111% recalculated to 11111.11 U/h with current basal 1.00 U/h
|
Safety: Percent rate 1111111% recalculated to 11111.11 U/h with current basal 1.00 U/h
|
||||||
Safety: Limiting max basal rate to 2.00 U/h because of hard limit
|
Safety: Limiting max basal rate to 2.00 U/h because of hard limit
|
||||||
Safety: Limiting max percent rate to 200% because of pump limit
|
Safety: Limiting max percent rate to 200% because of pump limit
|
||||||
Safety: Limiting max basal rate to 500.00 U/h because of pump limit
|
Safety: Limiting max basal rate to 500.00 U/h because of pump limit
|
||||||
""".trimIndent(), i.getReasons(aapsLogger)
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
Assertions.assertEquals("Safety: Limiting max percent rate to 200% because of pump limit", i.getMostLimitedReasons(aapsLogger))
|
assertThat(i.getMostLimitedReasons(aapsLogger)).isEqualTo(
|
||||||
|
"Safety: Limiting max percent rate to 200% because of pump limit")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -197,15 +198,14 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
|
||||||
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
|
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
|
||||||
val i = Constraint(Constants.REALLYHIGHBASALRATE)
|
val i = Constraint(Constants.REALLYHIGHBASALRATE)
|
||||||
openAPSSMBPlugin.applyBasalConstraints(i, validProfile)
|
openAPSSMBPlugin.applyBasalConstraints(i, validProfile)
|
||||||
Assertions.assertEquals(1.0, i.value(), 0.01)
|
assertThat(i.value()).isWithin(0.01).of(1.0)
|
||||||
Assertions.assertEquals(
|
assertThat(i.getReasons(aapsLogger)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
OpenAPSSMB: Limiting max basal rate to 1.00 U/h because of max value in preferences
|
OpenAPSSMB: Limiting max basal rate to 1.00 U/h because of max value in preferences
|
||||||
OpenAPSSMB: Limiting max basal rate to 4.00 U/h because of max basal multiplier
|
OpenAPSSMB: Limiting max basal rate to 4.00 U/h because of max basal multiplier
|
||||||
OpenAPSSMB: Limiting max basal rate to 3.00 U/h because of max daily basal multiplier
|
OpenAPSSMB: Limiting max basal rate to 3.00 U/h because of max daily basal multiplier
|
||||||
""".trimIndent(), i.getReasons(aapsLogger)
|
""".trimIndent())
|
||||||
)
|
assertThat(i.getMostLimitedReasons(aapsLogger)).isEqualTo("OpenAPSSMB: Limiting max basal rate to 1.00 U/h because of max value in preferences")
|
||||||
Assertions.assertEquals("OpenAPSSMB: Limiting max basal rate to 1.00 U/h because of max value in preferences", i.getMostLimitedReasons(aapsLogger))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -213,15 +213,14 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
||||||
val i = Constraint(-22)
|
val i = Constraint(-22)
|
||||||
safetyPlugin.applyBasalPercentConstraints(i, validProfile)
|
safetyPlugin.applyBasalPercentConstraints(i, validProfile)
|
||||||
Assertions.assertEquals(0, i.value())
|
assertThat(i.value()).isEqualTo(0)
|
||||||
Assertions.assertEquals(
|
assertThat(i.getReasons(aapsLogger)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
Safety: Percent rate -22% recalculated to -0.22 U/h with current basal 1.00 U/h
|
Safety: Percent rate -22% recalculated to -0.22 U/h with current basal 1.00 U/h
|
||||||
Safety: Limiting max basal rate to 0.00 U/h because of it must be positive value
|
Safety: Limiting max basal rate to 0.00 U/h because of it must be positive value
|
||||||
Safety: Limiting max percent rate to 0% because of pump limit
|
Safety: Limiting max percent rate to 0% because of pump limit
|
||||||
""".trimIndent(), i.getReasons(aapsLogger)
|
""".trimIndent())
|
||||||
)
|
assertThat(i.getMostLimitedReasons(aapsLogger)).isEqualTo("Safety: Limiting max percent rate to 0% because of pump limit")
|
||||||
Assertions.assertEquals("Safety: Limiting max percent rate to 0% because of pump limit", i.getMostLimitedReasons(aapsLogger))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -230,14 +229,13 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
||||||
var d = Constraint(Constants.REALLYHIGHBOLUS)
|
var d = Constraint(Constants.REALLYHIGHBOLUS)
|
||||||
d = safetyPlugin.applyBolusConstraints(d)
|
d = safetyPlugin.applyBolusConstraints(d)
|
||||||
Assertions.assertEquals(3.0, d.value(), 0.01)
|
assertThat(d.value()).isWithin(0.01).of(3.0)
|
||||||
Assertions.assertEquals(
|
assertThat(d.getReasons(aapsLogger)).isEqualTo(
|
||||||
"""
|
"""
|
||||||
Safety: Limiting bolus to 3.0 U because of max value in preferences
|
Safety: Limiting bolus to 3.0 U because of max value in preferences
|
||||||
Safety: Limiting bolus to 5.0 U because of hard limit
|
Safety: Limiting bolus to 5.0 U because of hard limit
|
||||||
""".trimIndent(), d.getReasons(aapsLogger)
|
""".trimIndent())
|
||||||
)
|
assertThat(d.getMostLimitedReasons(aapsLogger)).isEqualTo("Safety: Limiting bolus to 3.0 U because of max value in preferences")
|
||||||
Assertions.assertEquals("Safety: Limiting bolus to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -246,9 +244,9 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child")
|
||||||
var d = Constraint(-22.0)
|
var d = Constraint(-22.0)
|
||||||
d = safetyPlugin.applyBolusConstraints(d)
|
d = safetyPlugin.applyBolusConstraints(d)
|
||||||
Assertions.assertEquals(0.0, d.value(), 0.01)
|
assertThat(d.value()).isWithin(0.01).of(0.0)
|
||||||
Assertions.assertEquals("Safety: Limiting bolus to 0.0 U because of it must be positive value", d.getReasons(aapsLogger))
|
assertThat(d.getReasons(aapsLogger)).isEqualTo("Safety: Limiting bolus to 0.0 U because of it must be positive value")
|
||||||
Assertions.assertEquals("Safety: Limiting bolus to 0.0 U because of it must be positive value", d.getMostLimitedReasons(aapsLogger))
|
assertThat(d.getMostLimitedReasons(aapsLogger)).isEqualTo("Safety: Limiting bolus to 0.0 U because of it must be positive value")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -259,13 +257,13 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
|
||||||
// Negative carbs not allowed
|
// Negative carbs not allowed
|
||||||
var i = Constraint(-22)
|
var i = Constraint(-22)
|
||||||
safetyPlugin.applyCarbsConstraints(i)
|
safetyPlugin.applyCarbsConstraints(i)
|
||||||
Assertions.assertEquals(0, i.value())
|
assertThat(i.value()).isEqualTo(0)
|
||||||
Assertions.assertEquals("Safety: Limiting carbs to 0 g because of it must be positive value", i.getReasons(aapsLogger))
|
assertThat(i.getReasons(aapsLogger)).isEqualTo("Safety: Limiting carbs to 0 g because of it must be positive value")
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
i = safetyPlugin.applyCarbsConstraints(Constraint(Constants.REALLYHIGHCARBS))
|
i = safetyPlugin.applyCarbsConstraints(Constraint(Constants.REALLYHIGHCARBS))
|
||||||
Assertions.assertEquals(48, i.value())
|
assertThat(i.value()).isEqualTo(48)
|
||||||
Assertions.assertEquals("Safety: Limiting carbs to 48 g because of max value in preferences", i.getReasons(aapsLogger))
|
assertThat(i.getReasons(aapsLogger)).isEqualTo("Safety: Limiting carbs to 48 g because of max value in preferences")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -282,22 +280,22 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
var d = Constraint(Constants.REALLYHIGHIOB)
|
var d = Constraint(Constants.REALLYHIGHIOB)
|
||||||
d = safetyPlugin.applyMaxIOBConstraints(d)
|
d = safetyPlugin.applyMaxIOBConstraints(d)
|
||||||
Assertions.assertEquals(HardLimits.MAX_IOB_LGS, d.value(), 0.01)
|
assertThat(d.value()).isWithin(0.01).of(HardLimits.MAX_IOB_LGS)
|
||||||
Assertions.assertEquals("Safety: Limiting IOB to 0.0 U because of Low Glucose Suspend", d.getReasons(aapsLogger))
|
assertThat(d.getReasons(aapsLogger)).isEqualTo("Safety: Limiting IOB to 0.0 U because of Low Glucose Suspend")
|
||||||
Assertions.assertEquals("Safety: Limiting IOB to 0.0 U because of Low Glucose Suspend", d.getMostLimitedReasons(aapsLogger))
|
assertThat(d.getMostLimitedReasons(aapsLogger)).isEqualTo("Safety: Limiting IOB to 0.0 U because of Low Glucose Suspend")
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
d = Constraint(Constants.REALLYHIGHIOB)
|
d = Constraint(Constants.REALLYHIGHIOB)
|
||||||
val a = openAPSAMAPlugin.applyMaxIOBConstraints(d)
|
val a = openAPSAMAPlugin.applyMaxIOBConstraints(d)
|
||||||
Assertions.assertEquals(1.5, a.value(), 0.01)
|
assertThat(a.value()).isWithin(0.01).of(1.5)
|
||||||
Assertions.assertEquals("OpenAPSAMA: Limiting IOB to 1.5 U because of max value in preferences\nOpenAPSAMA: Limiting IOB to 7.0 U because of hard limit", d.getReasons(aapsLogger))
|
assertThat(d.getReasons(aapsLogger)).isEqualTo("OpenAPSAMA: Limiting IOB to 1.5 U because of max value in preferences\nOpenAPSAMA: Limiting IOB to 7.0 U because of hard limit")
|
||||||
Assertions.assertEquals("OpenAPSAMA: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger))
|
assertThat(d.getMostLimitedReasons(aapsLogger)).isEqualTo("OpenAPSAMA: Limiting IOB to 1.5 U because of max value in preferences")
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
d = Constraint(Constants.REALLYHIGHIOB)
|
d = Constraint(Constants.REALLYHIGHIOB)
|
||||||
val s = openAPSSMBPlugin.applyMaxIOBConstraints(d)
|
val s = openAPSSMBPlugin.applyMaxIOBConstraints(d)
|
||||||
Assertions.assertEquals(3.0, s.value(), 0.01)
|
assertThat(s.value()).isWithin(0.01).of(3.0)
|
||||||
Assertions.assertEquals("OpenAPSSMB: Limiting IOB to 3.0 U because of max value in preferences\nOpenAPSSMB: Limiting IOB to 22.0 U because of hard limit", d.getReasons(aapsLogger))
|
assertThat(d.getReasons(aapsLogger)).isEqualTo("OpenAPSSMB: Limiting IOB to 3.0 U because of max value in preferences\nOpenAPSSMB: Limiting IOB to 22.0 U because of hard limit")
|
||||||
Assertions.assertEquals("OpenAPSSMB: Limiting IOB to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger))
|
assertThat(d.getMostLimitedReasons(aapsLogger)).isEqualTo("OpenAPSSMB: Limiting IOB to 3.0 U because of max value in preferences")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.core.data
|
package info.nightscout.core.data
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.interfaces.iob.Iob
|
import info.nightscout.interfaces.iob.Iob
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class IobTest {
|
class IobTest {
|
||||||
|
@ -10,23 +10,23 @@ class IobTest {
|
||||||
val a = Iob().iobContrib(1.0).activityContrib(2.0)
|
val a = Iob().iobContrib(1.0).activityContrib(2.0)
|
||||||
val b = Iob().iobContrib(3.0).activityContrib(4.0)
|
val b = Iob().iobContrib(3.0).activityContrib(4.0)
|
||||||
a.plus(b)
|
a.plus(b)
|
||||||
Assertions.assertEquals(4.0, a.iobContrib, 0.01)
|
assertThat(a.iobContrib).isWithin(0.01).of(4.0)
|
||||||
Assertions.assertEquals(6.0, a.activityContrib, 0.01)
|
assertThat(a.activityContrib).isWithin(0.01).of(6.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun equalTest() {
|
@Test fun equalTest() {
|
||||||
val a1 = Iob().iobContrib(1.0).activityContrib(2.0)
|
val a1 = Iob().iobContrib(1.0).activityContrib(2.0)
|
||||||
val a2 = Iob().iobContrib(1.0).activityContrib(2.0)
|
val a2 = Iob().iobContrib(1.0).activityContrib(2.0)
|
||||||
val b = Iob().iobContrib(3.0).activityContrib(4.0)
|
val b = Iob().iobContrib(3.0).activityContrib(4.0)
|
||||||
Assertions.assertTrue(a1 == a2)
|
assertThat(a1).isEqualTo(a1)
|
||||||
Assertions.assertFalse(a1 == b)
|
assertThat(a1).isEqualTo(a2)
|
||||||
@Suppress("SENSELESS_COMPARISON")
|
assertThat(a1).isNotEqualTo(b)
|
||||||
Assertions.assertFalse(a1 == null)
|
assertThat(a1).isNotNull()
|
||||||
Assertions.assertFalse(a1 == Any())
|
assertThat(a1).isNotEqualTo(Any())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun hashCodeTest() {
|
@Test fun hashCodeTest() {
|
||||||
val a = Iob().iobContrib(1.0).activityContrib(2.0)
|
val a = Iob().iobContrib(1.0).activityContrib(2.0)
|
||||||
Assertions.assertNotEquals(0, a.hashCode().toLong())
|
assertThat(a.hashCode().toLong()).isNotEqualTo(0L)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.core.utils
|
package info.nightscout.core.utils
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.interfaces.utils.MidnightTime
|
import info.nightscout.interfaces.utils.MidnightTime
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
|
||||||
|
@ -10,40 +10,40 @@ class MidnightTimeTest {
|
||||||
@Test fun calc() {
|
@Test fun calc() {
|
||||||
// We get real midnight
|
// We get real midnight
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
Assertions.assertTrue(now >= MidnightTime.calc())
|
assertThat(MidnightTime.calc()).isAtMost(now)
|
||||||
val c = Calendar.getInstance()
|
val c = Calendar.getInstance()
|
||||||
c.timeInMillis = MidnightTime.calc()
|
c.timeInMillis = MidnightTime.calc()
|
||||||
Assertions.assertEquals(c[Calendar.HOUR_OF_DAY].toLong(), 0)
|
assertThat(c[Calendar.HOUR_OF_DAY].toLong()).isEqualTo(0L)
|
||||||
Assertions.assertEquals(c[Calendar.MINUTE].toLong(), 0)
|
assertThat(c[Calendar.MINUTE].toLong()).isEqualTo(0L)
|
||||||
Assertions.assertEquals(c[Calendar.SECOND].toLong(), 0)
|
assertThat(c[Calendar.SECOND].toLong()).isEqualTo(0L)
|
||||||
Assertions.assertEquals(c[Calendar.MILLISECOND].toLong(), 0)
|
assertThat(c[Calendar.MILLISECOND].toLong()).isEqualTo(0L)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun calc_time() {
|
@Test fun calc_time() {
|
||||||
// We get real midnight
|
// We get real midnight
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
val midnight = MidnightTime.calc(now)
|
val midnight = MidnightTime.calc(now)
|
||||||
Assertions.assertTrue(now >= midnight)
|
assertThat(midnight).isAtMost(now)
|
||||||
val c = Calendar.getInstance()
|
val c = Calendar.getInstance()
|
||||||
c.timeInMillis = MidnightTime.calc(now)
|
c.timeInMillis = MidnightTime.calc(now)
|
||||||
Assertions.assertEquals(c[Calendar.HOUR_OF_DAY].toLong(), 0)
|
assertThat(c[Calendar.HOUR_OF_DAY].toLong()).isEqualTo(0L)
|
||||||
Assertions.assertEquals(c[Calendar.MINUTE].toLong(), 0)
|
assertThat(c[Calendar.MINUTE].toLong()).isEqualTo(0L)
|
||||||
Assertions.assertEquals(c[Calendar.SECOND].toLong(), 0)
|
assertThat(c[Calendar.SECOND].toLong()).isEqualTo(0L)
|
||||||
Assertions.assertEquals(c[Calendar.MILLISECOND].toLong(), 0)
|
assertThat(c[Calendar.MILLISECOND].toLong()).isEqualTo(0L)
|
||||||
// Assure we get the same time from cache
|
// Assure we get the same time from cache
|
||||||
Assertions.assertEquals(midnight, MidnightTime.calc(now))
|
assertThat(midnight).isEqualTo(MidnightTime.calc(now))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun resetCache() {
|
@Test fun resetCache() {
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
MidnightTime.calc(now)
|
MidnightTime.calc(now)
|
||||||
MidnightTime.resetCache()
|
MidnightTime.resetCache()
|
||||||
Assertions.assertEquals(0, MidnightTime.times.size().toLong())
|
assertThat(MidnightTime.times.size().toLong()).isEqualTo(0L)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun log() {
|
@Test fun log() {
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
MidnightTime.calc(now)
|
MidnightTime.calc(now)
|
||||||
Assertions.assertTrue(MidnightTime.log().startsWith("Hits:"))
|
assertThat(MidnightTime.log()).startsWith("Hits:")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.core.utils
|
package info.nightscout.core.utils
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.shared.utils.T
|
import info.nightscout.shared.utils.T
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
@ -9,33 +9,33 @@ import kotlin.math.abs
|
||||||
class TTest {
|
class TTest {
|
||||||
|
|
||||||
@Test fun toUnits() {
|
@Test fun toUnits() {
|
||||||
Assertions.assertEquals(1, T.msecs(1000).secs())
|
assertThat(T.msecs(1000).secs()).isEqualTo(1)
|
||||||
Assertions.assertEquals(1, T.secs(60).mins())
|
assertThat(T.secs(60).mins()).isEqualTo(1)
|
||||||
Assertions.assertEquals(1, T.mins(60).hours())
|
assertThat(T.mins(60).hours()).isEqualTo(1)
|
||||||
Assertions.assertEquals(1, T.hours(24).days())
|
assertThat(T.hours(24).days()).isEqualTo(1)
|
||||||
Assertions.assertEquals(24, T.days(1).hours())
|
assertThat(T.days(1).hours()).isEqualTo(24)
|
||||||
Assertions.assertEquals(60000, T.mins(1).msecs())
|
assertThat(T.mins(1).msecs()).isEqualTo(60000)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun now() {
|
@Test fun now() {
|
||||||
Assertions.assertTrue(abs(T.now().msecs() - System.currentTimeMillis()) < 5000)
|
assertThat(abs(T.now().msecs() - System.currentTimeMillis())).isLessThan(5_000L)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun additions() {
|
@Test fun additions() {
|
||||||
val nowMsecs = System.currentTimeMillis()
|
val nowMsecs = System.currentTimeMillis()
|
||||||
val now = T.msecs(nowMsecs)
|
val now = T.msecs(nowMsecs)
|
||||||
Assertions.assertEquals(now.plus(T.secs(5)).msecs(), nowMsecs + 5 * 1000)
|
assertThat(nowMsecs + 5 * 1000).isEqualTo(now.plus(T.secs(5)).msecs())
|
||||||
Assertions.assertEquals(now.plus(T.mins(5)).msecs(), nowMsecs + 5 * 60 * 1000)
|
assertThat(nowMsecs + 5 * 60 * 1000).isEqualTo(now.plus(T.mins(5)).msecs())
|
||||||
Assertions.assertEquals(now.plus(T.hours(5)).msecs(), nowMsecs + 5 * 60 * 60 * 1000)
|
assertThat(nowMsecs + 5 * 60 * 60 * 1000).isEqualTo(now.plus(T.hours(5)).msecs())
|
||||||
Assertions.assertEquals(now.plus(T.days(5)).msecs(), nowMsecs + 5 * 24 * 60 * 60 * 1000)
|
assertThat(nowMsecs + 5 * 24 * 60 * 60 * 1000).isEqualTo(now.plus(T.days(5)).msecs())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun subtractions() {
|
@Test fun subtractions() {
|
||||||
val nowMsecs = System.currentTimeMillis()
|
val nowMsecs = System.currentTimeMillis()
|
||||||
val now = T.msecs(nowMsecs)
|
val now = T.msecs(nowMsecs)
|
||||||
Assertions.assertEquals(now.minus(T.secs(5)).msecs(), nowMsecs - 5 * 1000)
|
assertThat(nowMsecs - 5 * 1000).isEqualTo(now.minus(T.secs(5)).msecs())
|
||||||
Assertions.assertEquals(now.minus(T.mins(5)).msecs(), nowMsecs - 5 * 60 * 1000)
|
assertThat(nowMsecs - 5 * 60 * 1000).isEqualTo(now.minus(T.mins(5)).msecs())
|
||||||
Assertions.assertEquals(now.minus(T.hours(5)).msecs(), nowMsecs - 5 * 60 * 60 * 1000)
|
assertThat(nowMsecs - 5 * 60 * 60 * 1000).isEqualTo(now.minus(T.hours(5)).msecs())
|
||||||
Assertions.assertEquals(now.minus(T.days(5)).msecs(), nowMsecs - 5 * 24 * 60 * 60 * 1000)
|
assertThat(nowMsecs - 5 * 24 * 60 * 60 * 1000).isEqualTo(now.minus(T.days(5)).msecs())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.implementation.wizard
|
package info.nightscout.implementation.wizard
|
||||||
|
|
||||||
|
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.wizard.BolusWizard
|
import info.nightscout.core.wizard.BolusWizard
|
||||||
|
@ -14,7 +15,6 @@ import info.nightscout.interfaces.pump.defs.PumpDescription
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
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
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
|
@ -113,7 +113,7 @@ class BolusWizardTest : TestBaseWithProfile() {
|
||||||
useAlarm = false
|
useAlarm = false
|
||||||
)
|
)
|
||||||
val bolusForBg54 = bw.calculatedTotalInsulin
|
val bolusForBg54 = bw.calculatedTotalInsulin
|
||||||
Assertions.assertEquals(bolusForBg42, bolusForBg54, 0.01)
|
assertThat(bolusForBg54).isWithin( 0.01).of(bolusForBg42)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -159,7 +159,7 @@ class BolusWizardTest : TestBaseWithProfile() {
|
||||||
useAlarm = false
|
useAlarm = false
|
||||||
)
|
)
|
||||||
val bolusForBgInRange = bw.calculatedTotalInsulin
|
val bolusForBgInRange = bw.calculatedTotalInsulin
|
||||||
Assertions.assertTrue(bolusForHighBg > bolusForBgInRange)
|
assertThat(bolusForHighBg).isGreaterThan(bolusForBgInRange)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -205,6 +205,6 @@ class BolusWizardTest : TestBaseWithProfile() {
|
||||||
useAlarm = false
|
useAlarm = false
|
||||||
)
|
)
|
||||||
val bolusForBgInRange = bw.calculatedTotalInsulin
|
val bolusForBgInRange = bw.calculatedTotalInsulin
|
||||||
Assertions.assertTrue(bolusForLowBg < bolusForBgInRange)
|
assertThat(bolusForLowBg).isLessThan(bolusForBgInRange)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.automation.triggers
|
package info.nightscout.automation.triggers
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
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
|
||||||
|
|
||||||
class TriggerConnectorTest : TriggerTestBase() {
|
class TriggerConnectorTest : TriggerTestBase() {
|
||||||
|
@ -15,66 +15,65 @@ class TriggerConnectorTest : TriggerTestBase() {
|
||||||
val t = TriggerConnector(injector)
|
val t = TriggerConnector(injector)
|
||||||
val t2 = TriggerConnector(injector)
|
val t2 = TriggerConnector(injector)
|
||||||
val t3 = TriggerConnector(injector)
|
val t3 = TriggerConnector(injector)
|
||||||
Assertions.assertTrue(t.size() == 0)
|
assertThat(t.size()).isEqualTo(0)
|
||||||
t.list.add(t2)
|
t.list.add(t2)
|
||||||
Assertions.assertTrue(t.size() == 1)
|
assertThat(t.size()).isEqualTo(1)
|
||||||
Assertions.assertEquals(t2, t.list[0])
|
assertThat(t.list).containsExactly(t2)
|
||||||
t.list.add(t3)
|
t.list.add(t3)
|
||||||
Assertions.assertTrue(t.size() == 2)
|
assertThat(t.size()).isEqualTo(2)
|
||||||
Assertions.assertEquals(t2, t.list[0])
|
assertThat(t.list).containsExactly(t2, t3).inOrder()
|
||||||
Assertions.assertEquals(t3, t.list[1])
|
assertThat(t.list.remove(t2)).isTrue()
|
||||||
Assertions.assertTrue(t.list.remove(t2))
|
assertThat(t.size()).isEqualTo(1)
|
||||||
Assertions.assertTrue(t.size() == 1)
|
assertThat(t.list).containsExactly(t3)
|
||||||
Assertions.assertEquals(t3, t.list[0])
|
assertThat(t.shouldRun()).isTrue()
|
||||||
Assertions.assertTrue(t.shouldRun())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun testListTriggerOR() {
|
@Test fun testListTriggerOR() {
|
||||||
val t = TriggerConnector(injector, TriggerConnector.Type.OR)
|
val t = TriggerConnector(injector, TriggerConnector.Type.OR)
|
||||||
t.list.add(TriggerDummy(injector))
|
t.list.add(TriggerDummy(injector))
|
||||||
t.list.add(TriggerDummy(injector))
|
t.list.add(TriggerDummy(injector))
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
t.list.add(TriggerDummy(injector, true))
|
t.list.add(TriggerDummy(injector, true))
|
||||||
t.list.add(TriggerDummy(injector))
|
t.list.add(TriggerDummy(injector))
|
||||||
Assertions.assertTrue(t.shouldRun())
|
assertThat(t.shouldRun()).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun testListTriggerXOR() {
|
@Test fun testListTriggerXOR() {
|
||||||
val t = TriggerConnector(injector, TriggerConnector.Type.XOR)
|
val t = TriggerConnector(injector, TriggerConnector.Type.XOR)
|
||||||
t.list.add(TriggerDummy(injector))
|
t.list.add(TriggerDummy(injector))
|
||||||
t.list.add(TriggerDummy(injector))
|
t.list.add(TriggerDummy(injector))
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
t.list.add(TriggerDummy(injector, true))
|
t.list.add(TriggerDummy(injector, true))
|
||||||
t.list.add(TriggerDummy(injector))
|
t.list.add(TriggerDummy(injector))
|
||||||
Assertions.assertTrue(t.shouldRun())
|
assertThat(t.shouldRun()).isTrue()
|
||||||
t.list.add(TriggerDummy(injector, true))
|
t.list.add(TriggerDummy(injector, true))
|
||||||
t.list.add(TriggerDummy(injector))
|
t.list.add(TriggerDummy(injector))
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun testListTriggerAND() {
|
@Test fun testListTriggerAND() {
|
||||||
val t = TriggerConnector(injector, TriggerConnector.Type.AND)
|
val t = TriggerConnector(injector, TriggerConnector.Type.AND)
|
||||||
t.list.add(TriggerDummy(injector, true))
|
t.list.add(TriggerDummy(injector, true))
|
||||||
t.list.add(TriggerDummy(injector, true))
|
t.list.add(TriggerDummy(injector, true))
|
||||||
Assertions.assertTrue(t.shouldRun())
|
assertThat(t.shouldRun()).isTrue()
|
||||||
t.list.add(TriggerDummy(injector, true))
|
t.list.add(TriggerDummy(injector, true))
|
||||||
t.list.add(TriggerDummy(injector))
|
t.list.add(TriggerDummy(injector))
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun toJSONTest() {
|
@Test fun toJSONTest() {
|
||||||
val t = TriggerConnector(injector)
|
val t = TriggerConnector(injector)
|
||||||
Assertions.assertEquals(empty, t.toJSON())
|
assertThat(t.toJSON()).isEqualTo(empty)
|
||||||
t.list.add(TriggerConnector(injector))
|
t.list.add(TriggerConnector(injector))
|
||||||
Assertions.assertEquals(oneItem, t.toJSON())
|
assertThat(t.toJSON()).isEqualTo(oneItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @Throws(JSONException::class) fun fromJSONTest() {
|
@Test @Throws(JSONException::class) fun fromJSONTest() {
|
||||||
val t = TriggerConnector(injector)
|
val t = TriggerConnector(injector)
|
||||||
t.list.add(TriggerConnector(injector))
|
t.list.add(TriggerConnector(injector))
|
||||||
val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerConnector
|
val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerConnector
|
||||||
Assertions.assertEquals(1, t2.size().toLong())
|
assertThat(t2.size()).isEqualTo(1)
|
||||||
Assertions.assertTrue(t2.list[0] is TriggerConnector)
|
assertThat(t2.list[0]).isInstanceOf(TriggerConnector::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.automation.triggers
|
package info.nightscout.automation.triggers
|
||||||
|
|
||||||
import com.google.common.base.Optional
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.automation.R
|
import info.nightscout.automation.R
|
||||||
import info.nightscout.automation.elements.Comparator
|
import info.nightscout.automation.elements.Comparator
|
||||||
import info.nightscout.automation.elements.InputDelta.DeltaType
|
import info.nightscout.automation.elements.InputDelta.DeltaType
|
||||||
|
@ -8,7 +8,6 @@ import info.nightscout.database.entities.GlucoseValue
|
||||||
import info.nightscout.interfaces.GlucoseUnit
|
import info.nightscout.interfaces.GlucoseUnit
|
||||||
import info.nightscout.interfaces.iob.InMemoryGlucoseValue
|
import info.nightscout.interfaces.iob.InMemoryGlucoseValue
|
||||||
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`
|
||||||
|
@ -25,40 +24,40 @@ class TriggerDeltaTest : TriggerTestBase() {
|
||||||
@Test fun shouldRunTest() {
|
@Test fun shouldRunTest() {
|
||||||
`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateValidBgData())
|
`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(generateValidBgData())
|
||||||
var t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(73.0, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL)
|
var t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(73.0, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL)
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
Assertions.assertEquals(DeltaType.LONG_AVERAGE, t.delta.deltaType)
|
assertThat(t.delta.deltaType).isEqualTo(DeltaType.LONG_AVERAGE)
|
||||||
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(-2.0, DeltaType.SHORT_AVERAGE).comparator(Comparator.Compare.IS_EQUAL)
|
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(-2.0, DeltaType.SHORT_AVERAGE).comparator(Comparator.Compare.IS_EQUAL)
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
Assertions.assertEquals(DeltaType.SHORT_AVERAGE, t.delta.deltaType)
|
assertThat(t.delta.deltaType).isEqualTo(DeltaType.SHORT_AVERAGE)
|
||||||
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(-3.0, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER)
|
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(-3.0, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER)
|
||||||
Assertions.assertTrue(t.shouldRun())
|
assertThat(t.shouldRun()).isTrue()
|
||||||
Assertions.assertEquals(DeltaType.DELTA, t.delta.deltaType)
|
assertThat(t.delta.deltaType).isEqualTo(DeltaType.DELTA)
|
||||||
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(2.0, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(2.0, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
||||||
Assertions.assertTrue(t.shouldRun())
|
assertThat(t.shouldRun()).isTrue()
|
||||||
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(2.0, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL)
|
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(2.0, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL)
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(0.3, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(0.3, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
||||||
Assertions.assertTrue(t.shouldRun())
|
assertThat(t.shouldRun()).isTrue()
|
||||||
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(0.1, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER)
|
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(0.1, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER)
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(-0.5, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER)
|
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(-0.5, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_GREATER)
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(-0.2, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(-0.2, DeltaType.LONG_AVERAGE).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
||||||
Assertions.assertTrue(t.shouldRun())
|
assertThat(t.shouldRun()).isTrue()
|
||||||
`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(ArrayList())
|
`when`(autosensDataStore.getBucketedDataTableCopy()).thenReturn(ArrayList())
|
||||||
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(213.0, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
t = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(213.0, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
||||||
Assertions.assertFalse(t.shouldRun())
|
assertThat(t.shouldRun()).isFalse()
|
||||||
t = TriggerDelta(injector).comparator(Comparator.Compare.IS_NOT_AVAILABLE)
|
t = TriggerDelta(injector).comparator(Comparator.Compare.IS_NOT_AVAILABLE)
|
||||||
Assertions.assertTrue(t.shouldRun())
|
assertThat(t.shouldRun()).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun copyConstructorTest() {
|
@Test fun copyConstructorTest() {
|
||||||
val t: TriggerDelta = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(213.0, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
val t: TriggerDelta = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(213.0, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
||||||
val t1 = t.duplicate() as TriggerDelta
|
val t1 = t.duplicate() as TriggerDelta
|
||||||
Assertions.assertEquals(213.0, t1.delta.value, 0.01)
|
assertThat( t1.delta.value).isWithin( 0.01).of(213.0)
|
||||||
Assertions.assertEquals(GlucoseUnit.MGDL, t1.units)
|
assertThat(t1.units).isEqualTo(GlucoseUnit.MGDL)
|
||||||
Assertions.assertEquals(DeltaType.DELTA, t.delta.deltaType)
|
assertThat(t.delta.deltaType).isEqualTo(DeltaType.DELTA)
|
||||||
Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_LESSER, t.comparator.value)
|
assertThat(t.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_LESSER)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var deltaJson = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"deltaType\":\"DELTA\",\"units\":\"mg/dl\",\"value\":4.1},\"type\":\"TriggerDelta\"}"
|
private var deltaJson = "{\"data\":{\"comparator\":\"IS_EQUAL\",\"deltaType\":\"DELTA\",\"units\":\"mg/dl\",\"value\":4.1},\"type\":\"TriggerDelta\"}"
|
||||||
|
@ -66,26 +65,26 @@ class TriggerDeltaTest : TriggerTestBase() {
|
||||||
@Test
|
@Test
|
||||||
fun toJSONTest() {
|
fun toJSONTest() {
|
||||||
val t: TriggerDelta = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(4.1, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL)
|
val t: TriggerDelta = TriggerDelta(injector).units(GlucoseUnit.MGDL).setValue(4.1, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL)
|
||||||
Assertions.assertEquals(deltaJson, t.toJSON())
|
assertThat(t.toJSON()).isEqualTo(deltaJson)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun fromJSONTest() {
|
fun fromJSONTest() {
|
||||||
val t: TriggerDelta = TriggerDelta(injector).units(GlucoseUnit.MMOL).setValue(4.1, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL)
|
val t: TriggerDelta = TriggerDelta(injector).units(GlucoseUnit.MMOL).setValue(4.1, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL)
|
||||||
val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerDelta
|
val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerDelta
|
||||||
Assertions.assertEquals(Comparator.Compare.IS_EQUAL, t2.comparator.value)
|
assertThat(t2.comparator.value).isEqualTo(Comparator.Compare.IS_EQUAL)
|
||||||
Assertions.assertEquals(4.1, t2.delta.value, 0.01)
|
assertThat( t2.delta.value).isWithin( 0.01).of(4.1)
|
||||||
Assertions.assertEquals(GlucoseUnit.MMOL, t2.units)
|
assertThat(t2.units).isEqualTo(GlucoseUnit.MMOL)
|
||||||
Assertions.assertEquals(DeltaType.DELTA, t2.delta.deltaType)
|
assertThat(t2.delta.deltaType).isEqualTo(DeltaType.DELTA)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun iconTest() {
|
@Test fun iconTest() {
|
||||||
Assertions.assertEquals(Optional.of(R.drawable.ic_auto_delta), TriggerDelta(injector).icon())
|
assertThat(TriggerDelta(injector).icon()).hasValue(R.drawable.ic_auto_delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun initializerTest() {
|
@Test fun initializerTest() {
|
||||||
val t = TriggerDelta(injector)
|
val t = TriggerDelta(injector)
|
||||||
Assertions.assertTrue(t.units == GlucoseUnit.MGDL)
|
assertThat(t.units).isEqualTo(GlucoseUnit.MGDL)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateValidBgData(): MutableList<InMemoryGlucoseValue> {
|
private fun generateValidBgData(): MutableList<InMemoryGlucoseValue> {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.plugins.constraints.objectives
|
package info.nightscout.plugins.constraints.objectives
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
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.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
@ -16,16 +16,16 @@ class SntpClientTest : TestBase() {
|
||||||
// no internet
|
// no internet
|
||||||
SntpClient(aapsLogger, dateUtil).ntpTime(object : SntpClient.Callback() {
|
SntpClient(aapsLogger, dateUtil).ntpTime(object : SntpClient.Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
Assertions.assertFalse(networkConnected)
|
assertThat(networkConnected).isFalse()
|
||||||
Assertions.assertFalse(success)
|
assertThat(success).isFalse()
|
||||||
Assertions.assertEquals(0L, time)
|
assertThat(time).isEqualTo(0L)
|
||||||
}
|
}
|
||||||
}, false)
|
}, false)
|
||||||
// internet
|
// internet
|
||||||
SntpClient(aapsLogger, dateUtil).doNtpTime(object : SntpClient.Callback() {
|
SntpClient(aapsLogger, dateUtil).doNtpTime(object : SntpClient.Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
Assertions.assertTrue(success)
|
assertThat(success).isTrue()
|
||||||
Assertions.assertTrue(abs(time - System.currentTimeMillis()) < 60000)
|
assertThat(abs(time - System.currentTimeMillis())).isLessThan(60_000L)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.insulin
|
package info.nightscout.insulin
|
||||||
|
|
||||||
|
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.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
|
@ -13,7 +14,6 @@ import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
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.junit.jupiter.api.extension.ExtendWith
|
import org.junit.jupiter.api.extension.ExtendWith
|
||||||
|
@ -81,12 +81,12 @@ class InsulinOrefBasePluginTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testGetDia() {
|
fun testGetDia() {
|
||||||
Assertions.assertEquals(5.0, sut.dia, 0.0)
|
assertThat(sut.dia).isEqualTo(5.0)
|
||||||
testUserDefinedDia = 5.0 + 1
|
testUserDefinedDia = 5.0 + 1
|
||||||
Assertions.assertEquals(5.0 + 1, sut.dia, 0.0)
|
assertThat(sut.dia).isEqualTo(5.0 + 1)
|
||||||
testUserDefinedDia = 5.0 - 1
|
testUserDefinedDia = 5.0 - 1
|
||||||
Assertions.assertEquals(5.0, sut.dia, 0.0)
|
assertThat(sut.dia).isEqualTo(5.0)
|
||||||
Assertions.assertTrue(shortDiaNotificationSend)
|
assertThat(shortDiaNotificationSend).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -98,22 +98,22 @@ class InsulinOrefBasePluginTest {
|
||||||
// check directly after bolus
|
// check directly after bolus
|
||||||
treatment.timestamp = time
|
treatment.timestamp = time
|
||||||
treatment.amount = 10.0
|
treatment.amount = 10.0
|
||||||
Assertions.assertEquals(10.0, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
|
assertThat(sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib).isWithin(0.01).of(10.0)
|
||||||
// check after 1 hour
|
// check after 1 hour
|
||||||
treatment.timestamp = time - 1 * 60 * 60 * 1000 // 1 hour
|
treatment.timestamp = time - 1 * 60 * 60 * 1000 // 1 hour
|
||||||
treatment.amount = 10.0
|
treatment.amount = 10.0
|
||||||
Assertions.assertEquals(3.92, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
|
assertThat(sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib).isWithin(0.01).of(3.92)
|
||||||
// check after 2 hour
|
// check after 2 hour
|
||||||
treatment.timestamp = time - 2 * 60 * 60 * 1000 // 2 hours
|
treatment.timestamp = time - 2 * 60 * 60 * 1000 // 2 hours
|
||||||
treatment.amount = 10.0
|
treatment.amount = 10.0
|
||||||
Assertions.assertEquals(0.77, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
|
assertThat(sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib).isWithin(0.01).of(0.77)
|
||||||
// check after 3 hour
|
// check after 3 hour
|
||||||
treatment.timestamp = time - 3 * 60 * 60 * 1000 // 3 hours
|
treatment.timestamp = time - 3 * 60 * 60 * 1000 // 3 hours
|
||||||
treatment.amount = 10.0
|
treatment.amount = 10.0
|
||||||
Assertions.assertEquals(0.10, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
|
assertThat(sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib).isWithin(0.01).of(0.10)
|
||||||
// check after dia
|
// check after dia
|
||||||
treatment.timestamp = time - 4 * 60 * 60 * 1000 // 4 hours
|
treatment.timestamp = time - 4 * 60 * 60 * 1000 // 4 hours
|
||||||
treatment.amount = 10.0
|
treatment.amount = 10.0
|
||||||
Assertions.assertEquals(0.0, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
|
assertThat(sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib).isWithin(0.01).of(0.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.pump.dana
|
package info.nightscout.pump.dana
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.interfaces.profile.Instantiator
|
import info.nightscout.interfaces.profile.Instantiator
|
||||||
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
|
||||||
|
@ -21,6 +21,6 @@ class DanaPumpTest : TestBaseWithProfile() {
|
||||||
@Test
|
@Test
|
||||||
fun detectDanaRS() {
|
fun detectDanaRS() {
|
||||||
sut.hwModel = 0x05
|
sut.hwModel = 0x05
|
||||||
Assertions.assertTrue(sut.modelFriendlyName().contains("DanaRS"))
|
assertThat(sut.modelFriendlyName()).contains("DanaRS")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.pump.danars.comm
|
package info.nightscout.pump.danars.comm
|
||||||
|
|
||||||
|
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.pump.danars.DanaRSTestBase
|
import info.nightscout.pump.danars.DanaRSTestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() {
|
class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() {
|
||||||
|
@ -28,9 +28,9 @@ class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() {
|
||||||
putIntToArray(array, 0, (1.0 * 100).toInt())
|
putIntToArray(array, 0, (1.0 * 100).toInt())
|
||||||
putByteToArray(array, 2, (0.05 * 100).toInt().toByte())
|
putByteToArray(array, 2, (0.05 * 100).toInt().toByte())
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assertions.assertEquals(1.0, danaPump.maxBasal, 0.0)
|
assertThat(danaPump.maxBasal).isWithin(0.001).of(1.0)
|
||||||
Assertions.assertEquals(0.05, danaPump.basalStep, 0.0)
|
assertThat(danaPump.basalStep).isWithin(0.001).of(0.05)
|
||||||
Assertions.assertTrue(packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
Assertions.assertEquals("BASAL__GET_BASAL_RATE", packet.friendlyName)
|
assertThat(packet.friendlyName).isEqualTo("BASAL__GET_BASAL_RATE")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
|
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import com.google.crypto.tink.subtle.Hex
|
import com.google.crypto.tink.subtle.Hex
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter
|
||||||
import info.nightscout.core.utils.toHex
|
import info.nightscout.core.utils.toHex
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class PayloadSplitterTest {
|
class PayloadSplitterTest {
|
||||||
|
@ -16,10 +16,10 @@ class PayloadSplitterTest {
|
||||||
val splitter = PayloadSplitter(payload)
|
val splitter = PayloadSplitter(payload)
|
||||||
val packets = splitter.splitInPackets()
|
val packets = splitter.splitInPackets()
|
||||||
|
|
||||||
Assertions.assertEquals(packets.size, 2)
|
assertThat(packets).hasSize(2)
|
||||||
Assertions.assertEquals(f1, packets[0].toByteArray().toHex())
|
assertThat(packets[0].toByteArray().toHex()).isEqualTo(f1)
|
||||||
val p2 = packets[1].toByteArray()
|
val p2 = packets[1].toByteArray()
|
||||||
Assertions.assertTrue(p2.size >= 10)
|
assertThat(p2.size).isAtLeast(10)
|
||||||
Assertions.assertEquals(f2.subSequence(0, 20), p2.copyOfRange(0, 10).toHex())
|
assertThat(p2.copyOfRange(0, 10).toHex()).isEqualTo(f2.subSequence(0, 20))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response;
|
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response;
|
||||||
|
|
||||||
import org.joda.time.Duration;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.AlertSlot;
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.AlertSlot;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.DeliveryStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.DeliveryStatus;
|
||||||
|
@ -10,6 +8,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.Om
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodProgressStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodProgressStatus;
|
||||||
import info.nightscout.pump.core.utils.ByteUtil;
|
import info.nightscout.pump.core.utils.ByteUtil;
|
||||||
|
|
||||||
|
import org.joda.time.Duration;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class StatusResponseTest {
|
class StatusResponseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -18,7 +19,7 @@ class StatusResponseTest {
|
||||||
|
|
||||||
StatusResponse statusResponse = new StatusResponse(encodedData);
|
StatusResponse statusResponse = new StatusResponse(encodedData);
|
||||||
|
|
||||||
Assertions.assertArrayEquals(encodedData, statusResponse.getRawData());
|
assertThat(statusResponse.getRawData()).isEqualTo(encodedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -28,7 +29,7 @@ class StatusResponseTest {
|
||||||
|
|
||||||
StatusResponse statusResponse = new StatusResponse(encodedData);
|
StatusResponse statusResponse = new StatusResponse(encodedData);
|
||||||
|
|
||||||
Assertions.assertArrayEquals(expected, statusResponse.getRawData());
|
assertThat(statusResponse.getRawData()).isEqualTo(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -36,17 +37,17 @@ class StatusResponseTest {
|
||||||
byte[] bytes = ByteUtil.fromHexString("1d180258f80000146fff"); // From https://github.com/openaps/openomni/wiki/Command-1D-Status-response
|
byte[] bytes = ByteUtil.fromHexString("1d180258f80000146fff"); // From https://github.com/openaps/openomni/wiki/Command-1D-Status-response
|
||||||
StatusResponse statusResponse = new StatusResponse(bytes);
|
StatusResponse statusResponse = new StatusResponse(bytes);
|
||||||
|
|
||||||
Assertions.assertEquals(DeliveryStatus.NORMAL, statusResponse.getDeliveryStatus());
|
assertThat(statusResponse.getDeliveryStatus()).isEqualTo(DeliveryStatus.NORMAL);
|
||||||
Assertions.assertEquals(PodProgressStatus.ABOVE_FIFTY_UNITS, statusResponse.getPodProgressStatus());
|
assertThat(statusResponse.getPodProgressStatus()).isEqualTo(PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
Assertions.assertNull(statusResponse.getReservoirLevel());
|
assertThat(statusResponse.getReservoirLevel()).isNull();
|
||||||
Assertions.assertEquals(Duration.standardMinutes(1307).getMillis(), statusResponse.getTimeActive().getMillis());
|
assertThat(statusResponse.getTimeActive().getMillis()).isEqualTo(Duration.standardMinutes(1307).getMillis());
|
||||||
Assertions.assertEquals(1201, statusResponse.getTicksDelivered());
|
assertThat(statusResponse.getTicksDelivered()).isEqualTo(1201);
|
||||||
Assertions.assertEquals(60.05, statusResponse.getInsulinDelivered(), 0.000001);
|
assertThat(statusResponse.getInsulinDelivered()).isWithin(0.000001).of(60.05);
|
||||||
Assertions.assertEquals(15, statusResponse.getPodMessageCounter());
|
assertThat(statusResponse.getPodMessageCounter()).isEqualTo(15);
|
||||||
Assertions.assertEquals(0, statusResponse.getBolusNotDelivered(), 0.000001);
|
assertThat(statusResponse.getBolusNotDelivered()).isWithin(0.000001).of(0);
|
||||||
Assertions.assertEquals(0, statusResponse.getUnacknowledgedAlerts().getAlertSlots().size());
|
assertThat(statusResponse.getUnacknowledgedAlerts().getAlertSlots()).isEmpty();
|
||||||
|
|
||||||
Assertions.assertArrayEquals(ByteUtil.fromHexString("1d180258f80000146fff"), statusResponse.getRawData());
|
assertThat(statusResponse.getRawData()).isEqualTo(ByteUtil.fromHexString("1d180258f80000146fff"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -54,18 +55,17 @@ class StatusResponseTest {
|
||||||
byte[] bytes = ByteUtil.fromHexString("1d19061f6800044295e8"); // From https://github.com/openaps/openomni/wiki/Status-Response-1D-long-run-%28Lytrix%29
|
byte[] bytes = ByteUtil.fromHexString("1d19061f6800044295e8"); // From https://github.com/openaps/openomni/wiki/Status-Response-1D-long-run-%28Lytrix%29
|
||||||
StatusResponse statusResponse = new StatusResponse(bytes);
|
StatusResponse statusResponse = new StatusResponse(bytes);
|
||||||
|
|
||||||
Assertions.assertEquals(DeliveryStatus.NORMAL, statusResponse.getDeliveryStatus());
|
assertThat(statusResponse.getDeliveryStatus()).isEqualTo(DeliveryStatus.NORMAL);
|
||||||
Assertions.assertEquals(PodProgressStatus.FIFTY_OR_LESS_UNITS, statusResponse.getPodProgressStatus());
|
assertThat(statusResponse.getPodProgressStatus()).isEqualTo(PodProgressStatus.FIFTY_OR_LESS_UNITS);
|
||||||
Assertions.assertEquals(24.4, statusResponse.getReservoirLevel(), 0.000001);
|
assertThat(statusResponse.getReservoirLevel()).isWithin(0.000001).of(24.4);
|
||||||
Assertions.assertEquals(Duration.standardMinutes(4261).getMillis(), statusResponse.getTimeActive().getMillis());
|
assertThat(statusResponse.getTimeActive().getMillis()).isEqualTo(Duration.standardMinutes(4261).getMillis());
|
||||||
Assertions.assertEquals(3134, statusResponse.getTicksDelivered());
|
assertThat(statusResponse.getTicksDelivered()).isEqualTo(3134);
|
||||||
Assertions.assertEquals(156.7, statusResponse.getInsulinDelivered(), 0.000001);
|
assertThat(statusResponse.getInsulinDelivered()).isWithin(0.000001).of(156.7);
|
||||||
Assertions.assertEquals(13, statusResponse.getPodMessageCounter());
|
assertThat(statusResponse.getPodMessageCounter()).isEqualTo(13);
|
||||||
Assertions.assertEquals(0, statusResponse.getBolusNotDelivered(), 0.000001);
|
assertThat(statusResponse.getBolusNotDelivered()).isWithin(0.000001).of(0);
|
||||||
Assertions.assertEquals(1, statusResponse.getUnacknowledgedAlerts().getAlertSlots().size());
|
assertThat(statusResponse.getUnacknowledgedAlerts().getAlertSlots()).containsExactly(AlertSlot.SLOT3);
|
||||||
Assertions.assertEquals(AlertSlot.SLOT3, statusResponse.getUnacknowledgedAlerts().getAlertSlots().get(0));
|
|
||||||
|
|
||||||
Assertions.assertArrayEquals(ByteUtil.fromHexString("1d19061f6800044295e8"), statusResponse.getRawData());
|
assertThat(statusResponse.getRawData()).isEqualTo(ByteUtil.fromHexString("1d19061f6800044295e8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -73,16 +73,16 @@ class StatusResponseTest {
|
||||||
byte[] bytes = ByteUtil.fromHexString("1d11ffffffffffffffff");
|
byte[] bytes = ByteUtil.fromHexString("1d11ffffffffffffffff");
|
||||||
StatusResponse statusResponse = new StatusResponse(bytes);
|
StatusResponse statusResponse = new StatusResponse(bytes);
|
||||||
|
|
||||||
Assertions.assertEquals(Duration.standardMinutes(8191).getMillis(), statusResponse.getTimeActive().getMillis());
|
assertThat(statusResponse.getTimeActive().getMillis()).isEqualTo(Duration.standardMinutes(8191).getMillis());
|
||||||
Assertions.assertEquals(OmnipodConstants.POD_PULSE_SIZE * 1023, statusResponse.getBolusNotDelivered(), 0.000001);
|
assertThat(statusResponse.getBolusNotDelivered()).isWithin(0.000001).of(OmnipodConstants.POD_PULSE_SIZE * 1023);
|
||||||
Assertions.assertNull(statusResponse.getReservoirLevel());
|
assertThat(statusResponse.getReservoirLevel()).isNull();
|
||||||
Assertions.assertEquals(OmnipodConstants.POD_PULSE_SIZE * 8191, statusResponse.getInsulinDelivered(), 0.0000001);
|
assertThat(statusResponse.getInsulinDelivered()).isWithin(0.0000001).of(OmnipodConstants.POD_PULSE_SIZE * 8191);
|
||||||
Assertions.assertEquals(8191, statusResponse.getTicksDelivered());
|
assertThat(statusResponse.getTicksDelivered()).isEqualTo(8191);
|
||||||
Assertions.assertEquals(OmnipodConstants.POD_PULSE_SIZE * 8191, statusResponse.getInsulinDelivered(), 0.0000001);
|
assertThat(statusResponse.getInsulinDelivered()).isWithin(0.0000001).of(OmnipodConstants.POD_PULSE_SIZE * 8191);
|
||||||
Assertions.assertEquals(15, statusResponse.getPodMessageCounter());
|
assertThat(statusResponse.getPodMessageCounter()).isEqualTo(15);
|
||||||
Assertions.assertEquals(8, statusResponse.getUnacknowledgedAlerts().getAlertSlots().size());
|
assertThat(statusResponse.getUnacknowledgedAlerts().getAlertSlots()).hasSize(8);
|
||||||
|
|
||||||
Assertions.assertArrayEquals(ByteUtil.fromHexString("1d11ffffffffffffffff"), statusResponse.getRawData());
|
assertThat(statusResponse.getRawData()).isEqualTo(ByteUtil.fromHexString("1d11ffffffffffffffff"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -90,15 +90,15 @@ class StatusResponseTest {
|
||||||
byte[] bytes = ByteUtil.fromHexString("1d19050ec82c08376f98");
|
byte[] bytes = ByteUtil.fromHexString("1d19050ec82c08376f98");
|
||||||
StatusResponse statusResponse = new StatusResponse(bytes);
|
StatusResponse statusResponse = new StatusResponse(bytes);
|
||||||
|
|
||||||
Assertions.assertTrue(Duration.standardMinutes(3547).isEqual(statusResponse.getTimeActive()));
|
assertThat(statusResponse.getTimeActive()).isEqualTo(Duration.standardMinutes(3547));
|
||||||
Assertions.assertEquals(DeliveryStatus.NORMAL, statusResponse.getDeliveryStatus());
|
assertThat(statusResponse.getDeliveryStatus()).isEqualTo(DeliveryStatus.NORMAL);
|
||||||
Assertions.assertEquals(PodProgressStatus.FIFTY_OR_LESS_UNITS, statusResponse.getPodProgressStatus());
|
assertThat(statusResponse.getPodProgressStatus()).isEqualTo(PodProgressStatus.FIFTY_OR_LESS_UNITS);
|
||||||
Assertions.assertEquals(2589, statusResponse.getTicksDelivered());
|
assertThat(statusResponse.getTicksDelivered()).isEqualTo(2589);
|
||||||
Assertions.assertEquals(129.45, statusResponse.getInsulinDelivered(), 0.00001);
|
assertThat(statusResponse.getInsulinDelivered()).isWithin(0.00001).of(129.45);
|
||||||
Assertions.assertEquals(46.00, statusResponse.getReservoirLevel(), 0.00001);
|
assertThat(statusResponse.getReservoirLevel()).isWithin(0.00001).of(46.00);
|
||||||
Assertions.assertEquals(2.2, statusResponse.getBolusNotDelivered(), 0.0001);
|
assertThat(statusResponse.getBolusNotDelivered()).isWithin(0.0001).of(2.2);
|
||||||
Assertions.assertEquals(9, statusResponse.getPodMessageCounter());
|
assertThat(statusResponse.getPodMessageCounter()).isEqualTo(9);
|
||||||
|
|
||||||
Assertions.assertArrayEquals(ByteUtil.fromHexString("1d19050ec82c08376f98"), statusResponse.getRawData());
|
assertThat(statusResponse.getRawData()).isEqualTo(ByteUtil.fromHexString("1d19050ec82c08376f98"));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response.podinfo;
|
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response.podinfo;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,7 +16,7 @@ class PodInfoActiveAlertsTest {
|
||||||
PodInfoActiveAlerts podInfoActiveAlerts = new PodInfoActiveAlerts(encodedMessage);
|
PodInfoActiveAlerts podInfoActiveAlerts = new PodInfoActiveAlerts(encodedMessage);
|
||||||
|
|
||||||
List<PodInfoActiveAlerts.AlertActivation> alertActivations = podInfoActiveAlerts.getAlertActivations();
|
List<PodInfoActiveAlerts.AlertActivation> alertActivations = podInfoActiveAlerts.getAlertActivations();
|
||||||
Assertions.assertEquals(0, alertActivations.size());
|
assertThat(alertActivations).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -24,10 +25,10 @@ class PodInfoActiveAlertsTest {
|
||||||
PodInfoActiveAlerts podInfoActiveAlerts = new PodInfoActiveAlerts(encodedMessage);
|
PodInfoActiveAlerts podInfoActiveAlerts = new PodInfoActiveAlerts(encodedMessage);
|
||||||
|
|
||||||
List<PodInfoActiveAlerts.AlertActivation> alertActivations = podInfoActiveAlerts.getAlertActivations();
|
List<PodInfoActiveAlerts.AlertActivation> alertActivations = podInfoActiveAlerts.getAlertActivations();
|
||||||
Assertions.assertEquals(1, alertActivations.size());
|
assertThat(alertActivations).hasSize(1);
|
||||||
|
|
||||||
PodInfoActiveAlerts.AlertActivation alertActivation = alertActivations.get(0);
|
PodInfoActiveAlerts.AlertActivation alertActivation = alertActivations.get(0);
|
||||||
Duration expectedDuration = Duration.standardHours(72).plus(Duration.standardMinutes(1));
|
Duration expectedDuration = Duration.standardHours(72).plus(Duration.standardMinutes(1));
|
||||||
Assertions.assertTrue(expectedDuration.isEqual(alertActivation.getValueAsDuration()));
|
assertThat(expectedDuration).isEqualTo(alertActivation.getValueAsDuration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response.podinfo;
|
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response.podinfo;
|
||||||
|
|
||||||
import org.joda.time.Duration;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
|
import org.joda.time.Duration;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FaultEventCode;
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FaultEventCode;
|
||||||
import info.nightscout.pump.core.utils.ByteUtil;
|
import info.nightscout.pump.core.utils.ByteUtil;
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@ class PodInfoDataLogTest {
|
||||||
void testDecoding() {
|
void testDecoding() {
|
||||||
PodInfoDataLog podInfoDataLog = new PodInfoDataLog(ByteUtil.fromHexString("030100010001043c"), 8); // From https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitTests/PodInfoTests.swift
|
PodInfoDataLog podInfoDataLog = new PodInfoDataLog(ByteUtil.fromHexString("030100010001043c"), 8); // From https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitTests/PodInfoTests.swift
|
||||||
|
|
||||||
Assertions.assertEquals(FaultEventCode.FAILED_FLASH_ERASE, podInfoDataLog.getFaultEventCode());
|
assertThat(podInfoDataLog.getFaultEventCode()).isEqualTo(FaultEventCode.FAILED_FLASH_ERASE);
|
||||||
Assertions.assertTrue(Duration.standardMinutes(1).isEqual(podInfoDataLog.getTimeFaultEvent()));
|
assertThat(podInfoDataLog.getTimeFaultEvent()).isEqualTo(Duration.standardMinutes(1));
|
||||||
Assertions.assertTrue(Duration.standardMinutes(1).isEqual(podInfoDataLog.getTimeSinceActivation()));
|
assertThat(podInfoDataLog.getTimeSinceActivation()).isEqualTo(Duration.standardMinutes(1));
|
||||||
Assertions.assertEquals(4, podInfoDataLog.getDataChunkSize());
|
assertThat(podInfoDataLog.getDataChunkSize()).isEqualTo(4);
|
||||||
Assertions.assertEquals(60, podInfoDataLog.getMaximumNumberOfDwords());
|
assertThat(podInfoDataLog.getMaximumNumberOfDwords()).isEqualTo(60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response.podinfo;
|
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response.podinfo;
|
||||||
|
|
||||||
import org.joda.time.Duration;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.DeliveryStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.DeliveryStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.ErrorEventInfo;
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.ErrorEventInfo;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FaultEventCode;
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FaultEventCode;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodProgressStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodProgressStatus;
|
||||||
import info.nightscout.pump.core.utils.ByteUtil;
|
import info.nightscout.pump.core.utils.ByteUtil;
|
||||||
|
import org.joda.time.Duration;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @noinspection SpellCheckingInspection
|
* @noinspection SpellCheckingInspection
|
||||||
|
@ -18,143 +18,143 @@ class PodInfoDetailedStatusTest {
|
||||||
void testPodInfoFaultEventNoFaultAlerts() {
|
void testPodInfoFaultEventNoFaultAlerts() {
|
||||||
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("02080100000a003800000003ff008700000095ff0000"));
|
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("02080100000a003800000003ff008700000095ff0000"));
|
||||||
|
|
||||||
Assertions.assertEquals(PodProgressStatus.ABOVE_FIFTY_UNITS, podInfoDetailedStatus.getPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPodProgressStatus()).isEqualTo(PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
Assertions.assertEquals(DeliveryStatus.NORMAL, podInfoDetailedStatus.getDeliveryStatus());
|
assertThat(podInfoDetailedStatus.getDeliveryStatus()).isEqualTo(DeliveryStatus.NORMAL);
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getBolusNotDelivered(), 0.000001);
|
assertThat(podInfoDetailedStatus.getBolusNotDelivered()).isWithin(0.000001).of(0);
|
||||||
Assertions.assertEquals(0x0a, podInfoDetailedStatus.getPodMessageCounter());
|
assertThat(podInfoDetailedStatus.getPodMessageCounter()).isEqualTo(0x0a);
|
||||||
Assertions.assertNull(podInfoDetailedStatus.getFaultEventCode());
|
assertThat(podInfoDetailedStatus.getFaultEventCode()).isNull();
|
||||||
Assertions.assertTrue(Duration.ZERO.isEqual(podInfoDetailedStatus.getFaultEventTime()));
|
assertThat(podInfoDetailedStatus.getFaultEventTime()).isEqualTo(Duration.ZERO);
|
||||||
Assertions.assertNull(podInfoDetailedStatus.getReservoirLevel());
|
assertThat(podInfoDetailedStatus.getReservoirLevel()).isNull();
|
||||||
Assertions.assertTrue(Duration.standardSeconds(8100).isEqual(podInfoDetailedStatus.getTimeActive()));
|
assertThat(podInfoDetailedStatus.getTimeActive()).isEqualTo(Duration.standardSeconds(8100));
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue());
|
assertThat(podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue()).isEqualTo(0);
|
||||||
Assertions.assertFalse(podInfoDetailedStatus.isFaultAccessingTables());
|
assertThat(podInfoDetailedStatus.isFaultAccessingTables()).isFalse();
|
||||||
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
||||||
Assertions.assertNull(errorEventInfo);
|
assertThat(errorEventInfo).isNull();
|
||||||
Assertions.assertNull(podInfoDetailedStatus.getPreviousPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPreviousPodProgressStatus()).isNull();
|
||||||
Assertions.assertEquals(2, podInfoDetailedStatus.getReceiverLowGain());
|
assertThat(podInfoDetailedStatus.getReceiverLowGain()).isEqualTo(2);
|
||||||
Assertions.assertEquals(21, podInfoDetailedStatus.getRadioRSSI());
|
assertThat(podInfoDetailedStatus.getRadioRSSI()).isEqualTo(21);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testPodInfoFaultEventDeliveryErrorDuringPriming() {
|
void testPodInfoFaultEventDeliveryErrorDuringPriming() {
|
||||||
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020f0000000900345c000103ff0001000005ae056029"));
|
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020f0000000900345c000103ff0001000005ae056029"));
|
||||||
|
|
||||||
Assertions.assertEquals(PodProgressStatus.INACTIVE, podInfoDetailedStatus.getPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPodProgressStatus()).isEqualTo(PodProgressStatus.INACTIVE);
|
||||||
Assertions.assertEquals(DeliveryStatus.SUSPENDED, podInfoDetailedStatus.getDeliveryStatus());
|
assertThat(podInfoDetailedStatus.getDeliveryStatus()).isEqualTo(DeliveryStatus.SUSPENDED);
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getBolusNotDelivered(), 0.000001);
|
assertThat(podInfoDetailedStatus.getBolusNotDelivered()).isWithin(0.000001).of(0);
|
||||||
Assertions.assertEquals(0x09, podInfoDetailedStatus.getPodMessageCounter());
|
assertThat(podInfoDetailedStatus.getPodMessageCounter()).isEqualTo(0x09);
|
||||||
Assertions.assertEquals(FaultEventCode.PRIME_OPEN_COUNT_TOO_LOW, podInfoDetailedStatus.getFaultEventCode());
|
assertThat(podInfoDetailedStatus.getFaultEventCode()).isEqualTo(FaultEventCode.PRIME_OPEN_COUNT_TOO_LOW);
|
||||||
Assertions.assertTrue(Duration.standardSeconds(60).isEqual(podInfoDetailedStatus.getFaultEventTime()));
|
assertThat(podInfoDetailedStatus.getFaultEventTime()).isEqualTo(Duration.standardSeconds(60));
|
||||||
Assertions.assertNull(podInfoDetailedStatus.getReservoirLevel());
|
assertThat(podInfoDetailedStatus.getReservoirLevel()).isNull();
|
||||||
Assertions.assertTrue(Duration.standardSeconds(60).isEqual(podInfoDetailedStatus.getTimeActive()));
|
assertThat(podInfoDetailedStatus.getTimeActive()).isEqualTo(Duration.standardSeconds(60));
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue());
|
assertThat(podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue()).isEqualTo(0);
|
||||||
Assertions.assertFalse(podInfoDetailedStatus.isFaultAccessingTables());
|
assertThat(podInfoDetailedStatus.isFaultAccessingTables()).isFalse();
|
||||||
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
||||||
Assertions.assertFalse(errorEventInfo.isInsulinStateTableCorruption());
|
assertThat(errorEventInfo.isInsulinStateTableCorruption()).isFalse();
|
||||||
Assertions.assertEquals(0x00, errorEventInfo.getInternalVariable());
|
assertThat(errorEventInfo.getInternalVariable()).isEqualTo(0x00);
|
||||||
Assertions.assertFalse(errorEventInfo.isImmediateBolusInProgress());
|
assertThat(errorEventInfo.isImmediateBolusInProgress()).isFalse();
|
||||||
Assertions.assertEquals(PodProgressStatus.PRIMING_COMPLETED, errorEventInfo.getPodProgressStatus());
|
assertThat(errorEventInfo.getPodProgressStatus()).isEqualTo(PodProgressStatus.PRIMING_COMPLETED);
|
||||||
Assertions.assertEquals(PodProgressStatus.PRIMING_COMPLETED, podInfoDetailedStatus.getPreviousPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPreviousPodProgressStatus()).isEqualTo(PodProgressStatus.PRIMING_COMPLETED);
|
||||||
Assertions.assertEquals(2, podInfoDetailedStatus.getReceiverLowGain());
|
assertThat(podInfoDetailedStatus.getReceiverLowGain()).isEqualTo(2);
|
||||||
Assertions.assertEquals(46, podInfoDetailedStatus.getRadioRSSI());
|
assertThat(podInfoDetailedStatus.getRadioRSSI()).isEqualTo(46);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testPodInfoFaultEventErrorShuttingDown() {
|
void testPodInfoFaultEventErrorShuttingDown() {
|
||||||
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020d0000000407f28609ff03ff0a0200000823080000"));
|
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020d0000000407f28609ff03ff0a0200000823080000"));
|
||||||
|
|
||||||
Assertions.assertEquals(PodProgressStatus.FAULT_EVENT_OCCURRED, podInfoDetailedStatus.getPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPodProgressStatus()).isEqualTo(PodProgressStatus.FAULT_EVENT_OCCURRED);
|
||||||
Assertions.assertEquals(DeliveryStatus.SUSPENDED, podInfoDetailedStatus.getDeliveryStatus());
|
assertThat(podInfoDetailedStatus.getDeliveryStatus()).isEqualTo(DeliveryStatus.SUSPENDED);
|
||||||
Assertions.assertEquals(2034, podInfoDetailedStatus.getTicksDelivered());
|
assertThat(podInfoDetailedStatus.getTicksDelivered()).isEqualTo(2034);
|
||||||
Assertions.assertEquals(101.7, podInfoDetailedStatus.getInsulinDelivered(), 0.000001);
|
assertThat(podInfoDetailedStatus.getInsulinDelivered()).isWithin(0.000001).of(101.7);
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getBolusNotDelivered(), 0.000001);
|
assertThat(podInfoDetailedStatus.getBolusNotDelivered()).isWithin(0.000001).of(0);
|
||||||
Assertions.assertEquals(0x04, podInfoDetailedStatus.getPodMessageCounter());
|
assertThat(podInfoDetailedStatus.getPodMessageCounter()).isEqualTo(0x04);
|
||||||
Assertions.assertEquals(FaultEventCode.BASAL_OVER_INFUSION_PULSE, podInfoDetailedStatus.getFaultEventCode());
|
assertThat(podInfoDetailedStatus.getFaultEventCode()).isEqualTo(FaultEventCode.BASAL_OVER_INFUSION_PULSE);
|
||||||
Assertions.assertTrue(Duration.standardMinutes(2559).isEqual(podInfoDetailedStatus.getFaultEventTime()));
|
assertThat(podInfoDetailedStatus.getFaultEventTime()).isEqualTo(Duration.standardMinutes(2559));
|
||||||
Assertions.assertNull(podInfoDetailedStatus.getReservoirLevel());
|
assertThat(podInfoDetailedStatus.getReservoirLevel()).isNull();
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue());
|
assertThat(podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue()).isEqualTo(0);
|
||||||
Assertions.assertFalse(podInfoDetailedStatus.isFaultAccessingTables());
|
assertThat(podInfoDetailedStatus.isFaultAccessingTables()).isFalse();
|
||||||
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
||||||
Assertions.assertFalse(errorEventInfo.isInsulinStateTableCorruption());
|
assertThat(errorEventInfo.isInsulinStateTableCorruption()).isFalse();
|
||||||
Assertions.assertEquals(0x00, errorEventInfo.getInternalVariable());
|
assertThat(errorEventInfo.getInternalVariable()).isEqualTo(0x00);
|
||||||
Assertions.assertFalse(errorEventInfo.isImmediateBolusInProgress());
|
assertThat(errorEventInfo.isImmediateBolusInProgress()).isFalse();
|
||||||
Assertions.assertEquals(PodProgressStatus.ABOVE_FIFTY_UNITS, errorEventInfo.getPodProgressStatus());
|
assertThat(errorEventInfo.getPodProgressStatus()).isEqualTo(PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
Assertions.assertEquals(PodProgressStatus.ABOVE_FIFTY_UNITS, podInfoDetailedStatus.getPreviousPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPreviousPodProgressStatus()).isEqualTo(PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getReceiverLowGain());
|
assertThat(podInfoDetailedStatus.getReceiverLowGain()).isEqualTo(0);
|
||||||
Assertions.assertEquals(35, podInfoDetailedStatus.getRadioRSSI());
|
assertThat(podInfoDetailedStatus.getRadioRSSI()).isEqualTo(35);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testPodInfoFaultEventInsulinNotDelivered() {
|
void testPodInfoFaultEventInsulinNotDelivered() {
|
||||||
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020f0000010200ec6a026803ff026b000028a7082023"));
|
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020f0000010200ec6a026803ff026b000028a7082023"));
|
||||||
|
|
||||||
Assertions.assertEquals(PodProgressStatus.INACTIVE, podInfoDetailedStatus.getPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPodProgressStatus()).isEqualTo(PodProgressStatus.INACTIVE);
|
||||||
Assertions.assertEquals(DeliveryStatus.SUSPENDED, podInfoDetailedStatus.getDeliveryStatus());
|
assertThat(podInfoDetailedStatus.getDeliveryStatus()).isEqualTo(DeliveryStatus.SUSPENDED);
|
||||||
Assertions.assertEquals(236, podInfoDetailedStatus.getTicksDelivered());
|
assertThat(podInfoDetailedStatus.getTicksDelivered()).isEqualTo(236);
|
||||||
Assertions.assertEquals(11.8, podInfoDetailedStatus.getInsulinDelivered(), 0.000001);
|
assertThat(podInfoDetailedStatus.getInsulinDelivered()).isWithin(0.000001).of(11.8);
|
||||||
Assertions.assertEquals(0.05, podInfoDetailedStatus.getBolusNotDelivered(), 0.000001);
|
assertThat(podInfoDetailedStatus.getBolusNotDelivered()).isWithin(0.000001).of(0.05);
|
||||||
Assertions.assertEquals(0x02, podInfoDetailedStatus.getPodMessageCounter());
|
assertThat(podInfoDetailedStatus.getPodMessageCounter()).isEqualTo(0x02);
|
||||||
Assertions.assertEquals(FaultEventCode.OCCLUSION_CHECK_ABOVE_THRESHOLD, podInfoDetailedStatus.getFaultEventCode());
|
assertThat(podInfoDetailedStatus.getFaultEventCode()).isEqualTo(FaultEventCode.OCCLUSION_CHECK_ABOVE_THRESHOLD);
|
||||||
Assertions.assertTrue(Duration.standardMinutes(616).isEqual(podInfoDetailedStatus.getFaultEventTime()));
|
assertThat(podInfoDetailedStatus.getFaultEventTime()).isEqualTo(Duration.standardMinutes(616));
|
||||||
Assertions.assertNull(podInfoDetailedStatus.getReservoirLevel());
|
assertThat(podInfoDetailedStatus.getReservoirLevel()).isNull();
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue());
|
assertThat(podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue()).isEqualTo(0);
|
||||||
Assertions.assertFalse(podInfoDetailedStatus.isFaultAccessingTables());
|
assertThat(podInfoDetailedStatus.isFaultAccessingTables()).isFalse();
|
||||||
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
||||||
Assertions.assertFalse(errorEventInfo.isInsulinStateTableCorruption());
|
assertThat(errorEventInfo.isInsulinStateTableCorruption()).isFalse();
|
||||||
Assertions.assertEquals(0x01, errorEventInfo.getInternalVariable());
|
assertThat(errorEventInfo.getInternalVariable()).isEqualTo(0x01);
|
||||||
Assertions.assertFalse(errorEventInfo.isImmediateBolusInProgress());
|
assertThat(errorEventInfo.isImmediateBolusInProgress()).isFalse();
|
||||||
Assertions.assertEquals(PodProgressStatus.ABOVE_FIFTY_UNITS, errorEventInfo.getPodProgressStatus());
|
assertThat(errorEventInfo.getPodProgressStatus()).isEqualTo(PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
Assertions.assertEquals(PodProgressStatus.ABOVE_FIFTY_UNITS, podInfoDetailedStatus.getPreviousPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPreviousPodProgressStatus()).isEqualTo(PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
Assertions.assertEquals(2, podInfoDetailedStatus.getReceiverLowGain());
|
assertThat(podInfoDetailedStatus.getReceiverLowGain()).isEqualTo(2);
|
||||||
Assertions.assertEquals(39, podInfoDetailedStatus.getRadioRSSI());
|
assertThat(podInfoDetailedStatus.getRadioRSSI()).isEqualTo(39);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testPodInfoFaultEventMaxBolusNotDelivered() {
|
void testPodInfoFaultEventMaxBolusNotDelivered() {
|
||||||
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020f00ffff0200ec6a026803ff026b000028a7082023"));
|
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020f00ffff0200ec6a026803ff026b000028a7082023"));
|
||||||
|
|
||||||
Assertions.assertEquals(PodProgressStatus.INACTIVE, podInfoDetailedStatus.getPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPodProgressStatus()).isEqualTo(PodProgressStatus.INACTIVE);
|
||||||
Assertions.assertEquals(DeliveryStatus.SUSPENDED, podInfoDetailedStatus.getDeliveryStatus());
|
assertThat(podInfoDetailedStatus.getDeliveryStatus()).isEqualTo(DeliveryStatus.SUSPENDED);
|
||||||
Assertions.assertEquals(236, podInfoDetailedStatus.getTicksDelivered());
|
assertThat(podInfoDetailedStatus.getTicksDelivered()).isEqualTo(236);
|
||||||
Assertions.assertEquals(11.8, podInfoDetailedStatus.getInsulinDelivered(), 0.000001);
|
assertThat(podInfoDetailedStatus.getInsulinDelivered()).isWithin(0.000001).of(11.8);
|
||||||
Assertions.assertEquals(3276.75, podInfoDetailedStatus.getBolusNotDelivered(), 0.000001); // Insane and will not happen, but this verifies that we convert it to an unsigned int
|
assertThat(podInfoDetailedStatus.getBolusNotDelivered()).isWithin(0.000001).of(3276.75); // Insane and will not happen, but this verifies that we convert it to an unsigned int
|
||||||
Assertions.assertEquals(0x02, podInfoDetailedStatus.getPodMessageCounter());
|
assertThat(podInfoDetailedStatus.getPodMessageCounter()).isEqualTo(0x02);
|
||||||
Assertions.assertEquals(FaultEventCode.OCCLUSION_CHECK_ABOVE_THRESHOLD, podInfoDetailedStatus.getFaultEventCode());
|
assertThat(podInfoDetailedStatus.getFaultEventCode()).isEqualTo(FaultEventCode.OCCLUSION_CHECK_ABOVE_THRESHOLD);
|
||||||
Assertions.assertTrue(Duration.standardMinutes(616).isEqual(podInfoDetailedStatus.getFaultEventTime()));
|
assertThat(podInfoDetailedStatus.getFaultEventTime()).isEqualTo(Duration.standardMinutes(616));
|
||||||
Assertions.assertNull(podInfoDetailedStatus.getReservoirLevel());
|
assertThat(podInfoDetailedStatus.getReservoirLevel()).isNull();
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue());
|
assertThat(podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue()).isEqualTo(0);
|
||||||
Assertions.assertFalse(podInfoDetailedStatus.isFaultAccessingTables());
|
assertThat(podInfoDetailedStatus.isFaultAccessingTables()).isFalse();
|
||||||
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
||||||
Assertions.assertFalse(errorEventInfo.isInsulinStateTableCorruption());
|
assertThat(errorEventInfo.isInsulinStateTableCorruption()).isFalse();
|
||||||
Assertions.assertEquals(0x01, errorEventInfo.getInternalVariable());
|
assertThat(errorEventInfo.getInternalVariable()).isEqualTo(0x01);
|
||||||
Assertions.assertFalse(errorEventInfo.isImmediateBolusInProgress());
|
assertThat(errorEventInfo.isImmediateBolusInProgress()).isFalse();
|
||||||
Assertions.assertEquals(PodProgressStatus.ABOVE_FIFTY_UNITS, errorEventInfo.getPodProgressStatus());
|
assertThat(errorEventInfo.getPodProgressStatus()).isEqualTo(PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
Assertions.assertEquals(PodProgressStatus.ABOVE_FIFTY_UNITS, podInfoDetailedStatus.getPreviousPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPreviousPodProgressStatus()).isEqualTo(PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
Assertions.assertEquals(2, podInfoDetailedStatus.getReceiverLowGain());
|
assertThat(podInfoDetailedStatus.getReceiverLowGain()).isEqualTo(2);
|
||||||
Assertions.assertEquals(39, podInfoDetailedStatus.getRadioRSSI());
|
assertThat(podInfoDetailedStatus.getRadioRSSI()).isEqualTo(39);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testPodInfoFaultEventInsulinStateTableCorruptionFoundDuringErrorLogging() {
|
void testPodInfoFaultEventInsulinStateTableCorruptionFoundDuringErrorLogging() {
|
||||||
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020D00000000000012FFFF03FF00160000879A070000"));
|
PodInfoDetailedStatus podInfoDetailedStatus = new PodInfoDetailedStatus(ByteUtil.fromHexString("020D00000000000012FFFF03FF00160000879A070000"));
|
||||||
|
|
||||||
Assertions.assertEquals(PodProgressStatus.FAULT_EVENT_OCCURRED, podInfoDetailedStatus.getPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPodProgressStatus()).isEqualTo(PodProgressStatus.FAULT_EVENT_OCCURRED);
|
||||||
Assertions.assertEquals(DeliveryStatus.SUSPENDED, podInfoDetailedStatus.getDeliveryStatus());
|
assertThat(podInfoDetailedStatus.getDeliveryStatus()).isEqualTo(DeliveryStatus.SUSPENDED);
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getBolusNotDelivered(), 0.000001);
|
assertThat(podInfoDetailedStatus.getBolusNotDelivered()).isWithin(0.000001).of(0);
|
||||||
Assertions.assertEquals(0x00, podInfoDetailedStatus.getPodMessageCounter());
|
assertThat(podInfoDetailedStatus.getPodMessageCounter()).isEqualTo(0x00);
|
||||||
Assertions.assertEquals(FaultEventCode.RESET_DUE_TO_LVD, podInfoDetailedStatus.getFaultEventCode());
|
assertThat(podInfoDetailedStatus.getFaultEventCode()).isEqualTo(FaultEventCode.RESET_DUE_TO_LVD);
|
||||||
Assertions.assertTrue(Duration.ZERO.isEqual(podInfoDetailedStatus.getFaultEventTime()));
|
assertThat(podInfoDetailedStatus.getFaultEventTime()).isNull();
|
||||||
Assertions.assertNull(podInfoDetailedStatus.getReservoirLevel());
|
assertThat(podInfoDetailedStatus.getReservoirLevel()).isNull();
|
||||||
Assertions.assertTrue(Duration.standardSeconds(1320).isEqual(podInfoDetailedStatus.getTimeActive()));
|
assertThat(podInfoDetailedStatus.getTimeActive()).isEqualTo(Duration.standardSeconds(1320));
|
||||||
Assertions.assertEquals(0, podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue());
|
assertThat(podInfoDetailedStatus.getUnacknowledgedAlerts().getRawValue()).isEqualTo(0);
|
||||||
Assertions.assertFalse(podInfoDetailedStatus.isFaultAccessingTables());
|
assertThat(podInfoDetailedStatus.isFaultAccessingTables()).isFalse();
|
||||||
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
ErrorEventInfo errorEventInfo = podInfoDetailedStatus.getErrorEventInfo();
|
||||||
Assertions.assertTrue(errorEventInfo.isInsulinStateTableCorruption());
|
assertThat(errorEventInfo.isInsulinStateTableCorruption()).isTrue();
|
||||||
Assertions.assertEquals(0x00, errorEventInfo.getInternalVariable());
|
assertThat(errorEventInfo.getInternalVariable()).isEqualTo(0x00);
|
||||||
Assertions.assertFalse(errorEventInfo.isImmediateBolusInProgress());
|
assertThat(errorEventInfo.isImmediateBolusInProgress()).isFalse();
|
||||||
Assertions.assertEquals(PodProgressStatus.INSERTING_CANNULA, errorEventInfo.getPodProgressStatus());
|
assertThat(errorEventInfo.getPodProgressStatus()).isEqualTo(PodProgressStatus.INSERTING_CANNULA);
|
||||||
Assertions.assertEquals(PodProgressStatus.INSERTING_CANNULA, podInfoDetailedStatus.getPreviousPodProgressStatus());
|
assertThat(podInfoDetailedStatus.getPreviousPodProgressStatus()).isEqualTo(PodProgressStatus.INSERTING_CANNULA);
|
||||||
Assertions.assertEquals(2, podInfoDetailedStatus.getReceiverLowGain());
|
assertThat(podInfoDetailedStatus.getReceiverLowGain()).isEqualTo(2);
|
||||||
Assertions.assertEquals(26, podInfoDetailedStatus.getRadioRSSI());
|
assertThat(podInfoDetailedStatus.getRadioRSSI()).isEqualTo(26);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response.podinfo;
|
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response.podinfo;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import org.joda.time.Duration;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FaultEventCode;
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FaultEventCode;
|
||||||
import info.nightscout.pump.core.utils.ByteUtil;
|
import info.nightscout.pump.core.utils.ByteUtil;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.Duration;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class PodInfoFaultAndInitializationTimeTest {
|
class PodInfoFaultAndInitializationTimeTest {
|
||||||
@Test
|
@Test
|
||||||
void testDecoding() {
|
void testDecoding() {
|
||||||
PodInfoFaultAndInitializationTime podInfoFaultAndInitializationTime = new PodInfoFaultAndInitializationTime(ByteUtil.fromHexString("059200010000000000000000091912170e")); // From https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitTests/PodInfoTests.swift
|
PodInfoFaultAndInitializationTime podInfoFaultAndInitializationTime = new PodInfoFaultAndInitializationTime(ByteUtil.fromHexString("059200010000000000000000091912170e")); // From https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitTests/PodInfoTests.swift
|
||||||
|
|
||||||
Assertions.assertEquals(FaultEventCode.BAD_PUMP_REQ_2_STATE, podInfoFaultAndInitializationTime.getFaultEventCode());
|
assertThat(podInfoFaultAndInitializationTime.getFaultEventCode()).isEqualTo(FaultEventCode.BAD_PUMP_REQ_2_STATE);
|
||||||
Assertions.assertTrue(Duration.standardMinutes(1).isEqual(podInfoFaultAndInitializationTime.getTimeFaultEvent()));
|
assertThat(podInfoFaultAndInitializationTime.getTimeFaultEvent()).isEqualTo(Duration.standardMinutes(1));
|
||||||
|
|
||||||
DateTime dateTime = podInfoFaultAndInitializationTime.getInitializationTime();
|
DateTime dateTime = podInfoFaultAndInitializationTime.getInitializationTime();
|
||||||
Assertions.assertEquals(2018, dateTime.getYear());
|
assertThat(dateTime.getYear()).isEqualTo(2018);
|
||||||
Assertions.assertEquals(9, dateTime.getMonthOfYear());
|
assertThat(dateTime.getMonthOfYear()).isEqualTo(9);
|
||||||
Assertions.assertEquals(25, dateTime.getDayOfMonth());
|
assertThat(dateTime.getDayOfMonth()).isEqualTo(25);
|
||||||
Assertions.assertEquals(23, dateTime.getHourOfDay());
|
assertThat(dateTime.getHourOfDay()).isEqualTo(23);
|
||||||
Assertions.assertEquals(14, dateTime.getMinuteOfHour());
|
assertThat(dateTime.getMinuteOfHour()).isEqualTo(14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.interaction.utils
|
package info.nightscout.androidaps.interaction.utils
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
@ -34,15 +35,15 @@ class PairTest {
|
||||||
val set: MutableSet<Pair<*, *>> = HashSet()
|
val set: MutableSet<Pair<*, *>> = HashSet()
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
Assert.assertFalse(set.contains(inserted))
|
assertThat(set).doesNotContain(inserted)
|
||||||
set.add(inserted)
|
set.add(inserted)
|
||||||
Assert.assertTrue(set.contains(inserted))
|
assertThat(set).contains(inserted)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun toStringTest() {
|
@Test fun toStringTest() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val pair: Pair<*, *> = Pair.create("the-first", "2nd")
|
val pair: Pair<*, *> = Pair.create("the-first", "2nd")
|
||||||
Assert.assertTrue(pair.toString().contains("the-first"))
|
assertThat(pair.toString()).contains("the-first")
|
||||||
Assert.assertTrue(pair.toString().contains("2nd"))
|
assertThat(pair.toString()).contains("2nd")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.interaction.utils
|
package info.nightscout.androidaps.interaction.utils
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.androidaps.WearTestBase
|
import info.nightscout.androidaps.WearTestBase
|
||||||
import info.nightscout.androidaps.testing.mockers.WearUtilMocker
|
import info.nightscout.androidaps.testing.mockers.WearUtilMocker
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,21 +14,18 @@ class WearUtilTest : WearTestBase() {
|
||||||
@Test fun timestampAndTimeDiffsTest() {
|
@Test fun timestampAndTimeDiffsTest() {
|
||||||
|
|
||||||
// smoke for mocks - since we freeze "now" to get stable tests
|
// smoke for mocks - since we freeze "now" to get stable tests
|
||||||
Assertions.assertEquals(WearUtilMocker.REF_NOW, wearUtil.timestamp())
|
assertThat(wearUtil.timestamp()).isEqualTo(WearUtilMocker.REF_NOW)
|
||||||
Assertions.assertEquals(0L, wearUtil.msTill(WearUtilMocker.REF_NOW))
|
assertThat(wearUtil.msTill(WearUtilMocker.REF_NOW)).isEqualTo(0L)
|
||||||
Assertions.assertEquals(3456L, wearUtil.msTill(WearUtilMocker.REF_NOW + 3456L))
|
assertThat(wearUtil.msTill(WearUtilMocker.REF_NOW + 3456L)).isEqualTo(3456L)
|
||||||
Assertions.assertEquals(-6294L, wearUtil.msTill(WearUtilMocker.REF_NOW - 6294L))
|
assertThat(wearUtil.msTill(WearUtilMocker.REF_NOW - 6294L)).isEqualTo(-6294L)
|
||||||
Assertions.assertEquals(0L, wearUtil.msTill(WearUtilMocker.REF_NOW))
|
assertThat(wearUtil.msTill(WearUtilMocker.REF_NOW)).isEqualTo(0L)
|
||||||
Assertions.assertEquals(-3456L, wearUtil.msSince(WearUtilMocker.REF_NOW + 3456L))
|
assertThat(wearUtil.msSince(WearUtilMocker.REF_NOW + 3456L)).isEqualTo(-3456L)
|
||||||
Assertions.assertEquals(6294L, wearUtil.msSince(WearUtilMocker.REF_NOW - 6294L))
|
assertThat(wearUtil.msSince(WearUtilMocker.REF_NOW - 6294L)).isEqualTo(6294L)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun joinSetTest() {
|
@Test fun joinSetTest() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val refSet: MutableSet<String> = HashSet()
|
val refSet = setOf("element1", "second-elem", "3rd")
|
||||||
refSet.add("element1")
|
|
||||||
refSet.add("second-elem")
|
|
||||||
refSet.add("3rd")
|
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
val joined = persistence.joinSet(refSet, "|")
|
val joined = persistence.joinSet(refSet, "|")
|
||||||
|
@ -36,10 +33,10 @@ class WearUtilTest : WearTestBase() {
|
||||||
// THEN
|
// THEN
|
||||||
// we cannot guarantee order of items in joined string
|
// we cannot guarantee order of items in joined string
|
||||||
// but all items have to be there
|
// but all items have to be there
|
||||||
Assertions.assertEquals(joined.length, "element1".length + "second-elem".length + "3rd".length + "|".length * 2)
|
assertThat(joined).hasLength(refSet.sumOf { it.length } + (refSet.size-1))
|
||||||
Assertions.assertTrue("|$joined|".contains("|" + "element1" + "|"))
|
assertThat("|$joined|").contains("|element1|")
|
||||||
Assertions.assertTrue("|$joined|".contains("|" + "second-elem" + "|"))
|
assertThat("|$joined|").contains("|second-elem|")
|
||||||
Assertions.assertTrue("|$joined|".contains("|" + "3rd" + "|"))
|
assertThat("|$joined|").contains("|3rd|")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun explodeSetTest() {
|
@Test fun explodeSetTest() {
|
||||||
|
@ -50,10 +47,7 @@ class WearUtilTest : WearTestBase() {
|
||||||
val set = persistence.explodeSet(serializedSet, ":")
|
val set = persistence.explodeSet(serializedSet, ":")
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
Assertions.assertEquals(set.size, 3)
|
assertThat(set).containsExactly( "element1", "second-elem", "3rd")
|
||||||
Assertions.assertTrue(set.contains("element1"))
|
|
||||||
Assertions.assertTrue(set.contains("second-elem"))
|
|
||||||
Assertions.assertTrue(set.contains("3rd"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun explodeSetEmptyElemsTest() {
|
@Test fun explodeSetEmptyElemsTest() {
|
||||||
|
@ -64,27 +58,25 @@ class WearUtilTest : WearTestBase() {
|
||||||
val set = persistence.explodeSet(serializedSet, ",")
|
val set = persistence.explodeSet(serializedSet, ",")
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
Assertions.assertEquals(set.size, 2)
|
assertThat(set).containsExactly("real", "another")
|
||||||
Assertions.assertEquals(true, set.contains("real"))
|
|
||||||
Assertions.assertEquals(true, set.contains("another"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun joinExplodeStabilityTest() {
|
@Test fun joinExplodeStabilityTest() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val refSet: MutableSet<String> = HashSet()
|
val refSet = setOf(
|
||||||
refSet.add("element1")
|
"element1",
|
||||||
refSet.add("second-elem")
|
"second-elem",
|
||||||
refSet.add("3rd")
|
"3rd",
|
||||||
refSet.add("czwarty")
|
"czwarty",
|
||||||
refSet.add("V")
|
"V",
|
||||||
refSet.add("6")
|
"6")
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
val joinedSet = persistence.joinSet(refSet, "#")
|
val joinedSet = persistence.joinSet(refSet, "#")
|
||||||
val explodedSet = persistence.explodeSet(joinedSet, "#")
|
val explodedSet = persistence.explodeSet(joinedSet, "#")
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
Assertions.assertEquals(explodedSet, refSet)
|
assertThat(explodedSet).containsExactlyElementsIn(refSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mike: failing with new mockito
|
/* Mike: failing with new mockito
|
||||||
|
@ -100,8 +92,8 @@ class WearUtilTest : WearTestBase() {
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
// we cannot guarantee to be exact to the millisecond - we add some margin of error
|
// we cannot guarantee to be exact to the millisecond - we add some margin of error
|
||||||
Assertions.assertTrue(60L > measuredSleepDuration)
|
assertThat(measuredSleepDuration).isLessThan(60L)
|
||||||
Assertions.assertTrue(requestedSleepDuration + measuringMargin < measuredSleepDuration)
|
assertThat(measuredSleepDuration).isGreaterThan(requestedSleepDuration + measuringMargin)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@Test fun rateLimitTest() {
|
@Test fun rateLimitTest() {
|
||||||
|
@ -115,9 +107,9 @@ class WearUtilTest : WearTestBase() {
|
||||||
val callAfterRateLimit = wearUtil.isBelowRateLimit("test-limit", 3)
|
val callAfterRateLimit = wearUtil.isBelowRateLimit("test-limit", 3)
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
Assertions.assertTrue(firstCall)
|
assertThat(firstCall).isTrue()
|
||||||
Assertions.assertFalse(callAfterward)
|
assertThat(callAfterward).isFalse()
|
||||||
Assertions.assertFalse(callTooSoon)
|
assertThat(callTooSoon).isFalse()
|
||||||
Assertions.assertTrue(callAfterRateLimit)
|
assertThat(callAfterRateLimit).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue