Use ApprovalsUtil from PushOneCommit

This requires a bit of package reorganization, since GerritServer now
needs to bind PushOneCommit.Factory, so they must be in the same
package to avoid a circular import.

Change-Id: Id99abec0c297a36f6ba628e58b49197e9aabf5d5
This commit is contained in:
Dave Borowitz 2013-12-19 06:43:42 -08:00
parent b5b6f615ec
commit 1dd2db24a4
41 changed files with 236 additions and 171 deletions

View File

@ -31,6 +31,7 @@ java_library(
'//lib/log:impl_log4j',
'//lib/log:log4j',
'//lib/guice:guice',
'//lib/guice:guice-assistedinject',
'//lib/jgit:jgit',
'//lib/jgit:junit',
'//lib/mina:sshd',

View File

@ -146,6 +146,7 @@ public class GerritServer {
@Override
protected void configure() {
bind(AccountCreator.class);
factory(PushOneCommit.Factory.class);
}
};
return sysInjector.createChildInjector(module);

View File

@ -12,12 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance.git;
package com.google.gerrit.acceptance;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TempFileUtil;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.reviewdb.client.Project;
import com.jcraft.jsch.JSch;

View File

@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance.git;
package com.google.gerrit.acceptance;
import static com.google.gerrit.acceptance.git.GitUtil.add;
import static com.google.gerrit.acceptance.git.GitUtil.amendCommit;
import static com.google.gerrit.acceptance.git.GitUtil.createCommit;
import static com.google.gerrit.acceptance.git.GitUtil.pushHead;
import static com.google.gerrit.acceptance.GitUtil.add;
import static com.google.gerrit.acceptance.GitUtil.amendCommit;
import static com.google.gerrit.acceptance.GitUtil.createCommit;
import static com.google.gerrit.acceptance.GitUtil.pushHead;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -26,14 +26,15 @@ import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.GitUtil.Commit;
import com.google.gerrit.acceptance.GitUtil.Commit;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.ApprovalsUtil;
import com.google.gwtorm.server.OrmException;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
@ -54,6 +55,28 @@ public class PushOneCommit {
private static final String FILE_NAME = "a.txt";
private static final String FILE_CONTENT = "some content";
public interface Factory {
PushOneCommit create(
ReviewDb db,
PersonIdent i);
PushOneCommit create(
ReviewDb db,
PersonIdent i,
@Assisted("subject") String subject,
@Assisted("fileName") String fileName,
@Assisted("content") String content);
PushOneCommit create(
ReviewDb db,
PersonIdent i,
@Assisted("subject") String subject,
@Assisted("fileName") String fileName,
@Assisted("content") String content,
@Assisted("changeId") String changeId);
}
private final ApprovalsUtil approvalsUtil;
private final ReviewDb db;
private final PersonIdent i;
@ -63,18 +86,33 @@ public class PushOneCommit {
private String changeId;
private String tagName;
public PushOneCommit(ReviewDb db, PersonIdent i) {
this(db, i, SUBJECT, FILE_NAME, FILE_CONTENT);
@AssistedInject
PushOneCommit(ApprovalsUtil approvalsUtil,
@Assisted ReviewDb db,
@Assisted PersonIdent i) {
this(approvalsUtil, db, i, SUBJECT, FILE_NAME, FILE_CONTENT);
}
public PushOneCommit(ReviewDb db, PersonIdent i, String subject,
String fileName, String content) {
this(db, i, subject, fileName, content, null);
@AssistedInject
PushOneCommit(ApprovalsUtil approvalsUtil,
@Assisted ReviewDb db,
@Assisted PersonIdent i,
@Assisted("subject") String subject,
@Assisted("fileName") String fileName,
@Assisted("content") String content) {
this(approvalsUtil, db, i, subject, fileName, content, null);
}
public PushOneCommit(ReviewDb db, PersonIdent i, String subject,
String fileName, String content, String changeId) {
@AssistedInject
PushOneCommit(ApprovalsUtil approvalsUtil,
@Assisted ReviewDb db,
@Assisted PersonIdent i,
@Assisted("subject") String subject,
@Assisted("fileName") String fileName,
@Assisted("content") String content,
@Assisted("changeId") String changeId) {
this.db = db;
this.approvalsUtil = approvalsUtil;
this.i = i;
this.subject = subject;
this.fileName = fileName;
@ -95,7 +133,8 @@ public class PushOneCommit {
if (tagName != null) {
git.tag().setName(tagName).setAnnotated(false).call();
}
return new Result(db, ref, pushHead(git, ref, tagName != null), c, subject);
return new Result(db, approvalsUtil, ref,
pushHead(git, ref, tagName != null), c, subject);
}
public void setTag(final String tagName) {
@ -104,14 +143,16 @@ public class PushOneCommit {
public static class Result {
private final ReviewDb db;
private final ApprovalsUtil approvalsUtil;
private final String ref;
private final PushResult result;
private final Commit commit;
private final String subject;
private Result(ReviewDb db, String ref, PushResult result, Commit commit,
String subject) {
private Result(ReviewDb db, ApprovalsUtil approvalsUtil, String ref,
PushResult result, Commit commit, String subject) {
this.db = db;
this.approvalsUtil = approvalsUtil;
this.ref = ref;
this.result = result;
this.commit = commit;
@ -157,10 +198,10 @@ public class PushOneCommit {
}
}));
for (PatchSetApproval psa : db.patchSetApprovals().byPatchSet(
c.currentPatchSetId())) {
assertTrue("unexpected reviewer " + psa.getAccountId(),
expectedReviewerIds.remove(psa.getAccountId()));
for (Account.Id accountId
: approvalsUtil.getReviewers(db, c.getId()).values()) {
assertTrue("unexpected reviewer " + accountId,
expectedReviewerIds.remove(accountId));
}
assertTrue("missing reviewers: " + expectedReviewerIds,
expectedReviewerIds.isEmpty());

View File

@ -2,5 +2,5 @@ include_defs('//gerrit-acceptance-tests/tests.defs')
acceptance_tests(
srcs = glob(['*IT.java']),
deps = ['//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util'],
deps = ['//gerrit-acceptance-tests:lib'],
)

View File

@ -14,16 +14,16 @@
package com.google.gerrit.acceptance.api.change;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AcceptanceTestRequestScope;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.extensions.api.GerritApi;
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
import com.google.gerrit.extensions.api.changes.ReviewInput;
@ -61,6 +61,9 @@ public class ChangeIT extends AbstractDaemonTest {
@Inject
private IdentifiedUser.GenericFactory identifiedUserFactory;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private TestAccount user;
@ -148,7 +151,7 @@ public class ChangeIT extends AbstractDaemonTest {
private PushOneCommit.Result createChange() throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, "refs/for/master");
}

View File

@ -2,6 +2,6 @@ include_defs('//gerrit-acceptance-tests/tests.defs')
acceptance_tests(
srcs = glob(['*IT.java']),
deps = ['//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util'],
deps = ['//gerrit-acceptance-tests:lib'],
)

View File

@ -14,8 +14,8 @@
package com.google.gerrit.acceptance.api.project;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AcceptanceTestRequestScope;

View File

@ -2,5 +2,5 @@ include_defs('//gerrit-acceptance-tests/tests.defs')
acceptance_tests(
srcs = glob(['*IT.java']),
deps = ['//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util'],
deps = ['//gerrit-acceptance-tests:lib'],
)

View File

@ -14,16 +14,16 @@
package com.google.gerrit.acceptance.api.revision;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AcceptanceTestRequestScope;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.extensions.api.GerritApi;
import com.google.gerrit.extensions.api.changes.ChangeApi;
import com.google.gerrit.extensions.api.changes.CherryPickInput;
@ -62,6 +62,9 @@ public class RevisionIT extends AbstractDaemonTest {
@Inject
private IdentifiedUser.GenericFactory identifiedUserFactory;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private Git git;
private ReviewDb db;
@ -152,13 +155,13 @@ public class RevisionIT extends AbstractDaemonTest {
private PushOneCommit.Result createChange() throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, "refs/for/master");
}
private PushOneCommit.Result createDraft() throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, "refs/drafts/master");
}

View File

@ -14,12 +14,13 @@
package com.google.gerrit.acceptance.git;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.reviewdb.client.Change;
@ -50,6 +51,9 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
protected PushOneCommit.Factory pushFactory;
private TestAccount admin;
private Project.NameKey project;
private Git git;
@ -190,7 +194,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
private PushOneCommit.Result pushTo(String ref) throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, ref);
}
}

View File

@ -2,7 +2,7 @@ include_defs('//gerrit-acceptance-tests/tests.defs')
acceptance_tests(
srcs = ['SubmitOnPushIT.java'],
deps = [':util'],
deps = ['//gerrit-acceptance-tests:lib'],
)
acceptance_tests(
@ -13,26 +13,5 @@ acceptance_tests(
java_library(
name = 'push_for_review',
srcs = ['AbstractPushForReview.java'],
deps = [
':util',
'//gerrit-acceptance-tests:lib',
],
)
java_library(
name = 'util',
srcs = [
'GitUtil.java',
'PushOneCommit.java',
],
deps = [
'//gerrit-acceptance-tests:lib',
'//gerrit-reviewdb:server',
'//lib:guava',
'//lib:gwtorm',
'//lib:jsch',
'//lib/jgit:jgit',
'//lib:junit',
],
visibility = ['//gerrit-acceptance-tests/...'],
deps = ['//gerrit-acceptance-tests:lib'],
)

View File

@ -14,15 +14,16 @@
package com.google.gerrit.acceptance.git;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.common.data.AccessSection;
@ -88,6 +89,9 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
@Inject
private @GerritPersonIdent PersonIdent serverIdent;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private Project.NameKey project;
private Git git;
@ -131,7 +135,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
grant(Permission.SUBMIT, project, "refs/for/refs/heads/master");
grant(Permission.CREATE, project, "refs/tags/*");
final String tag = "v1.0";
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
push.setTag(tag);
PushOneCommit.Result r = push.to(git, "refs/for/master%submit");
r.assertOkStatus();
@ -309,21 +313,21 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
private PushOneCommit.Result pushTo(String ref) throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, ref);
}
private PushOneCommit.Result push(String ref, String subject,
String fileName, String content) throws GitAPIException, IOException {
PushOneCommit push =
new PushOneCommit(db, admin.getIdent(), subject, fileName, content);
pushFactory.create(db, admin.getIdent(), subject, fileName, content);
return push.to(git, ref);
}
private PushOneCommit.Result push(String ref, String subject,
String fileName, String content, String changeId) throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent(), subject,
PushOneCommit push = pushFactory.create(db, admin.getIdent(), subject,
fileName, content, changeId);
return push.to(git, ref);
}

View File

@ -4,7 +4,7 @@ acceptance_tests(
srcs = glob(['*IT.java']),
deps = [
':util',
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util',
'//gerrit-acceptance-tests:lib',
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change:util',
],
)

View File

@ -14,21 +14,21 @@
package com.google.gerrit.acceptance.rest.account;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.acceptance.git.PushOneCommit.Result;
import com.google.gerrit.acceptance.PushOneCommit.Result;
import com.google.gerrit.acceptance.rest.change.ChangeInfo;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
@ -56,6 +56,9 @@ public class StarredChangesIT extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private RestSession session;
@ -116,7 +119,7 @@ public class StarredChangesIT extends AbstractDaemonTest {
}
private Result createChange() throws GitAPIException, IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, "refs/for/master");
}
}

View File

@ -14,20 +14,20 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.GitUtil;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.GitUtil;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
@ -68,6 +68,9 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
@Inject
private GitRepositoryManager repoManager;
@Inject
protected PushOneCommit.Factory pushFactory;
protected RestSession session;
private TestAccount admin;
@ -137,14 +140,14 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
protected PushOneCommit.Result createChange(Git git) throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, "refs/for/master");
}
protected PushOneCommit.Result createChange(Git git, String subject,
String fileName, String content) throws GitAPIException, IOException {
PushOneCommit push =
new PushOneCommit(db, admin.getIdent(), subject, fileName, content);
pushFactory.create(db, admin.getIdent(), subject, fileName, content);
return push.to(git, "refs/for/master");
}

View File

@ -14,10 +14,10 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.checkout;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.acceptance.PushOneCommit;
import com.jcraft.jsch.JSchException;

View File

@ -23,7 +23,7 @@ acceptance_tests(
srcs = OTHER_TESTS,
deps = [
':util',
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util',
'//gerrit-acceptance-tests:lib',
],
)
@ -31,7 +31,7 @@ acceptance_tests(
srcs = SUBMIT_TESTS,
deps = [
':submit_util',
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util',
'//gerrit-acceptance-tests:lib',
],
)
@ -41,7 +41,6 @@ java_library(
deps = [
':util',
'//gerrit-acceptance-tests:lib',
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util',
],
)

View File

@ -14,20 +14,20 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gson.Gson;
@ -52,6 +52,9 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private RestSession session;
private Git git;
@ -113,7 +116,7 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
private String createChange() throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, "refs/for/master").getChangeId();
}

View File

@ -14,19 +14,19 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static com.google.gerrit.common.data.Permission.LABEL;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
@ -68,6 +68,9 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
@Inject
private ProjectCache projectCache;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount owner;
private TestAccount dev;
@ -145,7 +148,7 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
private String createChange() throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, owner.getIdent());
PushOneCommit push = pushFactory.create(db, owner.getIdent());
return push.to(git, "refs/for/master").getChangeId();
}

View File

@ -14,9 +14,9 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.checkout;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -25,12 +25,12 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.GitUtil;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.GitUtil;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gson.Gson;
@ -57,6 +57,9 @@ public class ConflictsOperatorIT extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private RestSession session;
private Project.NameKey project;
@ -114,7 +117,7 @@ public class ConflictsOperatorIT extends AbstractDaemonTest {
checkout(git, "origin/master");
String file = conflicting ? "test.txt" : "test-" + count + ".txt";
PushOneCommit push =
new PushOneCommit(db, admin.getIdent(), "Change " + count, file,
pushFactory.create(db, admin.getIdent(), "Change " + count, file,
"content " + count);
count++;
return push.to(git, "refs/for/master");

View File

@ -14,19 +14,19 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
@ -54,6 +54,9 @@ public class DeleteDraftChangeIT extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private RestSession session;
@ -137,12 +140,12 @@ public class DeleteDraftChangeIT extends AbstractDaemonTest {
private String createChange() throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, "refs/for/master").getChangeId();
}
private String createDraftChange() throws GitAPIException, IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, "refs/drafts/master").getChangeId();
}

View File

@ -14,20 +14,20 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.acceptance.git.PushOneCommit.Result;
import com.google.gerrit.acceptance.PushOneCommit.Result;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
@ -55,6 +55,9 @@ public class DeleteDraftPatchSetIT extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private TestAccount user;
@ -133,9 +136,9 @@ public class DeleteDraftPatchSetIT extends AbstractDaemonTest {
private String createChangeWith2PS(String ref) throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
Result result = push.to(git, ref);
push = new PushOneCommit(db, admin.getIdent(), PushOneCommit.SUBJECT,
push = pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
"b.txt", "4711", result.getChangeId());
return push.to(git, ref).getChangeId();
}

View File

@ -14,10 +14,10 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.checkout;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.jcraft.jsch.JSchException;

View File

@ -14,10 +14,10 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.checkout;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.jcraft.jsch.JSchException;

View File

@ -16,7 +16,7 @@ package com.google.gerrit.acceptance.rest.change;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.jcraft.jsch.JSchException;

View File

@ -2,7 +2,7 @@ package com.google.gerrit.acceptance.rest.change;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.jcraft.jsch.JSchException;

View File

@ -14,10 +14,10 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.checkout;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.jcraft.jsch.JSchException;

View File

@ -14,19 +14,19 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.GerritConfig;
import com.google.gerrit.acceptance.GerritConfigs;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gson.Gson;
@ -51,6 +51,9 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private RestSession session;
private Git git;
@ -148,7 +151,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
private String createChange(TestAccount account) throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, account.getIdent());
PushOneCommit push = pushFactory.create(db, account.getIdent());
return push.to(git, "refs/for/master").getChangeId();
}
}
}

View File

@ -5,7 +5,7 @@ acceptance_tests(
deps = [
':branch',
':project',
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util',
'//gerrit-acceptance-tests:lib',
],
)

View File

@ -14,8 +14,8 @@
package com.google.gerrit.acceptance.rest.project;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.AbstractDaemonTest;

View File

@ -14,7 +14,7 @@
package com.google.gerrit.acceptance.rest.project;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.AbstractDaemonTest;

View File

@ -14,7 +14,7 @@
package com.google.gerrit.acceptance.rest.project;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo;
import static org.junit.Assert.assertEquals;

View File

@ -14,20 +14,20 @@
package com.google.gerrit.acceptance.rest.project;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static com.google.gerrit.acceptance.rest.project.BranchAssert.assertBranches;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.Lists;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
@ -72,6 +72,9 @@ public class ListBranchesIT extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private RestSession session;
private SshSession sshSession;
@ -218,7 +221,7 @@ public class ListBranchesIT extends AbstractDaemonTest {
private PushOneCommit.Result pushTo(String ref) throws GitAPIException,
IOException {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
return push.to(git, ref);
}
}

View File

@ -14,7 +14,7 @@
package com.google.gerrit.acceptance.rest.project;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjects;

View File

@ -14,18 +14,18 @@
package com.google.gerrit.acceptance.rest.project;
import static com.google.gerrit.acceptance.git.GitUtil.checkout;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.fetch;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.fetch;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
@ -58,6 +58,9 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
@Inject
private AllProjectsNameProvider allProjects;
@Inject
private PushOneCommit.Factory pushFactory;
private ReviewDb db;
private TestAccount admin;
private SshSession sshSession;
@ -91,7 +94,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
cfg.setString("s1", null, "k1", "v1");
cfg.setString("s2", "ss", "k2", "v2");
PushOneCommit push =
new PushOneCommit(db, admin.getIdent(), "Create Project Level Config",
pushFactory.create(db, admin.getIdent(), "Create Project Level Config",
configName, cfg.toText());
push.to(git, RefNames.REFS_CONFIG);
@ -120,14 +123,14 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
fetch(parentGit, RefNames.REFS_CONFIG + ":refs/heads/config");
checkout(parentGit, "refs/heads/config");
PushOneCommit push =
new PushOneCommit(db, admin.getIdent(), "Create Project Level Config",
pushFactory.create(db, admin.getIdent(), "Create Project Level Config",
configName, parentCfg.toText());
push.to(parentGit, RefNames.REFS_CONFIG);
Config cfg = new Config();
cfg.setString("s1", null, "k1", "childValue1");
cfg.setString("s2", "ss", "k3", "childValue2");
push = new PushOneCommit(db, admin.getIdent(), "Create Project Level Config",
push = pushFactory.create(db, admin.getIdent(), "Create Project Level Config",
configName, cfg.toText());
push.to(git, RefNames.REFS_CONFIG);

View File

@ -14,8 +14,8 @@
package com.google.gerrit.acceptance.rest.project;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.AbstractDaemonTest;

View File

@ -4,7 +4,7 @@ acceptance_tests(
srcs = glob(['*IT.java']),
deps = [
':util',
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util',
'//gerrit-acceptance-tests:lib',
'//lib:gwtjsonrpc',
],
)

View File

@ -14,23 +14,23 @@
package com.google.gerrit.acceptance.server.change;
import static com.google.gerrit.acceptance.git.GitUtil.add;
import static com.google.gerrit.acceptance.git.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.git.GitUtil.createCommit;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.git.GitUtil.initSsh;
import static com.google.gerrit.acceptance.git.GitUtil.pushHead;
import static com.google.gerrit.acceptance.GitUtil.add;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createCommit;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.initSsh;
import static com.google.gerrit.acceptance.GitUtil.pushHead;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.AccountCreator;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.git.PushOneCommit;
import com.google.gerrit.acceptance.git.GitUtil.Commit;
import com.google.gerrit.acceptance.GitUtil.Commit;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
@ -59,6 +59,9 @@ public class GetRelatedIT extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private PushOneCommit.Factory pushFactory;
private TestAccount admin;
private RestSession session;
private Git git;
@ -86,7 +89,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
@Test
public void getRelatedNoResult() throws GitAPIException,
IOException, Exception {
PushOneCommit push = new PushOneCommit(db, admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent());
PatchSet.Id ps = push.to(git, "refs/for/master").getPatchSetId();
List<ChangeAndCommit> related = getRelated(ps);
assertEquals(0, related.size());

View File

@ -2,5 +2,5 @@ include_defs('//gerrit-acceptance-tests/tests.defs')
acceptance_tests(
srcs = glob(['*IT.java']),
deps = ['//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util'],
deps = ['//gerrit-acceptance-tests:lib'],
)

View File

@ -14,7 +14,7 @@
package com.google.gerrit.acceptance.ssh;
import static com.google.gerrit.acceptance.git.GitUtil.createProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;