@Override
    public Optional<String> getLocalHadoopConfigurationDirectory() {
        final String hadoopConfDirEnv = System.getenv(Constants.ENV_HADOOP_CONF_DIR);
        if (StringUtils.isNotBlank(hadoopConfDirEnv)) {
            return Optional.of(hadoopConfDirEnv);
        }

        final String hadoopHomeEnv = System.getenv(Constants.ENV_HADOOP_HOME);
        if (StringUtils.isNotBlank(hadoopHomeEnv)) {
            // Hadoop 2.2+
            final File hadoop2ConfDir = new File(hadoopHomeEnv, "/etc/hadoop");
            if (hadoop2ConfDir.exists()) {
                return Optional.of(hadoop2ConfDir.getAbsolutePath());
            }

            // Hadoop 1.x
            final File hadoop1ConfDir = new File(hadoopHomeEnv, "/conf");
            if (hadoop1ConfDir.exists()) {
                return Optional.of(hadoop1ConfDir.getAbsolutePath());
            }
        }

        return Optional.empty();
    }
@Test
    void testGetLocalHadoopConfigurationDirectoryFromHadoop2HomeEnv(@TempDir Path temporaryFolder)
            throws Exception {
        runTestWithEmptyEnv(
                () -> {
                    final String hadoopHome = temporaryFolder.toAbsolutePath().toString();
                    Files.createDirectories(temporaryFolder.resolve(Paths.get("etc", "hadoop")));
                    setEnv(Constants.ENV_HADOOP_HOME, hadoopHome);

                    final Optional<String> optional =
                            testingKubernetesParameters.getLocalHadoopConfigurationDirectory();
                    assertThat(optional).isPresent();
                    assertThat(optional.get()).isEqualTo(hadoopHome + "/etc/hadoop");
                });
    }