Search in sources :

Example 11 with RevisionApi

use of com.google.gerrit.extensions.api.changes.RevisionApi in project gerrit by GerritCodeReview.

the class StickyApprovalsIT method trivialRebase.

private void trivialRebase(String changeId) throws Exception {
    setApiUser(admin);
    testRepo.reset(getRemoteHead());
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, "Other Change", "a" + System.nanoTime() + ".txt", PushOneCommit.FILE_CONTENT);
    PushOneCommit.Result r = push.to("refs/for/master");
    r.assertOkStatus();
    RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
    ReviewInput in = new ReviewInput().label("Code-Review", 2).label("Verified", 1);
    revision.review(in);
    revision.submit();
    gApi.changes().id(changeId).current().rebase();
    assertThat(getChangeKind(changeId)).isEqualTo(TRIVIAL_REBASE);
}
Also used : RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit)

Example 12 with RevisionApi

use of com.google.gerrit.extensions.api.changes.RevisionApi in project gerrit by GerritCodeReview.

the class ImpersonationIT method voteOnBehalfOfRequiresLabel.

@Test
public void voteOnBehalfOfRequiresLabel() throws Exception {
    allowCodeReviewOnBehalfOf();
    PushOneCommit.Result r = createChange();
    RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
    ReviewInput in = new ReviewInput();
    in.onBehalfOf = user.id.toString();
    in.message = "Message on behalf of";
    exception.expect(AuthException.class);
    exception.expectMessage("label required to post review on behalf of \"" + in.onBehalfOf + '"');
    revision.review(in);
}
Also used : RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 13 with RevisionApi

use of com.google.gerrit.extensions.api.changes.RevisionApi in project gerrit by GerritCodeReview.

the class ImpersonationIT method voteOnBehalfOfInvisibleUserNotAllowed.

@GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
@Test
public void voteOnBehalfOfInvisibleUserNotAllowed() throws Exception {
    allowCodeReviewOnBehalfOf();
    setApiUser(accounts.user2());
    assertThat(accountControlFactory.get().canSee(user.id)).isFalse();
    PushOneCommit.Result r = createChange();
    RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
    ReviewInput in = new ReviewInput();
    in.onBehalfOf = user.id.toString();
    in.label("Code-Review", 1);
    exception.expect(UnprocessableEntityException.class);
    exception.expectMessage("Account Not Found: " + in.onBehalfOf);
    revision.review(in);
}
Also used : RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) GerritConfig(com.google.gerrit.acceptance.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 14 with RevisionApi

use of com.google.gerrit.extensions.api.changes.RevisionApi in project gerrit by GerritCodeReview.

the class ImpersonationIT method voteOnBehalfOfMissingUser.

@Test
public void voteOnBehalfOfMissingUser() throws Exception {
    allowCodeReviewOnBehalfOf();
    PushOneCommit.Result r = createChange();
    RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
    ReviewInput in = new ReviewInput();
    in.onBehalfOf = "doesnotexist";
    in.label("Code-Review", 1);
    exception.expect(UnprocessableEntityException.class);
    exception.expectMessage("Account Not Found: doesnotexist");
    revision.review(in);
}
Also used : RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 15 with RevisionApi

use of com.google.gerrit.extensions.api.changes.RevisionApi in project gerrit by GerritCodeReview.

the class ImpersonationIT method voteOnBehalfOfInvalidLabel.

@Test
public void voteOnBehalfOfInvalidLabel() throws Exception {
    allowCodeReviewOnBehalfOf();
    PushOneCommit.Result r = createChange();
    RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
    ReviewInput in = new ReviewInput();
    in.onBehalfOf = user.id.toString();
    in.strictLabels = true;
    in.label("Not-A-Label", 5);
    exception.expect(BadRequestException.class);
    exception.expectMessage("label \"Not-A-Label\" is not a configured label");
    revision.review(in);
}
Also used : RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)15 RevisionApi (com.google.gerrit.extensions.api.changes.RevisionApi)15 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)13 Test (org.junit.Test)13 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)9 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)2 GerritConfig (com.google.gerrit.acceptance.GerritConfig)1 LabelType (com.google.gerrit.common.data.LabelType)1 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)1 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)1 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)1 GitPerson (com.google.gerrit.extensions.common.GitPerson)1 ChangeMessage (com.google.gerrit.reviewdb.client.ChangeMessage)1 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)1 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)1 ChangeData (com.google.gerrit.server.query.change.ChangeData)1