parent
a801306d40
commit
b2fe352555
1 changed files with 9 additions and 9 deletions
|
@ -4,8 +4,8 @@ import app.aaps.plugins.automation.R
|
|||
import app.aaps.plugins.automation.elements.ComparatorExists
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.json.JSONObject
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.skyscreamer.jsonassert.JSONAssert
|
||||
|
||||
class TriggerTempTargetTest : TriggerTestBase() {
|
||||
|
||||
|
@ -13,33 +13,33 @@ class TriggerTempTargetTest : TriggerTestBase() {
|
|||
@Test fun shouldRunTest() {
|
||||
`when`(repository.getTemporaryTargetActiveAt(anyObject())).thenReturn(null)
|
||||
var t: TriggerTempTarget = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.EXISTS)
|
||||
Assertions.assertFalse(t.shouldRun())
|
||||
assertThat(t.shouldRun()).isFalse()
|
||||
t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS)
|
||||
Assertions.assertTrue(t.shouldRun())
|
||||
assertThat(t.shouldRun()).isTrue()
|
||||
`when`(repository.getTemporaryTargetActiveAt(anyObject())).thenReturn(TemporaryTarget(duration = 0, highTarget = 0.0, lowTarget = 0.0, reason = TemporaryTarget.Reason.CUSTOM, timestamp = 0))
|
||||
t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS)
|
||||
Assertions.assertFalse(t.shouldRun())
|
||||
assertThat(t.shouldRun()).isFalse()
|
||||
t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.EXISTS)
|
||||
Assertions.assertTrue(t.shouldRun())
|
||||
assertThat(t.shouldRun()).isTrue()
|
||||
}
|
||||
*/
|
||||
@Test fun copyConstructorTest() {
|
||||
val t: TriggerTempTarget = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS)
|
||||
val t1 = t.duplicate() as TriggerTempTarget
|
||||
Assertions.assertEquals(ComparatorExists.Compare.NOT_EXISTS, t1.comparator.value)
|
||||
assertThat(t1.comparator.value).isEqualTo(ComparatorExists.Compare.NOT_EXISTS)
|
||||
}
|
||||
|
||||
private var ttJson = "{\"data\":{\"comparator\":\"EXISTS\"},\"type\":\"TriggerTempTarget\"}"
|
||||
@Test fun toJSONTest() {
|
||||
val t: TriggerTempTarget = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.EXISTS)
|
||||
Assertions.assertEquals(ttJson, t.toJSON())
|
||||
JSONAssert.assertEquals(ttJson, t.toJSON(), true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun fromJSONTest() {
|
||||
val t: TriggerTempTarget = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS)
|
||||
val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerTempTarget
|
||||
Assertions.assertEquals(ComparatorExists.Compare.NOT_EXISTS, t2.comparator.value)
|
||||
assertThat(t2.comparator.value).isEqualTo(ComparatorExists.Compare.NOT_EXISTS)
|
||||
}
|
||||
|
||||
@Test fun iconTest() {
|
||||
|
|
Loading…
Reference in a new issue