MsgCheckValue extends MessageBase { @Override public void handleMessage(byte[] bytes) { DanaRPump pump = DanaRPump.getInstance(); pump.isNewPump = true; if (L.isEnabled(L.PUMPCOMM)) log.debug("New firmware confirmed"); pump.model = intFromBuff(bytes, 0, 1); pump.protocol = intFromBuff(bytes, 1, 1); pump.productCode = intFromBuff(bytes, 2, 1); if (pump.model != DanaRPump.EXPORT_MODEL) { DanaRPlugin.getPlugin().disconnect("Wrong Model"); log.debug("Wrong model selected"); } if (L.isEnabled(L.PUMPCOMM)) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); } } MsgCheckValue(); @Override void handleMessage(byte[] bytes);  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); Treatment t = new Treatment(); MsgCheckValue packet = new MsgCheckValue(); packet.handleMessage(createArray(34, (byte) 3)); DanaRPump pump = DanaRPump.getInstance(); assertEquals(DanaRPump.EXPORT_MODEL, pump.model); }