Search in sources :

Example 1 with CC

use of com.google.gerrit.extensions.client.ReviewerState.CC in project gerrit by GerritCodeReview.

the class ChangeIT method implicitlyAddReviewerOnVotingReview.

@Test
public void implicitlyAddReviewerOnVotingReview() throws Exception {
    PushOneCommit.Result r = createChange();
    setApiUser(user);
    gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.recommend().message("LGTM"));
    ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
    assertThat(c.reviewers.get(REVIEWER).stream().map(ai -> ai._accountId).collect(toList())).containsExactly(user.id.get());
    // Further test: remove the vote, then comment again. The user should be
    // implicitly re-added to the ReviewerSet, as a CC if we're using NoteDb.
    setApiUser(admin);
    gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).remove();
    c = gApi.changes().id(r.getChangeId()).get();
    assertThat(c.reviewers.values()).isEmpty();
    setApiUser(user);
    gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(new ReviewInput().message("hi"));
    c = gApi.changes().id(r.getChangeId()).get();
    ReviewerState state = notesMigration.readChanges() ? CC : REVIEWER;
    assertThat(c.reviewers.get(state).stream().map(ai -> ai._accountId).collect(toList())).containsExactly(user.id.get());
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) Arrays(java.util.Arrays) NotifyInfo(com.google.gerrit.extensions.api.changes.NotifyInfo) LabelInfo(com.google.gerrit.extensions.common.LabelInfo) CHANGE_OWNER(com.google.gerrit.server.group.SystemGroupBackend.CHANGE_OWNER) TestAccount(com.google.gerrit.acceptance.TestAccount) REGISTERED_USERS(com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval) RefNames.changeMetaRef(com.google.gerrit.reviewdb.client.RefNames.changeMetaRef) RevWalk(org.eclipse.jgit.revwalk.RevWalk) ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Map(java.util.Map) DraftHandling(com.google.gerrit.extensions.api.changes.ReviewInput.DraftHandling) Side(com.google.gerrit.extensions.client.Side) EnumSet(java.util.EnumSet) ApprovalInfo(com.google.gerrit.extensions.common.ApprovalInfo) FILE_NAME(com.google.gerrit.acceptance.PushOneCommit.FILE_NAME) DeleteVoteInput(com.google.gerrit.extensions.api.changes.DeleteVoteInput) Set(java.util.Set) Constants(org.eclipse.jgit.lib.Constants) MergePatchSetInput(com.google.gerrit.extensions.common.MergePatchSetInput) NoHttpd(com.google.gerrit.acceptance.NoHttpd) NotifyHandling(com.google.gerrit.extensions.api.changes.NotifyHandling) PersonIdent(org.eclipse.jgit.lib.PersonIdent) DeleteReviewerInput(com.google.gerrit.extensions.api.changes.DeleteReviewerInput) RefNames(com.google.gerrit.reviewdb.client.RefNames) PushResult(org.eclipse.jgit.transport.PushResult) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) LabelId(com.google.gerrit.reviewdb.client.LabelId) ChangeMessagesUtil(com.google.gerrit.server.ChangeMessagesUtil) Iterables(com.google.common.collect.Iterables) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Change(com.google.gerrit.reviewdb.client.Change) MergeInput(com.google.gerrit.extensions.common.MergeInput) TestTimeUtil(com.google.gerrit.testutil.TestTimeUtil) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) ChangeMessageModifier(com.google.gerrit.server.git.ChangeMessageModifier) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) GitUtil(com.google.gerrit.acceptance.GitUtil) Before(org.junit.Before) Project(com.google.gerrit.reviewdb.client.Project) TestRepository(org.eclipse.jgit.junit.TestRepository) TimeUtil(com.google.gerrit.common.TimeUtil) Test(org.junit.Test) ANONYMOUS_USERS(com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) ChangeKind(com.google.gerrit.extensions.client.ChangeKind) DynamicSet(com.google.gerrit.extensions.registration.DynamicSet) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) ProjectConfig(com.google.gerrit.server.git.ProjectConfig) FooterConstants(com.google.gerrit.common.FooterConstants) GitUtil.assertPushOk(com.google.gerrit.acceptance.GitUtil.assertPushOk) Repository(org.eclipse.jgit.lib.Repository) ChangeControl(com.google.gerrit.server.project.ChangeControl) AddReviewerResult(com.google.gerrit.extensions.api.changes.AddReviewerResult) Inject(com.google.inject.Inject) REVIEWER(com.google.gerrit.extensions.client.ReviewerState.REVIEWER) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) PrimaryStorage(com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage) InheritableBoolean(com.google.gerrit.extensions.client.InheritableBoolean) BatchUpdate(com.google.gerrit.server.update.BatchUpdate) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) After(org.junit.After) AuthException(com.google.gerrit.extensions.restapi.AuthException) Assert.fail(org.junit.Assert.fail) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Util.blockLabel(com.google.gerrit.server.project.Util.blockLabel) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) SubmitType(com.google.gerrit.extensions.client.SubmitType) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) Permission(com.google.gerrit.common.data.Permission) AcceptanceTestRequestScope(com.google.gerrit.acceptance.AcceptanceTestRequestScope) CommitInfo(com.google.gerrit.extensions.common.CommitInfo) LabelType(com.google.gerrit.common.data.LabelType) MethodNotAllowedException(com.google.gerrit.extensions.restapi.MethodNotAllowedException) AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup) List(java.util.List) RebaseInput(com.google.gerrit.extensions.api.changes.RebaseInput) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) Optional(java.util.Optional) RegistrationHandle(com.google.gerrit.extensions.registration.RegistrationHandle) BatchUpdateOp(com.google.gerrit.server.update.BatchUpdateOp) GitPerson(com.google.gerrit.extensions.common.GitPerson) Branch(com.google.gerrit.reviewdb.client.Branch) CC(com.google.gerrit.extensions.client.ReviewerState.CC) Message(com.google.gerrit.testutil.FakeEmailSender.Message) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) ReviewerState(com.google.gerrit.extensions.client.ReviewerState) HashMap(java.util.HashMap) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) Util.category(com.google.gerrit.server.project.Util.category) ImmutableList(com.google.common.collect.ImmutableList) ChangeResource(com.google.gerrit.server.change.ChangeResource) SUBJECT(com.google.gerrit.acceptance.PushOneCommit.SUBJECT) Range(com.google.gerrit.extensions.client.Comment.Range) Account(com.google.gerrit.reviewdb.client.Account) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ChangeContext(com.google.gerrit.server.update.ChangeContext) ListChangesOption(com.google.gerrit.extensions.client.ListChangesOption) TruthJUnit.assume(com.google.common.truth.TruthJUnit.assume) GitUtil.pushHead(com.google.gerrit.acceptance.GitUtil.pushHead) Iterator(java.util.Iterator) Sandboxed(com.google.gerrit.acceptance.Sandboxed) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) Truth.assertThat(com.google.common.truth.Truth.assertThat) Util(com.google.gerrit.server.project.Util) AnonymousCowardNameProvider(com.google.gerrit.server.config.AnonymousCowardNameProvider) Util.value(com.google.gerrit.server.project.Util.value) Collectors.toList(java.util.stream.Collectors.toList) RecipientType(com.google.gerrit.extensions.api.changes.RecipientType) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) ChangeStatus(com.google.gerrit.extensions.client.ChangeStatus) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ReviewerState(com.google.gerrit.extensions.client.ReviewerState) 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

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)1 TruthJUnit.assume (com.google.common.truth.TruthJUnit.assume)1 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 AcceptanceTestRequestScope (com.google.gerrit.acceptance.AcceptanceTestRequestScope)1 GerritConfig (com.google.gerrit.acceptance.GerritConfig)1 GitUtil (com.google.gerrit.acceptance.GitUtil)1 GitUtil.assertPushOk (com.google.gerrit.acceptance.GitUtil.assertPushOk)1 GitUtil.pushHead (com.google.gerrit.acceptance.GitUtil.pushHead)1 NoHttpd (com.google.gerrit.acceptance.NoHttpd)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 FILE_NAME (com.google.gerrit.acceptance.PushOneCommit.FILE_NAME)1 SUBJECT (com.google.gerrit.acceptance.PushOneCommit.SUBJECT)1 Sandboxed (com.google.gerrit.acceptance.Sandboxed)1 TestAccount (com.google.gerrit.acceptance.TestAccount)1