use of com.google.common.truth.Truth8.assertThat 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());
}
use of com.google.common.truth.Truth8.assertThat in project gerrit by GerritCodeReview.
the class ChangeIT method getReviewerState.
private Optional<ReviewerState> getReviewerState(String changeId, Account.Id accountId) throws Exception {
ChangeInfo c = gApi.changes().id(changeId).get(EnumSet.of(ListChangesOption.DETAILED_LABELS));
Set<ReviewerState> states = c.reviewers.entrySet().stream().filter(e -> e.getValue().stream().anyMatch(a -> a._accountId == accountId.get())).map(e -> e.getKey()).collect(toSet());
assertThat(states.size()).named(states.toString()).isAtMost(1);
return states.stream().findFirst();
}
use of com.google.common.truth.Truth8.assertThat 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();
}
use of com.google.common.truth.Truth8.assertThat in project gerrit by GerritCodeReview.
the class KillTaskIT method killTask.
private void killTask() throws Exception {
RestResponse r = adminRestSession.get("/config/server/tasks/");
List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
}.getType());
r.consume();
Optional<String> id = result.stream().filter(t -> "Log File Compressor".equals(t.command)).map(t -> t.id).findFirst();
assertThat(id).isPresent();
r = adminRestSession.delete("/config/server/tasks/" + id.get());
r.assertNoContent();
r.consume();
r = adminRestSession.get("/config/server/tasks/");
result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
}.getType());
r.consume();
Set<String> ids = result.stream().map(t -> t.id).collect(toSet());
assertThat(ids).doesNotContain(id.get());
}
use of com.google.common.truth.Truth8.assertThat in project gerrit by GerritCodeReview.
the class CommentsIT method deleteOneCommentMultipleTimes.
@Test
public void deleteOneCommentMultipleTimes() throws Exception {
PushOneCommit.Result result = createChange();
Change.Id id = result.getChange().getId();
String changeId = result.getChangeId();
String ps1 = result.getCommit().name();
CommentInput c1 = newComment(FILE_NAME, "comment 1");
CommentInput c2 = newComment(FILE_NAME, "comment 2");
CommentInput c3 = newComment(FILE_NAME, "comment 3");
addComments(changeId, ps1, c1);
addComments(changeId, ps1, c2);
addComments(changeId, ps1, c3);
List<CommentInfo> commentsBeforeDelete = getChangeSortedComments(changeId);
assertThat(commentsBeforeDelete).hasSize(3);
Optional<CommentInfo> targetComment = commentsBeforeDelete.stream().filter(c -> c.message.equals("comment 2")).findFirst();
assertThat(targetComment).isPresent();
String uuid = targetComment.get().id;
CommentInfo oldComment = gApi.changes().id(changeId).revision(ps1).comment(uuid).get();
List<RevCommit> commitsBeforeDelete = new ArrayList<>();
if (notesMigration.commitChangeWrites()) {
commitsBeforeDelete = getCommits(id);
}
setApiUser(admin);
for (int i = 0; i < 3; i++) {
DeleteCommentInput input = new DeleteCommentInput("delete comment 2, iteration: " + i);
gApi.changes().id(changeId).revision(ps1).comment(uuid).delete(input);
}
CommentInfo updatedComment = gApi.changes().id(changeId).revision(ps1).comment(uuid).get();
String expectedMsg = String.format("Comment removed by: %s; Reason: %s", admin.fullName, "delete comment 2, iteration: 2");
assertThat(updatedComment.message).isEqualTo(expectedMsg);
oldComment.message = expectedMsg;
assertThat(updatedComment).isEqualTo(oldComment);
if (notesMigration.commitChangeWrites()) {
assertMetaBranchCommitsAfterRewriting(commitsBeforeDelete, id, uuid, expectedMsg);
}
assertThat(getChangeSortedComments(changeId)).hasSize(3);
}
Aggregations