DeviceTypeManager implements DeviceManager { @Override public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { if (deviceId == null) { throw new DeviceManagementException("Cannot get the device. DeviceIdentifier is null"); } if (propertiesExist) { Device device; try { if (log.isDebugEnabled()) { log.debug("Getting the details of " + deviceType + " device : '" + deviceId.getId() + "'"); } deviceTypePluginDAOManager.getDeviceTypeDAOHandler().beginTransaction(); device = deviceTypePluginDAOManager.getDeviceDAO().getDevice(deviceId.getId()); } catch (DeviceTypeMgtPluginException e) { throw new DeviceManagementException( "Error occurred while fetching the " + deviceType + " device: '" + deviceId.getId() + "'", e); } finally { try { deviceTypePluginDAOManager.getDeviceTypeDAOHandler().closeConnection(); } catch (DeviceTypeMgtPluginException e) { String msg = "Error occurred while closing the transaction to get device " + deviceId.getId(); log.warn(msg, e); } } return device; } 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 getDevcie method of the DeviceTypeManager", dependsOnMethods = {"testEnrollDevice"}) public void testGetDevice() throws DeviceManagementException { DeviceIdentifier existingDeviceIdntifier = new DeviceIdentifier(sampleDevice2.getDeviceIdentifier(), androidDeviceType); Assert.assertNull(androidDeviceTypeManager.getDevice(nonExistingDeviceIdentifier), "Non existing sampleDevice was retrieved"); Assert.assertNotNull(androidDeviceTypeManager.getDevice(existingDeviceIdntifier), "Existing sampleDevice was not retrieved"); Device customDevice1 = customDeviceTypeManager .getDevice(new DeviceIdentifier(customDeviceType, customDeviceType)); Assert.assertEquals(customDevice1.getProperties().size(), 2, "GetDevice call" + " failed in custom deviceTypeManager"); }