fix tests
This commit is contained in:
parent
1ff6aa7bbf
commit
5f92f29f41
1 changed files with 15 additions and 6 deletions
|
@ -6,8 +6,10 @@ import info.nightscout.core.constraints.ConstraintObject
|
||||||
import info.nightscout.core.utils.JsonHelper.safeGetDouble
|
import info.nightscout.core.utils.JsonHelper.safeGetDouble
|
||||||
import info.nightscout.database.entities.TemporaryBasal
|
import info.nightscout.database.entities.TemporaryBasal
|
||||||
import info.nightscout.interfaces.aps.APSResult
|
import info.nightscout.interfaces.aps.APSResult
|
||||||
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.ConstraintsChecker
|
import info.nightscout.interfaces.constraints.ConstraintsChecker
|
||||||
import info.nightscout.interfaces.pump.defs.PumpType
|
import info.nightscout.interfaces.pump.defs.PumpType
|
||||||
|
import info.nightscout.plugins.aps.APSResultObject
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
@ -20,9 +22,15 @@ class APSResultTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var constraintsChecker: ConstraintsChecker
|
@Mock lateinit var constraintsChecker: ConstraintsChecker
|
||||||
|
|
||||||
private val injector = HasAndroidInjector { AndroidInjector { } }
|
private val injector = HasAndroidInjector {
|
||||||
|
AndroidInjector {
|
||||||
|
if (it is ConstraintObject<*>) {
|
||||||
|
it.aapsLogger = aapsLogger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var closedLoopEnabled = ConstraintObject(false, injector)
|
private lateinit var closedLoopEnabled: Constraint<Boolean>
|
||||||
|
|
||||||
private fun APSResult.percent(percent: Int): APSResult {
|
private fun APSResult.percent(percent: Int): APSResult {
|
||||||
this.percent = percent
|
this.percent = percent
|
||||||
|
@ -52,7 +60,7 @@ class APSResultTest : TestBaseWithProfile() {
|
||||||
@Test
|
@Test
|
||||||
fun changeRequestedTest() {
|
fun changeRequestedTest() {
|
||||||
|
|
||||||
val apsResult = info.nightscout.plugins.aps.APSResultObject { AndroidInjector { } }
|
val apsResult = APSResultObject { AndroidInjector { } }
|
||||||
.also {
|
.also {
|
||||||
it.aapsLogger = aapsLogger
|
it.aapsLogger = aapsLogger
|
||||||
it.constraintChecker = constraintsChecker
|
it.constraintChecker = constraintsChecker
|
||||||
|
@ -293,7 +301,7 @@ class APSResultTest : TestBaseWithProfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun cloneTest() {
|
@Test fun cloneTest() {
|
||||||
val apsResult = info.nightscout.plugins.aps.APSResultObject { AndroidInjector { } }
|
val apsResult = APSResultObject(injector)
|
||||||
.also {
|
.also {
|
||||||
it.aapsLogger = aapsLogger
|
it.aapsLogger = aapsLogger
|
||||||
it.constraintChecker = constraintsChecker
|
it.constraintChecker = constraintsChecker
|
||||||
|
@ -310,7 +318,7 @@ class APSResultTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Test fun jsonTest() {
|
@Test fun jsonTest() {
|
||||||
closedLoopEnabled.set(true)
|
closedLoopEnabled.set(true)
|
||||||
val apsResult = info.nightscout.plugins.aps.APSResultObject { AndroidInjector { } }
|
val apsResult = APSResultObject(injector)
|
||||||
.also {
|
.also {
|
||||||
it.aapsLogger = aapsLogger
|
it.aapsLogger = aapsLogger
|
||||||
it.constraintChecker = constraintsChecker
|
it.constraintChecker = constraintsChecker
|
||||||
|
@ -328,7 +336,8 @@ class APSResultTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun prepare() {
|
fun prepare() {
|
||||||
`when`(constraintsChecker.isClosedLoopAllowed(anyObject())).thenReturn(closedLoopEnabled)
|
closedLoopEnabled = ConstraintObject(false, injector)
|
||||||
|
`when`(constraintsChecker.isClosedLoopAllowed()).thenReturn(closedLoopEnabled)
|
||||||
`when`(sp.getDouble(ArgumentMatchers.anyInt(), ArgumentMatchers.anyDouble())).thenReturn(30.0)
|
`when`(sp.getDouble(ArgumentMatchers.anyInt(), ArgumentMatchers.anyDouble())).thenReturn(30.0)
|
||||||
`when`(profileFunction.getProfile()).thenReturn(validProfile)
|
`when`(profileFunction.getProfile()).thenReturn(validProfile)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue