@Test public void createTwoDeviceAndAssert() throws Exception { beginTx(); createTwoDevices(); List<Device> deviceList = m_deviceDao.findAll(); assertEquals(2, deviceList.size()); assertEquals(DEVICE_A, m_deviceDao.getDeviceByName(DEVICE_A).getDeviceName()); assertEquals(DEVICE_B, m_deviceDao.getDeviceByName(DEVICE_B).getDeviceName()); assertNull(m_deviceDao.getDeviceByName(DEVICE_C)); m_deviceDao.deleteAll(); closeTx(); }
@Override public Device getDeviceByName(String deviceName) { EntityDataStoreManager entityDataStoreManager = getPersistenceManager(); Map<String, Object> matchedValues = new HashMap<String, Object>(); matchedValues.put(JPAEntityDataStoreManager.buildQueryPath(DEVICE_NAME), deviceName); List<Device> devices = entityDataStoreManager.findByMatchValue(Device.class, matchedValues); if (devices != null && !devices.isEmpty()) { return devices.get(0); } return null; }
DeviceDaoImpl extends AbstractDao<Device, DevicePK> implements DeviceDao { @Override public Device getDeviceByName(String deviceName) { EntityDataStoreManager entityDataStoreManager = getPersistenceManager(); Map<String, Object> matchedValues = new HashMap<String, Object>(); matchedValues.put(JPAEntityDataStoreManager.buildQueryPath(DEVICE_NAME), deviceName); List<Device> devices = entityDataStoreManager.findByMatchValue(Device.class, matchedValues); if (devices != null && !devices.isEmpty()) { return devices.get(0); } return null; } }
DeviceDaoImpl extends AbstractDao<Device, DevicePK> implements DeviceDao { @Override public Device getDeviceByName(String deviceName) { EntityDataStoreManager entityDataStoreManager = getPersistenceManager(); Map<String, Object> matchedValues = new HashMap<String, Object>(); matchedValues.put(JPAEntityDataStoreManager.buildQueryPath(DEVICE_NAME), deviceName); List<Device> devices = entityDataStoreManager.findByMatchValue(Device.class, matchedValues); if (devices != null && !devices.isEmpty()) { return devices.get(0); } return null; } DeviceDaoImpl(PersistenceManagerUtil persistenceManagerUtil); }
DeviceDaoImpl extends AbstractDao<Device, DevicePK> implements DeviceDao { @Override public Device getDeviceByName(String deviceName) { EntityDataStoreManager entityDataStoreManager = getPersistenceManager(); Map<String, Object> matchedValues = new HashMap<String, Object>(); matchedValues.put(JPAEntityDataStoreManager.buildQueryPath(DEVICE_NAME), deviceName); List<Device> devices = entityDataStoreManager.findByMatchValue(Device.class, matchedValues); if (devices != null && !devices.isEmpty()) { return devices.get(0); } return null; } DeviceDaoImpl(PersistenceManagerUtil persistenceManagerUtil); @Override List<Device> findAllDevices(); @Override Device getDeviceByName(String deviceName); @Override Device findDeviceWithDuid(String duid); @Override DeviceState getDeviceState(String deviceName); @Override void updateDeviceAlignmentState(String deviceName, String verdict); }
DeviceDaoImpl extends AbstractDao<Device, DevicePK> implements DeviceDao { @Override public Device getDeviceByName(String deviceName) { EntityDataStoreManager entityDataStoreManager = getPersistenceManager(); Map<String, Object> matchedValues = new HashMap<String, Object>(); matchedValues.put(JPAEntityDataStoreManager.buildQueryPath(DEVICE_NAME), deviceName); List<Device> devices = entityDataStoreManager.findByMatchValue(Device.class, matchedValues); if (devices != null && !devices.isEmpty()) { return devices.get(0); } return null; } DeviceDaoImpl(PersistenceManagerUtil persistenceManagerUtil); @Override List<Device> findAllDevices(); @Override Device getDeviceByName(String deviceName); @Override Device findDeviceWithDuid(String duid); @Override DeviceState getDeviceState(String deviceName); @Override void updateDeviceAlignmentState(String deviceName, String verdict); static final String DEVICE_NAME; }