@Test public void testGetDevicesOneInRegistry() { DeviceEntity entity = new DeviceEntity("Computer", DEVICE_NAME1, ID1); when(this.spotifyAPICalls.getDevices()).thenReturn(devices); when(this.registry.findDeviceWithUri(ID1)).thenReturn(entity); List<DeviceEntity> result = this.deviceLogic.getDevices(); assertThat(result.get(0).getName(), equalTo(DEVICE_NAME1)); assertThat(result.get(1).getName(), equalTo(DEVICE_NAME2)); verify(this.spotifyAPICalls).getDevices(); }
public List<DeviceEntity> getDevices() { List<DeviceEntity> devicesList = new ArrayList<>(); Device[] devices = this.spotifyAPICalls.getDevices(); if (devices != null) { for (Device device : devices) { DeviceEntity deviceData; deviceData = new DeviceEntity(device.getType(), device.getName(), device.getId()); if (this.deviceRegistry.findDeviceWithUri(device.getId()) != null) { deviceData = this.deviceRegistry.findDeviceWithUri(device.getId()); } else { this.deviceRegistry.save(deviceData); } devicesList.add(deviceData); } } return devicesList; }
DeviceLogic { public List<DeviceEntity> getDevices() { List<DeviceEntity> devicesList = new ArrayList<>(); Device[] devices = this.spotifyAPICalls.getDevices(); if (devices != null) { for (Device device : devices) { DeviceEntity deviceData; deviceData = new DeviceEntity(device.getType(), device.getName(), device.getId()); if (this.deviceRegistry.findDeviceWithUri(device.getId()) != null) { deviceData = this.deviceRegistry.findDeviceWithUri(device.getId()); } else { this.deviceRegistry.save(deviceData); } devicesList.add(deviceData); } } return devicesList; } }
DeviceLogic { public List<DeviceEntity> getDevices() { List<DeviceEntity> devicesList = new ArrayList<>(); Device[] devices = this.spotifyAPICalls.getDevices(); if (devices != null) { for (Device device : devices) { DeviceEntity deviceData; deviceData = new DeviceEntity(device.getType(), device.getName(), device.getId()); if (this.deviceRegistry.findDeviceWithUri(device.getId()) != null) { deviceData = this.deviceRegistry.findDeviceWithUri(device.getId()); } else { this.deviceRegistry.save(deviceData); } devicesList.add(deviceData); } } return devicesList; }  }
DeviceLogic { public List<DeviceEntity> getDevices() { List<DeviceEntity> devicesList = new ArrayList<>(); Device[] devices = this.spotifyAPICalls.getDevices(); if (devices != null) { for (Device device : devices) { DeviceEntity deviceData; deviceData = new DeviceEntity(device.getType(), device.getName(), device.getId()); if (this.deviceRegistry.findDeviceWithUri(device.getId()) != null) { deviceData = this.deviceRegistry.findDeviceWithUri(device.getId()); } else { this.deviceRegistry.save(deviceData); } devicesList.add(deviceData); } } return devicesList; }  List<DeviceEntity> getDevices(); String setDevice(int deviceNumber); boolean setDevice(String deviceUri); DeviceEntity setNewDeviceName(String deviceUri, String newName); }
DeviceLogic { public List<DeviceEntity> getDevices() { List<DeviceEntity> devicesList = new ArrayList<>(); Device[] devices = this.spotifyAPICalls.getDevices(); if (devices != null) { for (Device device : devices) { DeviceEntity deviceData; deviceData = new DeviceEntity(device.getType(), device.getName(), device.getId()); if (this.deviceRegistry.findDeviceWithUri(device.getId()) != null) { deviceData = this.deviceRegistry.findDeviceWithUri(device.getId()); } else { this.deviceRegistry.save(deviceData); } devicesList.add(deviceData); } } return devicesList; }  List<DeviceEntity> getDevices(); String setDevice(int deviceNumber); boolean setDevice(String deviceUri); DeviceEntity setNewDeviceName(String deviceUri, String newName);  }