MsgSettingProfileRatios extends MessageBase { public void handleMessage(byte[] bytes) { DanaRPump pump = DanaRPump.getInstance(); if (pump.units == DanaRPump.UNITS_MGDL) { pump.currentCIR = intFromBuff(bytes, 0, 2); pump.currentCF = intFromBuff(bytes, 2, 2); pump.currentAI = intFromBuff(bytes, 4, 2) / 100d; pump.currentTarget = intFromBuff(bytes, 6, 2); pump.currentAIDR = intFromBuff(bytes, 8, 1); } else { pump.currentCIR = intFromBuff(bytes, 0, 2); pump.currentCF = intFromBuff(bytes, 2, 2) / 100d; pump.currentAI = intFromBuff(bytes, 4, 2) / 100d; pump.currentTarget = intFromBuff(bytes, 6, 2) / 100d; pump.currentAIDR = intFromBuff(bytes, 8, 1); } if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump units (saved): " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Current pump CIR: " + pump.currentCIR); log.debug("Current pump CF: " + pump.currentCF); log.debug("Current pump AI: " + pump.currentAI); log.debug("Current pump target: " + pump.currentTarget); log.debug("Current pump AIDR: " + pump.currentAIDR); } } MsgSettingProfileRatios(); void handleMessage(byte[] bytes);  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); MsgSettingProfileRatios packet = new MsgSettingProfileRatios(); DanaRPump pump = DanaRPump.getInstance(); pump.units = DanaRPump.UNITS_MGDL; packet.handleMessage(createArray(34, (byte) 7)); pump = DanaRPump.getInstance(); assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 0, 2), pump.currentCIR,0); }