MsgStatusAPS_v2 extends MessageBase { public void handleMessage(byte[] bytes) { double iob = intFromBuff(bytes, 0, 2) / 100d; double deliveredSoFar = intFromBuff(bytes, 2, 2) / 100d; DanaRPump pump = DanaRPump.getInstance(); pump.iob = iob; if (L.isEnabled(L.PUMPCOMM)) { log.debug("Delivered so far: " + deliveredSoFar); log.debug("Current pump IOB: " + iob); } } MsgStatusAPS_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){ } MsgStatusAPS_v2 packet = new MsgStatusAPS_v2(); byte[] testArray = createArray(34, (byte) 7); double iob = MessageBase.intFromBuff(testArray, 0, 2) / 100d; packet.handleMessage(testArray); DanaRPump pump = DanaRPump.getInstance(); assertEquals(iob, pump.iob, 0); }