DeviceTypeManager implements DeviceManager { @Override public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { if (propertiesExist) { boolean status; Device existingDevice = this.getDevice(deviceIdentifier); if (existingDevice == null) { return false; } existingDevice.setProperties(device.getProperties()); try { if (log.isDebugEnabled()) { log.debug( "updating the details of " + deviceType + " device : " + device.getDeviceIdentifier()); } deviceTypePluginDAOManager.getDeviceTypeDAOHandler().beginTransaction(); status = deviceTypePluginDAOManager.getDeviceDAO().updateDevice(existingDevice); deviceTypePluginDAOManager.getDeviceTypeDAOHandler().commitTransaction(); } catch (DeviceTypeMgtPluginException e) { try { deviceTypePluginDAOManager.getDeviceTypeDAOHandler().rollbackTransaction(); } catch (DeviceTypeMgtPluginException e1) { log.warn("Error occurred while roll back the update device info transaction : '" + device.toString() + "'", e1); } throw new DeviceManagementException( "Error occurred while updating the " + deviceType + " device: '" + device.getDeviceIdentifier() + "'", e); } return status; } return true; } 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 updateDeviceInfo method") public void testUpdateDeviceInfo() throws DeviceManagementException { DeviceIdentifier existingDeviceIdentifier = new DeviceIdentifier(sampleDevice2.getDeviceIdentifier(), androidDeviceType); Assert.assertFalse(androidDeviceTypeManager.updateDeviceInfo(nonExistingDeviceIdentifier, sampleDevice1), "Non-existing device was updated"); Assert.assertTrue(androidDeviceTypeManager.updateDeviceInfo(existingDeviceIdentifier, sampleDevice1), "Existing device update failed"); }