MsgSettingProfileRatiosAll extends MessageBase { public void handleMessage(byte[] bytes) { DanaRPump pump = DanaRPump.getInstance(); if (pump.units == DanaRPump.UNITS_MGDL) { pump.morningCIR = intFromBuff(bytes, 0, 2); pump.morningCF = intFromBuff(bytes, 2, 2); pump.afternoonCIR = intFromBuff(bytes, 4, 2); pump.afternoonCF = intFromBuff(bytes, 6, 2); pump.eveningCIR = intFromBuff(bytes, 8, 2); pump.eveningCF = intFromBuff(bytes, 10, 2); pump.nightCIR = intFromBuff(bytes, 12, 2); pump.nightCF = intFromBuff(bytes, 14, 2); } else { pump.morningCIR = intFromBuff(bytes, 0, 2); pump.morningCF = intFromBuff(bytes, 2, 2) / 100d; pump.afternoonCIR = intFromBuff(bytes, 4, 2); pump.afternoonCF = intFromBuff(bytes, 6, 2) / 100d; pump.eveningCIR = intFromBuff(bytes, 8, 2); pump.eveningCF = intFromBuff(bytes, 10, 2) / 100d; pump.nightCIR = intFromBuff(bytes, 12, 2); pump.nightCF = intFromBuff(bytes, 14, 2) / 100d; } if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Current pump morning CIR: " + pump.morningCIR); log.debug("Current pump morning CF: " + pump.morningCF); log.debug("Current pump afternoon CIR: " + pump.afternoonCIR); log.debug("Current pump afternoon CF: " + pump.afternoonCF); log.debug("Current pump evening CIR: " + pump.eveningCIR); log.debug("Current pump evening CF: " + pump.eveningCF); log.debug("Current pump night CIR: " + pump.nightCIR); log.debug("Current pump night CF: " + pump.nightCF); } pump.createConvertedProfile(); } MsgSettingProfileRatiosAll(); void handleMessage(byte[] bytes);  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); MsgSettingProfileRatiosAll packet = new MsgSettingProfileRatiosAll(); 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.morningCIR,0); }