DeviceTypeManager implements DeviceManager { @Override public List<Device> getAllDevices() throws DeviceManagementException { if (propertiesExist) { List<Device> devices = null; try { if (log.isDebugEnabled()) { log.debug("Fetching the details of all " + deviceType + " devices"); } deviceTypePluginDAOManager.getDeviceTypeDAOHandler().beginTransaction(); devices = deviceTypePluginDAOManager.getDeviceDAO().getAllDevices(); } catch (DeviceTypeMgtPluginException e) { throw new DeviceManagementException("Error occurred while fetching all " + deviceType + " devices", e); } finally { try { deviceTypePluginDAOManager.getDeviceTypeDAOHandler().closeConnection(); } catch (DeviceTypeMgtPluginException e) { String msg = "Error occurred while closing the transaction to get all devices."; log.warn(msg, e); } } return devices; } return null; } DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
                             DeviceTypeConfiguration deviceTypeConfiguration); @Override FeatureManager getFeatureManager(); @Override boolean saveConfiguration(PlatformConfiguration tenantConfiguration); @Override PlatformConfiguration getConfiguration(); @Override boolean enrollDevice(Device device); @Override boolean modifyEnrollment(Device device); @Override boolean disenrollDevice(DeviceIdentifier deviceId); @Override boolean isEnrolled(DeviceIdentifier deviceId); @Override boolean isActive(DeviceIdentifier deviceId); @Override boolean setActive(DeviceIdentifier deviceId, boolean status); @Override Device getDevice(DeviceIdentifier deviceId); @Override boolean updateDeviceProperties(DeviceIdentifier deviceId, List<Device.Property> propertyList); @Override boolean setOwnership(DeviceIdentifier deviceId, String ownershipType); @Override boolean isClaimable(DeviceIdentifier deviceIdentifier); @Override boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser,
                             EnrolmentInfo.Status status); @Override License getLicense(String languageCode); @Override void addLicense(License license); @Override boolean requireDeviceAuthorization(); @Override boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device); @Override List<Device> getAllDevices();  }
@Test(description = "This test case tests the get all devices method of the DeviceTypeManager", dependsOnMethods = {"testEnrollDevice"}) public void testGetAllDevices() throws DeviceManagementException { Assert.assertEquals(androidDeviceTypeManager.getAllDevices().size(), 1, "All the added devices are not fetched from the database"); Assert.assertEquals(customDeviceTypeManager.getAllDevices().size(), 1, "All the added devices are not fetched from the database"); }