test_class.declarator: environmentVariables = new EnvironmentVariables()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public EnvironmentVariables environmentVariables = new EnvironmentVariables();
test_class.type: EnvironmentVariables
test_class.var_name: environmentVariables
test_class.file: herd-code/herd-tools/herd-tools-common/src/test/java/org/finra/herd/tools/common/ToolsArgumentHelperTest.java
test_class.identifier: ToolsArgumentHelperTest
test_class.superclass: extends AbstractCoreTest
test_case.body: @Test
      public void validateCliEnvArgumentSuccess() throws ParseException
      {
          ArgumentParser argParser = new ArgumentParser("test");
          Option passwordOpt = argParser.addArgument("w", "password", true, "The password used for HTTPS client authentication.", false);
          Option enableEnvVariablesOpt = argParser.addArgument("E", "enableEnvVariables", true,
              "The enableEnvVariables used for HTTPS client authentication through environment provided variable.", false);
          // CLI password only
          String[] argumentsWithCliOpt = {"-w", "cliPassword"};
          argParser.parseArguments(argumentsWithCliOpt);
          ToolsArgumentHelper.validateCliEnvArgument(argParser, passwordOpt, enableEnvVariablesOpt);
  
          // enableEnvVariables true
          environmentVariables.set("HERD_PASSWORD", "envPassword");
          String[] argumentsWithEnableVarsOpt = {"--enableEnvVariables", "true"};
          argParser.parseArguments(argumentsWithEnableVarsOpt);
          ToolsArgumentHelper.validateCliEnvArgument(argParser, passwordOpt, enableEnvVariablesOpt);
          environmentVariables.clear("HERD_PASSWORD");
  
          // CLI password and enableEnvVariables true
          String[] argumentsWithCliAndEnableVarsOpt = {"-w", "cliPassword", "--enableEnvVariables", "true"};
          argParser.parseArguments(argumentsWithCliAndEnableVarsOpt);
          ToolsArgumentHelper.validateCliEnvArgument(argParser, passwordOpt, enableEnvVariablesOpt);
      }
test_case.class_method_signature: ToolsArgumentHelperTest.validateCliEnvArgumentSuccess()
test_case.full_signature: @Test public void validateCliEnvArgumentSuccess()
test_case.identifier: validateCliEnvArgumentSuccess
test_case.invocations: addArgument addArgument parseArguments validateCliEnvArgument set parseArguments validateCliEnvArgument clear parseArguments validateCliEnvArgument
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void validateCliEnvArgumentSuccess()
focal_class.file: herd-code/herd-tools/herd-tools-common/src/main/java/org/finra/herd/tools/common/ToolsArgumentHelper.java
focal_class.identifier: ToolsArgumentHelper
focal_class.class_method_signature: ToolsArgumentHelper.validateCliEnvArgument(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_class.full_signature: public static void validateCliEnvArgument(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_class.identifier: validateCliEnvArgument
focal_class.modifiers: public static
focal_class.parameters: (ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_class.return: void
focal_class.signature: void validateCliEnvArgument(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_class.class_method_signature: ToolsArgumentHelper.getCliEnvArgumentValue(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_class.full_signature: public static String getCliEnvArgumentValue(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_class.identifier: getCliEnvArgumentValue
focal_class.modifiers: public static
focal_class.parameters: (ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_class.return: String
focal_class.signature: String getCliEnvArgumentValue(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_class.class_method_signature: ToolsArgumentHelper.getEnvValue(Option option)
focal_class.full_signature: private static String getEnvValue(Option option)
focal_class.identifier: getEnvValue
focal_class.modifiers: private static
focal_class.parameters: (Option option)
focal_class.return: String
focal_class.signature: String getEnvValue(Option option)
focal_class.class_method_signature: ToolsArgumentHelper.getEnvVarName(Option option)
focal_class.full_signature: private static String getEnvVarName(Option option)
focal_class.identifier: getEnvVarName
focal_class.modifiers: private static
focal_class.parameters: (Option option)
focal_class.return: String
focal_class.signature: String getEnvVarName(Option option)
focal_method.body: public static void validateCliEnvArgument(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt) throws ParseException
      {
          String optionName = cliOpt.getLongOpt();
          String envVarName = getEnvVarName(cliOpt);
          //check password cli input, then env vars if enableEnvVariables is true
          boolean blankCliOption = StringUtils.isBlank(argParser.getStringValue(cliOpt));
          boolean enableEnvVars = argParser.getStringValueAsBoolean(enableEnvVariablesOpt, false);
          boolean blankEnvVars = StringUtils.isBlank(ToolsArgumentHelper.getEnvValue(cliOpt));
          if (blankCliOption && !enableEnvVars || blankCliOption && blankEnvVars)
          {
              {
                  throw new ParseException(String.format("Either %s or enableEnvVariables with env variable %s is required.", optionName, envVarName));
              }
  
          }
  
      }
focal_method.class_method_signature: ToolsArgumentHelper.validateCliEnvArgument(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_method.full_signature: public static void validateCliEnvArgument(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_method.identifier: validateCliEnvArgument
focal_method.invocations: getLongOpt getEnvVarName isBlank getStringValue getStringValueAsBoolean isBlank getEnvValue format
focal_method.modifiers: public static
focal_method.parameters: (ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)
focal_method.return: void
focal_method.signature: void validateCliEnvArgument(ArgumentParser argParser, Option cliOpt, Option enableEnvVariablesOpt)