From cbed17a9a891822d617f3ed1ce59fd7599fe2c8b Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Mon, 15 Jan 2024 11:42:19 +0000 Subject: [PATCH] Temporarily qualify calls to custom assertThat(Optional) methods The Truth team is working on migrating callers of the Truth8.assertThat methods to call equivalent methods on the main Truth class. Due to this calls to custom assertThat(Optional) methods will temporarily become ambiguous and hence need to be qualified to avoid breakage. Change-Id: I53afa474f4025cdaf6090868f13d46fead315dc0 Signed-off-by: Edwin Kempin Reviewed-on: https://gerrit-review.googlesource.com/c/plugins/code-owners/+/402728 Reviewed-by: Patrick Hiesel --- .../CodeOwnersPluginConfigValidatorIT.java | 8 +- .../api/PutCodeOwnerProjectConfigIT.java | 26 ++-- .../CodeOwnerConfigOperationsImplTest.java | 10 +- .../codeowners/backend/ChangedFileTest.java | 30 +++-- .../backend/CodeOwnersExceptionHookTest.java | 29 ++-- .../codeowners/backend/CodeOwnersTest.java | 6 +- .../backend/config/BackendConfigTest.java | 37 +++--- ...eOwnersPluginGlobalConfigSnapshotTest.java | 20 +-- ...OwnersPluginProjectConfigSnapshotTest.java | 58 +++++--- .../backend/config/GeneralConfigTest.java | 125 +++++++++--------- 10 files changed, 197 insertions(+), 152 deletions(-) diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnersPluginConfigValidatorIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnersPluginConfigValidatorIT.java index b0caf0a88..af8ba2e9b 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnersPluginConfigValidatorIT.java +++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnersPluginConfigValidatorIT.java @@ -20,7 +20,6 @@ import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_REVISION; import static com.google.gerrit.plugins.codeowners.testing.RequiredApprovalSubject.assertThat; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -46,6 +45,7 @@ import com.google.gerrit.plugins.codeowners.backend.config.StatusConfig; import com.google.gerrit.plugins.codeowners.backend.proto.ProtoBackend; import com.google.gerrit.plugins.codeowners.common.MergeCommitStrategy; +import com.google.gerrit.truth.OptionalSubject; import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevObject; @@ -257,7 +257,8 @@ public void configurePathExpressionsForProject() throws Exception { PushResult r = pushRefsMetaConfig(); assertThat(r.getRemoteUpdate(RefNames.REFS_CONFIG).getStatus()).isEqualTo(Status.OK); - assertThat(codeOwnersPluginConfiguration.getProjectConfig(project).getPathExpressions("master")) + OptionalSubject.assertThat( + codeOwnersPluginConfiguration.getProjectConfig(project).getPathExpressions("master")) .value() .isEqualTo(PathExpressions.GLOB); } @@ -276,7 +277,8 @@ public void configurePathExpressionsForBranch() throws Exception { PushResult r = pushRefsMetaConfig(); assertThat(r.getRemoteUpdate(RefNames.REFS_CONFIG).getStatus()).isEqualTo(Status.OK); - assertThat(codeOwnersPluginConfiguration.getProjectConfig(project).getPathExpressions("master")) + OptionalSubject.assertThat( + codeOwnersPluginConfiguration.getProjectConfig(project).getPathExpressions("master")) .value() .isEqualTo(PathExpressions.GLOB); } diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/PutCodeOwnerProjectConfigIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/PutCodeOwnerProjectConfigIT.java index e632f2ac7..ddddf39e2 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/PutCodeOwnerProjectConfigIT.java +++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/PutCodeOwnerProjectConfigIT.java @@ -19,7 +19,6 @@ import static com.google.gerrit.plugins.codeowners.testing.RequiredApprovalSubject.assertThat; import static com.google.gerrit.server.project.ProjectCache.illegalState; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -44,6 +43,7 @@ import com.google.gerrit.plugins.codeowners.common.MergeCommitStrategy; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.restapi.project.DeleteRef; +import com.google.gerrit.truth.OptionalSubject; import com.google.inject.Inject; import org.eclipse.jgit.revwalk.RevCommit; import org.junit.Before; @@ -181,7 +181,8 @@ public void cannotSetInvalidDisabledBranch() throws Exception { @Test public void setFileExtension() throws Exception { - assertThat(codeOwnersPluginConfiguration.getProjectConfig(project).getFileExtension()) + OptionalSubject.assertThat( + codeOwnersPluginConfiguration.getProjectConfig(project).getFileExtension()) .isEmpty(); CodeOwnerProjectConfigInput input = new CodeOwnerProjectConfigInput(); @@ -189,14 +190,16 @@ public void setFileExtension() throws Exception { CodeOwnerProjectConfigInfo updatedConfig = projectCodeOwnersApiFactory.project(project).updateConfig(input); assertThat(updatedConfig.general.fileExtension).isEqualTo("foo"); - assertThat(codeOwnersPluginConfiguration.getProjectConfig(project).getFileExtension()) + OptionalSubject.assertThat( + codeOwnersPluginConfiguration.getProjectConfig(project).getFileExtension()) .value() .isEqualTo("foo"); input.fileExtension = ""; updatedConfig = projectCodeOwnersApiFactory.project(project).updateConfig(input); assertThat(updatedConfig.general.fileExtension).isNull(); - assertThat(codeOwnersPluginConfiguration.getProjectConfig(project).getFileExtension()) + OptionalSubject.assertThat( + codeOwnersPluginConfiguration.getProjectConfig(project).getFileExtension()) .isEmpty(); } @@ -406,7 +409,8 @@ public void setImplicitApprovals() throws Exception { @Test public void setOverrideInfoUrl() throws Exception { - assertThat(codeOwnersPluginConfiguration.getProjectConfig(project).getOverrideInfoUrl()) + OptionalSubject.assertThat( + codeOwnersPluginConfiguration.getProjectConfig(project).getOverrideInfoUrl()) .isEmpty(); CodeOwnerProjectConfigInput input = new CodeOwnerProjectConfigInput(); @@ -414,20 +418,22 @@ public void setOverrideInfoUrl() throws Exception { CodeOwnerProjectConfigInfo updatedConfig = projectCodeOwnersApiFactory.project(project).updateConfig(input); assertThat(updatedConfig.general.overrideInfoUrl).isEqualTo("http://foo.bar"); - assertThat(codeOwnersPluginConfiguration.getProjectConfig(project).getOverrideInfoUrl()) + OptionalSubject.assertThat( + codeOwnersPluginConfiguration.getProjectConfig(project).getOverrideInfoUrl()) .value() .isEqualTo("http://foo.bar"); input.overrideInfoUrl = ""; updatedConfig = projectCodeOwnersApiFactory.project(project).updateConfig(input); assertThat(updatedConfig.general.overrideInfoUrl).isNull(); - assertThat(codeOwnersPluginConfiguration.getProjectConfig(project).getOverrideInfoUrl()) + OptionalSubject.assertThat( + codeOwnersPluginConfiguration.getProjectConfig(project).getOverrideInfoUrl()) .isEmpty(); } @Test public void setInvalidCodeOwnerConfigInfoUrl() throws Exception { - assertThat( + OptionalSubject.assertThat( codeOwnersPluginConfiguration .getProjectConfig(project) .getInvalidCodeOwnerConfigInfoUrl()) @@ -438,7 +444,7 @@ public void setInvalidCodeOwnerConfigInfoUrl() throws Exception { CodeOwnerProjectConfigInfo updatedConfig = projectCodeOwnersApiFactory.project(project).updateConfig(input); assertThat(updatedConfig.general.invalidCodeOwnerConfigInfoUrl).isEqualTo("http://foo.bar"); - assertThat( + OptionalSubject.assertThat( codeOwnersPluginConfiguration .getProjectConfig(project) .getInvalidCodeOwnerConfigInfoUrl()) @@ -448,7 +454,7 @@ public void setInvalidCodeOwnerConfigInfoUrl() throws Exception { input.invalidCodeOwnerConfigInfoUrl = ""; updatedConfig = projectCodeOwnersApiFactory.project(project).updateConfig(input); assertThat(updatedConfig.general.invalidCodeOwnerConfigInfoUrl).isNull(); - assertThat( + OptionalSubject.assertThat( codeOwnersPluginConfiguration .getProjectConfig(project) .getInvalidCodeOwnerConfigInfoUrl()) 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 17e3ccdc4..d5e4dd58c 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java @@ -17,7 +17,6 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.gerrit.plugins.codeowners.testing.CodeOwnerConfigSubject.assertThat; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -37,6 +36,7 @@ import com.google.gerrit.plugins.codeowners.backend.CodeOwners; import com.google.gerrit.plugins.codeowners.backend.CodeOwnersUpdate; import com.google.gerrit.server.ServerInitiated; +import com.google.gerrit.truth.OptionalSubject; import com.google.inject.Key; import com.google.inject.Provider; import java.nio.file.Paths; @@ -195,7 +195,7 @@ public void specifiedFileNameIsRespectedForCodeOwnerConfigCreation() throws Exce .fileName("OWNERS_foo") .addCodeOwnerEmail(admin.email()) .create(); - assertThat(codeOwnerConfigKey.fileName()).value().isEqualTo("OWNERS_foo"); + OptionalSubject.assertThat(codeOwnerConfigKey.fileName()).value().isEqualTo("OWNERS_foo"); assertThat(getCodeOwnerConfigFromServer(codeOwnerConfigKey)) .hasCodeOwnerSetsThat() .onlyElement() @@ -441,7 +441,7 @@ public void clearCodeOwners_emptyCodeOwnerConfigIsDeleted() throws Exception { // was dropped. // Since this made the code owner config empty it caused a deletion of the code owner config // file. - assertThat(codeOwners.getFromCurrentRevision(codeOwnerConfig.key())).isEmpty(); + OptionalSubject.assertThat(codeOwners.getFromCurrentRevision(codeOwnerConfig.key())).isEmpty(); } @Test @@ -507,7 +507,7 @@ public void clearCodeOwnerSets() throws Exception { .update(); // Removing all code owner sets leads to a deletion of the code owner config file. - assertThat(codeOwners.getFromCurrentRevision(codeOwnerConfig.key())).isEmpty(); + OptionalSubject.assertThat(codeOwners.getFromCurrentRevision(codeOwnerConfig.key())).isEmpty(); } @Test @@ -570,7 +570,7 @@ public void clearImports() throws Exception { .update(); // Removing all code owner sets leads to a deletion of the code owner config file. - assertThat(codeOwners.getFromCurrentRevision(codeOwnerConfig.key())).isEmpty(); + OptionalSubject.assertThat(codeOwners.getFromCurrentRevision(codeOwnerConfig.key())).isEmpty(); } @Test diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java index 2c8463462..cc3a6e749 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java @@ -16,7 +16,6 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import static org.mockito.Mockito.when; import com.google.gerrit.common.Nullable; @@ -25,6 +24,7 @@ import com.google.gerrit.plugins.codeowners.common.ChangedFile; 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.util.Optional; import org.eclipse.jgit.diff.DiffEntry; @@ -48,14 +48,16 @@ public class ChangedFileTest extends AbstractCodeOwnersTest { public void getNewPath_diffEntry() throws Exception { String newPath = "foo/bar/baz.txt"; setupDiffEntry(newPath, /* oldPath= */ null, ChangeType.ADD); - assertThat(ChangedFile.create(diffEntry).newPath()).value().isEqualTo(Paths.get("/" + newPath)); + OptionalSubject.assertThat(ChangedFile.create(diffEntry).newPath()) + .value() + .isEqualTo(Paths.get("/" + newPath)); } @Test public void getNewPath_patchListEntry() throws Exception { String newPath = "foo/bar/baz.txt"; setupPatchListEntry(newPath, /* oldPath= */ null, Patch.ChangeType.ADDED); - assertThat(ChangedFile.create(patchListEntry).newPath()) + OptionalSubject.assertThat(ChangedFile.create(patchListEntry).newPath()) .value() .isEqualTo(Paths.get("/" + newPath)); } @@ -64,7 +66,7 @@ public void getNewPath_patchListEntry() throws Exception { public void getNewPath_fileDiffOutput() throws Exception { String newPath = "foo/bar/baz.txt"; setupFileDiffOutput(newPath, /* oldPath= */ null, Patch.ChangeType.ADDED); - assertThat(ChangedFile.create(fileDiffOutput).newPath()) + OptionalSubject.assertThat(ChangedFile.create(fileDiffOutput).newPath()) .value() .isEqualTo(Paths.get("/" + newPath)); } @@ -72,19 +74,19 @@ public void getNewPath_fileDiffOutput() throws Exception { @Test public void getNewPathWhenNewPathIsNotSet_diffEntry() throws Exception { setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.ADD); - assertThat(ChangedFile.create(diffEntry).newPath()).isEmpty(); + OptionalSubject.assertThat(ChangedFile.create(diffEntry).newPath()).isEmpty(); } @Test public void getNewPathWhenNewPathIsNotSet_patchListEntry() throws Exception { setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.ADDED); - assertThat(ChangedFile.create(patchListEntry).newPath()).isEmpty(); + OptionalSubject.assertThat(ChangedFile.create(patchListEntry).newPath()).isEmpty(); } @Test public void getNewPathWhenNewPathIsNotSet_fileDiffOutput() throws Exception { setupFileDiffOutput(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.ADDED); - assertThat(ChangedFile.create(fileDiffOutput).newPath()).isEmpty(); + OptionalSubject.assertThat(ChangedFile.create(fileDiffOutput).newPath()).isEmpty(); } @Test @@ -193,14 +195,16 @@ public void cannotCheckHasNewPathWithRelativePath_fileDiffOutput() throws Except public void getOldPath_diffEntry() throws Exception { String oldPath = "foo/bar/baz.txt"; setupDiffEntry(/* newPath= */ null, oldPath, ChangeType.DELETE); - assertThat(ChangedFile.create(diffEntry).oldPath()).value().isEqualTo(Paths.get("/" + oldPath)); + OptionalSubject.assertThat(ChangedFile.create(diffEntry).oldPath()) + .value() + .isEqualTo(Paths.get("/" + oldPath)); } @Test public void getOldPath_patchListEntry() throws Exception { String oldPath = "foo/bar/baz.txt"; setupPatchListEntry(/* newPath= */ null, oldPath, Patch.ChangeType.DELETED); - assertThat(ChangedFile.create(patchListEntry).oldPath()) + OptionalSubject.assertThat(ChangedFile.create(patchListEntry).oldPath()) .value() .isEqualTo(Paths.get("/" + oldPath)); } @@ -209,7 +213,7 @@ public void getOldPath_patchListEntry() throws Exception { public void getOldPath_fileDiffOutput() throws Exception { String oldPath = "foo/bar/baz.txt"; setupFileDiffOutput(/* newPath= */ null, oldPath, Patch.ChangeType.DELETED); - assertThat(ChangedFile.create(fileDiffOutput).oldPath()) + OptionalSubject.assertThat(ChangedFile.create(fileDiffOutput).oldPath()) .value() .isEqualTo(Paths.get("/" + oldPath)); } @@ -218,19 +222,19 @@ public void getOldPath_fileDiffOutput() throws Exception { public void getOldPathWhenOldPathIsNotSet_diffEntry() throws Exception { setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.DELETE); when(diffEntry.getOldPath()).thenReturn(DiffEntry.DEV_NULL); - assertThat(ChangedFile.create(diffEntry).oldPath()).isEmpty(); + OptionalSubject.assertThat(ChangedFile.create(diffEntry).oldPath()).isEmpty(); } @Test public void getOldPathWhenOldPathIsNotSet_patchListEntry() throws Exception { setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.DELETED); - assertThat(ChangedFile.create(patchListEntry).oldPath()).isEmpty(); + OptionalSubject.assertThat(ChangedFile.create(patchListEntry).oldPath()).isEmpty(); } @Test public void getOldPathWhenOldPathIsNotSet_fileDiffOutput() throws Exception { setupFileDiffOutput(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.DELETED); - assertThat(ChangedFile.create(fileDiffOutput).oldPath()).isEmpty(); + OptionalSubject.assertThat(ChangedFile.create(fileDiffOutput).oldPath()).isEmpty(); } @Test diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnersExceptionHookTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnersExceptionHookTest.java index e1786d3a9..2f6451088 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnersExceptionHookTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnersExceptionHookTest.java @@ -15,13 +15,13 @@ package com.google.gerrit.plugins.codeowners.backend; import static com.google.common.truth.Truth.assertThat; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.common.collect.ImmutableList; import com.google.gerrit.acceptance.config.GerritConfig; import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest; import com.google.gerrit.plugins.codeowners.backend.config.InvalidPluginConfigurationException; import com.google.gerrit.server.ExceptionHook.Status; +import com.google.gerrit.truth.OptionalSubject; import java.nio.file.InvalidPathException; import java.util.Optional; import org.junit.Before; @@ -114,29 +114,36 @@ public void getUserMessages_withInvalidCodeOwnerConfigInfoUrl() throws Exception @Test public void getStatus() throws Exception { Status conflictStatus = Status.create(409, "Conflict"); - assertThat(getStatus(newInvalidPluginConfigurationException())) + OptionalSubject.assertThat(getStatus(newInvalidPluginConfigurationException())) .value() .isEqualTo(conflictStatus); - assertThat(getStatus(newExceptionWithCause(newInvalidPluginConfigurationException()))) + OptionalSubject.assertThat( + getStatus(newExceptionWithCause(newInvalidPluginConfigurationException()))) .value() .isEqualTo(conflictStatus); - assertThat(getStatus(newInvalidCodeOwnerConfigException())).value().isEqualTo(conflictStatus); - assertThat(getStatus(newExceptionWithCause(newInvalidCodeOwnerConfigException()))) + OptionalSubject.assertThat(getStatus(newInvalidCodeOwnerConfigException())) + .value() + .isEqualTo(conflictStatus); + OptionalSubject.assertThat( + getStatus(newExceptionWithCause(newInvalidCodeOwnerConfigException()))) .value() .isEqualTo(conflictStatus); - assertThat(getStatus(newInvalidPathException())).value().isEqualTo(conflictStatus); - assertThat(getStatus(newExceptionWithCause(newInvalidPathException()))) + OptionalSubject.assertThat(getStatus(newInvalidPathException())) + .value() + .isEqualTo(conflictStatus); + OptionalSubject.assertThat(getStatus(newExceptionWithCause(newInvalidPathException()))) .value() .isEqualTo(conflictStatus); - assertThat(getStatus(new Exception())).isEmpty(); - assertThat(getStatus(newExceptionWithCause(new Exception()))).isEmpty(); + OptionalSubject.assertThat(getStatus(new Exception())).isEmpty(); + OptionalSubject.assertThat(getStatus(newExceptionWithCause(new Exception()))).isEmpty(); - assertThat(getStatus(CodeOwnersInternalServerErrorException.newInternalServerError("msg"))) + OptionalSubject.assertThat( + getStatus(CodeOwnersInternalServerErrorException.newInternalServerError("msg"))) .isEmpty(); - assertThat( + OptionalSubject.assertThat( getStatus( newExceptionWithCause( CodeOwnersInternalServerErrorException.newInternalServerError("msg")))) diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnersTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnersTest.java index fafc620b7..294dfd09a 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnersTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnersTest.java @@ -16,7 +16,6 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -26,6 +25,7 @@ import com.google.gerrit.extensions.registration.PrivateInternals_DynamicMapImpl; import com.google.gerrit.extensions.registration.RegistrationHandle; import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest; +import com.google.gerrit.truth.OptionalSubject; import com.google.inject.Key; import com.google.inject.util.Providers; import java.util.Optional; @@ -92,7 +92,7 @@ public void codeOwnerConfigIsRetrievedFromConfiguredBackend() throws Exception { try (AutoCloseable registration = registerTestBackend("test-backend", codeOwnerBackendMock)) { Optional codeOwnerConfig = codeOwners.getFromCurrentRevision(codeOwnerConfigKey); - assertThat(codeOwnerConfig).value().isEqualTo(expectedCodeOwnersConfig); + OptionalSubject.assertThat(codeOwnerConfig).value().isEqualTo(expectedCodeOwnersConfig); verify(codeOwnerBackendMock).getCodeOwnerConfig(codeOwnerConfigKey, /* revision= */ null); } } @@ -110,7 +110,7 @@ public void revisionIsPassedToConfiguredBackend() throws Exception { .thenReturn(Optional.of(expectedCodeOwnersConfig)); try (AutoCloseable registration = registerTestBackend("test-backend", codeOwnerBackendMock)) { Optional codeOwnerConfig = codeOwners.get(codeOwnerConfigKey, TEST_REVISION); - assertThat(codeOwnerConfig).value().isEqualTo(expectedCodeOwnersConfig); + OptionalSubject.assertThat(codeOwnerConfig).value().isEqualTo(expectedCodeOwnersConfig); verify(codeOwnerBackendMock).getCodeOwnerConfig(codeOwnerConfigKey, TEST_REVISION); } } diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/config/BackendConfigTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/config/BackendConfigTest.java index dcc9cb34f..fffc2674b 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/config/BackendConfigTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/config/BackendConfigTest.java @@ -19,7 +19,6 @@ import static com.google.gerrit.plugins.codeowners.backend.config.BackendConfig.KEY_PATH_EXPRESSIONS; import static com.google.gerrit.plugins.codeowners.backend.config.CodeOwnersPluginConfiguration.SECTION_CODE_OWNERS; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; @@ -32,6 +31,7 @@ import com.google.gerrit.plugins.codeowners.backend.proto.ProtoBackend; import com.google.gerrit.server.git.validators.CommitValidationMessage; import com.google.gerrit.server.git.validators.ValidationMessage; +import com.google.gerrit.truth.OptionalSubject; import org.eclipse.jgit.lib.Config; import org.junit.Before; import org.junit.Test; @@ -65,7 +65,7 @@ public void cannotGetBackendForBranchForNullBranch() throws Exception { @Test public void getBackendForBranchWhenBackendIsNotSet() throws Exception { - assertThat( + OptionalSubject.assertThat( backendConfig.getBackendForBranch( new Config(), BranchNameKey.create(project, "master"))) .isEmpty(); @@ -79,7 +79,8 @@ public void getBackendForBranch() throws Exception { "refs/heads/master", KEY_BACKEND, CodeOwnerBackendId.FIND_OWNERS.getBackendId()); - assertThat(backendConfig.getBackendForBranch(cfg, BranchNameKey.create(project, "master"))) + OptionalSubject.assertThat( + backendConfig.getBackendForBranch(cfg, BranchNameKey.create(project, "master"))) .value() .isInstanceOf(FindOwnersBackend.class); } @@ -89,7 +90,8 @@ public void getBackendForBranchShortName() throws Exception { Config cfg = new Config(); cfg.setString( SECTION_CODE_OWNERS, "master", KEY_BACKEND, CodeOwnerBackendId.FIND_OWNERS.getBackendId()); - assertThat(backendConfig.getBackendForBranch(cfg, BranchNameKey.create(project, "master"))) + OptionalSubject.assertThat( + backendConfig.getBackendForBranch(cfg, BranchNameKey.create(project, "master"))) .value() .isInstanceOf(FindOwnersBackend.class); } @@ -131,7 +133,7 @@ public void cannotGetBackendForProjectForNullProject() throws Exception { @Test public void getBackendForProjectWhenBackendIsNotSet() throws Exception { - assertThat(backendConfig.getBackendForProject(new Config(), project)).isEmpty(); + OptionalSubject.assertThat(backendConfig.getBackendForProject(new Config(), project)).isEmpty(); } @Test @@ -139,7 +141,7 @@ public void getBackendForProject() throws Exception { Config cfg = new Config(); cfg.setString( SECTION_CODE_OWNERS, null, KEY_BACKEND, CodeOwnerBackendId.FIND_OWNERS.getBackendId()); - assertThat(backendConfig.getBackendForProject(cfg, project)) + OptionalSubject.assertThat(backendConfig.getBackendForProject(cfg, project)) .value() .isInstanceOf(FindOwnersBackend.class); } @@ -209,7 +211,7 @@ public void cannotGetPathExpressionsForBranchForNullBranch() throws Exception { @Test public void getPathExpressionsForBranchWhenPathExpressionsAreNotSet() throws Exception { - assertThat( + OptionalSubject.assertThat( backendConfig.getPathExpressionsForBranch( new Config(), BranchNameKey.create(project, "master"))) .isEmpty(); @@ -223,7 +225,7 @@ public void getPathExpressionsForBranch() throws Exception { "refs/heads/master", KEY_PATH_EXPRESSIONS, PathExpressions.GLOB.name()); - assertThat( + OptionalSubject.assertThat( backendConfig.getPathExpressionsForBranch(cfg, BranchNameKey.create(project, "master"))) .value() .isEqualTo(PathExpressions.GLOB); @@ -233,7 +235,7 @@ public void getPathExpressionsForBranch() throws Exception { public void getPathExpressionsForBranchShortName() throws Exception { Config cfg = new Config(); cfg.setString(SECTION_CODE_OWNERS, "master", KEY_PATH_EXPRESSIONS, PathExpressions.GLOB.name()); - assertThat( + OptionalSubject.assertThat( backendConfig.getPathExpressionsForBranch(cfg, BranchNameKey.create(project, "master"))) .value() .isEqualTo(PathExpressions.GLOB); @@ -243,7 +245,7 @@ public void getPathExpressionsForBranchShortName() throws Exception { public void getPathExpressionsForBranchIfConfigIsInvalid() throws Exception { Config cfg = new Config(); cfg.setString(SECTION_CODE_OWNERS, "master", KEY_PATH_EXPRESSIONS, "INVALID"); - assertThat( + OptionalSubject.assertThat( backendConfig.getPathExpressionsForBranch(cfg, BranchNameKey.create(project, "master"))) .isEmpty(); } @@ -268,14 +270,15 @@ public void cannotGetPathExpressionsForProjectForNullProject() throws Exception @Test public void getPathExpressionsForProjectWhenBackendIsNotSet() throws Exception { - assertThat(backendConfig.getPathExpressionsForProject(new Config(), project)).isEmpty(); + OptionalSubject.assertThat(backendConfig.getPathExpressionsForProject(new Config(), project)) + .isEmpty(); } @Test public void getPathExpressionsForProject() throws Exception { Config cfg = new Config(); cfg.setString(SECTION_CODE_OWNERS, null, KEY_PATH_EXPRESSIONS, PathExpressions.GLOB.name()); - assertThat(backendConfig.getPathExpressionsForProject(cfg, project)) + OptionalSubject.assertThat(backendConfig.getPathExpressionsForProject(cfg, project)) .value() .isEqualTo(PathExpressions.GLOB); } @@ -284,7 +287,7 @@ public void getPathExpressionsForProject() throws Exception { public void getPathExpressionsForProjectIfConfigIsInvalid() throws Exception { Config cfg = new Config(); cfg.setString(SECTION_CODE_OWNERS, null, KEY_PATH_EXPRESSIONS, "INVALID"); - assertThat(backendConfig.getPathExpressionsForProject(cfg, project)).isEmpty(); + OptionalSubject.assertThat(backendConfig.getPathExpressionsForProject(cfg, project)).isEmpty(); } @Test @@ -307,19 +310,21 @@ public void cannotValidateProjectLevelConfigWithForNullProjectLevelConfig() thro @Test public void getDefaultPathExpressions() throws Exception { - assertThat(backendConfig.getDefaultPathExpressions()).isEmpty(); + OptionalSubject.assertThat(backendConfig.getDefaultPathExpressions()).isEmpty(); } @Test @GerritConfig(name = "plugin.code-owners.pathExpressions", value = "GLOB") public void getConfiguredDefaultPathExpressions() throws Exception { - assertThat(backendConfig.getDefaultPathExpressions()).value().isEqualTo(PathExpressions.GLOB); + OptionalSubject.assertThat(backendConfig.getDefaultPathExpressions()) + .value() + .isEqualTo(PathExpressions.GLOB); } @Test @GerritConfig(name = "plugin.code-owners.pathExpressions", value = "INVALID") public void getDefaultPathExpressionsIfConfigIsInvalid() throws Exception { - assertThat(backendConfig.getDefaultPathExpressions()).isEmpty(); + OptionalSubject.assertThat(backendConfig.getDefaultPathExpressions()).isEmpty(); } @Test diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginGlobalConfigSnapshotTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginGlobalConfigSnapshotTest.java index 6a5c03d5f..e40d437b4 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginGlobalConfigSnapshotTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginGlobalConfigSnapshotTest.java @@ -16,11 +16,11 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.gerrit.acceptance.config.GerritConfig; import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest; +import com.google.gerrit.truth.OptionalSubject; import org.junit.Before; import org.junit.Test; @@ -65,7 +65,7 @@ public void experimentalRestEndpointsNotEnabled_invalidConfig() throws Exception @Test public void codeOwnerConfigCacheSizeIsLimitedByDefault() throws Exception { - assertThat(cfgSnapshot().getMaxCodeOwnerConfigCacheSize()) + OptionalSubject.assertThat(cfgSnapshot().getMaxCodeOwnerConfigCacheSize()) .value() .isEqualTo(CodeOwnersPluginGlobalConfigSnapshot.DEFAULT_MAX_CODE_OWNER_CONFIG_CACHE_SIZE); } @@ -73,26 +73,28 @@ public void codeOwnerConfigCacheSizeIsLimitedByDefault() throws Exception { @Test @GerritConfig(name = "plugin.code-owners.maxCodeOwnerConfigCacheSize", value = "0") public void codeOwnerConfigCacheSizeIsUnlimited() throws Exception { - assertThat(cfgSnapshot().getMaxCodeOwnerConfigCacheSize()).isEmpty(); + OptionalSubject.assertThat(cfgSnapshot().getMaxCodeOwnerConfigCacheSize()).isEmpty(); } @Test @GerritConfig(name = "plugin.code-owners.maxCodeOwnerConfigCacheSize", value = "10") public void codeOwnerConfigCacheSizeIsLimited() throws Exception { - assertThat(cfgSnapshot().getMaxCodeOwnerConfigCacheSize()).value().isEqualTo(10); + OptionalSubject.assertThat(cfgSnapshot().getMaxCodeOwnerConfigCacheSize()) + .value() + .isEqualTo(10); } @Test @GerritConfig(name = "plugin.code-owners.maxCodeOwnerConfigCacheSize", value = "invalid") public void maxCodeOwnerConfigCacheSize_invalidConfig() throws Exception { - assertThat(cfgSnapshot().getMaxCodeOwnerConfigCacheSize()) + OptionalSubject.assertThat(cfgSnapshot().getMaxCodeOwnerConfigCacheSize()) .value() .isEqualTo(CodeOwnersPluginGlobalConfigSnapshot.DEFAULT_MAX_CODE_OWNER_CONFIG_CACHE_SIZE); } @Test public void codeOwnerCacheSizeIsLimitedByDefault() throws Exception { - assertThat(cfgSnapshot().getMaxCodeOwnerCacheSize()) + OptionalSubject.assertThat(cfgSnapshot().getMaxCodeOwnerCacheSize()) .value() .isEqualTo(CodeOwnersPluginGlobalConfigSnapshot.DEFAULT_MAX_CODE_OWNER_CACHE_SIZE); } @@ -100,19 +102,19 @@ public void codeOwnerCacheSizeIsLimitedByDefault() throws Exception { @Test @GerritConfig(name = "plugin.code-owners.maxCodeOwnerCacheSize", value = "0") public void codeOwnerCacheSizeIsUnlimited() throws Exception { - assertThat(cfgSnapshot().getMaxCodeOwnerCacheSize()).isEmpty(); + OptionalSubject.assertThat(cfgSnapshot().getMaxCodeOwnerCacheSize()).isEmpty(); } @Test @GerritConfig(name = "plugin.code-owners.maxCodeOwnerCacheSize", value = "10") public void codeOwnerCacheSizeIsLimited() throws Exception { - assertThat(cfgSnapshot().getMaxCodeOwnerCacheSize()).value().isEqualTo(10); + OptionalSubject.assertThat(cfgSnapshot().getMaxCodeOwnerCacheSize()).value().isEqualTo(10); } @Test @GerritConfig(name = "plugin.code-owners.maxCodeOwnerCacheSize", value = "invalid") public void maxCodeOwnerCacheSize_invalidConfig() throws Exception { - assertThat(cfgSnapshot().getMaxCodeOwnerCacheSize()) + OptionalSubject.assertThat(cfgSnapshot().getMaxCodeOwnerCacheSize()) .value() .isEqualTo(CodeOwnersPluginGlobalConfigSnapshot.DEFAULT_MAX_CODE_OWNER_CACHE_SIZE); } diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginProjectConfigSnapshotTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginProjectConfigSnapshotTest.java index 66649f902..77f79bf2d 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginProjectConfigSnapshotTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginProjectConfigSnapshotTest.java @@ -19,7 +19,6 @@ import static com.google.gerrit.plugins.codeowners.testing.CodeOwnerSetSubject.hasEmail; import static com.google.gerrit.plugins.codeowners.testing.RequiredApprovalSubject.assertThat; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -48,6 +47,7 @@ import com.google.gerrit.plugins.codeowners.common.CodeOwnerConfigValidationPolicy; import com.google.gerrit.plugins.codeowners.common.MergeCommitStrategy; import com.google.gerrit.server.IdentifiedUser; +import com.google.gerrit.truth.OptionalSubject; import com.google.inject.Inject; import com.google.inject.Key; import com.google.inject.util.Providers; @@ -76,28 +76,28 @@ public void setUpCodeOwnersPlugin() throws Exception { @Test @GerritConfig(name = "plugin.code-owners.fileExtension", value = "foo") public void getFileExtensionIfNoneIsConfiguredOnProjectLevel() throws Exception { - assertThat(cfgSnapshot().getFileExtension()).value().isEqualTo("foo"); + OptionalSubject.assertThat(cfgSnapshot().getFileExtension()).value().isEqualTo("foo"); } @Test @GerritConfig(name = "plugin.code-owners.fileExtension", value = "foo") public void fileExtensionOnProjectLevelOverridesDefaultFileExtension() throws Exception { configureFileExtension(project, "bar"); - assertThat(cfgSnapshot().getFileExtension()).value().isEqualTo("bar"); + OptionalSubject.assertThat(cfgSnapshot().getFileExtension()).value().isEqualTo("bar"); } @Test @GerritConfig(name = "plugin.code-owners.fileExtension", value = "foo") public void fileExtensionIsInheritedFromParentProject() throws Exception { configureFileExtension(allProjects, "bar"); - assertThat(cfgSnapshot().getFileExtension()).value().isEqualTo("bar"); + OptionalSubject.assertThat(cfgSnapshot().getFileExtension()).value().isEqualTo("bar"); } @Test public void inheritedFileExtensionCanBeOverridden() throws Exception { configureFileExtension(allProjects, "foo"); configureFileExtension(project, "bar"); - assertThat(cfgSnapshot().getFileExtension()).value().isEqualTo("bar"); + OptionalSubject.assertThat(cfgSnapshot().getFileExtension()).value().isEqualTo("bar"); } @Test @@ -1043,18 +1043,20 @@ public void cannotGetPathExpressionsForNullBranch() throws Exception { @Test public void getPathExpressionsForNonExistingBranch() throws Exception { - assertThat(cfgSnapshot().getPathExpressions("non-existing")).isEmpty(); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("non-existing")).isEmpty(); } @Test public void getPathExpressionsWhenNoPathExpressionsAreConfigured() throws Exception { - assertThat(cfgSnapshot().getPathExpressions("master")).isEmpty(); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")).isEmpty(); } @Test @GerritConfig(name = "plugin.code-owners.pathExpressions", value = "GLOB") public void getConfiguredPathExpressions() throws Exception { - assertThat(cfgSnapshot().getPathExpressions("master")).value().isEqualTo(PathExpressions.GLOB); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) + .value() + .isEqualTo(PathExpressions.GLOB); } @Test @@ -1062,13 +1064,15 @@ public void getConfiguredPathExpressions() throws Exception { name = "plugin.code-owners.pathExpressions", value = "non-existing-path-expressions") public void getPathExpressionsIfNonExistingPathExpressionsAreConfigured() throws Exception { - assertThat(cfgSnapshot().getPathExpressions("master")).isEmpty(); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")).isEmpty(); } @Test public void getPathExpressionsConfiguredOnProjectLevel() throws Exception { configurePathExpressions(project, PathExpressions.GLOB.name()); - assertThat(cfgSnapshot().getPathExpressions("master")).value().isEqualTo(PathExpressions.GLOB); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) + .value() + .isEqualTo(PathExpressions.GLOB); } @Test @@ -1076,7 +1080,7 @@ public void getPathExpressionsConfiguredOnProjectLevel() throws Exception { public void pathExpressionsConfiguredOnProjectLevelOverrideDefaultPathExpressions() throws Exception { configurePathExpressions(project, PathExpressions.SIMPLE.name()); - assertThat(cfgSnapshot().getPathExpressions("master")) + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) .value() .isEqualTo(PathExpressions.SIMPLE); } @@ -1084,14 +1088,16 @@ public void pathExpressionsConfiguredOnProjectLevelOverrideDefaultPathExpression @Test public void pathExpressionsAreInheritedFromParentProject() throws Exception { configurePathExpressions(allProjects, PathExpressions.GLOB.name()); - assertThat(cfgSnapshot().getPathExpressions("master")).value().isEqualTo(PathExpressions.GLOB); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) + .value() + .isEqualTo(PathExpressions.GLOB); } @Test @GerritConfig(name = "plugin.code-owners.pathExpressions", value = "GLOB") public void inheritedPathExpressionsOverrideDefaultPathExpressions() throws Exception { configurePathExpressions(allProjects, PathExpressions.SIMPLE.name()); - assertThat(cfgSnapshot().getPathExpressions("master")) + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) .value() .isEqualTo(PathExpressions.SIMPLE); } @@ -1100,7 +1106,7 @@ public void inheritedPathExpressionsOverrideDefaultPathExpressions() throws Exce public void projectLevelPathExpressionsOverrideInheritedPathExpressions() throws Exception { configurePathExpressions(allProjects, PathExpressions.GLOB.name()); configurePathExpressions(project, PathExpressions.SIMPLE.name()); - assertThat(cfgSnapshot().getPathExpressions("master")) + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) .value() .isEqualTo(PathExpressions.SIMPLE); } @@ -1111,26 +1117,32 @@ public void projectLevelPathExpressionsOverrideInheritedPathExpressions() throws pathExpressionsAreReadFromGlobalConfigIfNonExistingPathExpressionsAreConfiguredOnProjectLevel() throws Exception { configurePathExpressions(project, "non-existing-path-expressions"); - assertThat(cfgSnapshot().getPathExpressions("master")).value().isEqualTo(PathExpressions.GLOB); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) + .value() + .isEqualTo(PathExpressions.GLOB); } @Test public void projectLevelPathExpressionsForOtherProjectHasNoEffect() throws Exception { Project.NameKey otherProject = projectOperations.newProject().create(); configurePathExpressions(otherProject, PathExpressions.GLOB.name()); - assertThat(cfgSnapshot().getPathExpressions("master")).isEmpty(); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")).isEmpty(); } @Test public void getPathExpressionsConfiguredOnBranchLevel() throws Exception { configurePathExpressions(project, "refs/heads/master", PathExpressions.GLOB.name()); - assertThat(cfgSnapshot().getPathExpressions("master")).value().isEqualTo(PathExpressions.GLOB); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) + .value() + .isEqualTo(PathExpressions.GLOB); } @Test public void getPathExpressionsConfiguredOnBranchLevelShortName() throws Exception { configurePathExpressions(project, "master", PathExpressions.GLOB.name()); - assertThat(cfgSnapshot().getPathExpressions("master")).value().isEqualTo(PathExpressions.GLOB); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) + .value() + .isEqualTo(PathExpressions.GLOB); } @Test @@ -1139,7 +1151,7 @@ public void getPathExpressionsConfiguredOnBranchLevelShortName() throws Exceptio throws Exception { configurePathExpressions(project, "master", PathExpressions.GLOB.name()); configurePathExpressions(project, "refs/heads/master", PathExpressions.SIMPLE.name()); - assertThat(cfgSnapshot().getPathExpressions("master")) + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) .value() .isEqualTo(PathExpressions.SIMPLE); } @@ -1148,7 +1160,7 @@ public void getPathExpressionsConfiguredOnBranchLevelShortName() throws Exceptio public void branchLevelPathExpressionsOverridesProjectLevelPathExpressions() throws Exception { configurePathExpressions(project, PathExpressions.GLOB.name()); configurePathExpressions(project, "master", PathExpressions.SIMPLE.name()); - assertThat(cfgSnapshot().getPathExpressions("master")) + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) .value() .isEqualTo(PathExpressions.SIMPLE); } @@ -1171,13 +1183,15 @@ public void branchLevelPathExpressionsOverridesProjectLevelPathExpressions() thr BackendConfig.KEY_PATH_EXPRESSIONS, "non-existing-path-expressions"); }); - assertThat(cfgSnapshot().getPathExpressions("master")).value().isEqualTo(PathExpressions.GLOB); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")) + .value() + .isEqualTo(PathExpressions.GLOB); } @Test public void branchLevelPathExpressionsForOtherBranchHaveNoEffect() throws Exception { configurePathExpressions(project, "foo", PathExpressions.GLOB.name()); - assertThat(cfgSnapshot().getPathExpressions("master")).isEmpty(); + OptionalSubject.assertThat(cfgSnapshot().getPathExpressions("master")).isEmpty(); } @Test diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java index 17663b287..819411a8c 100644 --- a/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java +++ b/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java @@ -39,7 +39,6 @@ import static com.google.gerrit.plugins.codeowners.backend.config.GeneralConfig.KEY_REJECT_NON_RESOLVABLE_IMPORTS; import static com.google.gerrit.plugins.codeowners.backend.config.GeneralConfig.SECTION_VALIDATION; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; @@ -54,6 +53,7 @@ import com.google.gerrit.server.git.validators.CommitValidationMessage; import com.google.gerrit.server.git.validators.ValidationMessage; import com.google.gerrit.testing.ConfigSuite; +import com.google.gerrit.truth.OptionalSubject; import org.eclipse.jgit.lib.Config; import org.junit.Before; import org.junit.Test; @@ -84,14 +84,16 @@ public void cannotGetFileExtensionForNullPluginConfig() throws Exception { @Test public void noFileExtensionConfigured() throws Exception { - assertThat(generalConfig.getFileExtension(new Config())).isEmpty(); + OptionalSubject.assertThat(generalConfig.getFileExtension(new Config())).isEmpty(); } @Test @GerritConfig(name = "plugin.code-owners.fileExtension", value = "foo") public void fileExtensionIsRetrievedFromGerritConfigIfNotSpecifiedOnProjectLevel() throws Exception { - assertThat(generalConfig.getFileExtension(new Config())).value().isEqualTo("foo"); + OptionalSubject.assertThat(generalConfig.getFileExtension(new Config())) + .value() + .isEqualTo("foo"); } @Test @@ -99,7 +101,7 @@ public void fileExtensionIsRetrievedFromGerritConfigIfNotSpecifiedOnProjectLevel public void fileExtensionInPluginConfigOverridesFileExtensionInGerritConfig() throws Exception { Config cfg = new Config(); cfg.setString(SECTION_CODE_OWNERS, /* subsection= */ null, KEY_FILE_EXTENSION, "bar"); - assertThat(generalConfig.getFileExtension(cfg)).value().isEqualTo("bar"); + OptionalSubject.assertThat(generalConfig.getFileExtension(cfg)).value().isEqualTo("bar"); } @Test @@ -401,7 +403,7 @@ public void cannotGetRejectNonResolvableCodeOwnersForBranchForNullConfig() throw @Test public void noBranchSpecificRejectNonResolvableCodeOwnersConfiguration() throws Exception { - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "master"), new Config())) .isEmpty(); @@ -416,7 +418,7 @@ public void noMatchingBranchSpecificRejectNonResolvableCodeOwnersConfiguration_e "refs/heads/foo", KEY_REJECT_NON_RESOLVABLE_CODE_OWNERS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -431,7 +433,7 @@ public void noMatchingBranchSpecificRejectNonResolvableCodeOwnersConfiguration_r "refs/heads/foo/*", KEY_REJECT_NON_RESOLVABLE_CODE_OWNERS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -446,7 +448,7 @@ public void noMatchingBranchSpecificRejectNonResolvableCodeOwnersConfiguration_r "^refs/heads/.*foo.*", KEY_REJECT_NON_RESOLVABLE_CODE_OWNERS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -461,7 +463,7 @@ public void noMatchingBranchSpecificRejectNonResolvableCodeOwnersConfiguration_i "^refs/heads/[", KEY_REJECT_NON_RESOLVABLE_CODE_OWNERS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -476,7 +478,7 @@ public void matchingBranchSpecificRejectNonResolvableCodeOwnersConfiguration_exa "refs/heads/master", KEY_REJECT_NON_RESOLVABLE_CODE_OWNERS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -492,7 +494,7 @@ public void matchingBranchSpecificRejectNonResolvableCodeOwnersConfiguration_ref "refs/heads/*", KEY_REJECT_NON_RESOLVABLE_CODE_OWNERS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -508,7 +510,7 @@ public void matchingBranchSpecificRejectNonResolvableCodeOwnersConfiguration_reg "^refs/heads/.*bar.*", KEY_REJECT_NON_RESOLVABLE_CODE_OWNERS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "foobarbaz"), cfg)) .value() @@ -521,7 +523,7 @@ public void branchSpecificRejectNonResolvableCodeOwnersConfigurationIsIgnoredIfV Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/master", KEY_REJECT_NON_RESOLVABLE_CODE_OWNERS, "INVALID"); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -549,7 +551,7 @@ public void multipleMatchingBranchSpecificRejectNonResolvableCodeOwnersConfigura // it is non-deterministic which of the branch-specific configurations takes precedence, but // since they all configure the same value it's not important for this assertion - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableCodeOwnersForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -638,7 +640,7 @@ public void cannotGetRejectNonResolvableImportsForBranchForNullConfig() throws E @Test public void noBranchSpecificRejectNonResolvableImportsConfiguration() throws Exception { - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "master"), new Config())) .isEmpty(); @@ -653,7 +655,7 @@ public void noMatchingBranchSpecificRejectNonResolvableImportsConfiguration_exac "refs/heads/foo", KEY_REJECT_NON_RESOLVABLE_IMPORTS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -668,7 +670,7 @@ public void noMatchingBranchSpecificRejectNonResolvableImportsConfiguration_refP "refs/heads/foo/*", KEY_REJECT_NON_RESOLVABLE_IMPORTS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -683,7 +685,7 @@ public void noMatchingBranchSpecificRejectNonResolvableImportsConfiguration_regE "^refs/heads/.*foo.*", KEY_REJECT_NON_RESOLVABLE_IMPORTS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -695,7 +697,7 @@ public void noMatchingBranchSpecificRejectNonResolvableImportsConfiguration_inva Config cfg = new Config(); cfg.setBoolean( SECTION_VALIDATION, "^refs/heads/[", KEY_REJECT_NON_RESOLVABLE_IMPORTS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -710,7 +712,7 @@ public void matchingBranchSpecificRejectNonResolvableImportsConfiguration_exact( "refs/heads/master", KEY_REJECT_NON_RESOLVABLE_IMPORTS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -723,7 +725,7 @@ public void matchingBranchSpecificRejectNonResolvableImportsConfiguration_refPat Config cfg = new Config(); cfg.setBoolean( SECTION_VALIDATION, "refs/heads/*", KEY_REJECT_NON_RESOLVABLE_IMPORTS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -739,7 +741,7 @@ public void matchingBranchSpecificRejectNonResolvableImportsConfiguration_regEx( "^refs/heads/.*bar.*", KEY_REJECT_NON_RESOLVABLE_IMPORTS, /* value= */ false); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "foobarbaz"), cfg)) .value() @@ -752,7 +754,7 @@ public void branchSpecificRejectNonResolvableImportsConfigurationIsIgnoredIfValu Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/master", KEY_REJECT_NON_RESOLVABLE_IMPORTS, "INVALID"); - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -777,7 +779,7 @@ public void multipleMatchingBranchSpecificRejectNonResolvableImportsConfiguratio // it is non-deterministic which of the branch-specific configurations takes precedence, but // since they all configure the same value it's not important for this assertion - assertThat( + OptionalSubject.assertThat( generalConfig.getRejectNonResolvableImportsForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -889,7 +891,7 @@ public void cannotGetEnableValidationOnBranchCreationForBranchForNullPluginConfi @Test public void noBranchSpecificEnableValidationOnBranchCreationConfiguration() throws Exception { - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "master"), new Config())) .isEmpty(); @@ -901,7 +903,7 @@ public void noMatchingBranchSpecificEnableValidationOnBranchCreationConfiguratio Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/foo", KEY_ENABLE_VALIDATION_ON_BRANCH_CREATION, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -913,7 +915,7 @@ public void noMatchingBranchSpecificEnableValidationOnBranchCreationConfiguratio Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/foo/*", KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -928,7 +930,7 @@ public void noMatchingBranchSpecificEnableValidationOnBranchCreationConfiguratio "^refs/heads/.*foo.*", KEY_ENABLE_VALIDATION_ON_BRANCH_CREATION, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -940,7 +942,7 @@ public void noMatchingBranchSpecificEnableValidationOnBranchCreationConfiguratio Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "^refs/heads/[", KEY_ENABLE_VALIDATION_ON_BRANCH_CREATION, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -952,7 +954,7 @@ public void matchingBranchSpecificEnableValidationOnBranchCreationConfiguration_ Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/master", KEY_ENABLE_VALIDATION_ON_BRANCH_CREATION, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -965,7 +967,7 @@ public void matchingBranchSpecificEnableValidationOnBranchCreationConfiguration_ Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/*", KEY_ENABLE_VALIDATION_ON_BRANCH_CREATION, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -981,7 +983,7 @@ public void matchingBranchSpecificEnableValidationOnBranchCreationConfiguration_ "^refs/heads/.*bar.*", KEY_ENABLE_VALIDATION_ON_BRANCH_CREATION, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "foobarbaz"), cfg)) .value() @@ -997,7 +999,7 @@ public void branchSpecificEnableValidationOnBranchCreationConfigurationIsIgnored "refs/heads/master", KEY_ENABLE_VALIDATION_ON_BRANCH_CREATION, "INVALID"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1016,7 +1018,7 @@ public void multipleMatchingBranchSpecificEnableValidationOnBranchCreationConfig // it is non-deterministic which of the branch-specific configurations takes precedence, but // since they all configure the same value it's not important for this assertion - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForBranchCreationForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -1117,7 +1119,7 @@ public void cannotGetEnableValidationOnCommitReceivedForBranchForNullPluginConfi @Test public void noBranchSpecificEnableValidationOnCommitReceivedConfiguration() throws Exception { - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), new Config())) .isEmpty(); @@ -1129,7 +1131,7 @@ public void noMatchingBranchSpecificEnableValidationOnCommitReceivedConfiguratio Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/foo", KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1141,7 +1143,7 @@ public void noMatchingBranchSpecificEnableValidationOnCommitReceivedConfiguratio Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/foo/*", KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1156,7 +1158,7 @@ public void noMatchingBranchSpecificEnableValidationOnCommitReceivedConfiguratio "^refs/heads/.*foo.*", KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1168,7 +1170,7 @@ public void noMatchingBranchSpecificEnableValidationOnCommitReceivedConfiguratio Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "^refs/heads/[", KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1180,7 +1182,7 @@ public void matchingBranchSpecificEnableValidationOnCommitReceivedConfiguration_ Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/master", KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -1193,7 +1195,7 @@ public void matchingBranchSpecificEnableValidationOnCommitReceivedConfiguration_ Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/*", KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -1209,7 +1211,7 @@ public void matchingBranchSpecificEnableValidationOnCommitReceivedConfiguration_ "^refs/heads/.*bar.*", KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "foobarbaz"), cfg)) .value() @@ -1225,7 +1227,7 @@ public void branchSpecificEnableValidationOnCommitReceivedConfigurationIsIgnored "refs/heads/master", KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, "INVALID"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1244,7 +1246,7 @@ public void multipleMatchingBranchSpecificEnableValidationOnCommitReceivedConfig // it is non-deterministic which of the branch-specific configurations takes precedence, but // since they all configure the same value it's not important for this assertion - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -1343,7 +1345,7 @@ public void cannotGetEnableValidationOnSubmitForBranchForNullPluginConfig() thro @Test public void noBranchSpecificEnableValidationOnSubmitConfiguration() throws Exception { - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForSubmitForBranch( BranchNameKey.create(project, "master"), new Config())) .isEmpty(); @@ -1354,7 +1356,7 @@ public void noMatchingBranchSpecificEnableValidationOnSubmitConfiguration_exact( throws Exception { Config cfg = new Config(); cfg.setString(SECTION_VALIDATION, "refs/heads/foo", KEY_ENABLE_VALIDATION_ON_SUBMIT, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForSubmitForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1365,7 +1367,7 @@ public void noMatchingBranchSpecificEnableValidationOnSubmitConfiguration_refPat throws Exception { Config cfg = new Config(); cfg.setString(SECTION_VALIDATION, "refs/heads/foo/*", KEY_ENABLE_VALIDATION_ON_SUBMIT, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForSubmitForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1377,7 +1379,7 @@ public void noMatchingBranchSpecificEnableValidationOnSubmitConfiguration_regEx( Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "^refs/heads/.*foo.*", KEY_ENABLE_VALIDATION_ON_SUBMIT, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForCommitReceivedForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1388,7 +1390,7 @@ public void noMatchingBranchSpecificEnableValidationOnSubmitConfiguration_invali throws Exception { Config cfg = new Config(); cfg.setString(SECTION_VALIDATION, "^refs/heads/[", KEY_ENABLE_VALIDATION_ON_SUBMIT, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForSubmitForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1399,7 +1401,7 @@ public void matchingBranchSpecificEnableValidationOnSubmitConfiguration_exact() Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/master", KEY_ENABLE_VALIDATION_ON_SUBMIT, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForSubmitForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -1411,7 +1413,7 @@ public void matchingBranchSpecificEnableValidationOnSubmitConfiguration_refPatte throws Exception { Config cfg = new Config(); cfg.setString(SECTION_VALIDATION, "refs/heads/*", KEY_ENABLE_VALIDATION_ON_SUBMIT, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForSubmitForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -1423,7 +1425,7 @@ public void matchingBranchSpecificEnableValidationOnSubmitConfiguration_regEx() Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "^refs/heads/.*bar.*", KEY_ENABLE_VALIDATION_ON_SUBMIT, "false"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForSubmitForBranch( BranchNameKey.create(project, "foobarbaz"), cfg)) .value() @@ -1436,7 +1438,7 @@ public void branchSpecificEnableValidationOnSubmitConfigurationIsIgnoredIfValueI Config cfg = new Config(); cfg.setString( SECTION_VALIDATION, "refs/heads/master", KEY_ENABLE_VALIDATION_ON_SUBMIT, "INVALID"); - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForSubmitForBranch( BranchNameKey.create(project, "master"), cfg)) .isEmpty(); @@ -1453,7 +1455,7 @@ public void multipleMatchingBranchSpecificEnableValidationOnSubmitConfiguration( // it is non-deterministic which of the branch-specific configurations takes precedence, but // since they all configure the same value it's not important for this assertion - assertThat( + OptionalSubject.assertThat( generalConfig.getCodeOwnerConfigValidationPolicyForSubmitForBranch( BranchNameKey.create(project, "master"), cfg)) .value() @@ -1856,14 +1858,14 @@ public void cannotGetOverrideInfoUrlForNullPluginConfig() throws Exception { @Test public void noOverrideInfoUrlConfigured() throws Exception { - assertThat(generalConfig.getOverrideInfoUrl(new Config())).isEmpty(); + OptionalSubject.assertThat(generalConfig.getOverrideInfoUrl(new Config())).isEmpty(); } @Test @GerritConfig(name = "plugin.code-owners.overrideInfoUrl", value = "http://foo.example.com") public void overrideInfoIsRetrievedFromGerritConfigIfNotSpecifiedOnProjectLevel() throws Exception { - assertThat(generalConfig.getOverrideInfoUrl(new Config())) + OptionalSubject.assertThat(generalConfig.getOverrideInfoUrl(new Config())) .value() .isEqualTo("http://foo.example.com"); } @@ -1878,7 +1880,9 @@ public void overrideInfoUrlInPluginConfigOverridesOverrideInfoUrlInGerritConfig( /* subsection= */ null, KEY_OVERRIDE_INFO_URL, "http://bar.example.com"); - assertThat(generalConfig.getOverrideInfoUrl(cfg)).value().isEqualTo("http://bar.example.com"); + OptionalSubject.assertThat(generalConfig.getOverrideInfoUrl(cfg)) + .value() + .isEqualTo("http://bar.example.com"); } @Test @@ -1892,7 +1896,8 @@ public void cannotGetInvalidCodeOwnerConfigInfoUrlForNullPluginConfig() throws E @Test public void noInvalidCodeOwnerConfigInfoUrlConfigured() throws Exception { - assertThat(generalConfig.getInvalidCodeOwnerConfigInfoUrl(new Config())).isEmpty(); + OptionalSubject.assertThat(generalConfig.getInvalidCodeOwnerConfigInfoUrl(new Config())) + .isEmpty(); } @Test @@ -1901,7 +1906,7 @@ public void noInvalidCodeOwnerConfigInfoUrlConfigured() throws Exception { value = "http://foo.example.com") public void invalidCodeOwnerConfigInfoIsRetrievedFromGerritConfigIfNotSpecifiedOnProjectLevel() throws Exception { - assertThat(generalConfig.getInvalidCodeOwnerConfigInfoUrl(new Config())) + OptionalSubject.assertThat(generalConfig.getInvalidCodeOwnerConfigInfoUrl(new Config())) .value() .isEqualTo("http://foo.example.com"); } @@ -1918,7 +1923,7 @@ public void invalidCodeOwnerConfigInfoUrlInPluginConfigOverridesOverrideInfoUrlI /* subsection= */ null, KEY_INVALID_CODE_OWNER_CONFIG_INFO_URL, "http://bar.example.com"); - assertThat(generalConfig.getInvalidCodeOwnerConfigInfoUrl(cfg)) + OptionalSubject.assertThat(generalConfig.getInvalidCodeOwnerConfigInfoUrl(cfg)) .value() .isEqualTo("http://bar.example.com"); }