MsgStatusBolusExtended_v2 extends MessageBase { public void handleMessage(byte[] bytes) { boolean isExtendedInProgress = intFromBuff(bytes, 0, 1) == 1; int extendedBolusHalfHours = intFromBuff(bytes, 1, 1); int extendedBolusMinutes = extendedBolusHalfHours * 30; double extendedBolusAmount = intFromBuff(bytes, 2, 2) / 100d; int extendedBolusSoFarInSecs = intFromBuff(bytes, 4, 3); int extendedBolusSoFarInMinutes = extendedBolusSoFarInSecs / 60; double extendedBolusAbsoluteRate = isExtendedInProgress ? extendedBolusAmount / extendedBolusMinutes * 60 : 0d; long extendedBolusStart = isExtendedInProgress ? getDateFromSecAgo(extendedBolusSoFarInSecs) : 0; int extendedBolusRemainingMinutes = extendedBolusMinutes - extendedBolusSoFarInMinutes; DanaRPump pump = DanaRPump.getInstance(); pump.isExtendedInProgress = isExtendedInProgress; pump.extendedBolusMinutes = extendedBolusMinutes; pump.extendedBolusAmount = extendedBolusAmount; pump.extendedBolusSoFarInMinutes = extendedBolusSoFarInMinutes; pump.extendedBolusAbsoluteRate = extendedBolusAbsoluteRate; pump.extendedBolusStart = extendedBolusStart; pump.extendedBolusRemainingMinutes = extendedBolusRemainingMinutes; if (L.isEnabled(L.PUMPCOMM)) { log.debug("Is extended bolus running: " + isExtendedInProgress); log.debug("Extended bolus min: " + extendedBolusMinutes); log.debug("Extended bolus amount: " + extendedBolusAmount); log.debug("Extended bolus so far in minutes: " + extendedBolusSoFarInMinutes); log.debug("Extended bolus absolute rate: " + extendedBolusAbsoluteRate); log.debug("Extended bolus start: " + extendedBolusStart); log.debug("Extended bolus remaining minutes: " + extendedBolusRemainingMinutes); } } MsgStatusBolusExtended_v2(); void handleMessage(byte[] bytes);  }
@Test public void runTest() throws Exception{ AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); try { AAPSMocker.mockTreatmentService(); } catch (Exception e){ } MsgStatusBolusExtended_v2 packet = new MsgStatusBolusExtended_v2(); packet.handleMessage(createArray(34, (byte) 7)); DanaRPump pump = DanaRPump.getInstance(); assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 2, 2)/100d, pump.extendedBolusAmount,0); }