AbstractDaemonTest: Add saveProjectConfig method

The same saveProjectConfig implementation is defined in 3 test classes
that are derived from AbstractDaemonTest.  Remove them and define it
once in AbstractDaemonTest instead.

Change-Id: Ic627f389a1a154cbb095c1b6a184178f0b154094
This commit is contained in:
David Pursehouse 2016-04-08 00:43:12 +09:00
parent 1525475046
commit 6816375f9f
4 changed files with 4 additions and 21 deletions

View File

@ -617,6 +617,10 @@ public abstract class AbstractDaemonTest {
projectCache.evict(cfg.getProject());
}
protected void saveProjectConfig(ProjectConfig cfg) throws Exception {
saveProjectConfig(project, cfg);
}
protected void grant(String permission, Project.NameKey project, String ref)
throws RepositoryNotFoundException, IOException, ConfigInvalidException {
grant(permission, project, ref, false);

View File

@ -39,7 +39,6 @@ import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.LabelInfo;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.group.SystemGroupBackend;
import com.google.gerrit.server.project.Util;
@ -88,12 +87,6 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
grant(Permission.LABEL + "Patch-Set-Lock", project, "refs/heads/*");
}
private void saveProjectConfig(ProjectConfig cfg) throws Exception {
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
cfg.commit(md);
}
}
protected void selectProtocol(Protocol p) throws Exception {
String url;
switch (p) {

View File

@ -32,7 +32,6 @@ import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.group.SystemGroupBackend;
import com.google.gerrit.server.project.Util;
@ -241,12 +240,6 @@ public class MoveChangeIT extends AbstractDaemonTest {
move(r.getChangeId(), newBranch.get());
}
private void saveProjectConfig(ProjectConfig cfg) throws Exception {
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
cfg.commit(md);
}
}
private void move(int changeNum, String destination)
throws RestApiException {
gApi.changes().id(changeNum).move(destination);

View File

@ -26,7 +26,6 @@ import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.LabelInfo;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.project.Util;
@ -416,12 +415,6 @@ public class LabelTypeIT extends AbstractDaemonTest {
saveProjectConfig(cfg);
}
private void saveProjectConfig(ProjectConfig cfg) throws Exception {
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
cfg.commit(md);
}
}
@Override
protected void merge(PushOneCommit.Result r) throws Exception {
super.merge(r);