MsgBolusStart extends MessageBase { @Override public void handleMessage(byte[] bytes) { errorCode = intFromBuff(bytes, 0, 1); if (errorCode != 2) { failed = true; if (L.isEnabled(L.PUMPCOMM)) log.debug("Messsage response: " + errorCode + " FAILED!!"); } else { if (L.isEnabled(L.PUMPCOMM)) log.debug("Messsage response: " + errorCode + " OK"); } } MsgBolusStart();  MsgBolusStart(double amount); @Override void handleMessage(byte[] bytes); static int errorCode; }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); MsgBolusStart packet = new MsgBolusStart(); packet.handleMessage(createArray(34, (byte) 1)); assertEquals(true, packet.failed); packet = new MsgBolusStart(); packet.handleMessage(createArray(34, (byte) 2)); assertEquals(false, packet.failed); }