Search in sources :

Example 61 with CommentInfo

use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.

the class PatchsetOperationsImplTest method commentCanBeCreatedOnOlderPatchset.

@Test
public void commentCanBeCreatedOnOlderPatchset() throws Exception {
    Change.Id changeId = changeOperations.newChange().create();
    PatchSet.Id previousPatchsetId = changeOperations.change(changeId).currentPatchset().get().patchsetId();
    changeOperations.change(changeId).newPatchset().create();
    String commentUuid = changeOperations.change(changeId).patchset(previousPatchsetId).newComment().create();
    CommentInfo comment = getCommentFromServer(changeId, commentUuid);
    assertThat(comment).patchSet().isEqualTo(previousPatchsetId.get());
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) Change(com.google.gerrit.entities.Change) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 62 with CommentInfo

use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.

the class PatchsetOperationsImplTest method commentCanBeCreatedOnAutoMergeCommit.

@Test
public void commentCanBeCreatedOnAutoMergeCommit() throws Exception {
    Change.Id parent1ChangeId = changeOperations.newChange().create();
    Change.Id parent2ChangeId = changeOperations.newChange().create();
    Change.Id changeId = changeOperations.newChange().mergeOf().change(parent1ChangeId).and().change(parent2ChangeId).create();
    String commentUuid = changeOperations.change(changeId).currentPatchset().newComment().onAutoMergeCommit().create();
    CommentInfo comment = getCommentFromServer(changeId, commentUuid);
    assertThat(comment).side().isEqualTo(Side.PARENT);
    assertThat(comment).parent().isNull();
}
Also used : Change(com.google.gerrit.entities.Change) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 63 with CommentInfo

use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.

the class PatchsetOperationsImplTest method draftCommentCanBeCreatedAsUnresolved.

@Test
public void draftCommentCanBeCreatedAsUnresolved() throws Exception {
    Change.Id changeId = changeOperations.newChange().create();
    String commentUuid = changeOperations.change(changeId).currentPatchset().newDraftComment().unresolved().create();
    CommentInfo comment = getDraftCommentFromServer(changeId, commentUuid);
    assertThat(comment).unresolved().isTrue();
}
Also used : Change(com.google.gerrit.entities.Change) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 64 with CommentInfo

use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.

the class PatchsetOperationsImplTest method zoneOfCreationDateCanBeOmitted.

@Test
public void zoneOfCreationDateCanBeOmitted() throws Exception {
    Change.Id changeId = changeOperations.newChange().create();
    // As we don't care about the exact time zone internally used as a default, do a relative test
    // so that we don't need to assert on exact instants in time. For a relative test, we need two
    // comments whose creation date should be exactly the specified amount apart.
    // Don't use nanos or millis. NoteDb supports only second precision.
    LocalDateTime creationTime1 = LocalDateTime.of(2020, Month.SEPTEMBER, 15, 12, 10, 43);
    LocalDateTime creationTime2 = creationTime1.plusMinutes(10);
    String commentUuid1 = changeOperations.change(changeId).currentPatchset().newComment().createdOn(creationTime1).create();
    String commentUuid2 = changeOperations.change(changeId).currentPatchset().newComment().createdOn(creationTime2).create();
    CommentInfo comment1 = getCommentFromServer(changeId, commentUuid1);
    Instant comment1Creation = comment1.updated.toInstant();
    CommentInfo comment2 = getCommentFromServer(changeId, commentUuid2);
    Instant comment2Creation = comment2.updated.toInstant();
    Duration commentCreationDifference = Duration.between(comment1Creation, comment2Creation);
    assertThat(commentCreationDifference).isEqualTo(Duration.ofMinutes(10));
}
Also used : LocalDateTime(java.time.LocalDateTime) Instant(java.time.Instant) Duration(java.time.Duration) Change(com.google.gerrit.entities.Change) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 65 with CommentInfo

use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.

the class PatchsetOperationsImplTest method commentIsCreatedWithSpecifiedAuthor.

@Test
public void commentIsCreatedWithSpecifiedAuthor() throws Exception {
    Change.Id changeId = changeOperations.newChange().create();
    Account.Id accountId = accountOperations.newAccount().create();
    String commentUuid = changeOperations.change(changeId).currentPatchset().newComment().author(accountId).create();
    CommentInfo comment = getCommentFromServer(changeId, commentUuid);
    assertThat(comment).author().id().isEqualTo(accountId.get());
}
Also used : Account(com.google.gerrit.entities.Account) Change(com.google.gerrit.entities.Change) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

CommentInfo (com.google.gerrit.extensions.common.CommentInfo)186 Test (org.junit.Test)178 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)164 Change (com.google.gerrit.entities.Change)120 PatchSet (com.google.gerrit.entities.PatchSet)62 RobotCommentInfo (com.google.gerrit.extensions.common.RobotCommentInfo)56 List (java.util.List)51 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)47 ImmutableList (com.google.common.collect.ImmutableList)46 IdString (com.google.gerrit.extensions.restapi.IdString)34 CommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput)27 ArrayList (java.util.ArrayList)26 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)25 Collectors.toList (java.util.stream.Collectors.toList)25 DraftInput (com.google.gerrit.extensions.api.changes.DraftInput)24 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)22 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)21 DeleteCommentInput (com.google.gerrit.extensions.api.changes.DeleteCommentInput)20 CommentInfoSubject.assertThatList (com.google.gerrit.extensions.common.testing.CommentInfoSubject.assertThatList)19 MailMessage (com.google.gerrit.mail.MailMessage)13