DeviceDaoImpl implements DeviceDao { @Override public void addDevice(final Device device) { devices.put(device.getId(), device); } 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 public void testAddDevice() throws UnknownDeviceException { Device device = createMock(Device.class); expect(device.getId()).andReturn("deviceId"); replay(device); DeviceDaoImpl deviceDao = new DeviceDaoImpl(); deviceDao.addDevice(device); assertEquals(1, deviceDao.getDevices().size()); assertNotNull(deviceDao.getDevice("deviceId")); verify(device); }