### Question:
PropertiesAdminService extends RegistryAbstractAdmin implements
        IPropertiesAdminService<PropertiesBean,RetentionBean> { public boolean setRetentionProperties(String path, RetentionBean bean) throws RegistryException { if(path.matches(".*;version:\\d$")) { throw new RegistryException("User is not authorized to change retention properties" + " of resource versions. Resource path = " + path); } UserRegistry registry = (UserRegistry) getRootRegistry(); if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) { return false; } Resource resource = registry.get(path); if (resource.getProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME) != null && !resource.getProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME).equals( registry.getUserName())) { throw new RegistryException("User is not authorized to change retention properties" + " of this resource. Resource path = " + path); } if (bean == null) { resource.removeProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME); resource.removeProperty(CommonConstants.RETENTION_FROM_DATE_PROP_NAME); resource.removeProperty(CommonConstants.RETENTION_TO_DATE_PROP_NAME); resource.removeProperty(CommonConstants.RETENTION_WRITE_LOCKED_PROP_NAME); resource.removeProperty(CommonConstants.RETENTION_DELETE_LOCKED_PROP_NAME); } else { resource.setProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME, registry.getUserName()); resource.setProperty(CommonConstants.RETENTION_FROM_DATE_PROP_NAME, bean.getFromDate()); resource.setProperty(CommonConstants.RETENTION_TO_DATE_PROP_NAME, bean.getToDate()); resource.setProperty(CommonConstants.RETENTION_WRITE_LOCKED_PROP_NAME, String.valueOf(bean.getWriteLocked())); resource.setProperty(CommonConstants.RETENTION_DELETE_LOCKED_PROP_NAME, String.valueOf(bean.getDeleteLocked())); } registry.put(resource.getPath(), resource); return true; }  PropertiesBean getProperties(String path, String viewProps); void setProperty(String path, String name, String value); void updateProperty(String path, String name, String value, String oldName); void removeProperty(String path, String name); boolean setRetentionProperties(String path, RetentionBean bean); RetentionBean getRetentionProperties(String path);  }### Answer:
@Test public void testSetRetentionProperties() throws Exception { System.setProperty("carbon.repo.write.mode", "true"); DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); RetentionBean retentionBean = new RetentionBean(); retentionBean.setDeleteLocked(true); String fromDate = df.format(Calendar.getInstance().getTime()); retentionBean.setFromDate(fromDate); retentionBean.setReadOnly(true); String toDate = df.format(Calendar.getInstance().getTime()); retentionBean.setToDate(toDate); retentionBean.setWriteLocked(true); retentionBean.setUserName("admin"); PropertiesAdminService adminService = new PropertiesAdminService(); assertTrue(adminService.setRetentionProperties(resourcePath, retentionBean)); assertEquals("admin", resource.getProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME)); assertEquals(fromDate, resource.getProperty(CommonConstants.RETENTION_FROM_DATE_PROP_NAME)); assertEquals(toDate, resource.getProperty(CommonConstants.RETENTION_TO_DATE_PROP_NAME)); assertEquals("true", resource.getProperty(CommonConstants.RETENTION_WRITE_LOCKED_PROP_NAME)); assertEquals("true", resource.getProperty(CommonConstants.RETENTION_DELETE_LOCKED_PROP_NAME)); System.clearProperty("carbon.repo.write.mode"); }