### Question:
FileSystemPathResolver { public Path resolveNameServices(Path path) { URI uri = path.toUri(); if (HDFS_SCHEME.equalsIgnoreCase(uri.getScheme())) { String nameService = configuration.get(DFSConfigKeys.DFS_NAMESERVICES); if (isNotBlank(nameService)) { String scheme = uri.getScheme(); String url = uri.getPath(); final String original = path.toString(); if (isBlank(scheme)) { url = String.format("/%s%s", nameService, path); path = new Path(url); } else { path = new Path(scheme, nameService, url); } LOG.info("Added nameservice to path. {} became {}", original, path); } } return path; } FileSystemPathResolver(Configuration configuration); Path resolveScheme(Path path); Path resolveNameServices(Path path);  }### Answer:
@Test public void resolveNameServiceAddsAuthorityToPathWithScheme() { setDfsPaths("hdp-ha"); Path input = new Path("hdfs:/etl/test/avsc/schema.avsc"); Path result = resolver.resolveNameServices(input); Path expected = new Path("hdfs: assertThat(result, is(expected)); }
@Test public void resolveNameServiceS3() { setDfsPaths("hdp-ha"); Path input = new Path("s3: Path result = resolver.resolveNameServices(input); assertThat(result, is(input)); }
@Test public void resolveNameServicesAddsAuthorityToFullyQualifiedPathWithScheme() { setDfsPaths("hdp-ha"); Path input = new Path("hdfs: Path result = resolver.resolveNameServices(input); Path expected = new Path("hdfs: assertThat(result, is(expected)); }
@Test public void resolveNameServicesAddsAuthorityToPathWithoutScheme() { setDfsPaths("foo"); Path input = new Path("/etl/test/avsc/schema.avsc"); Path result = resolver.resolveNameServices(input); Path expected = new Path("/etl/test/avsc/schema.avsc"); assertThat(result, is(expected)); }
@Test public void resolveNameServicesWithEmptyDfsNameservicesConfiguredReturnsOriginalPathFromFullyQualifiedPathWithScheme() { setDfsPaths(""); Path expected = new Path("hdfs: Path result = resolver.resolveNameServices(expected); assertThat(result, is(expected)); }
@Test public void resolveNameServicesWithEmptyDfsNameservicesConfiguredReturnsOriginalPathFromPathWithScheme() { setDfsPaths(""); Path expected = new Path("hdfs:/etl/test/avsc/schema.avsc"); Path result = resolver.resolveNameServices(expected); assertThat(result, is(expected)); }
@Test public void resolveNameServicesWithoutDfsNameservicesConfiguredReturnsOriginalPathFromFullyQualifiedPathWithScheme() { Path expected = new Path("hdfs: Path result = resolver.resolveNameServices(expected); assertThat(result, is(expected)); }
@Test public void resolveNameServicesWithoutDfsNameservicesConfiguredReturnsOriginalPathFromPathWithScheme() { Path expected = new Path("hdfs:/etl/test/avsc/schema.avsc"); Path result = resolver.resolveNameServices(expected); assertThat(result, is(expected)); }
@Test public void resolveNameServicesWithoutDfsNameservicesReturnsOriginalPathWithoutScheme() { Path expected = new Path("/etl/test/avsc/schema.avsc"); Path result = resolver.resolveNameServices(expected); assertThat(result, is(expected)); }