MsgBolusStop extends MessageBase { @Override public void handleMessage(byte[] bytes) { if (L.isEnabled(L.PUMPCOMM)) log.debug("Messsage received"); EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE; stopped = true; if (!forced) { t.insulin = amount; bolusingEvent.setStatus(MainApp.gs(R.string.overview_bolusprogress_delivered)); bolusingEvent.setPercent(100); } else { bolusingEvent.setStatus(MainApp.gs(R.string.overview_bolusprogress_stoped)); } RxBus.INSTANCE.send(bolusingEvent); } MsgBolusStop();  MsgBolusStop(Double amount, Treatment t); @Override void handleMessage(byte[] bytes); static boolean stopped; static boolean forced; }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); AAPSMocker.mockStrings(); Treatment t = new Treatment(); MsgBolusStop packet = new MsgBolusStop(1d,t); packet.handleMessage(createArray(34, (byte) 1)); assertEquals(true, packet.stopped); }