Convert Omnipod Dash tests to Kotlin

This commit is contained in:
Bart Sopers 2021-02-26 13:21:27 +01:00
parent 5db17e735c
commit f2922057c0
28 changed files with 484 additions and 534 deletions

View file

@ -1,21 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
public class DeactivateCommandTest {
@Test
public void testEncoding() throws DecoderException {
byte[] encoded = new DeactivateCommand.Builder() //
.setUniqueId(37879809) //
.setSequenceNumber((short) 5) //
.setNonce(1229869870) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("0242000114061C04494E532E001C"), encoded);
}
}

View file

@ -0,0 +1,20 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class DeactivateCommandTest {
@Test @Throws(DecoderException::class) fun testEncoding() {
val encoded = DeactivateCommand.Builder() //
.setUniqueId(37879809) //
.setSequenceNumber(5.toShort()) //
.setNonce(1229869870) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("0242000114061C04494E532E001C"), encoded)
}
}

View file

@ -1,20 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
public class GetVersionCommandTest {
@Test
public void testEncoding() throws DecoderException {
byte[] encoded = new GetVersionCommand.Builder() //
.setSequenceNumber((short) 0) //
.setUniqueId(GetVersionCommand.DEFAULT_UNIQUE_ID) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2"), encoded);
}
}

View file

@ -0,0 +1,19 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class GetVersionCommandTest {
@Test @Throws(DecoderException::class) fun testEncoding() {
val encoded = GetVersionCommand.Builder() //
.setSequenceNumber(0.toShort()) //
.setUniqueId(GetVersionCommand.DEFAULT_UNIQUE_ID) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2"), encoded)
}
}

View file

@ -1,86 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertSlot;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTriggerType;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType;
import static org.junit.Assert.assertArrayEquals;
public class ProgramAlertsCommandTest {
@Test
public void testExpirationAlerts() throws DecoderException {
List<AlertConfiguration> configurations = new ArrayList<>();
configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION, true, (short) 420, false, AlertTriggerType.TIME_TRIGGER, (short) 4305, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX3));
configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION_IMMINENT, true, (short) 0, false, AlertTriggerType.TIME_TRIGGER, (short) 4725, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX4));
byte[] encoded = new ProgramAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber((short) 3) //
.setMultiCommandFlag(true) //
.setNonce(1229869870) //
.setAlertConfigurations(configurations) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5"), encoded);
}
@Test
public void testLowReservoirAlert() throws DecoderException {
List<AlertConfiguration> configurations = new ArrayList<>();
configurations.add(new AlertConfiguration(AlertSlot.LOW_RESERVOIR, true, (short) 0, false, AlertTriggerType.RESERVOIR_VOLUME_TRIGGER, (short) 200, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX));
byte[] encoded = new ProgramAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber((short) 8) //
.setNonce(1229869870) //
.setAlertConfigurations(configurations) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149"), encoded);
}
@Test
public void testUserExpirationAlert() throws DecoderException {
List<AlertConfiguration> configurations = new ArrayList<>();
configurations.add(new AlertConfiguration(AlertSlot.USER_SET_EXPIRATION, true, (short) 0, false, AlertTriggerType.TIME_TRIGGER, (short) 4079, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX2));
byte[] encoded = new ProgramAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber((short) 15) //
.setNonce(1229869870) //
.setAlertConfigurations(configurations) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2"), encoded);
}
@Test
public void testLumpOfCoalAlert() throws DecoderException {
List<AlertConfiguration> configurations = new ArrayList<>();
configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION, true, (short) 55, false, AlertTriggerType.TIME_TRIGGER, (short) 5, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX5));
byte[] encoded = new ProgramAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber((short) 10) //
.setMultiCommandFlag(false) //
.setNonce(1229869870) //
.setAlertConfigurations(configurations) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("02420003280C190A494E532E7837000508020356"), encoded);
}
}

View file

@ -0,0 +1,78 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertSlot
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTriggerType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
import java.util.*
class ProgramAlertsCommandTest {
@Test @Throws(DecoderException::class) fun testExpirationAlerts() {
val configurations: MutableList<AlertConfiguration> = ArrayList()
configurations.add(AlertConfiguration(AlertSlot.EXPIRATION, true, 420.toShort(), false, AlertTriggerType.TIME_TRIGGER, 4305.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX3))
configurations.add(AlertConfiguration(AlertSlot.EXPIRATION_IMMINENT, true, 0.toShort(), false, AlertTriggerType.TIME_TRIGGER, 4725.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX4))
val encoded = ProgramAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber(3.toShort()) //
.setMultiCommandFlag(true) //
.setNonce(1229869870) //
.setAlertConfigurations(configurations) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5"), encoded)
}
@Test @Throws(DecoderException::class) fun testLowReservoirAlert() {
val configurations: MutableList<AlertConfiguration> = ArrayList()
configurations.add(AlertConfiguration(AlertSlot.LOW_RESERVOIR, true, 0.toShort(), false, AlertTriggerType.RESERVOIR_VOLUME_TRIGGER, 200.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX))
val encoded = ProgramAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber(8.toShort()) //
.setNonce(1229869870) //
.setAlertConfigurations(configurations) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149"), encoded)
}
@Test @Throws(DecoderException::class) fun testUserExpirationAlert() {
val configurations: MutableList<AlertConfiguration> = ArrayList()
configurations.add(AlertConfiguration(AlertSlot.USER_SET_EXPIRATION, true, 0.toShort(), false, AlertTriggerType.TIME_TRIGGER, 4079.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX2))
val encoded = ProgramAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber(15.toShort()) //
.setNonce(1229869870) //
.setAlertConfigurations(configurations) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2"), encoded)
}
@Test @Throws(DecoderException::class) fun testLumpOfCoalAlert() {
val configurations: MutableList<AlertConfiguration> = ArrayList()
configurations.add(AlertConfiguration(AlertSlot.EXPIRATION, true, 55.toShort(), false, AlertTriggerType.TIME_TRIGGER, 5.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX5))
val encoded = ProgramAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber(10.toShort()) //
.setMultiCommandFlag(false) //
.setNonce(1229869870) //
.setAlertConfigurations(configurations) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("02420003280C190A494E532E7837000508020356"), encoded)
}
}

View file

@ -1,38 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder;
import static org.junit.Assert.assertArrayEquals;
public class ProgramBasalCommandTest {
@Test
public void testProgramBasalCommand() throws DecoderException {
List<BasalProgram.Segment> segments = Arrays.asList(
new BasalProgram.Segment((short) 0, (short) 48, 300)
);
BasalProgram basalProgram = new BasalProgram(segments);
Date date = new Date(2021, 1, 17, 14, 47, 43);
byte[] encoded = new ProgramBasalCommand.Builder() //
.setUniqueId(37879809) //
.setNonce(1229869870) //
.setSequenceNumber((short) 10) //
.setBasalProgram(basalProgram) //
.setCurrentTime(date) //
.setProgramReminder(new ProgramReminder(false, true, (byte) 0)) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C"), encoded);
}
}

View file

@ -0,0 +1,32 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
import java.util.*
class ProgramBasalCommandTest {
@Test @Throws(DecoderException::class) fun testProgramBasalCommand() {
val segments = listOf(
BasalProgram.Segment(0.toShort(), 48.toShort(), 300)
)
val basalProgram = BasalProgram(segments)
val date = Date(2021, 1, 17, 14, 47, 43)
val encoded = ProgramBasalCommand.Builder() //
.setUniqueId(37879809) //
.setNonce(1229869870) //
.setSequenceNumber(10.toShort()) //
.setBasalProgram(basalProgram) //
.setCurrentTime(date) //
.setProgramReminder(ProgramReminder(false, true, 0.toByte())) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C"), encoded)
}
}

View file

@ -1,27 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder;
import static org.junit.Assert.assertArrayEquals;
public class ProgramBolusCommandTest {
@Test
public void testProgramBolusCommand() throws DecoderException {
byte[] encoded = new ProgramBolusCommand.Builder() //
.setNumberOfUnits(5) //
.setProgramReminder(new ProgramReminder(false, true, (byte) 0)) //
.setDelayBetweenPulsesInEighthSeconds((byte) 16) //
.setUniqueId(37879809) //
.setSequenceNumber((short) 14) //
.setNonce(1229869870) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6"), encoded);
}
}

View file

@ -0,0 +1,24 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class ProgramBolusCommandTest {
@Test @Throws(DecoderException::class) fun testProgramBolusCommand() {
val encoded = ProgramBolusCommand.Builder() //
.setNumberOfUnits(5.0) //
.setProgramReminder(ProgramReminder(false, true, 0.toByte())) //
.setDelayBetweenPulsesInEighthSeconds(16.toByte()) //
.setUniqueId(37879809) //
.setSequenceNumber(14.toShort()) //
.setNonce(1229869870) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6"), encoded)
}
}

View file

@ -1,39 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder;
import static org.junit.Assert.assertArrayEquals;
public class ProgramTempBasalCommandTest {
@Test
public void testExtraAlternateSegmentPulseTempBasal() throws DecoderException {
ProgramTempBasalCommand command = new ProgramTempBasalCommand.Builder() //
.setUniqueId(37879809) //
.setNonce(1229869870) //
.setSequenceNumber((short) 15) //
.setRateInUnitsPerHour(5.05d) //
.setDurationInMinutes((short) 60) //
.setProgramReminder(new ProgramReminder(false, true, (byte) 0)) //
.build();
assertArrayEquals(Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6"), command.getEncoded());
}
@Test
public void testZeroTempBasal() throws DecoderException {
ProgramTempBasalCommand command = new ProgramTempBasalCommand.Builder() //
.setUniqueId(37879809) //
.setNonce(1229869870) //
.setSequenceNumber((short) 7) //
.setRateInUnitsPerHour(0.0) //
.setDurationInMinutes((short) 300) //
.setProgramReminder(new ProgramReminder(true, true, (byte) 0)) //
.build();
assertArrayEquals(Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000AEB49D20001DE"), command.getEncoded());
}
}

View file

@ -0,0 +1,36 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class ProgramTempBasalCommandTest {
@Test @Throws(DecoderException::class) fun testExtraAlternateSegmentPulseTempBasal() {
val command = ProgramTempBasalCommand.Builder() //
.setUniqueId(37879809) //
.setNonce(1229869870) //
.setSequenceNumber(15.toShort()) //
.setRateInUnitsPerHour(5.05) //
.setDurationInMinutes(60.toShort()) //
.setProgramReminder(ProgramReminder(false, true, 0.toByte())) //
.build()
Assert.assertArrayEquals(Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6"), command.encoded)
}
@Test @Throws(DecoderException::class) fun testZeroTempBasal() {
val command = ProgramTempBasalCommand.Builder() //
.setUniqueId(37879809) //
.setNonce(1229869870) //
.setSequenceNumber(7.toShort()) //
.setRateInUnitsPerHour(0.0) //
.setDurationInMinutes(300.toShort()) //
.setProgramReminder(ProgramReminder(true, true, 0.toByte())) //
.build()
Assert.assertArrayEquals(Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000AEB49D20001DE"), command.encoded)
}
}

View file

@ -1,26 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import java.util.Date;
import static org.junit.Assert.assertArrayEquals;
public class SetUniqueIdCommandTest {
@Test
public void testEncoding() throws DecoderException {
@SuppressWarnings("deprecation")
byte[] encoded = new SetUniqueIdCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber((short) 6) //
.setLotNumber(135556289) //
.setPodSequenceNumber(681767) //
.setInitializationTime(new Date(2021, 1, 10, 14, 41)) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344"), encoded);
}
}

View file

@ -0,0 +1,23 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
import java.util.*
class SetUniqueIdCommandTest {
@Test @Throws(DecoderException::class) fun testEncoding() {
val encoded = SetUniqueIdCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber(6.toShort()) //
.setLotNumber(135556289) //
.setPodSequenceNumber(681767) //
.setInitializationTime(Date(2021, 1, 10, 14, 41)) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344"), encoded)
}
}

View file

@ -1,24 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
public class SilenceAlertsCommandTest {
@Test
public void testSilenceLowReservoirAlert() throws DecoderException {
byte[] encoded = new SilenceAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber((short) 1) //
.setNonce(1229869870) //
.setSilenceLowReservoirAlert(true) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("0242000304071105494E532E1081CE"), encoded);
}
// TODO capture more silence alerts commands
}

View file

@ -0,0 +1,23 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class SilenceAlertsCommandTest {
@Test @Throws(DecoderException::class) fun testSilenceLowReservoirAlert() {
val encoded = SilenceAlertsCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber(1.toShort()) //
.setNonce(1229869870) //
.setSilenceLowReservoirAlert(true) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("0242000304071105494E532E1081CE"), encoded)
}
// TODO capture more silence alerts commands
}

View file

@ -1,41 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType;
import static org.junit.Assert.assertArrayEquals;
public class StopDeliveryCommandTest {
@Test
public void testStopTempBasal() throws DecoderException {
byte[] encoded = new StopDeliveryCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber((short) 0) //
.setNonce(1229869870) //
.setDeliveryType(StopDeliveryCommand.DeliveryType.TEMP_BASAL) //
.setBeepType(BeepType.LONG_SINGLE_BEEP) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("0242000300071F05494E532E6201B1"), encoded);
}
@Test
public void testSuspendDelivery() throws DecoderException {
byte[] encoded = new StopDeliveryCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber((short) 2) //
.setNonce(1229869870) //
.setDeliveryType(StopDeliveryCommand.DeliveryType.ALL) //
.setBeepType(BeepType.SILENT) //
.build() //
.getEncoded();
assertArrayEquals(Hex.decodeHex("0242000308071F05494E532E078287"), encoded);
}
// TODO test cancel bolus
}

View file

@ -0,0 +1,38 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class StopDeliveryCommandTest {
@Test @Throws(DecoderException::class) fun testStopTempBasal() {
val encoded = StopDeliveryCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber(0.toShort()) //
.setNonce(1229869870) //
.setDeliveryType(StopDeliveryCommand.DeliveryType.TEMP_BASAL) //
.setBeepType(BeepType.LONG_SINGLE_BEEP) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("0242000300071F05494E532E6201B1"), encoded)
}
@Test @Throws(DecoderException::class) fun testSuspendDelivery() {
val encoded = StopDeliveryCommand.Builder() //
.setUniqueId(37879811) //
.setSequenceNumber(2.toShort()) //
.setNonce(1229869870) //
.setDeliveryType(StopDeliveryCommand.DeliveryType.ALL) //
.setBeepType(BeepType.SILENT) //
.build() //
.encoded
Assert.assertArrayEquals(Hex.decodeHex("0242000308071F05494E532E078287"), encoded)
}
// TODO test cancel bolus
}

View file

@ -1,56 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
public class AlarmStatusResponseTest {
@Test
public void testValidResponse() throws DecoderException {
byte[] encoded = Hex.decodeHex("021602080100000501BD00000003FF01950000000000670A");
AlarmStatusResponse response = new AlarmStatusResponse(encoded);
assertArrayEquals(encoded, response.getEncoded());
assertNotSame(encoded, response.getEncoded());
assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE, response.getResponseType());
assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE.getValue(), response.getMessageType());
assertEquals(ResponseType.AdditionalStatusResponseType.ALARM_STATUS, response.getStatusResponseType());
assertEquals(ResponseType.AdditionalStatusResponseType.ALARM_STATUS.getValue(), response.getAdditionalStatusResponseType());
assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.getPodStatus());
assertEquals(DeliveryStatus.BASAL_ACTIVE, response.getDeliveryStatus());
assertEquals((short) 0, response.getBolusPulsesRemaining());
assertEquals((short) 5, response.getSequenceNumberOfLastProgrammingCommand());
assertEquals((short) 445, response.getTotalPulsesDelivered());
assertEquals(AlarmType.NONE, response.getAlarmType());
assertEquals((short) 0, response.getAlarmTime());
assertEquals((short) 1023, response.getReservoirPulsesRemaining());
assertEquals((short) 405, response.getMinutesSinceActivation());
assertFalse(response.isAlert0Active());
assertFalse(response.isAlert1Active());
assertFalse(response.isAlert2Active());
assertFalse(response.isAlert3Active());
assertFalse(response.isAlert4Active());
assertFalse(response.isAlert5Active());
assertFalse(response.isAlert6Active());
assertFalse(response.isAlert7Active());
assertFalse(response.isOcclusionAlarm());
assertFalse(response.isPulseInfoInvalid());
assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred());
assertFalse(response.isImmediateBolusWhenAlarmOccurred());
assertEquals((byte) 0x00, response.getOcclusionType());
assertFalse(response.isOccurredWhenFetchingImmediateBolusActiveInformation());
assertEquals(0, response.getRssi());
assertEquals(0, response.getReceiverLowerGain());
assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred2());
assertEquals((short) 26378, response.getReturnAddressOfPodAlarmHandlerCaller());
}
}

View file

@ -0,0 +1,52 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class AlarmStatusResponseTest {
@Test @Throws(DecoderException::class) fun testValidResponse() {
val encoded = Hex.decodeHex("021602080100000501BD00000003FF01950000000000670A")
val response = AlarmStatusResponse(encoded)
Assert.assertArrayEquals(encoded, response.encoded)
Assert.assertNotSame(encoded, response.encoded)
Assert.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE, response.responseType)
Assert.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE.getValue(), response.getMessageType())
Assert.assertEquals(ResponseType.AdditionalStatusResponseType.ALARM_STATUS, response.statusResponseType)
Assert.assertEquals(ResponseType.AdditionalStatusResponseType.ALARM_STATUS.getValue(), response.getAdditionalStatusResponseType())
Assert.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.getPodStatus())
Assert.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.getDeliveryStatus())
Assert.assertEquals(0.toShort(), response.getBolusPulsesRemaining())
Assert.assertEquals(5.toShort(), response.getSequenceNumberOfLastProgrammingCommand())
Assert.assertEquals(445.toShort(), response.getTotalPulsesDelivered())
Assert.assertEquals(AlarmType.NONE, response.getAlarmType())
Assert.assertEquals(0.toShort(), response.getAlarmTime())
Assert.assertEquals(1023.toShort(), response.getReservoirPulsesRemaining())
Assert.assertEquals(405.toShort(), response.getMinutesSinceActivation())
Assert.assertFalse(response.isAlert0Active())
Assert.assertFalse(response.isAlert1Active())
Assert.assertFalse(response.isAlert2Active())
Assert.assertFalse(response.isAlert3Active())
Assert.assertFalse(response.isAlert4Active())
Assert.assertFalse(response.isAlert5Active())
Assert.assertFalse(response.isAlert6Active())
Assert.assertFalse(response.isAlert7Active())
Assert.assertFalse(response.isOcclusionAlarm())
Assert.assertFalse(response.isPulseInfoInvalid())
Assert.assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred())
Assert.assertFalse(response.isImmediateBolusWhenAlarmOccurred())
Assert.assertEquals(0x00.toByte(), response.getOcclusionType())
Assert.assertFalse(response.isOccurredWhenFetchingImmediateBolusActiveInformation())
Assert.assertEquals(0.toShort(), response.getRssi())
Assert.assertEquals(0.toShort(), response.getReceiverLowerGain())
Assert.assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred2())
Assert.assertEquals(26378.toShort(), response.getReturnAddressOfPodAlarmHandlerCaller())
}
}

View file

@ -1,41 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
public class DefaultStatusResponseTest {
@Test
public void testValidResponse() throws DecoderException {
byte[] encoded = Hex.decodeHex("1D1800A02800000463FF");
DefaultStatusResponse response = new DefaultStatusResponse(encoded);
assertArrayEquals(encoded, response.getEncoded());
assertNotSame(encoded, response.getEncoded());
assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.getResponseType());
assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.getValue(), response.getMessageType());
assertEquals(DeliveryStatus.BASAL_ACTIVE, response.getDeliveryStatus());
assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.getPodStatus());
assertEquals((short) 320, response.getTotalPulsesDelivered());
assertEquals((short) 5, response.getSequenceNumberOfLastProgrammingCommand());
assertEquals((short) 0, response.getBolusPulsesRemaining());
assertFalse(response.isOcclusionAlertActive());
assertFalse(response.isAlert1Active());
assertFalse(response.isAlert2Active());
assertFalse(response.isAlert3Active());
assertFalse(response.isAlert4Active());
assertFalse(response.isAlert5Active());
assertFalse(response.isAlert6Active());
assertFalse(response.isAlert7Active());
assertEquals((short) 280, response.getMinutesSinceActivation());
assertEquals((short) 1023, response.getReservoirPulsesRemaining());
}
}

View file

@ -0,0 +1,36 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class DefaultStatusResponseTest {
@Test @Throws(DecoderException::class) fun testValidResponse() {
val encoded = Hex.decodeHex("1D1800A02800000463FF")
val response = DefaultStatusResponse(encoded)
Assert.assertArrayEquals(encoded, response.encoded)
Assert.assertNotSame(encoded, response.encoded)
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType)
Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.getValue(), response.getMessageType())
Assert.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.getDeliveryStatus())
Assert.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.getPodStatus())
Assert.assertEquals(320.toShort(), response.getTotalPulsesDelivered())
Assert.assertEquals(5.toShort(), response.getSequenceNumberOfLastProgrammingCommand())
Assert.assertEquals(0.toShort(), response.getBolusPulsesRemaining())
Assert.assertFalse(response.isOcclusionAlertActive())
Assert.assertFalse(response.isAlert1Active())
Assert.assertFalse(response.isAlert2Active())
Assert.assertFalse(response.isAlert3Active())
Assert.assertFalse(response.isAlert4Active())
Assert.assertFalse(response.isAlert5Active())
Assert.assertFalse(response.isAlert6Active())
Assert.assertFalse(response.isAlert7Active())
Assert.assertEquals(280.toShort(), response.getMinutesSinceActivation())
Assert.assertEquals(1023.toShort(), response.getReservoirPulsesRemaining())
}
}

View file

@ -1,30 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.NakErrorType;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
public class NakResponseTest {
@Test
public void testValidResponse() throws DecoderException {
byte[] encoded = Hex.decodeHex("0603070009");
NakResponse response = new NakResponse(encoded);
assertArrayEquals(encoded, response.getEncoded());
assertNotSame(encoded, response.getEncoded());
assertEquals(ResponseType.NAK_RESPONSE, response.getResponseType());
assertEquals(ResponseType.NAK_RESPONSE.getValue(), response.getMessageType());
assertEquals(NakErrorType.ILLEGAL_PARAM, response.getNakErrorType());
assertEquals(AlarmType.NONE, response.getAlarmType());
assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.getPodStatus());
assertEquals((byte) 0x00, response.getSecurityNakSyncCount());
}
}

View file

@ -0,0 +1,27 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.NakErrorType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class NakResponseTest {
@Test @Throws(DecoderException::class) fun testValidResponse() {
val encoded = Hex.decodeHex("0603070009")
val response = NakResponse(encoded)
Assert.assertArrayEquals(encoded, response.encoded)
Assert.assertNotSame(encoded, response.encoded)
Assert.assertEquals(ResponseType.NAK_RESPONSE, response.responseType)
Assert.assertEquals(ResponseType.NAK_RESPONSE.getValue(), response.getMessageType())
Assert.assertEquals(NakErrorType.ILLEGAL_PARAM, response.getNakErrorType())
Assert.assertEquals(AlarmType.NONE, response.getAlarmType())
Assert.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.getPodStatus())
Assert.assertEquals(0x00.toShort(), response.getSecurityNakSyncCount())
}
}

View file

@ -1,44 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
public class SetUniqueIdResponseTest {
@Test
public void testValidResponse() throws DecoderException {
byte[] encoded = Hex.decodeHex("011B13881008340A50040A00010300040308146CC1000954D402420001");
SetUniqueIdResponse response = new SetUniqueIdResponse(encoded);
assertArrayEquals(encoded, response.getEncoded());
assertNotSame(encoded, response.getEncoded());
assertEquals(ResponseType.ACTIVATION_RESPONSE, response.getResponseType());
assertEquals(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, response.getActivationResponseType());
assertEquals(ResponseType.ACTIVATION_RESPONSE.getValue(), response.getMessageType());
assertEquals(27, response.getMessageLength());
assertEquals(5000, response.getPulseVolumeInTenThousandthMicroLiter());
assertEquals(16, response.getDeliveryRate());
assertEquals(8, response.getPrimeRate());
assertEquals(52, response.getNumberOfEngagingClutchDrivePulses());
assertEquals(10, response.getNumberOfPrimePulses());
assertEquals(80, response.getPodExpirationTimeInHours());
assertEquals(4, response.getFirmwareVersionMajor());
assertEquals(10, response.getFirmwareVersionMinor());
assertEquals(0, response.getFirmwareVersionInterim());
assertEquals(1, response.getBleVersionMajor());
assertEquals(3, response.getBleVersionMinor());
assertEquals(0, response.getBleVersionInterim());
assertEquals(4, response.getProductId());
assertEquals(PodStatus.UID_SET, response.getPodStatus());
assertEquals(135556289L, response.getLotNumber());
assertEquals(611540L, response.getPodSequenceNumber());
assertEquals(37879809L, response.getUniqueIdReceivedInCommand());
}
}

View file

@ -0,0 +1,40 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class SetUniqueIdResponseTest {
@Test @Throws(DecoderException::class) fun testValidResponse() {
val encoded = Hex.decodeHex("011B13881008340A50040A00010300040308146CC1000954D402420001")
val response = SetUniqueIdResponse(encoded)
Assert.assertArrayEquals(encoded, response.encoded)
Assert.assertNotSame(encoded, response.encoded)
Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType)
Assert.assertEquals(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, response.activationResponseType)
Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE.getValue(), response.getMessageType())
Assert.assertEquals(27.toShort(), response.getMessageLength())
Assert.assertEquals(5000.toShort(), response.getPulseVolumeInTenThousandthMicroLiter())
Assert.assertEquals(16.toShort(), response.getDeliveryRate())
Assert.assertEquals(8.toShort(), response.getPrimeRate())
Assert.assertEquals(52.toShort(), response.getNumberOfEngagingClutchDrivePulses())
Assert.assertEquals(10.toShort(), response.getNumberOfPrimePulses())
Assert.assertEquals(80.toShort(), response.getPodExpirationTimeInHours())
Assert.assertEquals(4.toShort(), response.getFirmwareVersionMajor())
Assert.assertEquals(10.toShort(), response.getFirmwareVersionMinor())
Assert.assertEquals(0.toShort(), response.getFirmwareVersionInterim())
Assert.assertEquals(1.toShort(), response.getBleVersionMajor())
Assert.assertEquals(3.toShort(), response.getBleVersionMinor())
Assert.assertEquals(0.toShort(), response.getBleVersionInterim())
Assert.assertEquals(4.toShort(), response.getProductId())
Assert.assertEquals(PodStatus.UID_SET, response.getPodStatus())
Assert.assertEquals(135556289L, response.getLotNumber())
Assert.assertEquals(611540L, response.getPodSequenceNumber())
Assert.assertEquals(37879809L, response.getUniqueIdReceivedInCommand())
}
}

View file

@ -1,41 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
public class VersionResponseTest {
@Test
public void testValidResponse() throws DecoderException {
byte[] encoded = Hex.decodeHex("0115040A00010300040208146CC1000954D400FFFFFFFF");
VersionResponse response = new VersionResponse(encoded);
assertArrayEquals(encoded, response.getEncoded());
assertNotSame(encoded, response.getEncoded());
assertEquals(ResponseType.ACTIVATION_RESPONSE, response.getResponseType());
assertEquals(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE, response.getActivationResponseType());
assertEquals(ResponseType.ACTIVATION_RESPONSE.getValue(), response.getMessageType());
assertEquals(21, response.getMessageLength());
assertEquals(4, response.getFirmwareVersionMajor());
assertEquals(10, response.getFirmwareVersionMinor());
assertEquals(0, response.getFirmwareVersionInterim());
assertEquals(1, response.getBleVersionMajor());
assertEquals(3, response.getBleVersionMinor());
assertEquals(0, response.getBleVersionInterim());
assertEquals(4, response.getProductId());
assertEquals(PodStatus.FILLED, response.getPodStatus());
assertEquals(135556289, response.getLotNumber());
assertEquals(611540, response.getPodSequenceNumber());
assertEquals(0L, response.getRssi());
assertEquals(0L, response.getReceiverLowerGain());
assertEquals(4294967295L, response.getUniqueIdReceivedInCommand());
}
}

View file

@ -0,0 +1,36 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType
import org.apache.commons.codec.DecoderException
import org.apache.commons.codec.binary.Hex
import org.junit.Assert
import org.junit.Test
class VersionResponseTest {
@Test @Throws(DecoderException::class) fun testValidResponse() {
val encoded = Hex.decodeHex("0115040A00010300040208146CC1000954D400FFFFFFFF")
val response = VersionResponse(encoded)
Assert.assertArrayEquals(encoded, response.encoded)
Assert.assertNotSame(encoded, response.encoded)
Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType)
Assert.assertEquals(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE, response.activationResponseType)
Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE.getValue(), response.getMessageType())
Assert.assertEquals(21.toShort(), response.getMessageLength())
Assert.assertEquals(4.toShort(), response.getFirmwareVersionMajor())
Assert.assertEquals(10.toShort(), response.getFirmwareVersionMinor())
Assert.assertEquals(0.toShort(), response.getFirmwareVersionInterim())
Assert.assertEquals(1.toShort(), response.getBleVersionMajor())
Assert.assertEquals(3.toShort(), response.getBleVersionMinor())
Assert.assertEquals(0.toShort(), response.getBleVersionInterim())
Assert.assertEquals(4.toShort(), response.getProductId())
Assert.assertEquals(PodStatus.FILLED, response.getPodStatus())
Assert.assertEquals(135556289L, response.getLotNumber())
Assert.assertEquals(611540L, response.getPodSequenceNumber())
Assert.assertEquals(0.toByte(), response.getRssi())
Assert.assertEquals(0.toByte(), response.getReceiverLowerGain())
Assert.assertEquals(4294967295L, response.getUniqueIdReceivedInCommand())
}
}