Skip to content

Commit

Permalink
failed temp rate test
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoglom committed Dec 27, 2024
1 parent f1cccf1 commit 44bfab4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public static byte[] buildCargo(byte[] raw) {
}


/**
* @return 0 if successful otherwise unsuccessful
*/
public int getStatus() {
return status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public AlertStatusResponse(BigInteger intMap) {
this.intMap = intMap;
}

public AlertStatusResponse(byte[] raw) {
parse(raw);
}

private static byte[] buildCargo(BigInteger byte0uint64) {
return Bytes.toUint64(byte0uint64.longValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static com.jwoglom.pumpx2.pump.messages.MessageTester.assertHexEquals;
import static com.jwoglom.pumpx2.pump.messages.MessageTester.initPumpState;

import static org.junit.Assert.assertEquals;

import com.jwoglom.pumpx2.pump.messages.MessageTester;
import com.jwoglom.pumpx2.pump.messages.PacketArrayList;
import com.jwoglom.pumpx2.pump.messages.bluetooth.CharacteristicUUID;
Expand Down Expand Up @@ -40,4 +42,16 @@ public void testSetTempRateResponse_101pct_15min() throws DecoderException {
);
assertHexEquals(expected.getCargo(), parsedReq.getCargo());
}


@Test
public void testSetTempRateResponse_failed() throws DecoderException {
initPumpState(PacketArrayList.IGNORE_INVALID_HMAC, 0L);

SetTempRateResponse expected = new SetTempRateResponse(
new byte[]{1,0,0,1}
);

assertEquals(1, expected.getStatus());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.jwoglom.pumpx2.pump.messages.response.currentStatus;

import static com.jwoglom.pumpx2.pump.messages.response.currentStatus.AlertStatusResponse.AlertResponseType.CGM_GRAPH_REMOVED;
import static org.junit.Assert.assertEquals;

import com.google.common.collect.ImmutableSet;
import com.jwoglom.pumpx2.pump.messages.MessageTester;
import com.jwoglom.pumpx2.pump.messages.bluetooth.CharacteristicUUID;

Expand Down Expand Up @@ -44,7 +48,6 @@ public void testAlertStatusWithDevicePaired() throws DecoderException {

@Test
public void testAlertStatusWithIncompleteCartridgeChange() throws DecoderException {
// empty cargo
AlertStatusResponse expected = new AlertStatusResponse(
AlertStatusResponse.AlertResponseType.INCOMPLETE_CARTRIDGE_CHANGE_ALERT.withBit());

Expand All @@ -58,4 +61,12 @@ public void testAlertStatusWithIncompleteCartridgeChange() throws DecoderExcepti

MessageTester.assertHexEquals(expected.getCargo(), parsedReq.getCargo());
}
@Test
public void testAlertStatusWithCgmGraphRemoved() {
AlertStatusResponse parsed = new AlertStatusResponse(
new byte[]{0,0,0,2,0,0,0,0}
);

assertEquals(ImmutableSet.of(AlertStatusResponse.AlertResponseType.CGM_GRAPH_REMOVED), parsed.getAlerts());
}
}

0 comments on commit 44bfab4

Please sign in to comment.