Use Path.of() instead of Paths.get() Path.of() makes Paths.get() obsolete in Java 11 Change-Id: Ibc94041804c1cc27f6517165881ab5b686bcfafc Signed-off-by: Edwin Kempin <ekempin@google.com> Reviewed-on: https://gerrit-review.googlesource.com/c/plugins/code-owners/+/405982 Tested-by: Zuul <zuul-63@gerritcodereview-ci.iam.gserviceaccount.com> Reviewed-by: Nitzan Gur-Furman <nitzan@google.com>
diff --git a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigCreation.java b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigCreation.java index 3dd651e..e47e1cc 100644 --- a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigCreation.java +++ b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigCreation.java
@@ -27,7 +27,6 @@ import com.google.gerrit.plugins.codeowners.backend.CodeOwnerReference; import com.google.gerrit.plugins.codeowners.backend.CodeOwnerSet; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Optional; /** @@ -142,7 +141,7 @@ new IllegalStateException( "project not specified, specifying a project is required for code owner config creation")); String branchName = branch().orElse("master"); - Path folderPath = folderPath().orElse(Paths.get("/")); + Path folderPath = folderPath().orElse(Path.of("/")); return CodeOwnerConfig.Key.create( BranchNameKey.create(projectName, branchName), folderPath, fileName().orElse(null)); } @@ -215,7 +214,7 @@ * @return the Builder instance for chaining calls */ public Builder folderPath(String folderPath) { - return folderPath(Paths.get(folderPath)); + return folderPath(Path.of(folderPath)); } /**
diff --git a/java/com/google/gerrit/plugins/codeowners/api/CodeOwnerConfigs.java b/java/com/google/gerrit/plugins/codeowners/api/CodeOwnerConfigs.java index 8754809..3b94482 100644 --- a/java/com/google/gerrit/plugins/codeowners/api/CodeOwnerConfigs.java +++ b/java/com/google/gerrit/plugins/codeowners/api/CodeOwnerConfigs.java
@@ -17,7 +17,6 @@ import com.google.gerrit.extensions.restapi.NotImplementedException; import com.google.gerrit.extensions.restapi.RestApiException; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Optional; /** @@ -41,7 +40,7 @@ * @return the code owner config if it exists */ default Optional<CodeOwnerConfigInfo> get(String path) throws RestApiException { - return get(Paths.get(path)); + return get(Path.of(path)); } /**
diff --git a/java/com/google/gerrit/plugins/codeowners/api/CodeOwners.java b/java/com/google/gerrit/plugins/codeowners/api/CodeOwners.java index 390e34c..1e3e3ed 100644 --- a/java/com/google/gerrit/plugins/codeowners/api/CodeOwners.java +++ b/java/com/google/gerrit/plugins/codeowners/api/CodeOwners.java
@@ -22,7 +22,6 @@ import com.google.gerrit.extensions.restapi.NotImplementedException; import com.google.gerrit.extensions.restapi.RestApiException; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Arrays; import java.util.EnumSet; import java.util.Optional; @@ -69,7 +68,7 @@ * @return the code owners for the given path */ public CodeOwnersInfo get(String path) throws RestApiException { - return get(Paths.get(path)); + return get(Path.of(path)); } /**
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java index fc78ab8..b72ab39 100644 --- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java +++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java
@@ -24,7 +24,6 @@ import com.google.gerrit.entities.BranchNameKey; import com.google.gerrit.entities.Project; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Optional; import org.eclipse.jgit.lib.ObjectId; @@ -328,7 +327,7 @@ * @return the code owner config key */ public static Key create(Project.NameKey project, String branch, String folderPath) { - return create(BranchNameKey.create(project, branch), Paths.get(folderPath)); + return create(BranchNameKey.create(project, branch), Path.of(folderPath)); } /** @@ -343,7 +342,7 @@ */ public static Key create( Project.NameKey project, String branch, String folderPath, @Nullable String fileName) { - return create(BranchNameKey.create(project, branch), Paths.get(folderPath), fileName); + return create(BranchNameKey.create(project, branch), Path.of(folderPath), fileName); } /**
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReference.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReference.java index dff2506..c9892e4 100644 --- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReference.java +++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReference.java
@@ -22,7 +22,6 @@ import com.google.gerrit.entities.Project; import com.google.gerrit.entities.RefNames; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Optional; /** @@ -67,7 +66,7 @@ * <p>May be absolute or relative to the path of the importing code owner config. */ public Path path() { - return firstNonNull(filePath().getParent(), Paths.get("")); + return firstNonNull(filePath().getParent(), Path.of("")); } /** The name of the code owner config file. */ @@ -118,7 +117,7 @@ */ public static Builder builder(CodeOwnerConfigImportMode importMode, String filePath) { requireNonNull(filePath, "filePath"); - return builder(importMode, Paths.get(filePath)); + return builder(importMode, Path.of(filePath)); } /**
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigTreeWalk.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigTreeWalk.java index 0836a53..674c5f3 100644 --- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigTreeWalk.java +++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigTreeWalk.java
@@ -25,7 +25,6 @@ import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Path; -import java.nio.file.Paths; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectLoader; import org.eclipse.jgit.lib.Ref; @@ -93,8 +92,8 @@ Path folderPath = filePath.getParent() != null ? JgitPath.of(filePath.getParent()).getAsAbsolutePath() - : Paths.get("/"); - String fileName = Paths.get(getPathString()).getFileName().toString(); + : Path.of("/"); + String fileName = Path.of(getPathString()).getFileName().toString(); return CodeOwnerConfig.Key.create(branchNameKey, folderPath, fileName); } @@ -162,7 +161,7 @@ "%s filtered out because it doesn't match the path glob", walker.getPathString()); return false; } - String fileName = Paths.get(walker.getPathString()).getFileName().toString(); + String fileName = Path.of(walker.getPathString()).getFileName().toString(); return codeOwnerBackend.isCodeOwnerConfigFile(project, fileName); }
diff --git a/java/com/google/gerrit/plugins/codeowners/restapi/AbstractPathResource.java b/java/com/google/gerrit/plugins/codeowners/restapi/AbstractPathResource.java index dd603fc..e3e22ba 100644 --- a/java/com/google/gerrit/plugins/codeowners/restapi/AbstractPathResource.java +++ b/java/com/google/gerrit/plugins/codeowners/restapi/AbstractPathResource.java
@@ -23,7 +23,6 @@ import com.google.gerrit.server.project.BranchResource; import java.nio.file.InvalidPathException; import java.nio.file.Path; -import java.nio.file.Paths; import org.eclipse.jgit.lib.ObjectId; /** @@ -41,14 +40,14 @@ protected static Path parsePath(IdString id) throws BadRequestException { Path path; try { - path = Paths.get(id.get()); + path = Path.of(id.get()); } catch (InvalidPathException e) { throw new BadRequestException("invalid path: " + e.getReason()); } if (!path.isAbsolute()) { // we assume that all paths are absolute, add the missing leading '/' - path = Paths.get("/").resolve(path); + path = Path.of("/").resolve(path); } return path; }
diff --git a/java/com/google/gerrit/plugins/codeowners/restapi/CheckCodeOwnerConfigFilesInRevision.java b/java/com/google/gerrit/plugins/codeowners/restapi/CheckCodeOwnerConfigFilesInRevision.java index af4b97f..d4dcede 100644 --- a/java/com/google/gerrit/plugins/codeowners/restapi/CheckCodeOwnerConfigFilesInRevision.java +++ b/java/com/google/gerrit/plugins/codeowners/restapi/CheckCodeOwnerConfigFilesInRevision.java
@@ -34,7 +34,7 @@ import com.google.inject.Singleton; import java.io.IOException; import java.nio.file.FileSystems; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.List; import java.util.Map; import java.util.Optional; @@ -103,9 +103,7 @@ changedFile -> codeOwnerBackend.isCodeOwnerConfigFile( revisionResource.getProject(), - Paths.get(changedFile.newPath().get().toString()) - .getFileName() - .toString())) + Path.of(changedFile.newPath().get().toString()).getFileName().toString())) .filter( changedFile -> input.path == null
diff --git a/java/com/google/gerrit/plugins/codeowners/util/JgitPath.java b/java/com/google/gerrit/plugins/codeowners/util/JgitPath.java index 18b77be..3de836c 100644 --- a/java/com/google/gerrit/plugins/codeowners/util/JgitPath.java +++ b/java/com/google/gerrit/plugins/codeowners/util/JgitPath.java
@@ -17,7 +17,6 @@ import static java.util.Objects.requireNonNull; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Objects; /** @@ -62,7 +61,7 @@ /** Returns the path as absolute path. */ public Path getAsAbsolutePath() { - return Paths.get("/" + get()); + return Path.of("/" + get()); } @Override
diff --git a/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java b/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java index c99001c..858b1a2 100644 --- a/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java +++ b/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java
@@ -87,7 +87,6 @@ import com.google.inject.Singleton; import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; import java.util.Optional; import java.util.stream.Stream; @@ -607,7 +606,7 @@ changedFile -> codeOwnerBackend.isCodeOwnerConfigFile( project, - Paths.get(changedFile.newPath().get().toString()).getFileName().toString())) + Path.of(changedFile.newPath().get().toString()).getFileName().toString())) .collect(toImmutableList()); } @@ -741,7 +740,7 @@ Path folderPath = filePath.getParent() != null ? JgitPath.of(filePath.getParent()).getAsAbsolutePath() - : Paths.get("/"); + : Path.of("/"); String fileName = filePath.getFileName().toString(); return CodeOwnerConfig.Key.create(branchNameKey, folderPath, fileName); }
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/GetCodeOwnerStatusIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/GetCodeOwnerStatusIT.java index fb87053..b378e3a 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/GetCodeOwnerStatusIT.java +++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/GetCodeOwnerStatusIT.java
@@ -32,7 +32,6 @@ import com.google.gerrit.server.util.AccountTemplateUtil; import com.google.inject.Inject; import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.Test; /** @@ -347,8 +346,8 @@ .addCodeOwnerEmail(user.email()) .create(); - Path oldPath = Paths.get("/foo/old.bar"); - Path newPath = Paths.get("/bar/new.bar"); + Path oldPath = Path.of("/foo/old.bar"); + Path newPath = Path.of("/bar/new.bar"); String changeId = createChangeWithFileRename(oldPath, newPath); // Add a reviewer that is a code owner of the old path.
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java index d5e4dd5..85da5bd 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java
@@ -39,7 +39,7 @@ import com.google.gerrit.truth.OptionalSubject; import com.google.inject.Key; import com.google.inject.Provider; -import java.nio.file.Paths; +import java.nio.file.Path; import org.junit.Before; import org.junit.Test; @@ -176,7 +176,7 @@ .folderPath(folderPath) .addCodeOwnerEmail(admin.email()) .create(); - Truth8.assertThat(codeOwnerConfigKey.folderPath()).isEqualTo(Paths.get(folderPath)); + Truth8.assertThat(codeOwnerConfigKey.folderPath()).isEqualTo(Path.of(folderPath)); assertThat(getCodeOwnerConfigFromServer(codeOwnerConfigKey)) .hasCodeOwnerSetsThat() .onlyElement()
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractFileBasedCodeOwnerBackendTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractFileBasedCodeOwnerBackendTest.java index 9dcadd8..7731055 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractFileBasedCodeOwnerBackendTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractFileBasedCodeOwnerBackendTest.java
@@ -26,7 +26,7 @@ import com.google.gerrit.plugins.codeowners.testing.backend.TestCodeOwnerConfigStorage; import com.google.gerrit.plugins.codeowners.util.JgitPath; import com.google.gerrit.server.IdentifiedUser; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.Optional; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.MissingObjectException; @@ -477,7 +477,7 @@ public void getFilePathForCodeOwnerConfigKeyWithoutFileName() throws Exception { CodeOwnerConfig.Key codeOwnerConfigKey = CodeOwnerConfig.Key.create(project, "master", "/"); Truth8.assertThat(codeOwnerBackend.getFilePath(codeOwnerConfigKey)) - .isEqualTo(Paths.get(codeOwnerConfigKey.folderPath() + getFileName())); + .isEqualTo(Path.of(codeOwnerConfigKey.folderPath() + getFileName())); } @Test @@ -485,8 +485,7 @@ CodeOwnerConfig.Key codeOwnerConfigKey = CodeOwnerConfig.Key.create(project, "master", "/", getFileName() + "_foo_bar"); Truth8.assertThat(codeOwnerBackend.getFilePath(codeOwnerConfigKey)) - .isEqualTo( - Paths.get(codeOwnerConfigKey.folderPath() + codeOwnerConfigKey.fileName().get())); + .isEqualTo(Path.of(codeOwnerConfigKey.folderPath() + codeOwnerConfigKey.fileName().get())); } @Test
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractPathExpressionMatcherTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractPathExpressionMatcherTest.java index 752eb01..33ace1f 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractPathExpressionMatcherTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractPathExpressionMatcherTest.java
@@ -18,7 +18,7 @@ import com.google.common.collect.ImmutableList; import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest; -import java.nio.file.Paths; +import java.nio.file.Path; /** Base class for testing {@link PathExpressionMatcher}s. */ public abstract class AbstractPathExpressionMatcherTest extends AbstractCodeOwnersTest { @@ -37,7 +37,7 @@ boolean expectedToMatch, String pathExpression, String firstPath, String... morePaths) { for (String path : toList(firstPath, morePaths)) { assertWithMessage("path expression %s matches path %s", pathExpression, path) - .that(getPathExpressionMatcher().matches(pathExpression, Paths.get(path))) + .that(getPathExpressionMatcher().matches(pathExpression, Path.of(path))) .isEqualTo(expectedToMatch); } }
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java index cc3a6e7..b6b6389 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java
@@ -25,7 +25,7 @@ import com.google.gerrit.server.patch.PatchListEntry; import com.google.gerrit.server.patch.filediff.FileDiffOutput; import com.google.gerrit.truth.OptionalSubject; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.Optional; import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.diff.DiffEntry.ChangeType; @@ -50,7 +50,7 @@ setupDiffEntry(newPath, /* oldPath= */ null, ChangeType.ADD); OptionalSubject.assertThat(ChangedFile.create(diffEntry).newPath()) .value() - .isEqualTo(Paths.get("/" + newPath)); + .isEqualTo(Path.of("/" + newPath)); } @Test @@ -59,7 +59,7 @@ setupPatchListEntry(newPath, /* oldPath= */ null, Patch.ChangeType.ADDED); OptionalSubject.assertThat(ChangedFile.create(patchListEntry).newPath()) .value() - .isEqualTo(Paths.get("/" + newPath)); + .isEqualTo(Path.of("/" + newPath)); } @Test @@ -68,7 +68,7 @@ setupFileDiffOutput(newPath, /* oldPath= */ null, Patch.ChangeType.ADDED); OptionalSubject.assertThat(ChangedFile.create(fileDiffOutput).newPath()) .value() - .isEqualTo(Paths.get("/" + newPath)); + .isEqualTo(Path.of("/" + newPath)); } @Test @@ -95,8 +95,8 @@ setupDiffEntry(newPath, /* oldPath= */ null, ChangeType.ADD); ChangedFile changedFile = ChangedFile.create(diffEntry); - assertThat(changedFile.hasNewPath(Paths.get("/" + newPath))).isTrue(); - assertThat(changedFile.hasNewPath(Paths.get("/otherPath"))).isFalse(); + assertThat(changedFile.hasNewPath(Path.of("/" + newPath))).isTrue(); + assertThat(changedFile.hasNewPath(Path.of("/otherPath"))).isFalse(); } @Test @@ -105,8 +105,8 @@ setupPatchListEntry(newPath, /* oldPath= */ null, Patch.ChangeType.ADDED); ChangedFile changedFile = ChangedFile.create(patchListEntry); - assertThat(changedFile.hasNewPath(Paths.get("/" + newPath))).isTrue(); - assertThat(changedFile.hasNewPath(Paths.get("/otherPath"))).isFalse(); + assertThat(changedFile.hasNewPath(Path.of("/" + newPath))).isTrue(); + assertThat(changedFile.hasNewPath(Path.of("/otherPath"))).isFalse(); } @Test @@ -115,8 +115,8 @@ setupFileDiffOutput(newPath, /* oldPath= */ null, Patch.ChangeType.ADDED); ChangedFile changedFile = ChangedFile.create(fileDiffOutput); - assertThat(changedFile.hasNewPath(Paths.get("/" + newPath))).isTrue(); - assertThat(changedFile.hasNewPath(Paths.get("/otherPath"))).isFalse(); + assertThat(changedFile.hasNewPath(Path.of("/" + newPath))).isTrue(); + assertThat(changedFile.hasNewPath(Path.of("/otherPath"))).isFalse(); } @Test @@ -159,7 +159,7 @@ IllegalStateException exception = assertThrows( IllegalStateException.class, - () -> ChangedFile.create(diffEntry).hasNewPath(Paths.get(relativePath))); + () -> ChangedFile.create(diffEntry).hasNewPath(Path.of(relativePath))); assertThat(exception) .hasMessageThat() .isEqualTo(String.format("path %s must be absolute", relativePath)); @@ -172,7 +172,7 @@ IllegalStateException exception = assertThrows( IllegalStateException.class, - () -> ChangedFile.create(patchListEntry).hasNewPath(Paths.get(relativePath))); + () -> ChangedFile.create(patchListEntry).hasNewPath(Path.of(relativePath))); assertThat(exception) .hasMessageThat() .isEqualTo(String.format("path %s must be absolute", relativePath)); @@ -185,7 +185,7 @@ IllegalStateException exception = assertThrows( IllegalStateException.class, - () -> ChangedFile.create(fileDiffOutput).hasNewPath(Paths.get(relativePath))); + () -> ChangedFile.create(fileDiffOutput).hasNewPath(Path.of(relativePath))); assertThat(exception) .hasMessageThat() .isEqualTo(String.format("path %s must be absolute", relativePath)); @@ -197,7 +197,7 @@ setupDiffEntry(/* newPath= */ null, oldPath, ChangeType.DELETE); OptionalSubject.assertThat(ChangedFile.create(diffEntry).oldPath()) .value() - .isEqualTo(Paths.get("/" + oldPath)); + .isEqualTo(Path.of("/" + oldPath)); } @Test @@ -206,7 +206,7 @@ setupPatchListEntry(/* newPath= */ null, oldPath, Patch.ChangeType.DELETED); OptionalSubject.assertThat(ChangedFile.create(patchListEntry).oldPath()) .value() - .isEqualTo(Paths.get("/" + oldPath)); + .isEqualTo(Path.of("/" + oldPath)); } @Test @@ -215,7 +215,7 @@ setupFileDiffOutput(/* newPath= */ null, oldPath, Patch.ChangeType.DELETED); OptionalSubject.assertThat(ChangedFile.create(fileDiffOutput).oldPath()) .value() - .isEqualTo(Paths.get("/" + oldPath)); + .isEqualTo(Path.of("/" + oldPath)); } @Test @@ -243,8 +243,8 @@ setupDiffEntry(/* newPath= */ null, oldPath, ChangeType.DELETE); ChangedFile changedFile = ChangedFile.create(diffEntry); - assertThat(changedFile.hasOldPath(Paths.get("/" + oldPath))).isTrue(); - assertThat(changedFile.hasOldPath(Paths.get("/otherPath"))).isFalse(); + assertThat(changedFile.hasOldPath(Path.of("/" + oldPath))).isTrue(); + assertThat(changedFile.hasOldPath(Path.of("/otherPath"))).isFalse(); } @Test @@ -253,8 +253,8 @@ setupPatchListEntry(/* newPath= */ null, oldPath, Patch.ChangeType.DELETED); ChangedFile changedFile = ChangedFile.create(patchListEntry); - assertThat(changedFile.hasOldPath(Paths.get("/" + oldPath))).isTrue(); - assertThat(changedFile.hasOldPath(Paths.get("/otherPath"))).isFalse(); + assertThat(changedFile.hasOldPath(Path.of("/" + oldPath))).isTrue(); + assertThat(changedFile.hasOldPath(Path.of("/otherPath"))).isFalse(); } @Test @@ -263,8 +263,8 @@ setupFileDiffOutput(/* newPath= */ null, oldPath, Patch.ChangeType.DELETED); ChangedFile changedFile = ChangedFile.create(fileDiffOutput); - assertThat(changedFile.hasOldPath(Paths.get("/" + oldPath))).isTrue(); - assertThat(changedFile.hasOldPath(Paths.get("/otherPath"))).isFalse(); + assertThat(changedFile.hasOldPath(Path.of("/" + oldPath))).isTrue(); + assertThat(changedFile.hasOldPath(Path.of("/otherPath"))).isFalse(); } @Test @@ -304,7 +304,7 @@ IllegalStateException exception = assertThrows( IllegalStateException.class, - () -> ChangedFile.create(diffEntry).hasOldPath(Paths.get(relativePath))); + () -> ChangedFile.create(diffEntry).hasOldPath(Path.of(relativePath))); assertThat(exception) .hasMessageThat() .isEqualTo(String.format("path %s must be absolute", relativePath)); @@ -317,7 +317,7 @@ IllegalStateException exception = assertThrows( IllegalStateException.class, - () -> ChangedFile.create(patchListEntry).hasOldPath(Paths.get(relativePath))); + () -> ChangedFile.create(patchListEntry).hasOldPath(Path.of(relativePath))); assertThat(exception) .hasMessageThat() .isEqualTo(String.format("path %s must be absolute", relativePath)); @@ -330,7 +330,7 @@ IllegalStateException exception = assertThrows( IllegalStateException.class, - () -> ChangedFile.create(fileDiffOutput).hasOldPath(Paths.get(relativePath))); + () -> ChangedFile.create(fileDiffOutput).hasOldPath(Path.of(relativePath))); assertThat(exception) .hasMessageThat() .isEqualTo(String.format("path %s must be absolute", relativePath));
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFilesTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFilesTest.java index d72e981..e82a2aa 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFilesTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFilesTest.java
@@ -45,7 +45,7 @@ import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.restapi.change.ChangesCollection; import com.google.inject.Inject; -import java.nio.file.Paths; +import java.nio.file.Path; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.revwalk.RevCommit; import org.junit.Before; @@ -134,7 +134,7 @@ changedFiles.getFromDiffCache(project, commit, MergeCommitStrategy.ALL_CHANGED_FILES); assertThat(changedFilesSet).hasSize(1); ChangedFile changedFile = Iterables.getOnlyElement(changedFilesSet); - assertThat(changedFile).hasNewPath().value().isEqualTo(Paths.get(path)); + assertThat(changedFile).hasNewPath().value().isEqualTo(Path.of(path)); assertThat(changedFile).hasOldPath().isEmpty(); assertThat(changedFile).isNoRename(); assertThat(changedFile).isNoDeletion(); @@ -153,8 +153,8 @@ changedFiles.getFromDiffCache(project, commit, MergeCommitStrategy.ALL_CHANGED_FILES); assertThat(changedFilesSet).hasSize(1); ChangedFile changedFile = Iterables.getOnlyElement(changedFilesSet); - assertThat(changedFile).hasNewPath().value().isEqualTo(Paths.get(path)); - assertThat(changedFile).hasOldPath().value().isEqualTo(Paths.get(path)); + assertThat(changedFile).hasNewPath().value().isEqualTo(Path.of(path)); + assertThat(changedFile).hasOldPath().value().isEqualTo(Path.of(path)); assertThat(changedFile).isNoRename(); assertThat(changedFile).isNoDeletion(); } @@ -172,7 +172,7 @@ assertThat(changedFilesSet).hasSize(1); ChangedFile changedFile = Iterables.getOnlyElement(changedFilesSet); assertThat(changedFile).hasNewPath().isEmpty(); - assertThat(changedFile).hasOldPath().value().isEqualTo(Paths.get(path)); + assertThat(changedFile).hasOldPath().value().isEqualTo(Path.of(path)); assertThat(changedFile).isNoRename(); assertThat(changedFile).isDeletion(); } @@ -191,8 +191,8 @@ getRevisionResource(changeId).getPatchSet().commitId(), MergeCommitStrategy.ALL_CHANGED_FILES); ChangedFileSubject changedFile = assertThatCollection(changedFilesSet).onlyElement(); - changedFile.hasNewPath().value().isEqualTo(Paths.get(newPath)); - changedFile.hasOldPath().value().isEqualTo(Paths.get(oldPath)); + changedFile.hasNewPath().value().isEqualTo(Path.of(newPath)); + changedFile.hasOldPath().value().isEqualTo(Path.of(oldPath)); changedFile.isRename(); changedFile.isNoDeletion(); } @@ -209,7 +209,7 @@ changedFiles.getFromDiffCache(project, commit, MergeCommitStrategy.ALL_CHANGED_FILES); assertThat(changedFilesSet).hasSize(1); ChangedFile changedFile = Iterables.getOnlyElement(changedFilesSet); - assertThat(changedFile).hasNewPath().value().isEqualTo(Paths.get(path)); + assertThat(changedFile).hasNewPath().value().isEqualTo(Path.of(path)); assertThat(changedFile).hasOldPath().isEmpty(); assertThat(changedFile).isNoRename(); assertThat(changedFile).isNoDeletion();
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckForAccountTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckForAccountTest.java index 499f42f..680c642 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckForAccountTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckForAccountTest.java
@@ -33,7 +33,6 @@ import com.google.gerrit.truth.ListSubject; import com.google.inject.Inject; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.stream.Stream; import org.junit.Before; import org.junit.Test; @@ -58,7 +57,7 @@ @Test public void notApprovedByUser() throws Exception { - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); ChangeNotes changeNotes = getChangeNotes(changeId); @@ -92,7 +91,7 @@ .addCodeOwnerEmail(codeOwner.email()) .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); ChangeNotes changeNotes = getChangeNotes(changeId); @@ -130,7 +129,7 @@ .addCodeOwnerEmail(codeOwner.email()) .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); ChangeNotes changeNotes = getChangeNotes(changeId); @@ -176,7 +175,7 @@ .addCodeOwnerEmail(codeOwner.email()) .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); ChangeNotes changeNotes = getChangeNotes(changeId); @@ -211,7 +210,7 @@ .addCodeOwnerEmail(user.email()) .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); ChangeNotes changeNotes = getChangeNotes(changeId); @@ -241,13 +240,13 @@ .addCodeOwnerEmail(user.email()) .create(); - Path path1 = Paths.get("/foo/bar.baz"); + Path path1 = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path1).get(), "file content") .getChangeId(); // amend change and add another file - Path path2 = Paths.get("/foo/baz.bar"); + Path path2 = Path.of("/foo/baz.bar"); PushOneCommit push = pushFactory.create( admin.newIdent(), @@ -305,7 +304,7 @@ @GerritConfig(name = "plugin.code-owners.fallbackCodeOwners", value = "ALL_USERS") @Test public void approvedByFallbackCodeOwner() throws Exception { - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); ChangeNotes changeNotes = getChangeNotes(changeId); @@ -340,7 +339,7 @@ .addCodeOwnerEmail(codeOwner.email()) .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); ChangeNotes changeNotes = getChangeNotes(changeId);
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckTest.java index 54d4e67..a497853 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckTest.java
@@ -50,7 +50,6 @@ import com.google.gerrit.server.util.AccountTemplateUtil; import com.google.inject.Inject; import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.Before; import org.junit.Test; @@ -93,7 +92,7 @@ public void getStatusForFileAddition_insufficientReviewers() throws Exception { TestAccount user2 = accountCreator.user2(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -114,7 +113,7 @@ public void getStatusForFileModification_insufficientReviewers() throws Exception { TestAccount user2 = accountCreator.user2(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); createChange("Test Change", JgitPath.of(path).get(), "file content").getChangeId(); String changeId = createChange("Change Modifying A File", JgitPath.of(path).get(), "new file content") @@ -137,7 +136,7 @@ public void getStatusForFileDeletion_insufficientReviewers() throws Exception { TestAccount user2 = accountCreator.user2(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChangeWithFileDeletion(path); // Add a reviewer that is not a code owner. @@ -157,8 +156,8 @@ public void getStatusForFileRename_insufficientReviewers() throws Exception { TestAccount user2 = accountCreator.user2(); - Path oldPath = Paths.get("/foo/old.bar"); - Path newPath = Paths.get("/foo/new.bar"); + Path oldPath = Path.of("/foo/old.bar"); + Path newPath = Path.of("/foo/new.bar"); String changeId = createChangeWithFileRename(oldPath, newPath); // Add a reviewer that is not a code owner. @@ -184,7 +183,7 @@ setAsRootCodeOwners(user); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -212,7 +211,7 @@ setAsRootCodeOwners(user); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); createChange("Test Change", JgitPath.of(path).get(), "file content").getChangeId(); String changeId = createChange("Change Modifying A File", JgitPath.of(path).get(), "new file content") @@ -242,7 +241,7 @@ setAsRootCodeOwners(user); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChangeWithFileDeletion(path); // Add a reviewer that is a code owner. @@ -269,8 +268,8 @@ setAsCodeOwners("/foo/bar/", user); - Path oldPath = Paths.get("/foo/bar/abc.txt"); - Path newPath = Paths.get("/foo/baz/abc.txt"); + Path oldPath = Path.of("/foo/bar/abc.txt"); + Path newPath = Path.of("/foo/baz/abc.txt"); String changeId = createChangeWithFileRename(oldPath, newPath); // Add a reviewer that is a code owner old path. @@ -300,8 +299,8 @@ setAsCodeOwners("/foo/baz/", user); - Path oldPath = Paths.get("/foo/bar/abc.txt"); - Path newPath = Paths.get("/foo/baz/abc.txt"); + Path oldPath = Path.of("/foo/bar/abc.txt"); + Path newPath = Path.of("/foo/baz/abc.txt"); String changeId = createChangeWithFileRename(oldPath, newPath); // Add a reviewer that is a code owner of the new path. @@ -329,7 +328,7 @@ public void getStatusForFileAddition_approved() throws Exception { setAsRootCodeOwners(user); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -352,7 +351,7 @@ public void getStatusForFileModification_approved() throws Exception { setAsRootCodeOwners(user); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); createChange("Test Change", JgitPath.of(path).get(), "file content").getChangeId(); String changeId = createChange("Change Modifying A File", JgitPath.of(path).get(), "new file content") @@ -377,7 +376,7 @@ public void getStatusForFileDeletion_approved() throws Exception { setAsRootCodeOwners(user); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChangeWithFileDeletion(path); // Add a Code-Review+1 from a code owner (by default this counts as code owner approval). @@ -399,8 +398,8 @@ public void getStatusForFileRename_approvedOldPath() throws Exception { setAsCodeOwners("/foo/bar/", user); - Path oldPath = Paths.get("/foo/bar/abc.txt"); - Path newPath = Paths.get("/foo/baz/abc.txt"); + Path oldPath = Path.of("/foo/bar/abc.txt"); + Path newPath = Path.of("/foo/baz/abc.txt"); String changeId = createChangeWithFileRename(oldPath, newPath); // Add a Code-Review+1 from a code owner of the old path (by default this counts as code owner @@ -426,8 +425,8 @@ public void getStatusForFileRename_approvedNewPath() throws Exception { setAsCodeOwners("/foo/baz/", user); - Path oldPath = Paths.get("/foo/bar/abc.txt"); - Path newPath = Paths.get("/foo/baz/abc.txt"); + Path oldPath = Path.of("/foo/bar/abc.txt"); + Path newPath = Path.of("/foo/baz/abc.txt"); String changeId = createChangeWithFileRename(oldPath, newPath); // Add a Code-Review+1 from a code owner of the new path (by default this counts as code owner @@ -479,7 +478,7 @@ setAsRootCodeOwners(changeOwner, otherCodeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -537,7 +536,7 @@ setAsRootCodeOwners(changeOwner, otherCodeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); createChange("Test Change", JgitPath.of(path).get(), "file content"); String changeId = createChange("Change Modifying A File", JgitPath.of(path).get(), "new file content") @@ -597,7 +596,7 @@ setAsRootCodeOwners(changeOwner, otherCodeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChangeWithFileDeletion(path); if (uploaderMatchesChangeOwner) { @@ -654,8 +653,8 @@ setAsCodeOwners("/foo/bar/", changeOwner, otherCodeOwner); - Path oldPath = Paths.get("/foo/bar/abc.txt"); - Path newPath = Paths.get("/foo/baz/abc.txt"); + Path oldPath = Path.of("/foo/bar/abc.txt"); + Path newPath = Path.of("/foo/baz/abc.txt"); String changeId = createChangeWithFileRename(oldPath, newPath); if (uploaderMatchesChangeOwner) { @@ -719,8 +718,8 @@ setAsCodeOwners("/foo/baz/", changeOwner, otherCodeOwner); - Path oldPath = Paths.get("/foo/bar/abc.txt"); - Path newPath = Paths.get("/foo/baz/abc.txt"); + Path oldPath = Path.of("/foo/bar/abc.txt"); + Path newPath = Path.of("/foo/baz/abc.txt"); String changeId = createChangeWithFileRename(oldPath, newPath); if (uploaderMatchesChangeOwner) { @@ -761,7 +760,7 @@ throws Exception { setAsRootCodeOwners(admin); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); amendChange(user, changeId); @@ -784,7 +783,7 @@ .create(); // Create a change. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -848,7 +847,7 @@ .create(); // Create a change as a user that is a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -889,7 +888,7 @@ .create(); // Create a change as a user that is a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -923,7 +922,7 @@ accountCreator.create("bot", "bot@example.com", "Bot", /* displayName= */ null); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -993,7 +992,7 @@ accountCreator.create( "other_bot", "otherBot@example.com", "Other Bot", /* displayName= */ null); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(bot, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1031,7 +1030,7 @@ accountCreator.create("bot", "bot@example.com", "Bot", /* displayName= */ null); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1083,7 +1082,7 @@ @GerritConfig(name = "plugin.code-owners.globalCodeOwner", value = "*") public void approvedByAnyoneWhenEveryoneIsGlobalCodeOwner() throws Exception { // Create a change. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1141,7 +1140,7 @@ TestAccount changeOwner = admin; TestAccount otherCodeOwner = user; // Create a change as a user that is a code owner only through the global code ownership. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -1174,7 +1173,7 @@ @GerritConfig(name = "plugin.code-owners.globalCodeOwner", value = "*") public void anyReviewerWhenEveryoneIsGlobalCodeOwner() throws Exception { // Create a change as a user that is a code owner only through the global code ownership. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -1210,7 +1209,7 @@ setAsCodeOwners("/foo/", user2); setAsCodeOwners("/foo/bar/", user3); - Path path = Paths.get("/foo/bar/baz.txt"); + Path path = Path.of("/foo/bar/baz.txt"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -1486,7 +1485,7 @@ createBranch(BranchNameKey.create(project, branchName)); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1502,7 +1501,7 @@ @TestProjectInput(createEmptyCommit = false) public void getStatus_initialChange_defaultCodeOwner() throws Exception { // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1557,7 +1556,7 @@ createBranch(BranchNameKey.create(project, branchName)); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(admin, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1578,7 +1577,7 @@ accountCreator.create("bot", "bot@example.com", "Bot", /* displayName= */ null); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(admin, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1633,7 +1632,7 @@ createBranch(BranchNameKey.create(project, branchName)); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(admin, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1650,7 +1649,7 @@ @GerritConfig(name = "plugin.code-owners.overrideApproval", value = "Owners-Override+1") public void getStatus_initialChange_override() throws Exception { // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(admin, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1689,7 +1688,7 @@ setAsRootCodeOwners(user); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user2, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1759,7 +1758,7 @@ gApi.projects().name(project.get()).label("Owners-Override").update(input); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1819,7 +1818,7 @@ setAsRootCodeOwners(user); // Create a change as 'user2' that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user2, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1876,7 +1875,7 @@ setAsRootCodeOwners(admin); // Create a change as 'user' that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1911,7 +1910,7 @@ setAsDefaultCodeOwners(user); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user2, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -1974,7 +1973,7 @@ setAsDefaultCodeOwners(changeOwner, otherCodeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -2009,7 +2008,7 @@ setAsDefaultCodeOwners(user); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user2, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -2061,7 +2060,7 @@ public void pureRevertsAreNotExemptedByDefault() throws Exception { setAsRootCodeOwners(admin); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); approve(changeId); @@ -2083,7 +2082,7 @@ public void pureRevertsAreExemptedIfConfigured() throws Exception { setAsRootCodeOwners(admin); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); approve(changeId); @@ -2108,7 +2107,7 @@ public void nonPureRevertsAreNotExempted() throws Exception { setAsRootCodeOwners(admin); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); approve(changeId); @@ -2147,7 +2146,7 @@ accountCreator.create( "exemptedUser", "exempted-user@example.com", "Exempted User", /* displayName= */ null); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(exemptedUser, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -2183,7 +2182,7 @@ TestAccount changeOwner = admin; setAsRootCodeOwners(changeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId();
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithAllUsersAsFallbackCodeOwnersTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithAllUsersAsFallbackCodeOwnersTest.java index b6c3a43..5fdef9f 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithAllUsersAsFallbackCodeOwnersTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithAllUsersAsFallbackCodeOwnersTest.java
@@ -35,7 +35,6 @@ import com.google.gerrit.testing.ConfigSuite; import com.google.inject.Inject; import java.nio.file.Path; -import java.nio.file.Paths; import org.eclipse.jgit.lib.Config; import org.junit.Before; import org.junit.Test; @@ -75,7 +74,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -115,7 +114,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -136,7 +135,7 @@ .addCodeOwnerEmail("non-resolvable-code-owner@example.com") .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -180,7 +179,7 @@ .addCodeOwnerEmail("non-resolvable-code-owner@example.com") .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -193,7 +192,7 @@ @Test public void approvedByFallbackCodeOwner() throws Exception { - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -238,7 +237,7 @@ @Test @GerritConfig(name = "plugin.code-owners.enableImplicitApprovals", value = "true") public void implicitlyApprovedByFallbackCodeOwner() throws Exception { - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -266,7 +265,7 @@ .ignoreParentCodeOwners() .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -309,7 +308,7 @@ .ignoreParentCodeOwners() .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -331,7 +330,7 @@ CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "/non-existing/OWNERS")) .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -375,7 +374,7 @@ CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "/non-existing/OWNERS")) .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -402,7 +401,7 @@ .autoBuild()) .create(); - Path path = Paths.get("/foo/bar.md"); + Path path = Path.of("/foo/bar.md"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -452,7 +451,7 @@ .autoBuild()) .create(); - Path path = Paths.get("/foo/bar.md"); + Path path = Path.of("/foo/bar.md"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -469,7 +468,7 @@ createBranch(BranchNameKey.create(project, branchName)); // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -485,7 +484,7 @@ @TestProjectInput(createEmptyCommit = false) public void getStatus_initialChange() throws Exception { // Create a change as a user that is not a code owner. - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(user, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId();
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithSelfApprovalsIgnoredTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithSelfApprovalsIgnoredTest.java index 43ab903..566af4d 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithSelfApprovalsIgnoredTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithSelfApprovalsIgnoredTest.java
@@ -32,7 +32,6 @@ import com.google.gerrit.testing.ConfigSuite; import com.google.inject.Inject; import java.nio.file.Path; -import java.nio.file.Paths; import org.eclipse.jgit.lib.Config; import org.junit.Before; import org.junit.Test; @@ -77,7 +76,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(codeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -106,7 +105,7 @@ "changeOwner", "changeOwner@example.com", "ChangeOwner", /* displayName= */ null); setAsRootCodeOwners(changeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(changeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -148,7 +147,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(changeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -192,7 +191,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(codeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -216,7 +215,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(changeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -239,7 +238,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(codeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -268,7 +267,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(changeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -289,7 +288,7 @@ accountCreator.create( "changeOwner", "changeOwner@example.com", "ChangeOwner", /* displayName= */ null); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(changeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -318,7 +317,7 @@ accountCreator.create( "changeOwner", "changeOwner@example.com", "ChangeOwner", /* displayName= */ null); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(changeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId(); @@ -355,7 +354,7 @@ accountCreator.create( "changeOwner", "changeOwner@example.com", "ChangeOwner", /* displayName= */ null); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange(changeOwner, "Change Adding A File", JgitPath.of(path).get(), "file content") .getChangeId();
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithStickyApprovalsTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithStickyApprovalsTest.java index 28f83f5..b26dcd3 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithStickyApprovalsTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckWithStickyApprovalsTest.java
@@ -37,7 +37,6 @@ import com.google.gerrit.testing.ConfigSuite; import com.google.inject.Inject; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Map; import org.eclipse.jgit.lib.Config; import org.junit.Before; @@ -70,7 +69,7 @@ @Test public void notApproved_noStickyApproval() throws Exception { - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -93,7 +92,7 @@ @Test public void notApproved_byPreviousApprovalOfNonCodeOwner() throws Exception { - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -118,7 +117,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -149,7 +148,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -189,8 +188,8 @@ "codeOwner2", "codeOwner2@example.com", "CodeOwner2", /* displayName= */ null); setAsCodeOwners("/bar/", codeOwner2); - Path path1 = Paths.get("/foo/bar.baz"); - Path path2 = Paths.get("/bar/foo.baz"); + Path path1 = Path.of("/foo/bar.baz"); + Path path2 = Path.of("/bar/foo.baz"); String changeId = createChange( "Change Adding A File", @@ -269,7 +268,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -325,7 +324,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -376,7 +375,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -424,7 +423,7 @@ TestAccount implicitCodeOwner = admin; // the changes is created by the admit user setAsRootCodeOwners(implicitCodeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -457,7 +456,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsRootCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -466,7 +465,7 @@ recommend(changeId); // create a second patch set that adds a new file - Path path2 = Paths.get("/foo/abc.xyz"); + Path path2 = Path.of("/foo/abc.xyz"); amendChange( changeId, "Change Adding A File", @@ -526,7 +525,7 @@ .addCodeOwnerEmail("*") .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -557,7 +556,7 @@ "codeOwner", "codeOwner@example.com", "CodeOwner", /* displayName= */ null); setAsDefaultCodeOwners(codeOwner); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -593,7 +592,7 @@ .addCodeOwnerEmail("*") .create(); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -625,7 +624,7 @@ TestAccount bot = accountCreator.create("bot", "bot@example.com", "Bot", /* displayName= */ null); - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId(); @@ -653,7 +652,7 @@ @GerritConfig(name = "plugin.code-owners.globalCodeOwner", value = "*") public void approved_byStickyApprovalOfGlobalCodeOnPreviousPatchSet_everyoneIsGlobalCodeOwner() throws Exception { - Path path = Paths.get("/foo/bar.baz"); + Path path = Path.of("/foo/bar.baz"); String changeId = createChange("Change Adding A File", JgitPath.of(path).get(), "file content").getChangeId();
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFileUpdateScannerTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFileUpdateScannerTest.java index ea8af79..827fa91 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFileUpdateScannerTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFileUpdateScannerTest.java
@@ -30,7 +30,6 @@ import com.google.gerrit.plugins.codeowners.util.JgitPath; import com.google.inject.Inject; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Optional; import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.lib.Ref; @@ -170,7 +169,7 @@ .addCodeOwnerEmail(admin.email()) .create(); Path path = - Paths.get(codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getFilePath()); + Path.of(codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getFilePath()); String content = codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getContent(); RevCommit oldHead = projectOperations.project(project).getHead("master"); @@ -204,7 +203,7 @@ .addCodeOwnerEmail(admin.email()) .create(); Path path1 = - Paths.get(codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey1).getFilePath()); + Path.of(codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey1).getFilePath()); String oldContent1 = codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey1).getContent(); String newContent1 = user.email() + "\n"; @@ -220,7 +219,7 @@ .addCodeOwnerEmail(user.email()) .create(); Path path2 = - Paths.get(codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey2).getFilePath()); + Path.of(codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey2).getFilePath()); String oldContent2 = codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey2).getContent(); String newContent2 = user2.email() + "\n"; @@ -265,7 +264,7 @@ assertThat(update).isPresent(); // Verify that we received the expected callbacks for the invalid code onwer config. - Mockito.verify(updater).update(Paths.get("/OWNERS"), "INVALID"); + Mockito.verify(updater).update(Path.of("/OWNERS"), "INVALID"); verifyNoMoreInteractions(updater); // Verify the code owner config file was updated. @@ -282,7 +281,7 @@ approve(changeId); gApi.changes().id(changeId).current().submit(); enableCodeOwnersForProject(project); - Path path = Paths.get(filePath); + Path path = Path.of(filePath); return CodeOwnerConfig.Key.create( project, "master", path.getParent().toString(), path.getFileName().toString()); }
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigHierarchyTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigHierarchyTest.java index 0422551..670ecf1 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigHierarchyTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigHierarchyTest.java
@@ -35,7 +35,7 @@ import com.google.gerrit.server.restapi.project.DeleteRef; import com.google.inject.Inject; import java.io.IOException; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.function.Consumer; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; @@ -83,7 +83,7 @@ codeOwnerConfigHierarchy.visit( /* branchNameKey= */ null, getCurrentRevision(BranchNameKey.create(project, "master")), - Paths.get("/foo/bar/baz.md"), + Path.of("/foo/bar/baz.md"), visitor)); assertThat(npe).hasMessageThat().isEqualTo("branch"); } @@ -93,7 +93,7 @@ codeOwnerConfigHierarchy.visit( BranchNameKey.create(project, "master"), /* revision= */ null, - Paths.get("/foo/bar/baz.md"), + Path.of("/foo/bar/baz.md"), visitor); verifyNoInteractions(visitor); } @@ -124,7 +124,7 @@ codeOwnerConfigHierarchy.visit( branchNameKey, getCurrentRevision(branchNameKey), - Paths.get(relativePath), + Path.of(relativePath), visitor)); assertThat(exception) .hasMessageThat() @@ -141,7 +141,7 @@ codeOwnerConfigHierarchy.visit( branchNameKey, getCurrentRevision(branchNameKey), - Paths.get("/foo/bar/baz.md"), + Path.of("/foo/bar/baz.md"), /* codeOwnerConfigVisitor= */ null)); assertThat(npe).hasMessageThat().isEqualTo("codeOwnerConfigVisitor"); } @@ -156,7 +156,7 @@ codeOwnerConfigHierarchy.visit( branchNameKey, getCurrentRevision(branchNameKey), - Paths.get("/foo/bar/baz.md"), + Path.of("/foo/bar/baz.md"), visitor, /* parentCodeOwnersIgnoredCallback= */ null)); assertThat(npe).hasMessageThat().isEqualTo("parentCodeOwnersIgnoredCallback"); @@ -320,7 +320,7 @@ when(visitor.visit(any(CodeOwnerConfig.class))).thenReturn(true); codeOwnerConfigHierarchy.visit( - BranchNameKey.create(project, branch), revision1, Paths.get("/foo/bar/baz.md"), visitor); + BranchNameKey.create(project, branch), revision1, Path.of("/foo/bar/baz.md"), visitor); // Verify that we received the callbacks for the code owner configs from the old revison, in // the right order, starting from the folder of the given path up to the root folder. @@ -593,7 +593,7 @@ codeOwnerConfigHierarchy.visit( BranchNameKey.create(project, "master"), /* revision= */ null, - Paths.get("/foo/bar/baz.md"), + Path.of("/foo/bar/baz.md"), visitor); verify(visitor).visit(codeOwnerConfigOperations.codeOwnerConfig(metaCodeOwnerConfigKey).get()); verifyNoMoreInteractions(visitor); @@ -781,7 +781,7 @@ codeOwnerConfigHierarchy.visit( branchNameKey, getCurrentRevision(branchNameKey), - Paths.get(path), + Path.of(path), visitor, parentCodeOwnersIgnoredCallback); }
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReferenceTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReferenceTest.java index 332ec6b..f82b4cf 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReferenceTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReferenceTest.java
@@ -22,7 +22,6 @@ import com.google.common.truth.Truth8; import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Optional; import org.junit.Test; @@ -53,7 +52,7 @@ @Test public void absoluteFilePathCanBeSpecifiedInDifferentFormats() throws Exception { - Path expectedPath = Paths.get("/foo/OWNERS"); + Path expectedPath = Path.of("/foo/OWNERS"); for (String inputPath : new String[] {"/foo/OWNERS", "//foo/OWNERS"}) { Path path = CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, inputPath).filePath(); @@ -66,7 +65,7 @@ public void relativeFilePathCanBeSpecified() throws Exception { Path path = CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "foo/OWNERS").filePath(); - Truth8.assertThat(path).isEqualTo(Paths.get("foo/OWNERS")); + Truth8.assertThat(path).isEqualTo(Path.of("foo/OWNERS")); assertThat(path.isAbsolute()).isFalse(); } }
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigScannerTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigScannerTest.java index 18fff7f..0d33dc6 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigScannerTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigScannerTest.java
@@ -27,7 +27,7 @@ import com.google.gerrit.entities.RefNames; import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest; import com.google.gerrit.plugins.codeowners.acceptance.testsuite.CodeOwnerConfigOperations; -import java.nio.file.Paths; +import java.nio.file.Path; import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; @@ -159,7 +159,7 @@ // Verify that we received the expected callbacks for the invalid code onwer config. Mockito.verify(invalidCodeOwnerConfigCallback) .onInvalidCodeOwnerConfig( - eq(Paths.get("/OWNERS")), any(InvalidCodeOwnerConfigException.class)); + eq(Path.of("/OWNERS")), any(InvalidCodeOwnerConfigException.class)); verifyNoMoreInteractions(invalidCodeOwnerConfigCallback); } @@ -190,7 +190,7 @@ // Verify that we received the expected callbacks for the invalid code onwer config. Mockito.verify(invalidCodeOwnerConfigCallback) .onInvalidCodeOwnerConfig( - eq(Paths.get("/OWNERS")), any(InvalidCodeOwnerConfigException.class)); + eq(Path.of("/OWNERS")), any(InvalidCodeOwnerConfigException.class)); verifyNoMoreInteractions(invalidCodeOwnerConfigCallback); }
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigTest.java index 09b40ca..764a576 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigTest.java
@@ -23,7 +23,6 @@ import com.google.gerrit.entities.RefNames; import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest; import java.nio.file.Path; -import java.nio.file.Paths; import org.eclipse.jgit.lib.ObjectId; import org.junit.Test; @@ -40,7 +39,7 @@ CodeOwnerConfig.Key codeOwnerConfigKeyCreatedByCustomConstructor = CodeOwnerConfig.Key.create(project, branch, folderPath); CodeOwnerConfig.Key codeOwnerConfigKeyCreatedByAutoValueConstructor = - CodeOwnerConfig.Key.create(BranchNameKey.create(project, branch), Paths.get(folderPath)); + CodeOwnerConfig.Key.create(BranchNameKey.create(project, branch), Path.of(folderPath)); assertThat(codeOwnerConfigKeyCreatedByCustomConstructor) .isEqualTo(codeOwnerConfigKeyCreatedByAutoValueConstructor); } @@ -89,7 +88,7 @@ CodeOwnerConfig.Key codeOwnerConfigKey = CodeOwnerConfig.Key.create(Project.nameKey("project"), "master", folderPath); Truth8.assertThat(codeOwnerConfigKey.filePath("OWNERS")) - .isEqualTo(Paths.get(folderPath, "OWNERS")); + .isEqualTo(Path.of(folderPath, "OWNERS")); } @Test @@ -100,7 +99,7 @@ CodeOwnerConfig.Key.create( Project.nameKey("project"), "master", folderPath, customFileName); Truth8.assertThat(codeOwnerConfigKey.filePath("OWNERS")) - .isEqualTo(Paths.get(folderPath, customFileName)); + .isEqualTo(Path.of(folderPath, customFileName)); } @Test @@ -138,17 +137,17 @@ CodeOwnerConfig.builder( CodeOwnerConfig.Key.create( BranchNameKey.create(Project.nameKey("project"), "master"), - Paths.get("/foo/bar/")), + Path.of("/foo/bar/")), TEST_REVISION) .build(); - Path relativizedPath = codeOwnerConfig.relativize(Paths.get("/foo/bar/baz.md")); - Truth8.assertThat(relativizedPath).isEqualTo(Paths.get("baz.md")); + Path relativizedPath = codeOwnerConfig.relativize(Path.of("/foo/bar/baz.md")); + Truth8.assertThat(relativizedPath).isEqualTo(Path.of("baz.md")); } private static CodeOwnerConfig.Builder createCodeOwnerBuilder() { return CodeOwnerConfig.builder( CodeOwnerConfig.Key.create( - BranchNameKey.create(Project.nameKey("project"), "master"), Paths.get("/")), + BranchNameKey.create(Project.nameKey("project"), "master"), Path.of("/")), TEST_REVISION); } }
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerResolverTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerResolverTest.java index 6171aca..e64c53e 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerResolverTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerResolverTest.java
@@ -35,7 +35,7 @@ import com.google.inject.Inject; import com.google.inject.Key; import com.google.inject.Provider; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.Optional; import java.util.Set; import org.eclipse.jgit.lib.ObjectId; @@ -358,7 +358,7 @@ CodeOwnerResolverResult result = codeOwnerResolverProvider .get() - .resolvePathCodeOwners(codeOwnerConfig, Paths.get("/README.md")); + .resolvePathCodeOwners(codeOwnerConfig, Path.of("/README.md")); assertThat(result.codeOwners()).isEmpty(); assertThat(result.ownedByAllUsers()).isFalse(); assertThat(result.hasUnresolvedCodeOwners()).isFalse(); @@ -374,7 +374,7 @@ CodeOwnerResolverResult result = codeOwnerResolverProvider .get() - .resolvePathCodeOwners(codeOwnerConfig, Paths.get("/README.md")); + .resolvePathCodeOwners(codeOwnerConfig, Path.of("/README.md")); assertThat(result.codeOwnersAccountIds()).containsExactly(admin.id(), user.id()); assertThat(result.ownedByAllUsers()).isFalse(); assertThat(result.hasUnresolvedCodeOwners()).isFalse(); @@ -391,7 +391,7 @@ CodeOwnerResolverResult result = codeOwnerResolverProvider .get() - .resolvePathCodeOwners(codeOwnerConfig, Paths.get("/README.md")); + .resolvePathCodeOwners(codeOwnerConfig, Path.of("/README.md")); assertThat(result.codeOwnersAccountIds()).isEmpty(); assertThat(result.ownedByAllUsers()).isTrue(); assertThat(result.hasUnresolvedCodeOwners()).isFalse(); @@ -408,7 +408,7 @@ CodeOwnerResolverResult result = codeOwnerResolverProvider .get() - .resolvePathCodeOwners(codeOwnerConfig, Paths.get("/README.md")); + .resolvePathCodeOwners(codeOwnerConfig, Path.of("/README.md")); assertThat(result.codeOwnersAccountIds()).containsExactly(admin.id()); assertThat(result.ownedByAllUsers()).isFalse(); assertThat(result.hasUnresolvedCodeOwners()).isTrue(); @@ -426,7 +426,7 @@ CodeOwnerResolverResult result = codeOwnerResolverProvider .get() - .resolvePathCodeOwners(codeOwnerConfig, Paths.get("/README.md")); + .resolvePathCodeOwners(codeOwnerConfig, Path.of("/README.md")); assertThat(result.codeOwnersAccountIds()).containsExactly(admin.id()); assertThat(result.ownedByAllUsers()).isTrue(); assertThat(result.hasUnresolvedCodeOwners()).isTrue(); @@ -452,7 +452,7 @@ CodeOwnerResolverResult result = codeOwnerResolverProvider .get() - .resolvePathCodeOwners(codeOwnerConfig, Paths.get("/README.md")); + .resolvePathCodeOwners(codeOwnerConfig, Path.of("/README.md")); assertThat(result.codeOwnersAccountIds()).containsExactly(admin.id(), user.id(), user2.id()); assertThat(result.annotations().keySet()) .containsExactly(CodeOwner.create(admin.id()), CodeOwner.create(user.id())); @@ -480,7 +480,7 @@ CodeOwnerResolverResult result = codeOwnerResolverProvider .get() - .resolvePathCodeOwners(codeOwnerConfig, Paths.get("/README.md")); + .resolvePathCodeOwners(codeOwnerConfig, Path.of("/README.md")); assertThat(result.codeOwnersAccountIds()).containsExactly(admin.id(), user.id()); assertThat(result.annotations().keySet()) .containsExactly(CodeOwner.create(admin.id()), CodeOwner.create(user.id())); @@ -513,7 +513,7 @@ CodeOwnerResolverResult result = codeOwnerResolverProvider .get() - .resolvePathCodeOwners(codeOwnerConfig, Paths.get("/README.md")); + .resolvePathCodeOwners(codeOwnerConfig, Path.of("/README.md")); assertThat(result.codeOwnersAccountIds()).containsExactly(user.id()); assertThat(result.annotations().keySet()).containsExactly(CodeOwner.create(user.id())); assertThat(result.annotations().get(CodeOwner.create(user.id()))) @@ -528,7 +528,7 @@ () -> codeOwnerResolverProvider .get() - .resolvePathCodeOwners(/* codeOwnerConfig= */ null, Paths.get("/README.md"))); + .resolvePathCodeOwners(/* codeOwnerConfig= */ null, Path.of("/README.md"))); assertThat(npe).hasMessageThat().isEqualTo("codeOwnerConfig"); } @@ -571,7 +571,7 @@ () -> codeOwnerResolverProvider .get() - .resolvePathCodeOwners(codeOwnerConfig, Paths.get(relativePath))); + .resolvePathCodeOwners(codeOwnerConfig, Path.of(relativePath))); assertThat(npe) .hasMessageThat() .isEqualTo(String.format("path %s must be absolute", relativePath));
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersResultTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersResultTest.java index d9b3a71..a33835d 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersResultTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersResultTest.java
@@ -15,7 +15,7 @@ package com.google.gerrit.plugins.codeowners.backend; import com.google.common.collect.ImmutableList; -import java.nio.file.Paths; +import java.nio.file.Path; import org.eclipse.jgit.lib.ObjectId; import org.junit.Test; @@ -33,7 +33,7 @@ CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "/baz/OWNERS"); PathCodeOwnersResult pathCodeOwnersResult = PathCodeOwnersResult.create( - Paths.get("/foo/bar/baz.md"), + Path.of("/foo/bar/baz.md"), CodeOwnerConfig.builder(codeOwnerConfigKey, TEST_REVISION) .addImport(resolvableCodeOwnerConfigReference) .addImport(unresolvableCodeOwnerConfigReference)
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java index 04df442..9accde0 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java
@@ -45,7 +45,6 @@ import com.google.inject.Provider; import com.google.inject.util.Providers; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Optional; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.revwalk.RevCommit; @@ -78,7 +77,7 @@ public void createPathCodeOwnersForCodeOwnerConfig() throws Exception { PathCodeOwners pathCodeOwners = pathCodeOwnersFactory.createWithoutCache( - createCodeOwnerBuilder().build(), Paths.get("/foo/bar/baz.md")); + createCodeOwnerBuilder().build(), Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners).isNotNull(); } @@ -89,7 +88,7 @@ NullPointerException.class, () -> pathCodeOwnersFactory.createWithoutCache( - /* codeOwnerConfig= */ null, Paths.get("/foo/bar/baz.md"))); + /* codeOwnerConfig= */ null, Path.of("/foo/bar/baz.md"))); assertThat(npe).hasMessageThat().isEqualTo("codeOwnerConfig"); } @@ -112,8 +111,7 @@ IllegalStateException exception = assertThrows( IllegalStateException.class, - () -> - pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Paths.get(relativePath))); + () -> pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Path.of(relativePath))); assertThat(exception) .hasMessageThat() .isEqualTo(String.format("path %s must be absolute", relativePath)); @@ -135,7 +133,7 @@ transientCodeOwnerConfigCacheProvider.get(), codeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners).isPresent(); } @@ -148,9 +146,9 @@ pathCodeOwnersFactory.create( /* transientCodeOwnerConfigCache= */ null, CodeOwnerConfig.Key.create( - BranchNameKey.create(project, "master"), Paths.get("/")), + BranchNameKey.create(project, "master"), Path.of("/")), projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md"))); + Path.of("/foo/bar/baz.md"))); assertThat(npe).hasMessageThat().isEqualTo("transientCodeOwnerConfigCache"); } @@ -164,7 +162,7 @@ transientCodeOwnerConfigCacheProvider.get(), /* codeOwnerConfigKey= */ null, projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md"))); + Path.of("/foo/bar/baz.md"))); assertThat(npe).hasMessageThat().isEqualTo("codeOwnerConfigKey"); } @@ -177,9 +175,9 @@ pathCodeOwnersFactory.create( transientCodeOwnerConfigCacheProvider.get(), CodeOwnerConfig.Key.create( - BranchNameKey.create(project, "master"), Paths.get("/")), + BranchNameKey.create(project, "master"), Path.of("/")), /* revision= */ null, - Paths.get("/foo/bar/baz.md"))); + Path.of("/foo/bar/baz.md"))); assertThat(npe).hasMessageThat().isEqualTo("revision"); } @@ -226,7 +224,7 @@ transientCodeOwnerConfigCacheProvider.get(), codeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get(relativePath))); + Path.of(relativePath))); assertThat(exception) .hasMessageThat() .isEqualTo(String.format("path %s must be absolute", relativePath)); @@ -236,8 +234,7 @@ public void getEmptyPathCodeOwners() throws Exception { CodeOwnerConfig emptyCodeOwnerConfig = createCodeOwnerBuilder().build(); PathCodeOwners pathCodeOwners = - pathCodeOwnersFactory.createWithoutCache( - emptyCodeOwnerConfig, Paths.get("/foo/bar/baz.md")); + pathCodeOwnersFactory.createWithoutCache(emptyCodeOwnerConfig, Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().getPathCodeOwners()).isEmpty(); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().resolvedImports()).isEmpty(); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().unresolvedImports()).isEmpty(); @@ -250,7 +247,7 @@ .addCodeOwnerSet(CodeOwnerSet.createWithoutPathExpressions(admin.email(), user.email())) .build(); PathCodeOwners pathCodeOwners = - pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Paths.get("/foo/bar/baz.md")); + pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().getPathCodeOwners()) .comparingElementsUsing(hasEmail()) .containsExactly(admin.email(), user.email()); @@ -288,7 +285,7 @@ .addCodeOwnerSet(nonMatchingCodeOwnerSet) .build(); PathCodeOwners pathCodeOwners = - pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Paths.get("/foo/bar/baz.md")); + pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().getPathCodeOwners()) .comparingElementsUsing(hasEmail()) .containsExactly(admin.email(), user.email()); @@ -309,7 +306,7 @@ .build()) .build(); PathCodeOwners pathCodeOwners = - pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Paths.get("/foo/bar/baz.md")); + pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().getPathCodeOwners()).isEmpty(); } } @@ -341,7 +338,7 @@ .addCodeOwnerSet(globalCodeOwnerSet) .build(); PathCodeOwners pathCodeOwners = - pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Paths.get("/foo/bar/baz.md")); + pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().getPathCodeOwners()) .comparingElementsUsing(hasEmail()) .containsExactly(admin.email()); @@ -375,7 +372,7 @@ .addCodeOwnerSet(globalCodeOwnerSet) .build(); PathCodeOwners pathCodeOwners = - pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Paths.get("/foo/bar/baz.md")); + pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().getPathCodeOwners()) .comparingElementsUsing(hasEmail()) .containsExactly(admin.email(), user.email()); @@ -410,7 +407,7 @@ .addCodeOwnerSet(perFileCodeOwnerSet2) .build(); PathCodeOwners pathCodeOwners = - pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Paths.get("/foo/bar/baz.md")); + pathCodeOwnersFactory.createWithoutCache(codeOwnerConfig, Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().getPathCodeOwners()) .comparingElementsUsing(hasEmail()) .containsExactly(admin.email(), user.email()); @@ -423,7 +420,7 @@ PathCodeOwners pathCodeOwners = pathCodeOwnersFactory.createWithoutCache( createCodeOwnerBuilder().setIgnoreParentCodeOwners().build(), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().ignoreParentCodeOwners()).isTrue(); } @@ -433,7 +430,7 @@ PathCodeOwners pathCodeOwners = pathCodeOwnersFactory.createWithoutCache( createCodeOwnerBuilder().setIgnoreParentCodeOwners(false).build(), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().ignoreParentCodeOwners()).isFalse(); } @@ -449,7 +446,7 @@ .addPathExpression("*.md") .build()) .build(), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().ignoreParentCodeOwners()).isTrue(); } @@ -466,7 +463,7 @@ .addPathExpression("*.txt") .build()) .build(), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners.resolveCodeOwnerConfig().get().ignoreParentCodeOwners()).isFalse(); } @@ -493,7 +490,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global code owner from the importing code owner config, the @@ -549,7 +546,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global code owner from the importing code owner config, the @@ -608,7 +605,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global code owner from the importing code owner config, the @@ -669,7 +666,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global code owner from the importing code owner config and the global @@ -727,7 +724,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global code owners from the importing and the imported code owner @@ -784,7 +781,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the matching per-file code owners from the importing and the imported @@ -841,7 +838,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we only get the matching per-file code owners from the importing code owner @@ -900,7 +897,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we only get the matching per-file code owners from the importing code owner @@ -958,7 +955,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we only get the matching per-file code owners from the imported code owner @@ -1019,7 +1016,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we only get the global code owners from the importing code owner config, the @@ -1079,7 +1076,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we only get the global code owners from the importing code owner config, the @@ -1131,7 +1128,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: ignoreParentCodeOwners is true because the ignoreParentCodeOwners flag in the @@ -1180,7 +1177,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: ignoreParentCodeOwners is false because the ignoreParentCodeOwners flag in the @@ -1255,7 +1252,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing code owner config, the imported code @@ -1332,7 +1329,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing code owner config and the imported @@ -1400,7 +1397,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global code owners from the importing and the imported code owner @@ -1454,7 +1451,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing and the imported code owner config @@ -1516,7 +1513,7 @@ transientCodeOwnerConfigCacheProvider.get(), rootCodeOwnerConfigKey, oldRevision, - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing and the imported code owner config @@ -1557,7 +1554,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing and the imported code owner config @@ -1597,7 +1594,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing code owner config @@ -1650,7 +1647,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing code owner config, the global code @@ -1695,7 +1692,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing code owner config @@ -1746,7 +1743,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing and the imported code owner config @@ -1805,7 +1802,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead(branchName), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing and the imported code owner config @@ -1857,7 +1854,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing and the imported code owner config @@ -1911,7 +1908,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo/bar/baz.md")); + Path.of("/foo/bar/baz.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing and the imported code owner config @@ -1956,7 +1953,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the per file code owner from the importing code owner config, the @@ -2025,7 +2022,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the per file code owners from the importing and the global code owner @@ -2101,7 +2098,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing code owner config, the imported code @@ -2179,7 +2176,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing code owner config and the imported @@ -2276,7 +2273,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.xyz")); + Path.of("/foo.xyz")); assertThat(pathCodeOwners).isPresent(); PathCodeOwnersResult pathCodeOwnersResult = pathCodeOwners.get().resolveCodeOwnerConfig().get(); assertThat(pathCodeOwnersResult.getPathCodeOwners()).isEmpty(); @@ -2294,7 +2291,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); pathCodeOwnersResult = pathCodeOwners.get().resolveCodeOwnerConfig().get(); assertThat(pathCodeOwnersResult.getPathCodeOwners()) @@ -2319,7 +2316,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.txt")); + Path.of("/foo.txt")); assertThat(pathCodeOwners).isPresent(); pathCodeOwnersResult = pathCodeOwners.get().resolveCodeOwnerConfig().get(); assertThat(pathCodeOwnersResult.getPathCodeOwners()) @@ -2345,7 +2342,7 @@ () -> PathCodeOwners.matches( /* codeOwnerSet= */ null, - Paths.get("bar/baz.md"), + Path.of("bar/baz.md"), mock(PathExpressionMatcher.class))); assertThat(npe).hasMessageThat().isEqualTo("codeOwnerSet"); } @@ -2372,7 +2369,7 @@ () -> PathCodeOwners.matches( CodeOwnerSet.createWithoutPathExpressions(admin.email()), - Paths.get(absolutePath), + Path.of(absolutePath), mock(PathExpressionMatcher.class))); assertThat(exception) .hasMessageThat() @@ -2387,7 +2384,7 @@ () -> PathCodeOwners.matches( CodeOwnerSet.createWithoutPathExpressions(admin.email()), - Paths.get("bar/baz.md"), + Path.of("bar/baz.md"), /* matcher= */ null)); assertThat(npe).hasMessageThat().isEqualTo("matcher"); } @@ -2401,7 +2398,7 @@ () -> PathCodeOwners.matches( CodeOwnerSet.createWithoutPathExpressions(admin.email()), - Paths.get("bar/baz.md"), + Path.of("bar/baz.md"), pathExpressionMatcher)); assertThat(exception).hasMessageThat().isEqualTo("code owner set must have path expressions"); } @@ -2416,7 +2413,7 @@ .addPathExpression("*.md") .addCodeOwnerEmail(admin.email()) .build(), - Paths.get("bar/baz.md"), + Path.of("bar/baz.md"), pathExpressionMatcher)) .isTrue(); } @@ -2431,7 +2428,7 @@ .addPathExpression("*.md") .addCodeOwnerEmail(admin.email()) .build(), - Paths.get("bar/baz.md"), + Path.of("bar/baz.md"), pathExpressionMatcher)) .isFalse(); } @@ -2450,7 +2447,7 @@ .addPathExpression("build/*") .addCodeOwnerEmail(admin.email()) .build(), - Paths.get("bar/baz.md"), + Path.of("bar/baz.md"), pathExpressionMatcher)) .isTrue(); } @@ -2496,7 +2493,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global code owner from the imported code owner config (since it is @@ -2564,7 +2561,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the code owner from the matching per-file rule in the importing code @@ -2635,7 +2632,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing code owner config and from the @@ -2708,7 +2705,7 @@ transientCodeOwnerConfigCacheProvider.get(), importingCodeOwnerConfigKey, projectOperations.project(project).getHead("master"), - Paths.get("/foo.md")); + Path.of("/foo.md")); assertThat(pathCodeOwners).isPresent(); // Expectation: we get the global owners from the importing code owner config and from the @@ -2732,7 +2729,7 @@ private CodeOwnerConfig.Builder createCodeOwnerBuilder() { return CodeOwnerConfig.builder( - CodeOwnerConfig.Key.create(BranchNameKey.create(project, "master"), Paths.get("/")), + CodeOwnerConfig.Key.create(BranchNameKey.create(project, "master"), Path.of("/")), ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef")); }
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java index 260e635..199dfc1 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java
@@ -36,7 +36,6 @@ import com.google.gerrit.plugins.codeowners.testing.CodeOwnerConfigReferenceSubject; import com.google.gerrit.plugins.codeowners.testing.CodeOwnerSetSubject; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.regex.Pattern; import org.junit.Test; @@ -221,7 +220,7 @@ @Test public void importCodeOwnerConfigWithComment() throws Exception { - Path path = Paths.get("/foo/bar/OWNERS"); + Path path = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference = CodeOwnerConfigReference.builder(CodeOwnerConfigImportMode.ALL, path).build(); assertParseAndFormat( @@ -385,7 +384,7 @@ @Test public void importCodeOwnerConfigFromSameProjectAndBranch() throws Exception { - Path path = Paths.get("/foo/bar/OWNERS"); + Path path = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference = CodeOwnerConfigReference.builder(CodeOwnerConfigImportMode.ALL, path).build(); assertParseAndFormat( @@ -402,7 +401,7 @@ @Test public void importCodeOwnerConfigFromOtherProject() throws Exception { String otherProject = "otherProject"; - Path path = Paths.get("/foo/bar/OWNERS"); + Path path = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference = CodeOwnerConfigReference.builder(CodeOwnerConfigImportMode.ALL, path) .setProject(Project.nameKey(otherProject)) @@ -420,7 +419,7 @@ @Test public void cannotFormatCodeOwnerConfigWithImportThatSpecifiesBranchWithoutProject() throws Exception { - Path path = Paths.get("/foo/bar/OWNERS"); + Path path = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference = CodeOwnerConfigReference.builder(CodeOwnerConfigImportMode.ALL, path) .setBranch("refs/heads/foo") @@ -453,7 +452,7 @@ } private void testImportCodeOwnerConfigFromOtherBranch(String branchName) throws Exception { - Path path = Paths.get("/foo/bar/OWNERS"); + Path path = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference = CodeOwnerConfigReference.builder(CodeOwnerConfigImportMode.ALL, path) .setProject(project) @@ -507,10 +506,10 @@ @Test public void importMultipleCodeOwnerConfigs() throws Exception { - Path path1 = Paths.get("/foo/bar/OWNERS"); + Path path1 = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference1 = CodeOwnerConfigReference.builder(CodeOwnerConfigImportMode.ALL, path1).build(); - Path path2 = Paths.get("/foo/baz/OWNERS"); + Path path2 = Path.of("/foo/baz/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference2 = CodeOwnerConfigReference.builder( CodeOwnerConfigImportMode.GLOBAL_CODE_OWNER_SETS_ONLY, path2) @@ -569,7 +568,7 @@ @Test public void perFileCodeOwnerConfigImportFromSameProjectAndBranch() throws Exception { - Path path = Paths.get("/foo/bar/OWNERS"); + Path path = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference = CodeOwnerConfigReference.builder( CodeOwnerConfigImportMode.GLOBAL_CODE_OWNER_SETS_ONLY, path) @@ -600,7 +599,7 @@ @Test public void perFileCodeOwnerConfigImportFromOtherProject() throws Exception { String otherProject = "otherProject"; - Path path = Paths.get("/foo/bar/OWNERS"); + Path path = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference = CodeOwnerConfigReference.builder( CodeOwnerConfigImportMode.GLOBAL_CODE_OWNER_SETS_ONLY, path) @@ -631,7 +630,7 @@ @Test public void cannotFormatCodeOwnerConfigWithPerFileImportThatSpecifiesBranchWithoutProject() throws Exception { - Path path = Paths.get("/foo/bar/OWNERS"); + Path path = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference = CodeOwnerConfigReference.builder( CodeOwnerConfigImportMode.GLOBAL_CODE_OWNER_SETS_ONLY, path) @@ -670,7 +669,7 @@ private void testPerFileImportOfCodeOwnerConfigFromOtherBranch(String branchName) throws Exception { - Path path = Paths.get("/foo/bar/OWNERS"); + Path path = Path.of("/foo/bar/OWNERS"); CodeOwnerConfigReference codeOwnerConfigReference = CodeOwnerConfigReference.builder( CodeOwnerConfigImportMode.GLOBAL_CODE_OWNER_SETS_ONLY, path)
diff --git a/javatests/com/google/gerrit/plugins/codeowners/restapi/CodeOwnerStatusInfoJsonTest.java b/javatests/com/google/gerrit/plugins/codeowners/restapi/CodeOwnerStatusInfoJsonTest.java index 17fbdb1..67884c0 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/restapi/CodeOwnerStatusInfoJsonTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/restapi/CodeOwnerStatusInfoJsonTest.java
@@ -38,7 +38,7 @@ import com.google.gerrit.plugins.codeowners.testing.FileCodeOwnerStatusInfoSubject; import com.google.gerrit.server.util.AccountTemplateUtil; import com.google.gerrit.truth.ListSubject; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.Optional; import org.eclipse.jgit.diff.DiffEntry; import org.junit.Before; @@ -67,7 +67,7 @@ @Test public void formatPathCodeOwnerStatus() throws Exception { PathCodeOwnerStatus pathCodeOwnerStatus = - PathCodeOwnerStatus.create(Paths.get("/foo/bar.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/bar.baz"), CodeOwnerStatus.APPROVED); PathCodeOwnerStatusInfo pathCodeOwnerStatusInfo = CodeOwnerStatusInfoJson.format(pathCodeOwnerStatus); assertThat(pathCodeOwnerStatusInfo).hasPathThat().isEqualTo("foo/bar.baz"); @@ -78,7 +78,7 @@ @Test public void formatPathCodeOwnerStatusWithReasons() throws Exception { PathCodeOwnerStatus pathCodeOwnerStatus = - PathCodeOwnerStatus.builder(Paths.get("/foo/bar.baz"), CodeOwnerStatus.APPROVED) + PathCodeOwnerStatus.builder(Path.of("/foo/bar.baz"), CodeOwnerStatus.APPROVED) .addReason("one reason") .addReason("another reason") .build(); @@ -107,7 +107,7 @@ ChangedFile changedFile = mock(ChangedFile.class); when(changedFile.changeType()).thenReturn(DiffEntry.ChangeType.ADD); PathCodeOwnerStatus pathCodeOwnerStatus = - PathCodeOwnerStatus.create(Paths.get("/foo/bar.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/bar.baz"), CodeOwnerStatus.APPROVED); FileCodeOwnerStatus fileCodeOwnerStatus = FileCodeOwnerStatus.create(changedFile, Optional.of(pathCodeOwnerStatus), Optional.empty()); FileCodeOwnerStatusInfo fileCodeOwnerStatusInfo = @@ -131,7 +131,7 @@ ChangedFile changedFile = mock(ChangedFile.class); when(changedFile.changeType()).thenReturn(DiffEntry.ChangeType.MODIFY); PathCodeOwnerStatus pathCodeOwnerStatus = - PathCodeOwnerStatus.create(Paths.get("/foo/bar.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/bar.baz"), CodeOwnerStatus.APPROVED); FileCodeOwnerStatus fileCodeOwnerStatus = FileCodeOwnerStatus.create(changedFile, Optional.of(pathCodeOwnerStatus), Optional.empty()); FileCodeOwnerStatusInfo fileCodeOwnerStatusInfo = @@ -155,7 +155,7 @@ ChangedFile changedFile = mock(ChangedFile.class); when(changedFile.changeType()).thenReturn(DiffEntry.ChangeType.DELETE); PathCodeOwnerStatus pathCodeOwnerStatus = - PathCodeOwnerStatus.create(Paths.get("/foo/bar.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/bar.baz"), CodeOwnerStatus.APPROVED); FileCodeOwnerStatus fileCodeOwnerStatus = FileCodeOwnerStatus.create(changedFile, Optional.empty(), Optional.of(pathCodeOwnerStatus)); FileCodeOwnerStatusInfo fileCodeOwnerStatusInfo = @@ -179,9 +179,9 @@ ChangedFile changedFile = mock(ChangedFile.class); when(changedFile.changeType()).thenReturn(DiffEntry.ChangeType.RENAME); PathCodeOwnerStatus newPathCodeOwnerStatus = - PathCodeOwnerStatus.create(Paths.get("/foo/new.baz"), CodeOwnerStatus.PENDING); + PathCodeOwnerStatus.create(Path.of("/foo/new.baz"), CodeOwnerStatus.PENDING); PathCodeOwnerStatus oldPathCodeOwnerStatus = - PathCodeOwnerStatus.create(Paths.get("/foo/old.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/old.baz"), CodeOwnerStatus.APPROVED); FileCodeOwnerStatus fileCodeOwnerStatus = FileCodeOwnerStatus.create( changedFile, Optional.of(newPathCodeOwnerStatus), Optional.of(oldPathCodeOwnerStatus)); @@ -235,7 +235,7 @@ ChangedFile changedFile = mock(ChangedFile.class); when(changedFile.changeType()).thenReturn(DiffEntry.ChangeType.ADD); PathCodeOwnerStatus pathCodeOwnerStatus = - PathCodeOwnerStatus.create(Paths.get("/foo/bar.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/bar.baz"), CodeOwnerStatus.APPROVED); FileCodeOwnerStatus fileCodeOwnerStatus = FileCodeOwnerStatus.create(changedFile, Optional.of(pathCodeOwnerStatus), Optional.empty()); CodeOwnerStatusInfo codeOwnerStatusInfo = @@ -265,7 +265,7 @@ ChangedFile changedFile = mock(ChangedFile.class); when(changedFile.changeType()).thenReturn(DiffEntry.ChangeType.ADD); PathCodeOwnerStatus pathCodeOwnerStatus = - PathCodeOwnerStatus.builder(Paths.get("/foo/bar.baz"), CodeOwnerStatus.APPROVED) + PathCodeOwnerStatus.builder(Path.of("/foo/bar.baz"), CodeOwnerStatus.APPROVED) .addReason("one reason") .addReason("another reason") .build(); @@ -312,7 +312,7 @@ ChangedFile changedFile = mock(ChangedFile.class); when(changedFile.changeType()).thenReturn(DiffEntry.ChangeType.ADD); PathCodeOwnerStatus pathCodeOwnerStatus = - PathCodeOwnerStatus.builder(Paths.get("/foo/bar.baz"), CodeOwnerStatus.APPROVED) + PathCodeOwnerStatus.builder(Path.of("/foo/bar.baz"), CodeOwnerStatus.APPROVED) .addReason(reason1) .addReason(reason2) .build(); @@ -349,7 +349,7 @@ ChangedFile changedFile1 = mock(ChangedFile.class); when(changedFile1.changeType()).thenReturn(DiffEntry.ChangeType.ADD); PathCodeOwnerStatus pathCodeOwnerStatus1 = - PathCodeOwnerStatus.create(Paths.get("/foo/a/bar.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/a/bar.baz"), CodeOwnerStatus.APPROVED); FileCodeOwnerStatus fileCodeOwnerStatus1 = FileCodeOwnerStatus.create( changedFile1, Optional.of(pathCodeOwnerStatus1), Optional.empty()); @@ -357,7 +357,7 @@ ChangedFile changedFile2 = mock(ChangedFile.class); when(changedFile2.changeType()).thenReturn(DiffEntry.ChangeType.DELETE); PathCodeOwnerStatus pathCodeOwnerStatus2 = - PathCodeOwnerStatus.create(Paths.get("/foo/b/bar.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/b/bar.baz"), CodeOwnerStatus.APPROVED); FileCodeOwnerStatus fileCodeOwnerStatus2 = FileCodeOwnerStatus.create( changedFile2, Optional.empty(), Optional.of(pathCodeOwnerStatus2)); @@ -365,9 +365,9 @@ ChangedFile changedFile3 = mock(ChangedFile.class); when(changedFile3.changeType()).thenReturn(DiffEntry.ChangeType.DELETE); PathCodeOwnerStatus newPathCodeOwnerStatus3 = - PathCodeOwnerStatus.create(Paths.get("/foo/c/new.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/c/new.baz"), CodeOwnerStatus.APPROVED); PathCodeOwnerStatus oldPathCodeOwnerStatus3 = - PathCodeOwnerStatus.create(Paths.get("/foo/c/old.baz"), CodeOwnerStatus.APPROVED); + PathCodeOwnerStatus.create(Path.of("/foo/c/old.baz"), CodeOwnerStatus.APPROVED); FileCodeOwnerStatus fileCodeOwnerStatus3 = FileCodeOwnerStatus.create( changedFile3,
diff --git a/javatests/com/google/gerrit/plugins/codeowners/util/JgitPathTest.java b/javatests/com/google/gerrit/plugins/codeowners/util/JgitPathTest.java index 1340aea..9571146 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/util/JgitPathTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/util/JgitPathTest.java
@@ -20,7 +20,6 @@ import com.google.common.truth.Truth8; import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest; import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.Test; /** Tests for {@link com.google.gerrit.plugins.codeowners.util.JgitPath}. */ @@ -40,8 +39,8 @@ @Test public void getJgitPathOfPath() throws Exception { - assertThat(JgitPath.of(Paths.get("foo/bar/OWNERS")).get()).isEqualTo("foo/bar/OWNERS"); - assertThat(JgitPath.of(Paths.get("/foo/bar/OWNERS")).get()).isEqualTo("foo/bar/OWNERS"); + assertThat(JgitPath.of(Path.of("foo/bar/OWNERS")).get()).isEqualTo("foo/bar/OWNERS"); + assertThat(JgitPath.of(Path.of("/foo/bar/OWNERS")).get()).isEqualTo("foo/bar/OWNERS"); } @Test @@ -54,7 +53,7 @@ @Test public void getPathAsAbsolutePath() throws Exception { Truth8.assertThat(JgitPath.of("foo/bar/OWNERS").getAsAbsolutePath()) - .isEqualTo(Paths.get("/foo/bar/OWNERS")); + .isEqualTo(Path.of("/foo/bar/OWNERS")); } @Test