test_class.declarator: expectedException = ExpectedException.none()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public ExpectedException expectedException = ExpectedException.none();
test_class.type: ExpectedException
test_class.var_name: expectedException
test_class.declarator: configurationHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ConfigurationHelper configurationHelper;
test_class.type: ConfigurationHelper
test_class.var_name: configurationHelper
test_class.declarator: credStashHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private CredStashHelper credStashHelper;
test_class.type: CredStashHelper
test_class.var_name: credStashHelper
test_class.declarator: ldapOperations
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private LdapOperations ldapOperations;
test_class.type: LdapOperations
test_class.var_name: ldapOperations
test_class.declarator: subjectMatterExpertDaoImpl
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private SubjectMatterExpertDaoImpl subjectMatterExpertDaoImpl;
test_class.type: SubjectMatterExpertDaoImpl
test_class.var_name: subjectMatterExpertDaoImpl
test_class.file: herd-code/herd-dao/src/test/java/org/finra/herd/dao/impl/SubjectMatterExpertDaoImplTest.java
test_class.identifier: SubjectMatterExpertDaoImplTest
test_case.body: @Test
      public void testGetSubjectMatterExpertByKey() throws Exception
      {
          // Create a subject matter expert key.
          SubjectMatterExpertKey subjectMatterExpertKey = new SubjectMatterExpertKey(USER_ID);
  
          // Create subject matter expert contact details initialised with test data.
          SubjectMatterExpertContactDetails subjectMatterExpertContactDetails =
              new SubjectMatterExpertContactDetails(USER_FULL_NAME, USER_JOB_TITLE, USER_EMAIL_ADDRESS, USER_TELEPHONE_NUMBER);
  
          // Mock the external calls.
          when(configurationHelper.getProperty(ConfigurationValue.LDAP_URL)).thenReturn(LDAP_URL);
          when(configurationHelper.getProperty(ConfigurationValue.LDAP_BASE)).thenReturn(LDAP_BASE);
          when(configurationHelper.getProperty(ConfigurationValue.LDAP_USER_DN)).thenReturn(LDAP_USER_DN);
          when(configurationHelper.getProperty(ConfigurationValue.CREDSTASH_HERD_ENCRYPTION_CONTEXT)).thenReturn(CREDSTASH_ENCRYPTION_CONTEXT);
          when(configurationHelper.getProperty(ConfigurationValue.LDAP_USER_CREDENTIAL_NAME)).thenReturn(USER_CREDENTIAL_NAME);
          when(credStashHelper.getCredentialFromCredStash(CREDSTASH_ENCRYPTION_CONTEXT, USER_CREDENTIAL_NAME)).thenReturn(PASSWORD);
          when(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_ID)).thenReturn(LDAP_ATTRIBUTE_USER_ID);
          when(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_FULL_NAME)).thenReturn(LDAP_ATTRIBUTE_USER_FULL_NAME);
          when(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_JOB_TITLE)).thenReturn(LDAP_ATTRIBUTE_USER_JOB_TITLE);
          when(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS)).thenReturn(LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS);
          when(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_TELEPHONE_NUMBER)).thenReturn(LDAP_ATTRIBUTE_USER_TELEPHONE_NUMBER);
          when(
              ldapOperations.search(any(LdapTemplate.class), any(LdapQuery.class), any(SubjectMatterExpertDaoImpl.SubjectMatterExpertContactDetailsMapper.class)))
              .thenReturn(Collections.singletonList(subjectMatterExpertContactDetails));
  
          // Call the method under test.
          SubjectMatterExpertContactDetails result = subjectMatterExpertDaoImpl.getSubjectMatterExpertByKey(subjectMatterExpertKey);
  
          // Validate the results.
          assertEquals(subjectMatterExpertContactDetails, result);
  
          // Verify the external calls.
          verify(configurationHelper).getProperty(ConfigurationValue.LDAP_URL);
          verify(configurationHelper).getProperty(ConfigurationValue.LDAP_BASE);
          verify(configurationHelper).getProperty(ConfigurationValue.LDAP_USER_DN);
          verify(configurationHelper).getProperty(ConfigurationValue.CREDSTASH_HERD_ENCRYPTION_CONTEXT);
          verify(configurationHelper).getProperty(ConfigurationValue.LDAP_USER_CREDENTIAL_NAME);
          verify(credStashHelper).getCredentialFromCredStash(CREDSTASH_ENCRYPTION_CONTEXT, USER_CREDENTIAL_NAME);
          verify(configurationHelper).getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_ID);
          verify(configurationHelper).getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_FULL_NAME);
          verify(configurationHelper).getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_JOB_TITLE);
          verify(configurationHelper).getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS);
          verify(configurationHelper).getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_TELEPHONE_NUMBER);
          verify(ldapOperations)
              .search(any(LdapTemplate.class), any(LdapQuery.class), any(SubjectMatterExpertDaoImpl.SubjectMatterExpertContactDetailsMapper.class));
          verifyNoMoreInteractionsHelper();
      }
test_case.class_method_signature: SubjectMatterExpertDaoImplTest.testGetSubjectMatterExpertByKey()
test_case.full_signature: @Test public void testGetSubjectMatterExpertByKey()
test_case.identifier: testGetSubjectMatterExpertByKey
test_case.invocations: thenReturn when getProperty thenReturn when getProperty thenReturn when getProperty thenReturn when getProperty thenReturn when getProperty thenReturn when getCredentialFromCredStash thenReturn when getProperty thenReturn when getProperty thenReturn when getProperty thenReturn when getProperty thenReturn when getProperty thenReturn when search any any any singletonList getSubjectMatterExpertByKey assertEquals getProperty verify getProperty verify getProperty verify getProperty verify getProperty verify getCredentialFromCredStash verify getProperty verify getProperty verify getProperty verify getProperty verify getProperty verify search verify any any any verifyNoMoreInteractionsHelper
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetSubjectMatterExpertByKey()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(SubjectMatterExpertDaoImpl.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(SubjectMatterExpertDaoImpl.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: configurationHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ConfigurationHelper configurationHelper;
focal_class.type: ConfigurationHelper
focal_class.var_name: configurationHelper
focal_class.declarator: credStashHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private CredStashHelper credStashHelper;
focal_class.type: CredStashHelper
focal_class.var_name: credStashHelper
focal_class.declarator: ldapOperations
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private LdapOperations ldapOperations;
focal_class.type: LdapOperations
focal_class.var_name: ldapOperations
focal_class.file: herd-code/herd-dao/src/main/java/org/finra/herd/dao/impl/SubjectMatterExpertDaoImpl.java
focal_class.identifier: SubjectMatterExpertDaoImpl
focal_class.interfaces: implements SubjectMatterExpertDao
focal_class.class_method_signature: SubjectMatterExpertDaoImpl.getSubjectMatterExpertByKey(SubjectMatterExpertKey subjectMatterExpertKey)
focal_class.full_signature: @Override public SubjectMatterExpertContactDetails getSubjectMatterExpertByKey(SubjectMatterExpertKey subjectMatterExpertKey)
focal_class.identifier: getSubjectMatterExpertByKey
focal_class.modifiers: @Override public
focal_class.parameters: (SubjectMatterExpertKey subjectMatterExpertKey)
focal_class.return: SubjectMatterExpertContactDetails
focal_class.signature: SubjectMatterExpertContactDetails getSubjectMatterExpertByKey(SubjectMatterExpertKey subjectMatterExpertKey)
focal_method.body: @Override
      public SubjectMatterExpertContactDetails getSubjectMatterExpertByKey(SubjectMatterExpertKey subjectMatterExpertKey)
      {
          // Get LDAP specific configuration settings.
          final String ldapUrl = configurationHelper.getProperty(ConfigurationValue.LDAP_URL);
          final String ldapBase = configurationHelper.getProperty(ConfigurationValue.LDAP_BASE);
          final String ldapUserDn = configurationHelper.getProperty(ConfigurationValue.LDAP_USER_DN);
          final String credStashEncryptionContext = configurationHelper.getProperty(ConfigurationValue.CREDSTASH_HERD_ENCRYPTION_CONTEXT);
          final String ldapUserCredentialName = configurationHelper.getProperty(ConfigurationValue.LDAP_USER_CREDENTIAL_NAME);
  
          // Log configuration values being used to create LDAP context source.
          LOGGER.info("Creating LDAP context source using the following parameters: {}=\"{}\" {}=\"{}\" {}=\"{}\" {}=\"{}\" {}=\"{}\"...",
              ConfigurationValue.LDAP_URL.getKey(), ldapUrl, ConfigurationValue.LDAP_BASE.getKey(), ldapBase, ConfigurationValue.LDAP_USER_DN.getKey(),
              ldapUserDn, ConfigurationValue.CREDSTASH_HERD_ENCRYPTION_CONTEXT.getKey(), credStashEncryptionContext,
              ConfigurationValue.LDAP_USER_CREDENTIAL_NAME.getKey(), ldapUserCredentialName);
  
          // Retrieve LDAP user password from the credstash.
          String ldapUserPassword;
          try
          {
              ldapUserPassword = credStashHelper.getCredentialFromCredStash(credStashEncryptionContext, ldapUserCredentialName);
          }
          catch (CredStashGetCredentialFailedException e)
          {
              throw new IllegalStateException(e);
          }
  
          // Create and initialize an LDAP context source.
          LdapContextSource contextSource = new LdapContextSource();
          contextSource.setUrl(ldapUrl);
          contextSource.setBase(ldapBase);
          contextSource.setUserDn(ldapUserDn);
          contextSource.setPassword(ldapUserPassword);
          contextSource.afterPropertiesSet();
  
          // Create an LDAP template.
          LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
  
          // Create an LDAP query.
          LdapQuery ldapQuery = query().where(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_ID)).is(subjectMatterExpertKey.getUserId());
  
          // Create a subject matter expert contact details mapper.
          SubjectMatterExpertContactDetailsMapper subjectMatterExpertContactDetailsMapper =
              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),
                  configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_TELEPHONE_NUMBER));
  
          // Gets information for the specified subject matter expert.
          List<SubjectMatterExpertContactDetails> subjectMatterExpertContactDetailsList =
              ldapOperations.search(ldapTemplate, ldapQuery, subjectMatterExpertContactDetailsMapper);
  
          // Return the results.
          return CollectionUtils.isNotEmpty(subjectMatterExpertContactDetailsList) ? subjectMatterExpertContactDetailsList.get(0) : null;
      }
focal_method.class_method_signature: SubjectMatterExpertDaoImpl.getSubjectMatterExpertByKey(SubjectMatterExpertKey subjectMatterExpertKey)
focal_method.full_signature: @Override public SubjectMatterExpertContactDetails getSubjectMatterExpertByKey(SubjectMatterExpertKey subjectMatterExpertKey)
focal_method.identifier: getSubjectMatterExpertByKey
focal_method.invocations: getProperty getProperty getProperty getProperty getProperty info getKey getKey getKey getKey getKey getCredentialFromCredStash setUrl setBase setUserDn setPassword afterPropertiesSet is where query getProperty getUserId getProperty getProperty getProperty getProperty search isNotEmpty get
focal_method.modifiers: @Override public
focal_method.parameters: (SubjectMatterExpertKey subjectMatterExpertKey)
focal_method.return: SubjectMatterExpertContactDetails
focal_method.signature: SubjectMatterExpertContactDetails getSubjectMatterExpertByKey(SubjectMatterExpertKey subjectMatterExpertKey)