MsgError extends MessageBase { @Override public void handleMessage(byte[] bytes) { int errorCode = intFromBuff(bytes, 0, 1); String errorString = ""; switch (errorCode) { case 1: case 2: case 3: errorString = MainApp.gs(R.string.pumperror) + " " + errorCode; break; case 4: errorString = MainApp.gs(R.string.pumpshutdown); break; case 5: errorString = MainApp.gs(R.string.occlusion); break; case 7: errorString = MainApp.gs(R.string.lowbattery); break; case 8: errorString = MainApp.gs(R.string.batterydischarged); break; } if (errorCode < 8) { EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE; MsgBolusStop.stopped = true; bolusingEvent.setStatus(errorString); RxBus.INSTANCE.send(bolusingEvent); failed=true; } if (L.isEnabled(L.PUMPCOMM)) log.debug("Error detected: " + errorString); NSUpload.uploadError(errorString); } MsgError(); @Override void handleMessage(byte[] bytes);  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); AAPSMocker.mockNSUpload(); MsgError packet = new MsgError(); packet.handleMessage(createArray(34, (byte) 1)); assertEquals(true, packet.failed); packet = new MsgError(); packet.handleMessage(createArray(34, (byte) 10)); assertEquals(false, packet.failed); }