Rewrites PodInfoFaultAndInitializationTimeTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-08 19:55:14 -07:00
parent 29113520c2
commit 36ce238cc9

View file

@ -1,26 +1,26 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication.message.response.podinfo;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static com.google.common.truth.Truth.assertThat;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FaultEventCode;
import info.nightscout.pump.core.utils.ByteUtil;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.jupiter.api.Test;
class PodInfoFaultAndInitializationTimeTest {
@Test
void testDecoding() {
PodInfoFaultAndInitializationTime podInfoFaultAndInitializationTime = new PodInfoFaultAndInitializationTime(ByteUtil.fromHexString("059200010000000000000000091912170e")); // From https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitTests/PodInfoTests.swift
Assertions.assertEquals(FaultEventCode.BAD_PUMP_REQ_2_STATE, podInfoFaultAndInitializationTime.getFaultEventCode());
Assertions.assertTrue(Duration.standardMinutes(1).isEqual(podInfoFaultAndInitializationTime.getTimeFaultEvent()));
assertThat(podInfoFaultAndInitializationTime.getFaultEventCode()).isEqualTo(FaultEventCode.BAD_PUMP_REQ_2_STATE);
assertThat(podInfoFaultAndInitializationTime.getTimeFaultEvent()).isEqualTo(Duration.standardMinutes(1));
DateTime dateTime = podInfoFaultAndInitializationTime.getInitializationTime();
Assertions.assertEquals(2018, dateTime.getYear());
Assertions.assertEquals(9, dateTime.getMonthOfYear());
Assertions.assertEquals(25, dateTime.getDayOfMonth());
Assertions.assertEquals(23, dateTime.getHourOfDay());
Assertions.assertEquals(14, dateTime.getMinuteOfHour());
assertThat(dateTime.getYear()).isEqualTo(2018);
assertThat(dateTime.getMonthOfYear()).isEqualTo(9);
assertThat(dateTime.getDayOfMonth()).isEqualTo(25);
assertThat(dateTime.getHourOfDay()).isEqualTo(23);
assertThat(dateTime.getMinuteOfHour()).isEqualTo(14);
}
}