@Test public final void testAttribMapperNulls() throws NamingException { final Attributes attributeMock = context.mock(Attributes.class); context.checking(new Expectations() { { oneOf(attributeMock).get("cn"); will(returnValue(null)); } }); sut.mapFromAttributes(attributeMock); context.assertIsSatisfied(); }
public Object mapFromAttributes(final Attributes attrs) throws NamingException { Person person = null; try { log.debug("Found person: " + attrs.get(fullNameAttrib).get().toString()); String accountId = attrs.get(accountAttrib).get().toString(); String firstName = attrs.get(firstNameAttrib).get().toString(); String lastName = attrs.get(lastNameAttrib).get().toString(); String email = (null != attrs.get(emailAttrib)) ? attrs.get(emailAttrib).get().toString() : ""; String middleName = (null != attrs.get(middleNameAttrib)) ? attrs.get(middleNameAttrib).get().toString() : ""; String companyName = (null != attrs.get(companyAttrib)) ? attrs.get(companyAttrib).get().toString() : ""; String title = (null != attrs.get(titleAttrib)) ? attrs.get(titleAttrib).get().toString() : ""; String[] splitCn = attrs.get(fullNameAttrib).get().toString().split(", "); String preferredName = (splitCn.length > 1) ? splitCn[1] : firstName; person = new Person(accountId, firstName, middleName, lastName, preferredName); log.debug("Company Name:" + companyName); person.setCompanyName(companyName); person.setTitle(title); person.setEmail(email); if (attributesToDisplayNameSuffixTransformer != null) { String displayNameSuffix = attributesToDisplayNameSuffixTransformer.transform(attrs); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); log.debug("Setting the display name suffix: " + displayNameSuffix); } if (additionalProperties != null) { HashMap<String, String> propertiesMap = new HashMap<String, String>(); for (String property : additionalProperties) { try { propertiesMap.put(property, attrs.get(property).get().toString()); } catch (Exception ex) { if (log.isInfoEnabled()) { log.info("Additional Property: " + property + " not found for user " + accountId); } } } person.setAdditionalProperties(propertiesMap); } } catch (Exception e) { log.error("Error instantiating person object.", e); } return person; }
LdapToPersonMapper implements AttributesMapper { public Object mapFromAttributes(final Attributes attrs) throws NamingException { Person person = null; try { log.debug("Found person: " + attrs.get(fullNameAttrib).get().toString()); String accountId = attrs.get(accountAttrib).get().toString(); String firstName = attrs.get(firstNameAttrib).get().toString(); String lastName = attrs.get(lastNameAttrib).get().toString(); String email = (null != attrs.get(emailAttrib)) ? attrs.get(emailAttrib).get().toString() : ""; String middleName = (null != attrs.get(middleNameAttrib)) ? attrs.get(middleNameAttrib).get().toString() : ""; String companyName = (null != attrs.get(companyAttrib)) ? attrs.get(companyAttrib).get().toString() : ""; String title = (null != attrs.get(titleAttrib)) ? attrs.get(titleAttrib).get().toString() : ""; String[] splitCn = attrs.get(fullNameAttrib).get().toString().split(", "); String preferredName = (splitCn.length > 1) ? splitCn[1] : firstName; person = new Person(accountId, firstName, middleName, lastName, preferredName); log.debug("Company Name:" + companyName); person.setCompanyName(companyName); person.setTitle(title); person.setEmail(email); if (attributesToDisplayNameSuffixTransformer != null) { String displayNameSuffix = attributesToDisplayNameSuffixTransformer.transform(attrs); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); log.debug("Setting the display name suffix: " + displayNameSuffix); } if (additionalProperties != null) { HashMap<String, String> propertiesMap = new HashMap<String, String>(); for (String property : additionalProperties) { try { propertiesMap.put(property, attrs.get(property).get().toString()); } catch (Exception ex) { if (log.isInfoEnabled()) { log.info("Additional Property: " + property + " not found for user " + accountId); } } } person.setAdditionalProperties(propertiesMap); } } catch (Exception e) { log.error("Error instantiating person object.", e); } return person; } }
LdapToPersonMapper implements AttributesMapper { public Object mapFromAttributes(final Attributes attrs) throws NamingException { Person person = null; try { log.debug("Found person: " + attrs.get(fullNameAttrib).get().toString()); String accountId = attrs.get(accountAttrib).get().toString(); String firstName = attrs.get(firstNameAttrib).get().toString(); String lastName = attrs.get(lastNameAttrib).get().toString(); String email = (null != attrs.get(emailAttrib)) ? attrs.get(emailAttrib).get().toString() : ""; String middleName = (null != attrs.get(middleNameAttrib)) ? attrs.get(middleNameAttrib).get().toString() : ""; String companyName = (null != attrs.get(companyAttrib)) ? attrs.get(companyAttrib).get().toString() : ""; String title = (null != attrs.get(titleAttrib)) ? attrs.get(titleAttrib).get().toString() : ""; String[] splitCn = attrs.get(fullNameAttrib).get().toString().split(", "); String preferredName = (splitCn.length > 1) ? splitCn[1] : firstName; person = new Person(accountId, firstName, middleName, lastName, preferredName); log.debug("Company Name:" + companyName); person.setCompanyName(companyName); person.setTitle(title); person.setEmail(email); if (attributesToDisplayNameSuffixTransformer != null) { String displayNameSuffix = attributesToDisplayNameSuffixTransformer.transform(attrs); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); log.debug("Setting the display name suffix: " + displayNameSuffix); } if (additionalProperties != null) { HashMap<String, String> propertiesMap = new HashMap<String, String>(); for (String property : additionalProperties) { try { propertiesMap.put(property, attrs.get(property).get().toString()); } catch (Exception ex) { if (log.isInfoEnabled()) { log.info("Additional Property: " + property + " not found for user " + accountId); } } } person.setAdditionalProperties(propertiesMap); } } catch (Exception e) { log.error("Error instantiating person object.", e); } return person; }  }
LdapToPersonMapper implements AttributesMapper { public Object mapFromAttributes(final Attributes attrs) throws NamingException { Person person = null; try { log.debug("Found person: " + attrs.get(fullNameAttrib).get().toString()); String accountId = attrs.get(accountAttrib).get().toString(); String firstName = attrs.get(firstNameAttrib).get().toString(); String lastName = attrs.get(lastNameAttrib).get().toString(); String email = (null != attrs.get(emailAttrib)) ? attrs.get(emailAttrib).get().toString() : ""; String middleName = (null != attrs.get(middleNameAttrib)) ? attrs.get(middleNameAttrib).get().toString() : ""; String companyName = (null != attrs.get(companyAttrib)) ? attrs.get(companyAttrib).get().toString() : ""; String title = (null != attrs.get(titleAttrib)) ? attrs.get(titleAttrib).get().toString() : ""; String[] splitCn = attrs.get(fullNameAttrib).get().toString().split(", "); String preferredName = (splitCn.length > 1) ? splitCn[1] : firstName; person = new Person(accountId, firstName, middleName, lastName, preferredName); log.debug("Company Name:" + companyName); person.setCompanyName(companyName); person.setTitle(title); person.setEmail(email); if (attributesToDisplayNameSuffixTransformer != null) { String displayNameSuffix = attributesToDisplayNameSuffixTransformer.transform(attrs); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); log.debug("Setting the display name suffix: " + displayNameSuffix); } if (additionalProperties != null) { HashMap<String, String> propertiesMap = new HashMap<String, String>(); for (String property : additionalProperties) { try { propertiesMap.put(property, attrs.get(property).get().toString()); } catch (Exception ex) { if (log.isInfoEnabled()) { log.info("Additional Property: " + property + " not found for user " + accountId); } } } person.setAdditionalProperties(propertiesMap); } } catch (Exception e) { log.error("Error instantiating person object.", e); } return person; }  Object mapFromAttributes(final Attributes attrs); void setAccountAttrib(final String inAccountAttrib); void setFirstNameAttrib(final String inFirstNameAttrib); void setLastNameAttrib(final String inLastNameAttrib); void setMiddleNameAttrib(final String inMiddleNameAttrib); void setTitleAttrib(final String inTitleAttrib); void setFullNameAttrib(final String inFullNameAttrib); void setEmailAttrib(final String inEmailAttrib); void setAdditionalProperties(final List<String> inAdditionalProperties); void setCompanyAttrib(final String inCompanyAttrib); void setAttributesToDisplayNameSuffixTransformer(
            final Transformer<Attributes, String> inAttributesToDisplayNameSuffixTransformer); }
LdapToPersonMapper implements AttributesMapper { public Object mapFromAttributes(final Attributes attrs) throws NamingException { Person person = null; try { log.debug("Found person: " + attrs.get(fullNameAttrib).get().toString()); String accountId = attrs.get(accountAttrib).get().toString(); String firstName = attrs.get(firstNameAttrib).get().toString(); String lastName = attrs.get(lastNameAttrib).get().toString(); String email = (null != attrs.get(emailAttrib)) ? attrs.get(emailAttrib).get().toString() : ""; String middleName = (null != attrs.get(middleNameAttrib)) ? attrs.get(middleNameAttrib).get().toString() : ""; String companyName = (null != attrs.get(companyAttrib)) ? attrs.get(companyAttrib).get().toString() : ""; String title = (null != attrs.get(titleAttrib)) ? attrs.get(titleAttrib).get().toString() : ""; String[] splitCn = attrs.get(fullNameAttrib).get().toString().split(", "); String preferredName = (splitCn.length > 1) ? splitCn[1] : firstName; person = new Person(accountId, firstName, middleName, lastName, preferredName); log.debug("Company Name:" + companyName); person.setCompanyName(companyName); person.setTitle(title); person.setEmail(email); if (attributesToDisplayNameSuffixTransformer != null) { String displayNameSuffix = attributesToDisplayNameSuffixTransformer.transform(attrs); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); log.debug("Setting the display name suffix: " + displayNameSuffix); } if (additionalProperties != null) { HashMap<String, String> propertiesMap = new HashMap<String, String>(); for (String property : additionalProperties) { try { propertiesMap.put(property, attrs.get(property).get().toString()); } catch (Exception ex) { if (log.isInfoEnabled()) { log.info("Additional Property: " + property + " not found for user " + accountId); } } } person.setAdditionalProperties(propertiesMap); } } catch (Exception e) { log.error("Error instantiating person object.", e); } return person; }  Object mapFromAttributes(final Attributes attrs); void setAccountAttrib(final String inAccountAttrib); void setFirstNameAttrib(final String inFirstNameAttrib); void setLastNameAttrib(final String inLastNameAttrib); void setMiddleNameAttrib(final String inMiddleNameAttrib); void setTitleAttrib(final String inTitleAttrib); void setFullNameAttrib(final String inFullNameAttrib); void setEmailAttrib(final String inEmailAttrib); void setAdditionalProperties(final List<String> inAdditionalProperties); void setCompanyAttrib(final String inCompanyAttrib); void setAttributesToDisplayNameSuffixTransformer(
            final Transformer<Attributes, String> inAttributesToDisplayNameSuffixTransformer);  }