MsgSettingBasal extends MessageBase { public void handleMessage(byte[] bytes) { DanaRPump pump = DanaRPump.getInstance(); if (pump.pumpProfiles == null) pump.pumpProfiles = new double[4][]; pump.pumpProfiles[pump.activeProfile] = new double[24]; for (int index = 0; index < 24; index++) { int basal = intFromBuff(bytes, 2 * index, 2); if (basal < DanaRPlugin.getPlugin().pumpDescription.basalMinimumRate) basal = 0; pump.pumpProfiles[pump.activeProfile][index] = basal / 100d; } if (L.isEnabled(L.PUMPCOMM)) for (int index = 0; index < 24; index++) { log.debug("Basal " + String.format(Locale.ENGLISH, "%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]); } } MsgSettingBasal(); void handleMessage(byte[] bytes);  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); MsgSettingBasal packet = new MsgSettingBasal(); packet.handleMessage(createArray(100, (byte) 1)); DanaRPump pump = DanaRPump.getInstance(); int expected = MessageBase.intFromBuff(createArray(100, (byte) 1), 2 * 1, 2); assertEquals((double) expected/100d, pump.pumpProfiles[pump.activeProfile][1], 0); }