Search in sources :

Example 1 with DETAILED_LABELS

use of com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS in project gerrit by GerritCodeReview.

the class RevisionIT method postSubmitApprovalAfterVoteRemoved.

@Test
public void postSubmitApprovalAfterVoteRemoved() throws Exception {
    PushOneCommit.Result r = createChange();
    String changeId = project.get() + "~master~" + r.getChangeId();
    setApiUser(admin);
    revision(r).review(ReviewInput.approve());
    setApiUser(user);
    revision(r).review(ReviewInput.recommend());
    setApiUser(admin);
    gApi.changes().id(changeId).reviewer(user.username).deleteVote("Code-Review");
    Optional<ApprovalInfo> crUser = get(changeId, DETAILED_LABELS).labels.get("Code-Review").all.stream().filter(a -> a._accountId == user.id.get()).findFirst();
    assertThat(crUser).isPresent();
    assertThat(crUser.get().value).isEqualTo(0);
    revision(r).submit();
    setApiUser(user);
    ReviewInput in = new ReviewInput();
    in.label("Code-Review", 1);
    in.message = "Still LGTM";
    revision(r).review(in);
    ApprovalInfo cr = gApi.changes().id(changeId).get(EnumSet.of(ListChangesOption.DETAILED_LABELS)).labels.get("Code-Review").all.stream().filter(a -> a._accountId == user.getId().get()).findFirst().get();
    assertThat(cr.postSubmit).isTrue();
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) NotifyInfo(com.google.gerrit.extensions.api.changes.NotifyInfo) LabelInfo(com.google.gerrit.extensions.common.LabelInfo) PATCH_FILE_ONLY(com.google.gerrit.acceptance.PushOneCommit.PATCH_FILE_ONLY) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) Inject(com.google.inject.Inject) RestResponse(com.google.gerrit.acceptance.RestResponse) REVIEWER(com.google.gerrit.extensions.client.ReviewerState.REVIEWER) REGISTERED_USERS(com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) FILE_CONTENT(com.google.gerrit.acceptance.PushOneCommit.FILE_CONTENT) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval) PATCH(com.google.gerrit.acceptance.PushOneCommit.PATCH) DraftApi(com.google.gerrit.extensions.api.changes.DraftApi) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) Locale(java.util.Locale) Map(java.util.Map) AuthException(com.google.gerrit.extensions.restapi.AuthException) Assert.fail(org.junit.Assert.fail) DateFormat(java.text.DateFormat) EnumSet(java.util.EnumSet) ApprovalInfo(com.google.gerrit.extensions.common.ApprovalInfo) FILE_NAME(com.google.gerrit.acceptance.PushOneCommit.FILE_NAME) ImmutableSet(com.google.common.collect.ImmutableSet) PatchSetWebLink(com.google.gerrit.extensions.webui.PatchSetWebLink) ImmutableMap(com.google.common.collect.ImmutableMap) RefSpec(org.eclipse.jgit.transport.RefSpec) SubmitType(com.google.gerrit.extensions.client.SubmitType) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) DETAILED_LABELS(com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS) HEAD(org.eclipse.jgit.lib.Constants.HEAD) Permission(com.google.gerrit.common.data.Permission) RefUpdate(org.eclipse.jgit.lib.RefUpdate) CommitInfo(com.google.gerrit.extensions.common.CommitInfo) MethodNotAllowedException(com.google.gerrit.extensions.restapi.MethodNotAllowedException) NotifyHandling(com.google.gerrit.extensions.api.changes.NotifyHandling) PersonIdent(org.eclipse.jgit.lib.PersonIdent) ChangeData(com.google.gerrit.server.query.change.ChangeData) List(java.util.List) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Optional(java.util.Optional) GitPerson(com.google.gerrit.extensions.common.GitPerson) Joiner(com.google.common.base.Joiner) Branch(com.google.gerrit.reviewdb.client.Branch) MergeableInfo(com.google.gerrit.extensions.common.MergeableInfo) Iterables(com.google.common.collect.Iterables) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) DiffInfo(com.google.gerrit.extensions.common.DiffInfo) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Change(com.google.gerrit.reviewdb.client.Change) COMMIT_MSG(com.google.gerrit.reviewdb.client.Patch.COMMIT_MSG) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) MERGE_LIST(com.google.gerrit.reviewdb.client.Patch.MERGE_LIST) BinaryResult(com.google.gerrit.extensions.restapi.BinaryResult) ImmutableList(com.google.common.collect.ImmutableList) SUBJECT(com.google.gerrit.acceptance.PushOneCommit.SUBJECT) CommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput) Account(com.google.gerrit.reviewdb.client.Account) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) FileInfo(com.google.gerrit.extensions.common.FileInfo) GetRevisionActions(com.google.gerrit.server.change.GetRevisionActions) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) ListChangesOption(com.google.gerrit.extensions.client.ListChangesOption) Iterator(java.util.Iterator) UTF_8(java.nio.charset.StandardCharsets.UTF_8) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) ObjectId(org.eclipse.jgit.lib.ObjectId) ETagView(com.google.gerrit.extensions.restapi.ETagView) WebLinkInfo(com.google.gerrit.extensions.common.WebLinkInfo) RecipientType(com.google.gerrit.extensions.api.changes.RecipientType) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) RevisionResource(com.google.gerrit.server.change.RevisionResource) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) DynamicSet(com.google.gerrit.extensions.registration.DynamicSet) CherryPickInput(com.google.gerrit.extensions.api.changes.CherryPickInput) Collections(java.util.Collections) ChangeStatus(com.google.gerrit.extensions.client.ChangeStatus) NameKey(com.google.gerrit.reviewdb.client.Branch.NameKey) ApprovalInfo(com.google.gerrit.extensions.common.ApprovalInfo) 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

Joiner (com.google.common.base.Joiner)1 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 Iterators (com.google.common.collect.Iterators)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)1 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 FILE_CONTENT (com.google.gerrit.acceptance.PushOneCommit.FILE_CONTENT)1 FILE_NAME (com.google.gerrit.acceptance.PushOneCommit.FILE_NAME)1 PATCH (com.google.gerrit.acceptance.PushOneCommit.PATCH)1 PATCH_FILE_ONLY (com.google.gerrit.acceptance.PushOneCommit.PATCH_FILE_ONLY)1 SUBJECT (com.google.gerrit.acceptance.PushOneCommit.SUBJECT)1 RestResponse (com.google.gerrit.acceptance.RestResponse)1 TestAccount (com.google.gerrit.acceptance.TestAccount)1 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)1 Permission (com.google.gerrit.common.data.Permission)1 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)1