new SubjectMatterExpertContactDetailsMapper(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_FULL_NAME), configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_JOB_TITLE), configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS),
@Test public void testSubjectMatterExpertContactDetailsMapper() throws Exception { // Create a subject matter expert contact details mapper. SubjectMatterExpertDaoImpl.SubjectMatterExpertContactDetailsMapper subjectMatterExpertContactDetailsMapper = new SubjectMatterExpertDaoImpl.SubjectMatterExpertContactDetailsMapper(LDAP_ATTRIBUTE_USER_FULL_NAME, LDAP_ATTRIBUTE_USER_JOB_TITLE, LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS, LDAP_ATTRIBUTE_USER_TELEPHONE_NUMBER); // Create attributes object with ignoreCase flag set to "true". BasicAttributes attributes = new BasicAttributes(true); // Populate the attributes with predefined set of results. attributes.put(new BasicAttribute(LDAP_ATTRIBUTE_USER_FULL_NAME, USER_FULL_NAME)); attributes.put(new BasicAttribute(LDAP_ATTRIBUTE_USER_JOB_TITLE, USER_JOB_TITLE)); attributes.put(new BasicAttribute(LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS, USER_EMAIL_ADDRESS)); attributes.put(new BasicAttribute(LDAP_ATTRIBUTE_USER_TELEPHONE_NUMBER, USER_TELEPHONE_NUMBER)); // Map the results. List<SubjectMatterExpertContactDetails> result = Collections.singletonList(subjectMatterExpertContactDetailsMapper.mapFromAttributes(attributes)); // Validate the results. assertEquals( Collections.singletonList(new SubjectMatterExpertContactDetails(USER_FULL_NAME, USER_JOB_TITLE, USER_EMAIL_ADDRESS, USER_TELEPHONE_NUMBER)), result); }
new SubjectMatterExpertContactDetailsMapper(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_FULL_NAME), configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_JOB_TITLE), configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS),
new SubjectMatterExpertDaoImpl.SubjectMatterExpertContactDetailsMapper((String) ConfigurationValue.LDAP_ATTRIBUTE_USER_FULL_NAME.getDefaultValue(), (String) ConfigurationValue.LDAP_ATTRIBUTE_USER_JOB_TITLE.getDefaultValue(), (String) ConfigurationValue.LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS.getDefaultValue(),
/** * Map attributes to a subject matter expert details object. The supplied attributes are the attributes from a single search result. * * @param attributes the attributes from a search result * * @return the subject matter expert contact details * @throws NamingException if a naming exception was encountered while retrieving attribute value */ public SubjectMatterExpertContactDetails mapFromAttributes(Attributes attributes) throws NamingException { SubjectMatterExpertContactDetails subjectMatterExpertContactDetails = new SubjectMatterExpertContactDetails(); subjectMatterExpertContactDetails.setFullName(getAttributeById(attributes, userFullNameAttribute)); subjectMatterExpertContactDetails.setJobTitle(getAttributeById(attributes, userJobTitleAttribute)); subjectMatterExpertContactDetails.setEmailAddress(getAttributeById(attributes, userEmailAddressAttribute)); subjectMatterExpertContactDetails.setTelephoneNumber(getAttributeById(attributes, userTelephoneNumberAttribute)); return subjectMatterExpertContactDetails; }
/** * Map attributes to a subject matter expert details object. The supplied attributes are the attributes from a single search result. * * @param attributes the attributes from a search result * * @return the subject matter expert contact details * @throws NamingException if a naming exception was encountered while retrieving attribute value */ public SubjectMatterExpertContactDetails mapFromAttributes(Attributes attributes) throws NamingException { SubjectMatterExpertContactDetails subjectMatterExpertContactDetails = new SubjectMatterExpertContactDetails(); subjectMatterExpertContactDetails.setFullName(getAttributeById(attributes, userFullNameAttribute)); subjectMatterExpertContactDetails.setJobTitle(getAttributeById(attributes, userJobTitleAttribute)); subjectMatterExpertContactDetails.setEmailAddress(getAttributeById(attributes, userEmailAddressAttribute)); subjectMatterExpertContactDetails.setTelephoneNumber(getAttributeById(attributes, userTelephoneNumberAttribute)); return subjectMatterExpertContactDetails; }