@Test public void convert() { final Date now = new Date(); PFUserDO user = new PFUserDO(); user.setUsername("k.reinhard"); user.setFirstname("Kai"); user.setLastname("Reinhard"); user.setEmail("k.reinhard@micromata.de"); user.setDescription("Developer"); user.setOrganization("Micromata GmbH"); user.setId(42); user.setLastWlanPasswordChange(now); LdapUser ldapUser = pfUserDOConverter.convert(user); assertEquals("k.reinhard", ldapUser.getUid()); assertEquals("k.reinhard", ldapUser.getId()); assertEquals(PFUserDOConverter.ID_PREFIX + "42", ldapUser.getEmployeeNumber()); assertEquals("Kai Reinhard", ldapUser.getCommonName()); assertEquals("Developer", ldapUser.getDescription()); assertEquals("Kai", ldapUser.getGivenName()); assertEquals("Reinhard", ldapUser.getSurname()); assertEquals("Micromata GmbH", ldapUser.getOrganization()); assertEquals(1, ldapUser.getMail().length); assertEquals("k.reinhard@micromata.de", ldapUser.getMail()[0]); assertEquals(now, ldapUser.getSambaPwdLastSet()); user = pfUserDOConverter.convert(ldapUser); assertEquals("k.reinhard", user.getUsername()); assertEquals(new Integer(42), user.getId()); assertEquals("Developer", user.getDescription()); assertEquals("Kai", user.getFirstname()); assertEquals("Reinhard", user.getLastname()); assertEquals("Micromata GmbH", user.getOrganization()); assertEquals("k.reinhard@micromata.de", user.getEmail()); assertEquals(now, user.getLastWlanPasswordChange()); user = new PFUserDO(); ldapUser = pfUserDOConverter.convert(user); assertNull(ldapUser.getId()); assertNull(ldapUser.getUid()); assertNull(ldapUser.getEmployeeNumber()); }
public PFUserDO convert(final LdapUser ldapUser) { final PFUserDO user = new PFUserDO(); user.setLastname(ldapUser.getSurname()); user.setFirstname(ldapUser.getGivenName()); user.setUsername(ldapUser.getUid()); user.setId(getId(ldapUser)); user.setOrganization(ldapUser.getOrganization()); user.setDescription(ldapUser.getDescription()); user.setLastWlanPasswordChange(ldapUser.getSambaPwdLastSet()); final String[] mails = ldapUser.getMail(); if (mails != null) { for (final String mail : mails) { if (StringUtils.isNotEmpty(mail)) { user.setEmail(mail); break; } } } if (ldapUser.isDeleted()) { user.setDeleted(true); } if (ldapUser.isDeactivated() || ldapUserDao.isDeactivated(ldapUser)) { user.setDeactivated(true); } if (ldapUser.isRestrictedUser() || ldapUserDao.isRestrictedUser(ldapUser)) { user.setRestrictedUser(true); } if (!isPosixAccountValuesEmpty(ldapUser)) { user.setLdapValues(getLdapValuesAsXml(ldapUser)); } return user; }
PFUserDOConverter { public PFUserDO convert(final LdapUser ldapUser) { final PFUserDO user = new PFUserDO(); user.setLastname(ldapUser.getSurname()); user.setFirstname(ldapUser.getGivenName()); user.setUsername(ldapUser.getUid()); user.setId(getId(ldapUser)); user.setOrganization(ldapUser.getOrganization()); user.setDescription(ldapUser.getDescription()); user.setLastWlanPasswordChange(ldapUser.getSambaPwdLastSet()); final String[] mails = ldapUser.getMail(); if (mails != null) { for (final String mail : mails) { if (StringUtils.isNotEmpty(mail)) { user.setEmail(mail); break; } } } if (ldapUser.isDeleted()) { user.setDeleted(true); } if (ldapUser.isDeactivated() || ldapUserDao.isDeactivated(ldapUser)) { user.setDeactivated(true); } if (ldapUser.isRestrictedUser() || ldapUserDao.isRestrictedUser(ldapUser)) { user.setRestrictedUser(true); } if (!isPosixAccountValuesEmpty(ldapUser)) { user.setLdapValues(getLdapValuesAsXml(ldapUser)); } return user; } }
PFUserDOConverter { public PFUserDO convert(final LdapUser ldapUser) { final PFUserDO user = new PFUserDO(); user.setLastname(ldapUser.getSurname()); user.setFirstname(ldapUser.getGivenName()); user.setUsername(ldapUser.getUid()); user.setId(getId(ldapUser)); user.setOrganization(ldapUser.getOrganization()); user.setDescription(ldapUser.getDescription()); user.setLastWlanPasswordChange(ldapUser.getSambaPwdLastSet()); final String[] mails = ldapUser.getMail(); if (mails != null) { for (final String mail : mails) { if (StringUtils.isNotEmpty(mail)) { user.setEmail(mail); break; } } } if (ldapUser.isDeleted()) { user.setDeleted(true); } if (ldapUser.isDeactivated() || ldapUserDao.isDeactivated(ldapUser)) { user.setDeactivated(true); } if (ldapUser.isRestrictedUser() || ldapUserDao.isRestrictedUser(ldapUser)) { user.setRestrictedUser(true); } if (!isPosixAccountValuesEmpty(ldapUser)) { user.setLdapValues(getLdapValuesAsXml(ldapUser)); } return user; }  }
PFUserDOConverter { public PFUserDO convert(final LdapUser ldapUser) { final PFUserDO user = new PFUserDO(); user.setLastname(ldapUser.getSurname()); user.setFirstname(ldapUser.getGivenName()); user.setUsername(ldapUser.getUid()); user.setId(getId(ldapUser)); user.setOrganization(ldapUser.getOrganization()); user.setDescription(ldapUser.getDescription()); user.setLastWlanPasswordChange(ldapUser.getSambaPwdLastSet()); final String[] mails = ldapUser.getMail(); if (mails != null) { for (final String mail : mails) { if (StringUtils.isNotEmpty(mail)) { user.setEmail(mail); break; } } } if (ldapUser.isDeleted()) { user.setDeleted(true); } if (ldapUser.isDeactivated() || ldapUserDao.isDeactivated(ldapUser)) { user.setDeactivated(true); } if (ldapUser.isRestrictedUser() || ldapUserDao.isRestrictedUser(ldapUser)) { user.setRestrictedUser(true); } if (!isPosixAccountValuesEmpty(ldapUser)) { user.setLdapValues(getLdapValuesAsXml(ldapUser)); } return user; }  static Integer getId(final LdapUser user); PFUserDO convert(final LdapUser ldapUser); LdapUser convert(final PFUserDO user); static boolean isPosixAccountValuesEmpty(final LdapUser ldapUser); static boolean isSambaAccountValuesEmpty(final LdapUser ldapUser); void setLdapValues(final LdapUser ldapUser, final String ldapValuesAsXml); static LdapUserValues readLdapUserValues(final String ldapValuesAsXml); String getLdapValuesAsXml(final LdapUser ldapUser); static String getLdapValuesAsXml(final LdapUserValues values); static String buildEmployeeNumber(final PFUserDO user); static boolean copyUserFields(final PFUserDO src, final PFUserDO dest); boolean copyUserFields(final LdapUser src, final LdapUser dest); }
PFUserDOConverter { public PFUserDO convert(final LdapUser ldapUser) { final PFUserDO user = new PFUserDO(); user.setLastname(ldapUser.getSurname()); user.setFirstname(ldapUser.getGivenName()); user.setUsername(ldapUser.getUid()); user.setId(getId(ldapUser)); user.setOrganization(ldapUser.getOrganization()); user.setDescription(ldapUser.getDescription()); user.setLastWlanPasswordChange(ldapUser.getSambaPwdLastSet()); final String[] mails = ldapUser.getMail(); if (mails != null) { for (final String mail : mails) { if (StringUtils.isNotEmpty(mail)) { user.setEmail(mail); break; } } } if (ldapUser.isDeleted()) { user.setDeleted(true); } if (ldapUser.isDeactivated() || ldapUserDao.isDeactivated(ldapUser)) { user.setDeactivated(true); } if (ldapUser.isRestrictedUser() || ldapUserDao.isRestrictedUser(ldapUser)) { user.setRestrictedUser(true); } if (!isPosixAccountValuesEmpty(ldapUser)) { user.setLdapValues(getLdapValuesAsXml(ldapUser)); } return user; }  static Integer getId(final LdapUser user); PFUserDO convert(final LdapUser ldapUser); LdapUser convert(final PFUserDO user); static boolean isPosixAccountValuesEmpty(final LdapUser ldapUser); static boolean isSambaAccountValuesEmpty(final LdapUser ldapUser); void setLdapValues(final LdapUser ldapUser, final String ldapValuesAsXml); static LdapUserValues readLdapUserValues(final String ldapValuesAsXml); String getLdapValuesAsXml(final LdapUser ldapUser); static String getLdapValuesAsXml(final LdapUserValues values); static String buildEmployeeNumber(final PFUserDO user); static boolean copyUserFields(final PFUserDO src, final PFUserDO dest); boolean copyUserFields(final LdapUser src, final LdapUser dest);  }