parent
60c4d70a3f
commit
3c85552413
|
@ -4,9 +4,9 @@ import app.aaps.core.interfaces.utils.T
|
|||
import app.aaps.plugins.automation.R
|
||||
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.mockito.Mockito
|
||||
import org.skyscreamer.jsonassert.JSONAssert
|
||||
|
||||
class TriggerTimeTest : TriggerTestBase() {
|
||||
|
||||
|
@ -19,11 +19,11 @@ class TriggerTimeTest : TriggerTestBase() {
|
|||
|
||||
// scheduled 1 min before
|
||||
var t: TriggerTime = TriggerTime(injector).runAt(now - T.mins(1).msecs())
|
||||
Assertions.assertTrue(t.shouldRun())
|
||||
assertThat(t.shouldRun()).isTrue()
|
||||
|
||||
// scheduled 1 min in the future
|
||||
t = TriggerTime(injector).runAt(now + T.mins(1).msecs())
|
||||
Assertions.assertFalse(t.shouldRun())
|
||||
assertThat(t.shouldRun()).isFalse()
|
||||
}
|
||||
|
||||
private var timeJson = "{\"data\":{\"runAt\":1656358762000},\"type\":\"TriggerTime\"}"
|
||||
|
@ -31,14 +31,14 @@ class TriggerTimeTest : TriggerTestBase() {
|
|||
@Test
|
||||
fun toJSONTest() {
|
||||
val t: TriggerTime = TriggerTime(injector).runAt(now - T.mins(1).msecs())
|
||||
Assertions.assertEquals(timeJson, t.toJSON())
|
||||
JSONAssert.assertEquals(timeJson, t.toJSON(), true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun fromJSONTest() {
|
||||
val t: TriggerTime = TriggerTime(injector).runAt(now - T.mins(1).msecs())
|
||||
val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerTime
|
||||
Assertions.assertEquals(now - T.mins(1).msecs(), t2.time.value)
|
||||
assertThat(t2.time.value).isEqualTo(now - T.mins(1).msecs())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -46,22 +46,22 @@ class TriggerTimeTest : TriggerTestBase() {
|
|||
val t = TriggerTime(injector)
|
||||
t.runAt(now)
|
||||
val t1 = t.duplicate() as TriggerTime
|
||||
Assertions.assertEquals(now, t1.time.value)
|
||||
assertThat(t1.time.value).isEqualTo(now)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun friendlyNameTest() {
|
||||
Assertions.assertEquals(app.aaps.core.ui.R.string.time, TriggerTime(injector).friendlyName())
|
||||
assertThat(TriggerTime(injector).friendlyName()).isEqualTo(app.aaps.core.ui.R.string.time)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun friendlyDescriptionTest() {
|
||||
Mockito.`when`(rh.gs(R.string.atspecifiedtime)).thenReturn("At %1\$s")
|
||||
Assertions.assertTrue(TriggerTime(injector).friendlyDescription().startsWith("At "))
|
||||
assertThat(TriggerTime(injector).friendlyDescription()).startsWith("At ")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun iconTest() {
|
||||
assertThat(TriggerTime(injector).icon().get()).isEqualTo(app.aaps.core.main.R.drawable.ic_access_alarm_24dp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue