MsgInitConnStatusTime extends MessageBase { @Override public void handleMessage(byte[] bytes) { if (bytes.length - 10 > 7) { Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); RxBus.INSTANCE.send(new EventNewNotification(notification)); DanaRPlugin.getPlugin().disconnect("Wrong Model"); log.error("Wrong model selected. Switching to Korean DanaR"); DanaRKoreanPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true); DanaRKoreanPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, true); DanaRPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, false); DanaRPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, false); DanaRPump.reset(); if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)) { (DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false); (DanaRKoreanPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true); } ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaDriver"); RxBus.INSTANCE.send(new EventRebuildTabs()); ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); failed = false; return; } else { failed = true; } long time = dateTimeSecFromBuff(bytes, 0); int versionCode = intFromBuff(bytes, 6, 1); if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump time: " + DateUtil.dateAndTimeFullString(time)); log.debug("Version code: " + versionCode); } } MsgInitConnStatusTime(); @Override void handleMessage(byte[] bytes);  }
@Test public void runTest() { MsgInitConnStatusTime packet = new MsgInitConnStatusTime(); packet.handleMessage(createArray(20, (byte) 1)); assertEquals(false, packet.failed); packet.handleMessage(createArray(15, (byte) 1)); assertEquals(true, packet.failed); }