### Question:
DeviceLogic { public DeviceEntity setNewDeviceName(String deviceUri, String newName) { DeviceEntity deviceToChange = this.deviceRegistry.findDeviceWithUri(deviceUri); if (deviceToChange != null) { deviceToChange.setName(newName); this.deviceRegistry.save(deviceToChange); return deviceToChange; } return null; }  List<DeviceEntity> getDevices(); String setDevice(int deviceNumber); boolean setDevice(String deviceUri); DeviceEntity setNewDeviceName(String deviceUri, String newName);  }### Answer:
@Test public void testSetNewName() { DeviceEntity entity = new DeviceEntity("Computer", DEVICE_NAME1, ID1); when(this.registry.findDeviceWithUri(ID1)).thenReturn(entity); assertThat(this.deviceLogic.setNewDeviceName(ID1, DEVICE_NAME2).getName(), equalTo(DEVICE_NAME2)); verify(this.registry).save(entity); }
@Test public void testSetNewNameNotinReg() { DeviceEntity entity = new DeviceEntity("Computer", DEVICE_NAME1, ID1); when(this.registry.findDeviceWithUri(ID1)).thenReturn(null); assertThat(this.deviceLogic.setNewDeviceName(ID1, DEVICE_NAME2), equalTo(null)); }