Rewrites AapsErosPodStateManagerTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-05 22:54:57 -07:00
parent df233bbb81
commit 65b5519361

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.eros.manager
import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FirmwareVersion
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodProgressStatus
import org.joda.time.DateTime
@ -9,7 +10,6 @@ import org.joda.time.DateTimeUtils
import org.joda.time.DateTimeZone
import org.joda.time.Duration
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -28,11 +28,10 @@ class AapsErosPodStateManagerTest : TestBase() {
0, 0, FirmwareVersion(1, 1, 1),
FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS
)
Assertions.assertEquals(now, podStateManager.time)
Assertions.assertEquals(
assertThat(podStateManager.time).isEqualTo(now)
assertThat(podStateManager.scheduleOffset).isEqualTo(
Duration.standardHours(1)
.plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))),
podStateManager.scheduleOffset
.plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3)))
)
}
@ -52,11 +51,10 @@ class AapsErosPodStateManagerTest : TestBase() {
// The system time zone has been updated, but the pod session state's time zone hasn't
// So the pods time should not have been changed
Assertions.assertEquals(now, podStateManager.time)
Assertions.assertEquals(
assertThat(podStateManager.time).isEqualTo(now)
assertThat(podStateManager.scheduleOffset).isEqualTo(
Duration.standardHours(1)
.plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))),
podStateManager.scheduleOffset
.plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3)))
)
}
@ -77,15 +75,14 @@ class AapsErosPodStateManagerTest : TestBase() {
// Both the system time zone have been updated
// So the pods time should have been changed (to +2 hours)
Assertions.assertEquals(now.withZone(newTimeZone), podStateManager.time)
Assertions.assertEquals(
assertThat(podStateManager.time).isEqualTo(now.withZone(newTimeZone))
assertThat(podStateManager.scheduleOffset).isEqualTo(
Duration.standardHours(3)
.plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))),
podStateManager.scheduleOffset
.plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3)))
)
}
@AfterEach fun tearDown() {
DateTimeUtils.setCurrentMillisSystem()
}
}
}