MsgSettingUserOptions extends MessageBase { public void handleMessage(byte[] packet) { DanaRPump pump = DanaRPump.getInstance(); byte[] bytes = getDataBytes(packet, 0, packet.length - 10); pump.userOptionsFrompump = Arrays.copyOf(bytes, bytes.length); for(int pos=0; pos < bytes.length; pos++) { log.debug("[" + pos + "]" + bytes[pos]); } pump.timeDisplayType = bytes[0] == (byte) 1 ? 0 : 1; pump.buttonScrollOnOff = bytes[1] == (byte) 1 ? 1 : 0; pump.beepAndAlarm = bytes[2]; pump.lcdOnTimeSec = bytes[3] & 255; pump.backlightOnTimeSec = bytes[4] & 255; pump.selectedLanguage = bytes[5]; pump.units = bytes[8]; pump.shutdownHour = bytes[9]; pump.lowReservoirRate = bytes[32] & 255; if (L.isEnabled(L.PUMPCOMM)) { log.debug("timeDisplayType: " + pump.timeDisplayType); log.debug("Button scroll: " + pump.buttonScrollOnOff); log.debug("BeepAndAlarm: " + pump.beepAndAlarm); log.debug("screen timeout: " + pump.lcdOnTimeSec); log.debug("Backlight: " + pump.backlightOnTimeSec); log.debug("Selected language: " + pump.selectedLanguage); log.debug("Units: " + pump.getUnits()); log.debug("Shutdown: " + pump.shutdownHour); log.debug("Low reservoir: " + pump.lowReservoirRate); } } MsgSettingUserOptions(); void handleMessage(byte[] packet); static byte[] getDataBytes(byte[] bytes, int start, int len);  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); MsgSettingUserOptions packet = new MsgSettingUserOptions(); DanaRPump pump = DanaRPump.getInstance(); pump.units = DanaRPump.UNITS_MGDL; packet.handleMessage(createArray(48, (byte) 7)); pump = DanaRPump.getInstance(); assertEquals((byte) 7 & 255 , pump.lcdOnTimeSec); }