Skip to content

Commit

Permalink
Use assertThat from Truth instead of Truth8 where possible and qualif…
Browse files Browse the repository at this point in the history
…y other Truth8 calls

The Truth team is moving methods from Truth8 into Truth and for this
migration it's required that classes do not have static imports for
both Truth.assertThat and Thruth8.assertThat.

Change-Id: I7fbc975d5a731ab907e6616bb31ce6ea7b620715
Signed-off-by: Edwin Kempin <ekempin@google.com>
Reviewed-on: https://gerrit-review.googlesource.com/c/plugins/code-owners/+/405560
Tested-by: Zuul <zuul-63@gerritcodereview-ci.iam.gserviceaccount.com>
Reviewed-by: Dmitrii Filippov <dmfilippov@google.com>
  • Loading branch information
EdwinKempin committed Jan 31, 2024
1 parent 00c11f9 commit 3f2a11b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
package com.google.gerrit.plugins.codeowners.backend;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.plugins.codeowners.testing.CodeOwnerConfigSubject.assertThatOptional;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;

import com.google.common.truth.Truth8;
import com.google.gerrit.acceptance.config.GerritConfig;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.entities.BranchNameKey;
Expand Down Expand Up @@ -476,15 +476,15 @@ public void cannotUpdateCodeOwnerConfigInNonExistingBranch() throws Exception {
@Test
public void getFilePathForCodeOwnerConfigKeyWithoutFileName() throws Exception {
CodeOwnerConfig.Key codeOwnerConfigKey = CodeOwnerConfig.Key.create(project, "master", "/");
assertThat(codeOwnerBackend.getFilePath(codeOwnerConfigKey))
Truth8.assertThat(codeOwnerBackend.getFilePath(codeOwnerConfigKey))
.isEqualTo(Paths.get(codeOwnerConfigKey.folderPath() + getFileName()));
}

@Test
public void getFilePathForCodeOwnerConfigKeyWithFileName() throws Exception {
CodeOwnerConfig.Key codeOwnerConfigKey =
CodeOwnerConfig.Key.create(project, "master", "/", getFileName() + "_foo_bar");
assertThat(codeOwnerBackend.getFilePath(codeOwnerConfigKey))
Truth8.assertThat(codeOwnerBackend.getFilePath(codeOwnerConfigKey))
.isEqualTo(
Paths.get(codeOwnerConfigKey.folderPath() + codeOwnerConfigKey.fileName().get()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import static com.google.common.truth.PathSubject.paths;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;

import com.google.common.truth.Truth8;
import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -66,7 +66,7 @@ public void absoluteFilePathCanBeSpecifiedInDifferentFormats() throws Exception
public void relativeFilePathCanBeSpecified() throws Exception {
Path path =
CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "foo/OWNERS").filePath();
assertThat(path).isEqualTo(Paths.get("foo/OWNERS"));
Truth8.assertThat(path).isEqualTo(Paths.get("foo/OWNERS"));
assertThat(path.isAbsolute()).isFalse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package com.google.gerrit.plugins.codeowners.backend;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;

import com.google.common.truth.Truth8;
import com.google.gerrit.entities.BranchNameKey;
import com.google.gerrit.entities.Project;
import com.google.gerrit.entities.RefNames;
Expand Down Expand Up @@ -88,7 +88,8 @@ public void getFilePath() throws Exception {
String folderPath = "/foo/bar/";
CodeOwnerConfig.Key codeOwnerConfigKey =
CodeOwnerConfig.Key.create(Project.nameKey("project"), "master", folderPath);
assertThat(codeOwnerConfigKey.filePath("OWNERS")).isEqualTo(Paths.get(folderPath, "OWNERS"));
Truth8.assertThat(codeOwnerConfigKey.filePath("OWNERS"))
.isEqualTo(Paths.get(folderPath, "OWNERS"));
}

@Test
Expand All @@ -98,7 +99,7 @@ public void getFilePathWithCustomFileName() throws Exception {
CodeOwnerConfig.Key codeOwnerConfigKey =
CodeOwnerConfig.Key.create(
Project.nameKey("project"), "master", folderPath, customFileName);
assertThat(codeOwnerConfigKey.filePath("OWNERS"))
Truth8.assertThat(codeOwnerConfigKey.filePath("OWNERS"))
.isEqualTo(Paths.get(folderPath, customFileName));
}

Expand Down Expand Up @@ -141,7 +142,7 @@ public void relativizePath() throws Exception {
TEST_REVISION)
.build();
Path relativizedPath = codeOwnerConfig.relativize(Paths.get("/foo/bar/baz.md"));
assertThat(relativizedPath).isEqualTo(Paths.get("baz.md"));
Truth8.assertThat(relativizedPath).isEqualTo(Paths.get("baz.md"));
}

private static CodeOwnerConfig.Builder createCodeOwnerBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package com.google.gerrit.plugins.codeowners.util;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;

import com.google.common.truth.Truth8;
import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -53,7 +53,7 @@ public void cannotGetJgitPathOfNullPath() throws Exception {

@Test
public void getPathAsAbsolutePath() throws Exception {
assertThat(JgitPath.of("foo/bar/OWNERS").getAsAbsolutePath())
Truth8.assertThat(JgitPath.of("foo/bar/OWNERS").getAsAbsolutePath())
.isEqualTo(Paths.get("/foo/bar/OWNERS"));
}

Expand Down

0 comments on commit 3f2a11b

Please # to comment.