DeviceDaoImpl implements DeviceDao { @Override public Device getDevice(final String deviceId) throws UnknownDeviceException { return Optional.ofNullable(devices.get(deviceId)).orElseThrow(() -> new UnknownDeviceException(deviceId)); } DeviceDaoImpl(); @Override void addDevice(final Device device); @Override boolean removeDevice(final String deviceId); @Override Device getDevice(final String deviceId); @Override Collection<Device> getDevices(); @Override Collection<Device> findDevices(final String hostAddress);  }
@Test(expected = UnknownDeviceException.class) public void testGetUnknownDevice() throws UnknownDeviceException { DeviceDaoImpl deviceDao = new DeviceDaoImpl(); deviceDao.getDevice("deviceId"); }