Java 8: Make GerritConfig repeatable annotation

Change-Id: I6e823a5b2ecb960f87c7128342b811fa40e4d1ba
This commit is contained in:
David Ostrovsky
2016-10-26 09:00:51 +02:00
parent bc1062f2b6
commit df7fd81464
5 changed files with 40 additions and 51 deletions

View File

@@ -17,11 +17,13 @@ package com.google.gerrit.acceptance;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Target({METHOD})
@Retention(RUNTIME)
@Repeatable(GerritConfigs.class)
public @interface GerritConfig {
String name();
String value() default "";

View File

@@ -35,10 +35,8 @@ public class UseGerritConfigAnnotationTest extends AbstractDaemonTest {
}
@Test
@GerritConfigs({
@GerritConfig(name = "x.y", value = "z"),
@GerritConfig(name = "x.y", value = "z")
@GerritConfig(name = "a.b", value = "c")
})
public void testMultiple() {
assertThat(serverConfig.getString("x", null, "y")).isEqualTo("z");
assertThat(serverConfig.getString("a", null, "b")).isEqualTo("c");

View File

@@ -36,7 +36,6 @@ import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AcceptanceTestRequestScope;
import com.google.gerrit.acceptance.GerritConfig;
import com.google.gerrit.acceptance.GerritConfigs;
import com.google.gerrit.acceptance.GitUtil;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.PushOneCommit;
@@ -1699,10 +1698,8 @@ public class ChangeIT extends AbstractDaemonTest {
}
@Test
@GerritConfigs({
@GerritConfig(name = "gerrit.editGpgKeys", value = "true"),
@GerritConfig(name = "receive.enableSignedPush", value = "true"),
})
@GerritConfig(name = "gerrit.editGpgKeys", value = "true")
@GerritConfig(name = "receive.enableSignedPush", value = "true")
public void pushCertificates() throws Exception {
PushOneCommit.Result r1 = createChange();
PushOneCommit.Result r2 = amendChange(r1.getChangeId());

View File

@@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.GerritConfig;
import com.google.gerrit.acceptance.GerritConfigs;
import com.google.gerrit.acceptance.Sandboxed;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.common.data.GlobalCapability;
@@ -84,10 +83,8 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
}
@Test
@GerritConfigs(
{@GerritConfig(name = "suggest.from", value = "1"),
@GerritConfig(name = "suggest.from", value = "1")
@GerritConfig(name = "accounts.visibility", value = "NONE")
})
public void suggestReviewersNoResult2() throws Exception {
String changeId = createChange().getChangeId();
List<SuggestedReviewerInfo> reviewers =
@@ -227,10 +224,8 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
}
@Test
@GerritConfigs({
@GerritConfig(name = "addreviewer.maxAllowed", value="2"),
@GerritConfig(name = "addreviewer.maxWithoutConfirmation", value="1"),
})
@GerritConfig(name = "addreviewer.maxAllowed", value="2")
@GerritConfig(name = "addreviewer.maxWithoutConfirmation", value="1")
public void suggestReviewersGroupSizeConsiderations() throws Exception {
AccountGroup largeGroup = group("large");
AccountGroup mediumGroup = group("medium");

View File

@@ -19,7 +19,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.GerritConfig;
import com.google.gerrit.acceptance.GerritConfigs;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.extensions.client.AccountFieldName;
import com.google.gerrit.extensions.client.AuthType;
@@ -37,44 +36,42 @@ import java.nio.file.Path;
public class ServerInfoIT extends AbstractDaemonTest {
@Test
@GerritConfigs({
// auth
@GerritConfig(name = "auth.type", value = "HTTP"),
@GerritConfig(name = "auth.contributorAgreements", value = "true"),
@GerritConfig(name = "auth.loginUrl", value = "https://example.com/login"),
@GerritConfig(name = "auth.loginText", value = "LOGIN"),
@GerritConfig(name = "auth.switchAccountUrl", value = "https://example.com/switch"),
@GerritConfig(name = "auth.type", value = "HTTP")
@GerritConfig(name = "auth.contributorAgreements", value = "true")
@GerritConfig(name = "auth.loginUrl", value = "https://example.com/login")
@GerritConfig(name = "auth.loginText", value = "LOGIN")
@GerritConfig(name = "auth.switchAccountUrl", value = "https://example.com/switch")
// auth fields ignored when auth == HTTP
@GerritConfig(name = "auth.registerUrl", value = "https://example.com/register"),
@GerritConfig(name = "auth.registerText", value = "REGISTER"),
@GerritConfig(name = "auth.editFullNameUrl", value = "https://example.com/editname"),
@GerritConfig(name = "auth.httpPasswordUrl", value = "https://example.com/password"),
@GerritConfig(name = "auth.registerUrl", value = "https://example.com/register")
@GerritConfig(name = "auth.registerText", value = "REGISTER")
@GerritConfig(name = "auth.editFullNameUrl", value = "https://example.com/editname")
@GerritConfig(name = "auth.httpPasswordUrl", value = "https://example.com/password")
// change
@GerritConfig(name = "change.allowDrafts", value = "false"),
@GerritConfig(name = "change.largeChange", value = "300"),
@GerritConfig(name = "change.replyTooltip", value = "Publish votes and draft comments"),
@GerritConfig(name = "change.replyLabel", value = "Vote"),
@GerritConfig(name = "change.updateDelay", value = "50s"),
@GerritConfig(name = "change.allowDrafts", value = "false")
@GerritConfig(name = "change.largeChange", value = "300")
@GerritConfig(name = "change.replyTooltip", value = "Publish votes and draft comments")
@GerritConfig(name = "change.replyLabel", value = "Vote")
@GerritConfig(name = "change.updateDelay", value = "50s")
// download
@GerritConfig(name = "download.archive", values = {"tar",
"tbz2", "tgz", "txz"}),
"tbz2", "tgz", "txz"})
// gerrit
@GerritConfig(name = "gerrit.allProjects", value = "Root"),
@GerritConfig(name = "gerrit.allUsers", value = "Users"),
@GerritConfig(name = "gerrit.enableGwtUi", value = "true"),
@GerritConfig(name = "gerrit.reportBugText", value = "REPORT BUG"),
@GerritConfig(name = "gerrit.reportBugUrl", value = "https://example.com/report"),
@GerritConfig(name = "gerrit.allProjects", value = "Root")
@GerritConfig(name = "gerrit.allUsers", value = "Users")
@GerritConfig(name = "gerrit.enableGwtUi", value = "true")
@GerritConfig(name = "gerrit.reportBugText", value = "REPORT BUG")
@GerritConfig(name = "gerrit.reportBugUrl", value = "https://example.com/report")
// suggest
@GerritConfig(name = "suggest.from", value = "3"),
@GerritConfig(name = "suggest.from", value = "3")
// user
@GerritConfig(name = "user.anonymousCoward", value = "Unnamed User"),
})
@GerritConfig(name = "user.anonymousCoward", value = "Unnamed User")
public void serverConfig() throws Exception {
ServerInfo i = gApi.config().server().getInfo();