use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method addReviewerToReviewerChangeInfo.
@Test
public void addReviewerToReviewerChangeInfo() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
ReviewerInput in = new ReviewerInput();
in.reviewer = user.email();
in.state = CC;
addReviewer(changeId, in);
in.state = REVIEWER;
addReviewer(changeId, in);
gApi.changes().id(changeId).current().review(ReviewInput.dislike());
requestScopeOperations.setApiUser(user.id());
// By posting a review the user is added as reviewer.
gApi.changes().id(changeId).current().review(ReviewInput.dislike());
deleteReviewer(changeId, user).assertNoContent();
ChangeInfo c = gApi.changes().id(changeId).get();
assertThat(c.reviewerUpdates).isNotNull();
assertThat(c.reviewerUpdates).hasSize(3);
Iterator<ReviewerUpdateInfo> it = c.reviewerUpdates.iterator();
ReviewerUpdateInfo reviewerChange = it.next();
assertThat(reviewerChange.state).isEqualTo(CC);
assertThat(reviewerChange.reviewer._accountId).isEqualTo(user.id().get());
assertThat(reviewerChange.updatedBy._accountId).isEqualTo(admin.id().get());
reviewerChange = it.next();
assertThat(reviewerChange.state).isEqualTo(REVIEWER);
assertThat(reviewerChange.reviewer._accountId).isEqualTo(user.id().get());
assertThat(reviewerChange.updatedBy._accountId).isEqualTo(admin.id().get());
reviewerChange = it.next();
assertThat(reviewerChange.state).isEqualTo(REMOVED);
assertThat(reviewerChange.reviewer._accountId).isEqualTo(user.id().get());
assertThat(reviewerChange.updatedBy._accountId).isEqualTo(admin.id().get());
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method moveReviewerToCc.
@Test
public void moveReviewerToCc() throws Exception {
// Allow everyone to approve changes.
projectOperations.project(project).forUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(REGISTERED_USERS).range(-2, 2)).update();
// Create a change and add 'user' as reviewer.
String changeId = createChange().getChangeId();
gApi.changes().id(changeId).addReviewer(user.id().toString());
// Verify that 'user' is a reviewer on the change and that there are no CCs.
ChangeInfo c = gApi.changes().id(changeId).get();
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
assertThat(reviewers).isNotNull();
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(user.id().get());
assertThat(c.reviewers.get(CC)).isNull();
// Let 'user' approve the change and verify that the change has the approval.
requestScopeOperations.setApiUser(user.id());
approve(changeId);
c = gApi.changes().id(changeId).get();
assertThat(c.labels.get(LabelId.CODE_REVIEW).approved._accountId).isEqualTo(user.id().get());
// Move 'user' from reviewer to CC.
requestScopeOperations.setApiUser(admin.id());
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.reviewer = user.id().toString();
reviewerInput.state = CC;
gApi.changes().id(changeId).addReviewer(reviewerInput);
// Verify that 'user' is a CC on the change now and that there are no reviewers.
c = gApi.changes().id(changeId).get();
Collection<AccountInfo> ccs = c.reviewers.get(CC);
assertThat(ccs).isNotNull();
assertThat(ccs).hasSize(1);
assertThat(ccs.iterator().next()._accountId).isEqualTo(user.id().get());
assertThat(c.reviewers.get(REVIEWER)).isNull();
// Verify that the approval of 'user' is still there.
assertThat(c.labels.get(LabelId.CODE_REVIEW).approved._accountId).isEqualTo(user.id().get());
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class SubmitByRebaseAlwaysIT method getCurrentCommit.
private RevCommit getCurrentCommit(PushOneCommit.Result change) throws Throwable {
testRepo.git().fetch().setRemote("origin").call();
ChangeInfo info = get(change.getChangeId(), CURRENT_REVISION);
RevCommit c = testRepo.getRevWalk().parseCommit(ObjectId.fromString(info.currentRevision));
testRepo.getRevWalk().parseBody(c);
return c;
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class ListChangesOptionsIT method currentRevision.
@Test
public void currentRevision() throws Exception {
ChangeInfo c = get(changeId, CURRENT_REVISION);
assertThat(c.currentRevision).isEqualTo(commitId(2));
assertThat(c.revisions.keySet()).containsAtLeastElementsIn(ImmutableSet.of(commitId(2)));
assertThat(c.revisions.get(commitId(2))._number).isEqualTo(3);
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class CreateChangeIT method createDefaultAuthor.
@Test
public void createDefaultAuthor() throws Exception {
ChangeInput input = newChangeInput(ChangeStatus.NEW);
ChangeInfo info = assertCreateSucceeds(input);
GitPerson person = gApi.changes().id(info.id).current().commit(false).author;
assertThat(person).email().isEqualTo(admin.email());
}
Aggregations