DeviceTypeManager implements DeviceManager { @Override public boolean updateDeviceProperties(DeviceIdentifier deviceId, List<Device.Property> propertyList) throws DeviceManagementException { boolean status = false; if (propertiesExist) { try { if (log.isDebugEnabled()) { log.debug("Getting the details of " + deviceType + " device : '" + deviceId.getId() + "'"); } Device updatedDevice = new Device(); updatedDevice.setDeviceIdentifier(deviceId.getId()); updatedDevice.setProperties(propertyList); deviceTypePluginDAOManager.getDeviceTypeDAOHandler().beginTransaction(); status = deviceTypePluginDAOManager.getDeviceDAO().updateDevice(updatedDevice); deviceTypePluginDAOManager.getDeviceTypeDAOHandler().commitTransaction(); } catch (DeviceTypeMgtPluginException e) { try { deviceTypePluginDAOManager.getDeviceTypeDAOHandler().rollbackTransaction(); } catch (DeviceTypeMgtPluginException transactionException) { String msg = "Error occurred while rolling back transaction for device: " + deviceId.getId(); log.warn(msg, transactionException); } throw new DeviceManagementException( "Error occurred while fetching the " + deviceType + " device: '" + deviceId.getId() + "'", e); } } return status; } 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 updateDeviceProperties method") public void testUpdateDeviceProperties() throws DeviceManagementException { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(customDeviceType, customDeviceType); Device customDevice = customDeviceTypeManager .getDevice(deviceIdentifier); List<Device.Property> list = customDevice.getProperties(); Assert.assertEquals(customDevice.getProperties().size(), 2, "GetDevice call" + " failed in custom deviceTypeManager"); Device.Property property = list.get(0); property.setValue(updatedDeviceTypePropertyValue); customDeviceTypeManager.updateDeviceProperties(deviceIdentifier, list); customDevice = customDeviceTypeManager .getDevice(deviceIdentifier); Assert.assertEquals(customDevice.getProperties().get(0).getValue(), updatedDeviceTypePropertyValue, "GetDevice call" + " failed in custom deviceTypeManager"); }