MsgSettingMeal extends MessageBase { public void handleMessage(byte[] bytes) { DanaRPump pump = DanaRPump.getInstance(); pump.basalStep = intFromBuff(bytes, 0, 1) / 100d; pump.bolusStep = intFromBuff(bytes, 1, 1) / 100d; boolean bolusEnabled = intFromBuff(bytes, 2, 1) == 1; int melodyTime = intFromBuff(bytes, 3, 1); int blockTime = intFromBuff(bytes, 4, 1); pump.isConfigUD = intFromBuff(bytes, 5, 1) == 1; if (L.isEnabled(L.PUMPCOMM)) { log.debug("Basal step: " + pump.basalStep); log.debug("Bolus step: " + pump.bolusStep); log.debug("Bolus enabled: " + bolusEnabled); log.debug("Melody time: " + melodyTime); log.debug("Block time: " + blockTime); log.debug("Is Config U/d: " + pump.isConfigUD); } if (DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PUMP)) { pump.basalStep = 0.01d; } if (pump.basalStep != 0.01d) { Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.gs(R.string.danar_setbasalstep001), Notification.URGENT); RxBus.INSTANCE.send(new EventNewNotification(notification)); } else { RxBus.INSTANCE.send(new EventDismissNotification(Notification.WRONGBASALSTEP)); } if (pump.isConfigUD) { Notification notification = new Notification(Notification.UD_MODE_ENABLED, MainApp.gs(R.string.danar_switchtouhmode), Notification.URGENT); RxBus.INSTANCE.send(new EventNewNotification(notification)); } else { RxBus.INSTANCE.send(new EventDismissNotification(Notification.UD_MODE_ENABLED)); } } MsgSettingMeal(); void handleMessage(byte[] bytes);  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); MsgSettingMeal packet = new MsgSettingMeal(); packet.handleMessage(createArray(34, (byte) 1)); DanaRPump pump = DanaRPump.getInstance(); assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 1), 0, 1) / 100d, pump.bolusStep, 0); }