parent
392cd48ff5
commit
86f805add8
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.constraints.objectives
|
package info.nightscout.plugins.constraints.objectives
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBase
|
import app.aaps.shared.tests.TestBase
|
||||||
|
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.constraints.ConstraintObject
|
import info.nightscout.core.constraints.ConstraintObject
|
||||||
|
@ -12,7 +13,6 @@ import info.nightscout.plugins.constraints.objectives.objectives.Objective
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
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
|
||||||
|
@ -50,29 +50,29 @@ class ObjectivesPluginTest : TestBase() {
|
||||||
@Test fun notStartedObjectivesShouldLimitLoopInvocation() {
|
@Test fun notStartedObjectivesShouldLimitLoopInvocation() {
|
||||||
objectivesPlugin.objectives[Objectives.FIRST_OBJECTIVE].startedOn = 0
|
objectivesPlugin.objectives[Objectives.FIRST_OBJECTIVE].startedOn = 0
|
||||||
val c = objectivesPlugin.isLoopInvocationAllowed(ConstraintObject(true, aapsLogger))
|
val c = objectivesPlugin.isLoopInvocationAllowed(ConstraintObject(true, aapsLogger))
|
||||||
Assertions.assertEquals("Objectives: Objective 1 not started", c.getReasons())
|
assertThat(c.getReasons()).isEqualTo("Objectives: Objective 1 not started")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
objectivesPlugin.objectives[Objectives.FIRST_OBJECTIVE].startedOn = dateUtil.now()
|
objectivesPlugin.objectives[Objectives.FIRST_OBJECTIVE].startedOn = dateUtil.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun notStartedObjective6ShouldLimitClosedLoop() {
|
@Test fun notStartedObjective6ShouldLimitClosedLoop() {
|
||||||
objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0
|
objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0
|
||||||
val c = objectivesPlugin.isClosedLoopAllowed(ConstraintObject(true, aapsLogger))
|
val c = objectivesPlugin.isClosedLoopAllowed(ConstraintObject(true, aapsLogger))
|
||||||
Assertions.assertEquals(true, c.getReasons().contains("Objective 6 not started"))
|
assertThat(c.getReasons()).contains("Objective 6 not started")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun notStartedObjective8ShouldLimitAutosensMode() {
|
@Test fun notStartedObjective8ShouldLimitAutosensMode() {
|
||||||
objectivesPlugin.objectives[Objectives.AUTOSENS_OBJECTIVE].startedOn = 0
|
objectivesPlugin.objectives[Objectives.AUTOSENS_OBJECTIVE].startedOn = 0
|
||||||
val c = objectivesPlugin.isAutosensModeEnabled(ConstraintObject(true, aapsLogger))
|
val c = objectivesPlugin.isAutosensModeEnabled(ConstraintObject(true, aapsLogger))
|
||||||
Assertions.assertEquals(true, c.getReasons().contains("Objective 8 not started"))
|
assertThat(c.getReasons()).contains("Objective 8 not started")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun notStartedObjective10ShouldLimitSMBMode() {
|
@Test fun notStartedObjective10ShouldLimitSMBMode() {
|
||||||
objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0
|
objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0
|
||||||
val c = objectivesPlugin.isSMBModeEnabled(ConstraintObject(true, aapsLogger))
|
val c = objectivesPlugin.isSMBModeEnabled(ConstraintObject(true, aapsLogger))
|
||||||
Assertions.assertEquals(true, c.getReasons().contains("Objective 9 not started"))
|
assertThat(c.getReasons()).contains("Objective 9 not started")
|
||||||
Assertions.assertEquals(false, c.value())
|
assertThat(c.value()).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue