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: awsHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private AwsHelper awsHelper;
test_class.type: AwsHelper
test_class.var_name: awsHelper
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: credStashFactory
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private CredStashFactory credStashFactory;
test_class.type: CredStashFactory
test_class.var_name: credStashFactory
test_class.declarator: credStashHelper
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private CredStashHelper credStashHelper;
test_class.type: CredStashHelper
test_class.var_name: credStashHelper
test_class.declarator: jsonHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private JsonHelper jsonHelper;
test_class.type: JsonHelper
test_class.var_name: jsonHelper
test_class.file: herd-code/herd-dao/src/test/java/org/finra/herd/dao/helper/CredStashHelperTest.java
test_class.identifier: CredStashHelperTest
test_case.body: @Test
      public void testGetCredentialFromCredStashEmptyPasswordValue() throws Exception
      {
          // Build AWS parameters.
          AwsParamsDto awsParamsDto =
              new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT, NO_AWS_REGION_NAME);
  
          // Build AWS client configuration.
          ClientConfiguration clientConfiguration = new ClientConfiguration();
  
          // Create CredStash encryption context map.
          Map<String, String> credStashEncryptionContextMap = new HashMap<>();
          credStashEncryptionContextMap.put(KEY, VALUE);
  
          // Mock the CredStash.
          CredStash credStash = mock(CredStash.class);
          when(credStash.getCredential(USER_CREDENTIAL_NAME, credStashEncryptionContextMap)).thenReturn(EMPTY_STRING);
  
          // Mock the external calls.
          when(configurationHelper.getProperty(ConfigurationValue.CREDSTASH_AWS_REGION_NAME)).thenReturn(AWS_REGION_NAME);
          when(configurationHelper.getProperty(ConfigurationValue.CREDSTASH_TABLE_NAME)).thenReturn(TABLE_NAME);
          when(awsHelper.getAwsParamsDto()).thenReturn(awsParamsDto);
          when(awsHelper.getClientConfiguration(awsParamsDto)).thenReturn(clientConfiguration);
          when(credStashFactory.getCredStash(AWS_REGION_NAME, TABLE_NAME, clientConfiguration)).thenReturn(credStash);
          when(jsonHelper.unmarshallJsonToObject(Map.class, CREDSTASH_ENCRYPTION_CONTEXT)).thenReturn(credStashEncryptionContextMap);
  
          // Specify the expected exception.
          expectedException.expect(CredStashGetCredentialFailedException.class);
          expectedException.expectMessage(String
              .format("Failed to obtain credential from credstash. credStashAwsRegion=%s credStashTableName=%s credStashEncryptionContext=%s credentialName=%s",
                  AWS_REGION_NAME, TABLE_NAME, CREDSTASH_ENCRYPTION_CONTEXT, USER_CREDENTIAL_NAME));
  
          // Try to call the method under test.
          credStashHelper.getCredentialFromCredStash(CREDSTASH_ENCRYPTION_CONTEXT, USER_CREDENTIAL_NAME);
  
          // Verify the external calls.
          verify(configurationHelper).getProperty(ConfigurationValue.CREDSTASH_AWS_REGION_NAME);
          verify(configurationHelper).getProperty(ConfigurationValue.CREDSTASH_TABLE_NAME);
          verify(awsHelper).getAwsParamsDto();
          verify(awsHelper).getClientConfiguration(awsParamsDto);
          verify(credStashFactory).getCredStash(AWS_REGION_NAME, TABLE_NAME, clientConfiguration);
          verify(jsonHelper).unmarshallJsonToObject(Map.class, CREDSTASH_ENCRYPTION_CONTEXT);
          verify(credStash).getCredential(USER_CREDENTIAL_NAME, credStashEncryptionContextMap);
          verifyNoMoreInteractions(credStash);
          verifyNoMoreInteractionsHelper();
      }
test_case.class_method_signature: CredStashHelperTest.testGetCredentialFromCredStashEmptyPasswordValue()
test_case.full_signature: @Test public void testGetCredentialFromCredStashEmptyPasswordValue()
test_case.identifier: testGetCredentialFromCredStashEmptyPasswordValue
test_case.invocations: put mock thenReturn when getCredential thenReturn when getProperty thenReturn when getProperty thenReturn when getAwsParamsDto thenReturn when getClientConfiguration thenReturn when getCredStash thenReturn when unmarshallJsonToObject expect expectMessage format getCredentialFromCredStash getProperty verify getProperty verify getAwsParamsDto verify getClientConfiguration verify getCredStash verify unmarshallJsonToObject verify getCredential verify verifyNoMoreInteractions verifyNoMoreInteractionsHelper
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetCredentialFromCredStashEmptyPasswordValue()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(CredStashHelper.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(CredStashHelper.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: awsHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private AwsHelper awsHelper;
focal_class.type: AwsHelper
focal_class.var_name: awsHelper
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: credStashFactory
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private CredStashFactory credStashFactory;
focal_class.type: CredStashFactory
focal_class.var_name: credStashFactory
focal_class.declarator: jsonHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private JsonHelper jsonHelper;
focal_class.type: JsonHelper
focal_class.var_name: jsonHelper
focal_class.file: herd-code/herd-dao/src/main/java/org/finra/herd/dao/helper/CredStashHelper.java
focal_class.identifier: CredStashHelper
focal_class.class_method_signature: CredStashHelper.getCredentialFromCredStash(String credStashEncryptionContext, String credentialName)
focal_class.full_signature: @Retryable(maxAttempts = 3, value = CredStashGetCredentialFailedException.class, backoff = @Backoff(delay = 5000, multiplier = 2)) @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) public String getCredentialFromCredStash(String credStashEncryptionContext, String credentialName)
focal_class.identifier: getCredentialFromCredStash
focal_class.modifiers: @Retryable(maxAttempts = 3, value = CredStashGetCredentialFailedException.class, backoff = @Backoff(delay = 5000, multiplier = 2)) @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) public
focal_class.parameters: (String credStashEncryptionContext, String credentialName)
focal_class.return: String
focal_class.signature: String getCredentialFromCredStash(String credStashEncryptionContext, String credentialName)
focal_method.body: @Retryable(maxAttempts = 3, value = CredStashGetCredentialFailedException.class, backoff = @Backoff(delay = 5000, multiplier = 2))
      @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME)
      public String getCredentialFromCredStash(String credStashEncryptionContext, String credentialName) throws CredStashGetCredentialFailedException
      {
          // Get AWS region and table name for the credstash.
          String credStashAwsRegion = configurationHelper.getProperty(ConfigurationValue.CREDSTASH_AWS_REGION_NAME);
          String credStashTableName = configurationHelper.getProperty(ConfigurationValue.CREDSTASH_TABLE_NAME);
  
          // Log configuration values and input parameters.
          LOGGER.info("credStashAwsRegion={} credStashTableName={} credStashEncryptionContext={} credentialName={}", credStashAwsRegion, credStashTableName,
              credStashEncryptionContext, credentialName);
  
          // Get the AWS client configuration.
          ClientConfiguration clientConfiguration = awsHelper.getClientConfiguration(awsHelper.getAwsParamsDto());
  
          // Get the credstash interface for getting a credential from credstash.
          CredStash credstash = credStashFactory.getCredStash(credStashAwsRegion, credStashTableName, clientConfiguration);
  
          // Try to obtain the credential from credstash.
          String password = null;
          String errorMessage = null;
          try
          {
              // Convert the JSON config file version of the encryption context to a Java Map class.
              @SuppressWarnings("unchecked")
              Map<String, String> credstashEncryptionContextMap = jsonHelper.unmarshallJsonToObject(Map.class, credStashEncryptionContext);
              // Get password value from the credstash.
              password = credstash.getCredential(credentialName, credstashEncryptionContextMap);
          }
          catch (Exception exception)
          {
              LOGGER.error("Caught exception when attempting to get a credential value from CredStash.", exception);
              errorMessage = exception.getMessage();
          }
  
          // If password value is empty and could not be obtained as credential from the credstash, then throw a CredStashGetCredentialFailedException.
          if (StringUtils.isEmpty(password))
          {
              throw new CredStashGetCredentialFailedException(String.format("Failed to obtain credential from credstash.%s " +
                      "credStashAwsRegion=%s credStashTableName=%s credStashEncryptionContext=%s credentialName=%s",
                  StringUtils.isNotBlank(errorMessage) ? " Reason: " + errorMessage : "", credStashAwsRegion, credStashTableName, credStashEncryptionContext,
                  credentialName));
          }
  
          // Return the retrieved password value.
          return password;
      }
focal_method.class_method_signature: CredStashHelper.getCredentialFromCredStash(String credStashEncryptionContext, String credentialName)
focal_method.full_signature: @Retryable(maxAttempts = 3, value = CredStashGetCredentialFailedException.class, backoff = @Backoff(delay = 5000, multiplier = 2)) @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) public String getCredentialFromCredStash(String credStashEncryptionContext, String credentialName)
focal_method.identifier: getCredentialFromCredStash
focal_method.invocations: getProperty getProperty info getClientConfiguration getAwsParamsDto getCredStash unmarshallJsonToObject getCredential error getMessage isEmpty format isNotBlank
focal_method.modifiers: @Retryable(maxAttempts = 3, value = CredStashGetCredentialFailedException.class, backoff = @Backoff(delay = 5000, multiplier = 2)) @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) public
focal_method.parameters: (String credStashEncryptionContext, String credentialName)
focal_method.return: String
focal_method.signature: String getCredentialFromCredStash(String credStashEncryptionContext, String credentialName)