MsgInitConnStatusBolus extends MessageBase { @Override public void handleMessage(byte[] bytes) { if (bytes.length - 10 > 12) { failed = true; return; } DanaRPump pump = DanaRPump.getInstance(); int bolusConfig = intFromBuff(bytes, 0, 1); pump.isExtendedBolusEnabled = (bolusConfig & 0x01) != 0; pump.bolusStep = intFromBuff(bytes, 1, 1) / 100d; pump.maxBolus = intFromBuff(bytes, 2, 2) / 100d; if (L.isEnabled(L.PUMPCOMM)) { log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Bolus increment: " + pump.bolusStep); log.debug("Bolus max: " + pump.maxBolus); } if (!pump.isExtendedBolusEnabled) { Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.gs(R.string.danar_enableextendedbolus), Notification.URGENT); RxBus.INSTANCE.send(new EventNewNotification(notification)); } else { RxBus.INSTANCE.send(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED)); } } MsgInitConnStatusBolus(); @Override void handleMessage(byte[] bytes);  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); MsgInitConnStatusBolus packet = new MsgInitConnStatusBolus(); packet.handleMessage(createArray(34, (byte) 1)); assertEquals(true, packet.failed); packet.handleMessage(createArray(20, (byte) 1)); DanaRPump pump = DanaRPump.getInstance(); assertEquals(true, pump.isExtendedBolusEnabled); }