SessionRecyclerAdapter extends CardRecyclerAdapter { public void setDevices(List<DeviceCard> devices, boolean notify) { updateList(deviceItems, devices, this::findDeviceOffset, notify); } SessionRecyclerAdapter(SessionPresenter presenter);   SessionRecyclerAdapter(); @Override android.databinding.DataBindingComponent getBindingComponent(); @Override void applyAdditionalBinding(Card card, CardViewHolder holder); void setNotifications(List<NotifCard> notifs, boolean notify); void setFolders(List<FolderCard> folders, boolean notify); void setThisDevice(MyDeviceCard myDevice, boolean notify); void setDevices(List<DeviceCard> devices, boolean notify); Card getItem(int pos); @Override int getItemCount(); @Override long getItemId(int position);  }
@Test public void testSetDevices() { List<FolderCard> folders = new LinkedList<>(); folders.add(new FolderCard(null, null, null)); folders.add(new FolderCard(null, null, null)); adapter.setFolders(folders, false); List<DeviceCard> devices = new LinkedList<>(); devices.add(new DeviceCard(null, null, null, null, 0)); devices.add(new DeviceCard(null, null, null, null, 0)); devices.add(new DeviceCard(null, null, null, null, 0)); adapter.setDevices(devices, true); verify(adapter).notifyItemRangeInserted(4,3); }
@Test public void testSetDevicesMore() { List<DeviceCard> devices = new LinkedList<>(); DeviceConfig d1 = new DeviceConfig(); d1.deviceID = "id1"; devices.add(new DeviceCard(null, d1, null, null, 0)); DeviceConfig d2 = new DeviceConfig(); d2.deviceID = "id2"; devices.add(new DeviceCard(null, d2, null, null, 0)); DeviceConfig d3 = new DeviceConfig(); d3.deviceID = "id3"; devices.add(new DeviceCard(null, d3, null, null, 0)); adapter.setDevices(devices, false); List<DeviceCard> devices2 = new LinkedList<>(); DeviceConfig d4 = new DeviceConfig(); d4.deviceID = "id1"; devices2.add(new DeviceCard(null, d4, null, null, 0)); DeviceConfig d5 = new DeviceConfig(); d5.deviceID = "id2"; devices2.add(new DeviceCard(null, d5, null, null, 0)); DeviceConfig d6 = new DeviceConfig(); d6.deviceID = "id3"; devices2.add(new DeviceCard(null, d6, null, null, 0)); DeviceConfig d7 = new DeviceConfig(); d7.deviceID = "id4"; devices2.add(new DeviceCard(null, d7, null, null, 0)); DeviceConfig d8 = new DeviceConfig(); d8.deviceID = "id5"; devices2.add(new DeviceCard(null, d8, null, null, 0)); adapter.setDevices(devices2, true); verify(adapter).notifyItemRangeChanged(2, 3); verify(adapter).notifyItemRangeInserted(5, 2); }
@Test public void testSetDevicesLess() { List<DeviceCard> devices2 = new LinkedList<>(); DeviceConfig d4 = new DeviceConfig(); d4.deviceID = "id1"; devices2.add(new DeviceCard(null, d4, null, null, 0)); DeviceConfig d5 = new DeviceConfig(); d5.deviceID = "id2"; devices2.add(new DeviceCard(null, d5, null, null, 0)); DeviceConfig d6 = new DeviceConfig(); d6.deviceID = "id3"; devices2.add(new DeviceCard(null, d6, null, null, 0)); DeviceConfig d7 = new DeviceConfig(); d7.deviceID = "id4"; devices2.add(new DeviceCard(null, d7, null, null, 0)); DeviceConfig d8 = new DeviceConfig(); d8.deviceID = "id5"; devices2.add(new DeviceCard(null, d8, null, null, 0)); adapter.setDevices(devices2, false); List<DeviceCard> devices = new LinkedList<>(); DeviceConfig d1 = new DeviceConfig(); d1.deviceID = "id1"; devices.add(new DeviceCard(null, d1, null, null, 0)); DeviceConfig d2 = new DeviceConfig(); d2.deviceID = "id2"; devices.add(new DeviceCard(null, d2, null, null, 0)); DeviceConfig d3 = new DeviceConfig(); d3.deviceID = "id3"; devices.add(new DeviceCard(null, d3, null, null, 0)); adapter.setDevices(devices, true); verify(adapter).notifyItemRangeChanged(2, 3); verify(adapter).notifyItemRangeRemoved(5, 2); }