MsgSettingPumpTime extends MessageBase { public void handleMessage(byte[] bytes) { long time = new Date( 100 + intFromBuff(bytes, 5, 1), intFromBuff(bytes, 4, 1) - 1, intFromBuff(bytes, 3, 1), intFromBuff(bytes, 2, 1), intFromBuff(bytes, 1, 1), intFromBuff(bytes, 0, 1) ).getTime(); if (L.isEnabled(L.PUMPCOMM)) log.debug("Pump time: " + DateUtil.dateAndTimeFullString(time) + " Phone time: " + new Date()); DanaRPump.getInstance().pumpTime = time; } MsgSettingPumpTime(); void handleMessage(byte[] bytes); @Override void handleMessageNotReceived();  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); MsgSettingPumpTime packet = new MsgSettingPumpTime(); DanaRPump pump = DanaRPump.getInstance(); pump.units = DanaRPump.UNITS_MGDL; byte[] bytes = createArray(34, (byte) 7); long time = new Date( 100 + MessageBase.intFromBuff(bytes, 5, 1), MessageBase.intFromBuff(bytes, 4, 1) - 1, MessageBase.intFromBuff(bytes, 3, 1), MessageBase.intFromBuff(bytes, 2, 1), MessageBase.intFromBuff(bytes, 1, 1), MessageBase.intFromBuff(bytes, 0, 1) ).getTime(); packet.handleMessage(bytes); pump = DanaRPump.getInstance(); assertEquals(time, pump.pumpTime); }