Search in sources :

Example 21 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);
    UnprocessableEntityException thrown = assertThrows(UnprocessableEntityException.class, () -> revision.review(in));
    assertThat(thrown).hasMessageThat().contains("not found");
    assertThat(thrown).hasMessageThat().contains("doesnotexist");
}
Also used : UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) 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 22 with RevisionApi

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

the class CreateChangeIT method createMergeChangeAuthor.

@Test
public void createMergeChangeAuthor() throws Exception {
    changeInTwoBranches("branchA", "a.txt", "branchB", "b.txt");
    ChangeInput in = newMergeChangeInput("branchA", "branchB", "");
    in.author = new AccountInput();
    in.author.name = "Gerritless Jane";
    in.author.email = "gerritlessjane@invalid";
    ChangeInfo change = assertCreateSucceeds(in);
    RevisionApi rApi = gApi.changes().id(change.id).current();
    GitPerson author = rApi.commit(false).author;
    assertThat(author).email().isEqualTo(in.author.email);
    GitPerson committer = rApi.commit(false).committer;
    assertThat(committer).email().isEqualTo(admin.getNameEmail().email());
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) GitPerson(com.google.gerrit.extensions.common.GitPerson) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) AccountInput(com.google.gerrit.extensions.api.accounts.AccountInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 23 with RevisionApi

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

the class CreateChangeIT method createAuthorOverride.

@Test
public void createAuthorOverride() throws Exception {
    ChangeInput input = newChangeInput(ChangeStatus.NEW);
    input.author = new AccountInput();
    input.author.email = "gerritlessjane@invalid";
    // This is an email address that doesn't exist as account on the Gerrit server.
    input.author.name = "Gerritless Jane";
    ChangeInfo info = assertCreateSucceeds(input);
    RevisionApi rApi = gApi.changes().id(info.id).current();
    GitPerson author = rApi.commit(false).author;
    assertThat(author).email().isEqualTo(input.author.email);
    assertThat(author).name().isEqualTo(input.author.name);
    GitPerson committer = rApi.commit(false).committer;
    assertThat(committer).email().isEqualTo(admin.getNameEmail().email());
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) GitPerson(com.google.gerrit.extensions.common.GitPerson) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) AccountInput(com.google.gerrit.extensions.api.accounts.AccountInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

RevisionApi (com.google.gerrit.extensions.api.changes.RevisionApi)23 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)21 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)20 Test (org.junit.Test)20 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)8 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)6 AuthException (com.google.gerrit.extensions.restapi.AuthException)5 PatchSetApproval (com.google.gerrit.entities.PatchSetApproval)3 GitPerson (com.google.gerrit.extensions.common.GitPerson)3 UnprocessableEntityException (com.google.gerrit.extensions.restapi.UnprocessableEntityException)3 TestAccount (com.google.gerrit.acceptance.TestAccount)2 AccountInput (com.google.gerrit.extensions.api.accounts.AccountInput)2 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)2 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)1 VerifyNoPiiInChangeNotes (com.google.gerrit.acceptance.VerifyNoPiiInChangeNotes)1 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)1 ChangeMessage (com.google.gerrit.entities.ChangeMessage)1 LabelType (com.google.gerrit.entities.LabelType)1 Project (com.google.gerrit.entities.Project)1 SubmitRequirementResult (com.google.gerrit.entities.SubmitRequirementResult)1