Rewrites TriggerRecurringTimeTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-04 22:14:29 -07:00
parent 8b98f5d470
commit 23af538733

View file

@ -2,11 +2,12 @@ package app.aaps.plugins.automation.triggers
import app.aaps.core.interfaces.utils.MidnightTime import app.aaps.core.interfaces.utils.MidnightTime
import app.aaps.core.interfaces.utils.T import app.aaps.core.interfaces.utils.T
import com.google.common.truth.Truth.assertThat
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 import org.mockito.Mockito
import org.skyscreamer.jsonassert.JSONAssert
class TriggerRecurringTimeTest : TriggerTestBase() { class TriggerRecurringTimeTest : TriggerTestBase() {
@ -19,12 +20,12 @@ class TriggerRecurringTimeTest : TriggerTestBase() {
var t: TriggerRecurringTime = TriggerRecurringTime(injector).time(89) var t: TriggerRecurringTime = TriggerRecurringTime(injector).time(89)
t.days.setAll(true) t.days.setAll(true)
Assertions.assertFalse(t.shouldRun()) assertThat(t.shouldRun()).isFalse()
// scheduled 1 min before // scheduled 1 min before
t = TriggerRecurringTime(injector).time(94) t = TriggerRecurringTime(injector).time(94)
t.days.setAll(true) t.days.setAll(true)
Assertions.assertTrue(t.shouldRun()) assertThat(t.shouldRun()).isTrue()
} }
private var timeJson = private var timeJson =
@ -33,13 +34,13 @@ class TriggerRecurringTimeTest : TriggerTestBase() {
@Test @Test
fun toJSONTest() { fun toJSONTest() {
val t = TriggerRecurringTime(injector).time(4444) val t = TriggerRecurringTime(injector).time(4444)
Assertions.assertEquals(timeJson, t.toJSON()) JSONAssert.assertEquals(timeJson, t.toJSON(), true)
} }
@Test @Test
fun fromJSONTest() { fun fromJSONTest() {
val t = TriggerRecurringTime(injector).time(4444) val t = TriggerRecurringTime(injector).time(4444)
val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerRecurringTime val t2 = TriggerDummy(injector).instantiate(JSONObject(t.toJSON())) as TriggerRecurringTime
Assertions.assertEquals(4444, t2.time.value) assertThat(t2.time.value).isEqualTo(4444)
} }
} }