Rename Util to TestLabels, since that's all that's left

Change-Id: Iedbb4086abdf00896b9e2b44d8089d5d199ae214
This commit is contained in:
Dave Borowitz
2019-05-16 14:00:22 +02:00
parent 33cd6a7d66
commit 45e43929bb
16 changed files with 54 additions and 47 deletions

View File

@@ -24,8 +24,8 @@ import static com.google.common.truth.TruthJUnit.assume;
import static com.google.gerrit.extensions.api.changes.SubmittedTogetherOption.NON_VISIBLE_CHANGES;
import static com.google.gerrit.reviewdb.client.Patch.COMMIT_MSG;
import static com.google.gerrit.reviewdb.client.Patch.MERGE_LIST;
import static com.google.gerrit.server.project.testing.Util.category;
import static com.google.gerrit.server.project.testing.Util.value;
import static com.google.gerrit.server.project.testing.TestLabels.category;
import static com.google.gerrit.server.project.testing.TestLabels.value;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;

View File

@@ -19,7 +19,7 @@ import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelValue;
import java.util.Arrays;
public class Util {
public class TestLabels {
public static LabelType codeReview() {
return category(
"Code-Review",
@@ -49,5 +49,5 @@ public class Util {
return new LabelType(name, Arrays.asList(values));
}
private Util() {}
private TestLabels() {}
}

View File

@@ -52,8 +52,8 @@ import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
import static com.google.gerrit.server.group.SystemGroupBackend.CHANGE_OWNER;
import static com.google.gerrit.server.group.SystemGroupBackend.PROJECT_OWNERS;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static com.google.gerrit.server.project.testing.Util.category;
import static com.google.gerrit.server.project.testing.Util.value;
import static com.google.gerrit.server.project.testing.TestLabels.category;
import static com.google.gerrit.server.project.testing.TestLabels.value;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -156,7 +156,7 @@ import com.google.gerrit.server.group.SystemGroupBackend;
import com.google.gerrit.server.index.change.ChangeIndex;
import com.google.gerrit.server.index.change.ChangeIndexCollection;
import com.google.gerrit.server.index.change.IndexedChangeQuery;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.ChangeQueryBuilder.ChangeOperatorFactory;
import com.google.gerrit.server.restapi.change.PostReview;
@@ -3269,7 +3269,7 @@ public class ChangeIT extends AbstractDaemonTest {
// add new label and assert that it's returned for existing changes
AccountGroup.UUID registeredUsers = systemGroupBackend.getGroup(REGISTERED_USERS).getUUID();
LabelType verified = Util.verified();
LabelType verified = TestLabels.verified();
String heads = RefNames.REFS_HEADS + "*";
try (ProjectConfigUpdate u = updateProject(project)) {
@@ -3334,7 +3334,7 @@ public class ChangeIT extends AbstractDaemonTest {
assertThat(change.permittedLabels.keySet()).containsExactly("Code-Review");
assertPermitted(change, "Code-Review", 2);
LabelType verified = Util.verified();
LabelType verified = TestLabels.verified();
AccountGroup.UUID registeredUsers = systemGroupBackend.getGroup(REGISTERED_USERS).getUUID();
String heads = RefNames.REFS_HEADS + "*";
@@ -3438,7 +3438,10 @@ public class ChangeIT extends AbstractDaemonTest {
.project(project)
.forUpdate()
.add(
allowLabel(Util.codeReview().getName()).ref(heads).group(REGISTERED_USERS).range(-2, 2))
allowLabel(TestLabels.codeReview().getName())
.ref(heads)
.group(REGISTERED_USERS)
.range(-2, 2))
.update();
PushOneCommit.Result r = createChange();

View File

@@ -27,8 +27,8 @@ import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_COMM
import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_REVISION;
import static com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static com.google.gerrit.server.project.testing.Util.category;
import static com.google.gerrit.server.project.testing.Util.value;
import static com.google.gerrit.server.project.testing.TestLabels.category;
import static com.google.gerrit.server.project.testing.TestLabels.value;
import static org.eclipse.jgit.lib.Constants.HEAD;
import com.google.common.collect.ImmutableList;
@@ -48,7 +48,7 @@ import com.google.gerrit.extensions.common.ApprovalInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.inject.Inject;
import java.util.EnumSet;
import java.util.List;
@@ -92,12 +92,12 @@ public class StickyApprovalsIT extends AbstractDaemonTest {
.project(project)
.forUpdate()
.add(
allowLabel(Util.codeReview().getName())
allowLabel(TestLabels.codeReview().getName())
.ref(RefNames.REFS_HEADS + "*")
.group(REGISTERED_USERS)
.range(-2, 2))
.add(
allowLabel(Util.verified().getName())
allowLabel(TestLabels.verified().getName())
.ref(RefNames.REFS_HEADS + "*")
.group(REGISTERED_USERS)
.range(-1, 1))

View File

@@ -59,7 +59,7 @@ import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.ChangeMessagesUtil;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.gerrit.server.restapi.change.ChangeEdits.EditMessage;
import com.google.gerrit.server.restapi.change.ChangeEdits.Post;
import com.google.gerrit.server.restapi.change.ChangeEdits.Put;
@@ -601,7 +601,7 @@ public class ChangeEditIT extends AbstractDaemonTest {
public void editCommitMessageCopiesLabelScores() throws Exception {
String cr = "Code-Review";
try (ProjectConfigUpdate u = updateProject(project)) {
LabelType codeReview = Util.codeReview();
LabelType codeReview = TestLabels.codeReview();
codeReview.setCopyAllScoresIfNoCodeChange(true);
u.getConfig().getLabelSections().put(cr, codeReview);
u.save();

View File

@@ -38,8 +38,8 @@ import static com.google.gerrit.extensions.common.testing.EditInfoSubject.assert
import static com.google.gerrit.server.git.receive.ReceiveConstants.PUSH_OPTION_SKIP_VALIDATION;
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static com.google.gerrit.server.project.testing.Util.category;
import static com.google.gerrit.server.project.testing.Util.value;
import static com.google.gerrit.server.project.testing.TestLabels.category;
import static com.google.gerrit.server.project.testing.TestLabels.value;
import static java.util.Comparator.comparing;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.joining;
@@ -98,7 +98,7 @@ import com.google.gerrit.server.git.receive.NoteDbPushOption;
import com.google.gerrit.server.git.receive.ReceiveConstants;
import com.google.gerrit.server.git.validators.CommitValidators.ChangeIdValidator;
import com.google.gerrit.server.group.SystemGroupBackend;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.testing.FakeEmailSender.Message;
import com.google.gerrit.testing.TestTimeUtil;
@@ -160,7 +160,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
@Before
public void setUpPatchSetLock() throws Exception {
try (ProjectConfigUpdate u = updateProject(project)) {
patchSetLock = Util.patchSetLock();
patchSetLock = TestLabels.patchSetLock();
u.getConfig().getLabelSections().put(patchSetLock.getName(), patchSetLock);
u.save();
}
@@ -1942,7 +1942,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
@Test
public void pushNewPatchsetOverridingStickyLabel() throws Exception {
try (ProjectConfigUpdate u = updateProject(project)) {
LabelType codeReview = Util.codeReview();
LabelType codeReview = TestLabels.codeReview();
codeReview.setCopyMaxScore(true);
u.getConfig().getLabelSections().put(codeReview.getName(), codeReview);
u.save();

View File

@@ -66,7 +66,7 @@ import com.google.gerrit.server.ApprovalsUtil;
import com.google.gerrit.server.ChangeMessagesUtil;
import com.google.gerrit.server.CommentsUtil;
import com.google.gerrit.server.account.AccountControl;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.inject.Inject;
import org.apache.http.Header;
@@ -173,7 +173,7 @@ public class ImpersonationIT extends AbstractDaemonTest {
@Test
public void voteOnBehalfOfLabelNotPermitted() throws Exception {
try (ProjectConfigUpdate u = updateProject(project)) {
LabelType verified = Util.verified();
LabelType verified = TestLabels.verified();
u.getConfig().getLabelSections().put(verified.getName(), verified);
u.save();
}
@@ -578,7 +578,7 @@ public class ImpersonationIT extends AbstractDaemonTest {
.project(project)
.forUpdate()
.add(
allowLabel(Util.codeReview().getName())
allowLabel(TestLabels.codeReview().getName())
.impersonation(true)
.ref("refs/heads/*")
.group(REGISTERED_USERS)
@@ -594,7 +594,10 @@ public class ImpersonationIT extends AbstractDaemonTest {
.add(allow(Permission.SUBMIT_AS).ref(heads).group(REGISTERED_USERS))
.add(allow(Permission.SUBMIT).ref(heads).group(REGISTERED_USERS))
.add(
allowLabel(Util.codeReview().getName()).ref(heads).group(REGISTERED_USERS).range(-2, 2))
allowLabel(TestLabels.codeReview().getName())
.ref(heads)
.group(REGISTERED_USERS)
.range(-2, 2))
.update();
}

View File

@@ -35,7 +35,7 @@ import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.reviewdb.client.BranchNameKey;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.inject.Inject;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
@@ -65,7 +65,7 @@ public abstract class AbstractSubmitByRebase extends AbstractSubmit {
.add(block(Permission.ADD_PATCH_SET).ref("refs/*").group(REGISTERED_USERS))
.add(allow(Permission.SUBMIT).ref("refs/heads/*").group(REGISTERED_USERS))
.add(
allowLabel(Util.codeReview().getName())
allowLabel(TestLabels.codeReview().getName())
.ref("refs/heads/*")
.group(REGISTERED_USERS)
.range(-2, 2))

View File

@@ -40,7 +40,7 @@ import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.BranchNameKey;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.inject.Inject;
import java.util.Arrays;
import org.eclipse.jgit.junit.TestRepository;
@@ -243,7 +243,7 @@ public class MoveChangeIT extends AbstractDaemonTest {
BranchNameKey newBranch = BranchNameKey.create(r.getChange().change().getProject(), "moveTest");
createBranch(newBranch);
LabelType patchSetLock = Util.patchSetLock();
LabelType patchSetLock = TestLabels.patchSetLock();
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().getLabelSections().put(patchSetLock.getName(), patchSetLock);
u.save();

View File

@@ -18,8 +18,8 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowLabel;
import static com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS;
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
import static com.google.gerrit.server.project.testing.Util.category;
import static com.google.gerrit.server.project.testing.Util.value;
import static com.google.gerrit.server.project.testing.TestLabels.category;
import static com.google.gerrit.server.project.testing.TestLabels.value;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;

View File

@@ -27,8 +27,8 @@ import static com.google.gerrit.extensions.client.ListChangesOption.LABELS;
import static com.google.gerrit.extensions.client.ListChangesOption.SUBMITTABLE;
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static com.google.gerrit.server.project.testing.Util.category;
import static com.google.gerrit.server.project.testing.Util.value;
import static com.google.gerrit.server.project.testing.TestLabels.category;
import static com.google.gerrit.server.project.testing.TestLabels.value;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import com.google.gerrit.acceptance.AbstractDaemonTest;

View File

@@ -17,8 +17,8 @@ package com.google.gerrit.server.change;
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowLabel;
import static com.google.gerrit.common.data.Permission.forLabel;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static com.google.gerrit.server.project.testing.Util.category;
import static com.google.gerrit.server.project.testing.Util.value;
import static com.google.gerrit.server.project.testing.TestLabels.category;
import static com.google.gerrit.server.project.testing.TestLabels.value;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.ImmutableList;

View File

@@ -53,7 +53,7 @@ import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectConfig;
import com.google.gerrit.server.project.ProjectState;
import com.google.gerrit.server.project.RefPattern;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.gerrit.server.schema.SchemaCreator;
import com.google.gerrit.server.util.ThreadLocalRequestContext;
import com.google.gerrit.testing.InMemoryModule;
@@ -204,7 +204,7 @@ public class RefControlTest {
try (MetaDataUpdate md = metaDataUpdateFactory.create(allProjectsName)) {
ProjectConfig allProjectsConfig = projectConfigFactory.create(allProjectsName);
allProjectsConfig.load(md);
LabelType cr = Util.codeReview();
LabelType cr = TestLabels.codeReview();
allProjectsConfig.getLabelSections().put(cr.getName(), cr);
allProjectsConfig.commit(md);
}

View File

@@ -36,7 +36,7 @@ import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
import com.google.gerrit.server.git.ValidationError;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -340,11 +340,11 @@ public class ProjectConfigTest {
cfg.getLabelSections()
.put(
"My-Label",
Util.category(
TestLabels.category(
"My-Label",
Util.value(-1, "Negative"),
Util.value(0, "No score"),
Util.value(1, "Positive")));
TestLabels.value(-1, "Negative"),
TestLabels.value(0, "No score"),
TestLabels.value(1, "Positive")));
rev = commit(cfg);
assertThat(text(rev, "project.config"))
.isEqualTo(

View File

@@ -22,8 +22,8 @@ import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.a
import static com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS;
import static com.google.gerrit.extensions.client.ListChangesOption.REVIEWED;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static com.google.gerrit.server.project.testing.Util.category;
import static com.google.gerrit.server.project.testing.Util.value;
import static com.google.gerrit.server.project.testing.TestLabels.category;
import static com.google.gerrit.server.project.testing.TestLabels.value;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;

View File

@@ -19,7 +19,7 @@ import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import static org.easymock.EasyMock.expect;
import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.server.project.testing.Util;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.inject.AbstractModule;
import com.googlecode.prolog_cafe.exceptions.CompileException;
@@ -58,7 +58,8 @@ public class GerritCommonTest extends PrologTestCase {
@Override
protected void setUpEnvironment(PrologEnvironment env) throws Exception {
LabelTypes labelTypes = new LabelTypes(Arrays.asList(Util.codeReview(), Util.verified()));
LabelTypes labelTypes =
new LabelTypes(Arrays.asList(TestLabels.codeReview(), TestLabels.verified()));
ChangeData cd = EasyMock.createMock(ChangeData.class);
expect(cd.getLabelTypes()).andStubReturn(labelTypes);
EasyMock.replay(cd);