Merge changes Iad9c0692,I4af5946c,I9d8091c3,Ie2713ebd,I4d347d65, ...
* changes: Document ported comments endpoints Only port unresolved comment threads Don't reimplement comment threads for attention set Extract and rewrite the logic for comment threads PortedCommentsIT: Harden a test against execution speed issues Allow comments created via the test API to have a specific creation time
This commit is contained in:
@@ -27,6 +27,7 @@ import com.google.common.truth.Correspondence;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.change.ChangeOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.change.TestCommentCreation;
|
||||
import com.google.gerrit.acceptance.testsuite.change.TestPatchset;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.entities.Account;
|
||||
@@ -37,10 +38,10 @@ import com.google.gerrit.extensions.common.CommentInfo;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.truth.NullAwareCorrespondence;
|
||||
import com.google.inject.Inject;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
@@ -57,9 +58,9 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
PatchSet.Id patchset3Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String comment1Uuid = changeOps.change(changeId).patchset(patchset1Id).newComment().create();
|
||||
changeOps.change(changeId).patchset(patchset2Id).newComment().create();
|
||||
changeOps.change(changeId).patchset(patchset3Id).newComment().create();
|
||||
String comment1Uuid = newComment(patchset1Id).create();
|
||||
newComment(patchset2Id).create();
|
||||
newComment(patchset3Id).create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
|
||||
@@ -75,8 +76,8 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset3Id = changeOps.change(changeId).newPatchset().create();
|
||||
PatchSet.Id patchset4Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String comment1Uuid = changeOps.change(changeId).patchset(patchset1Id).newComment().create();
|
||||
String comment3Uuid = changeOps.change(changeId).patchset(patchset3Id).newComment().create();
|
||||
String comment1Uuid = newComment(patchset1Id).create();
|
||||
String comment3Uuid = newComment(patchset3Id).create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset4Id));
|
||||
|
||||
@@ -92,8 +93,8 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String comment1Uuid = changeOps.change(changeId).patchset(patchset1Id).newComment().create();
|
||||
String comment2Uuid = changeOps.change(changeId).patchset(patchset1Id).newComment().create();
|
||||
String comment1Uuid = newComment(patchset1Id).create();
|
||||
String comment2Uuid = newComment(patchset1Id).create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
|
||||
@@ -109,21 +110,9 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String rootCommentUuid = changeOps.change(changeId).patchset(patchset1Id).newComment().create();
|
||||
String child1CommentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.parentUuid(rootCommentUuid)
|
||||
.create();
|
||||
String child2CommentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.parentUuid(child1CommentUuid)
|
||||
.create();
|
||||
String rootCommentUuid = newComment(patchset1Id).create();
|
||||
String child1CommentUuid = newComment(patchset1Id).parentUuid(rootCommentUuid).create();
|
||||
String child2CommentUuid = newComment(patchset1Id).parentUuid(child1CommentUuid).create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
|
||||
@@ -133,17 +122,14 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
// TODO(aliceks): Filter out unresolved comment threads.
|
||||
@Ignore
|
||||
public void onlyUnresolvedCommentsArePorted() throws Exception {
|
||||
public void onlyUnresolvedPublishedCommentsArePorted() throws Exception {
|
||||
// Set up change and patchsets.
|
||||
Change.Id changeId = changeOps.newChange().create();
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().resolved().create();
|
||||
String comment2Uuid =
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().unresolved().create();
|
||||
newComment(patchset1Id).resolved().create();
|
||||
String comment2Uuid = newComment(patchset1Id).unresolved().create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
|
||||
@@ -151,33 +137,34 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
// TODO(aliceks): Filter out unresolved comment threads.
|
||||
@Ignore
|
||||
public void onlyUnresolvedDraftCommentsArePorted() throws Exception {
|
||||
Account.Id accountId = accountOps.newAccount().create();
|
||||
// Set up change and patchsets.
|
||||
Change.Id changeId = changeOps.newChange().create();
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
newDraftComment(patchset1Id).author(accountId).resolved().create();
|
||||
String comment2Uuid = newDraftComment(patchset1Id).author(accountId).unresolved().create();
|
||||
|
||||
List<CommentInfo> portedComments =
|
||||
flatten(getPortedDraftCommentsOfUser(patchset2Id, accountId));
|
||||
|
||||
assertThat(portedComments).comparingElementsUsing(hasUuid()).containsExactly(comment2Uuid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unresolvedStateOfLastCommentInThreadMatters() throws Exception {
|
||||
// Set up change and patchsets.
|
||||
Change.Id changeId = changeOps.newChange().create();
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String rootComment1Uuid =
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().resolved().create();
|
||||
String rootComment1Uuid = newComment(patchset1Id).resolved().create();
|
||||
String childComment1Uuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.parentUuid(rootComment1Uuid)
|
||||
.unresolved()
|
||||
.create();
|
||||
String rootComment2Uuid =
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().unresolved().create();
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.parentUuid(rootComment2Uuid)
|
||||
.resolved()
|
||||
.create();
|
||||
newComment(patchset1Id).parentUuid(rootComment1Uuid).unresolved().create();
|
||||
String rootComment2Uuid = newComment(patchset1Id).unresolved().create();
|
||||
newComment(patchset1Id).parentUuid(rootComment2Uuid).resolved().create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
|
||||
@@ -192,24 +179,21 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
Change.Id changeId = changeOps.newChange().create();
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String rootCommentUuid =
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().resolved().create();
|
||||
// Add comments. Comments should be more than 1 second apart as NoteDb only supports second
|
||||
// precision.
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String rootCommentUuid = newComment(patchset1Id).resolved().createdOn(now).create();
|
||||
String childComment1Uuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.parentUuid(rootCommentUuid)
|
||||
.resolved()
|
||||
.createdOn(now.plusSeconds(5))
|
||||
.create();
|
||||
String childComment2Uuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.parentUuid(rootCommentUuid)
|
||||
.unresolved()
|
||||
.createdOn(now.plusSeconds(10))
|
||||
.create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
@@ -219,6 +203,30 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.containsExactly(rootCommentUuid, childComment1Uuid, childComment2Uuid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unresolvedStateOfDraftCommentsIsIgnoredForPublishedComments() throws Exception {
|
||||
Account.Id accountId = accountOps.newAccount().create();
|
||||
// Set up change and patchsets.
|
||||
Change.Id changeId = changeOps.newChange().create();
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String rootComment1Uuid = newComment(patchset1Id).resolved().create();
|
||||
newDraftComment(patchset1Id)
|
||||
.author(accountId)
|
||||
.parentUuid(rootComment1Uuid)
|
||||
.unresolved()
|
||||
.create();
|
||||
String rootComment2Uuid = newComment(patchset1Id).unresolved().create();
|
||||
newDraftComment(patchset1Id).author(accountId).parentUuid(rootComment2Uuid).resolved().create();
|
||||
|
||||
// Draft comments are only visible to their author.
|
||||
requestScopeOps.setApiUser(accountId);
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
|
||||
assertThat(portedComments).comparingElementsUsing(hasUuid()).containsExactly(rootComment2Uuid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void draftCommentsAreNotPortedViaApiForPublishedComments() throws Exception {
|
||||
Account.Id accountId = accountOps.newAccount().create();
|
||||
@@ -227,7 +235,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add draft comment.
|
||||
changeOps.change(changeId).patchset(patchset1Id).newDraftComment().author(accountId).create();
|
||||
newDraftComment(patchset1Id).author(accountId).create();
|
||||
|
||||
// Draft comments are only visible to their author.
|
||||
requestScopeOps.setApiUser(accountId);
|
||||
@@ -244,7 +252,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().author(accountId).create();
|
||||
newComment(patchset1Id).author(accountId).create();
|
||||
|
||||
List<CommentInfo> portedComments =
|
||||
flatten(getPortedDraftCommentsOfUser(patchset2Id, accountId));
|
||||
@@ -260,7 +268,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add draft comment.
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().author(accountId).create();
|
||||
newComment(patchset1Id).author(accountId).create();
|
||||
|
||||
List<CommentInfo> portedComments =
|
||||
flatten(getPortedDraftCommentsOfUser(patchset2Id, accountId));
|
||||
@@ -277,7 +285,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add draft comment.
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().author(otherUserId).create();
|
||||
newComment(patchset1Id).author(otherUserId).create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedDraftCommentsOfUser(patchset2Id, userId));
|
||||
|
||||
@@ -292,10 +300,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String rangeCommentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.message("Range comment")
|
||||
.fromLine(1)
|
||||
.charOffset(2)
|
||||
@@ -304,30 +309,11 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String lineCommentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.message("Line comment")
|
||||
.onLine(1)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
newComment(patchset1Id).message("Line comment").onLine(1).ofFile("myFile").create();
|
||||
String fileCommentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.message("File comment")
|
||||
.onFileLevelOf("myFile")
|
||||
.create();
|
||||
newComment(patchset1Id).message("File comment").onFileLevelOf("myFile").create();
|
||||
String patchsetLevelCommentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.message("Patchset-level comment")
|
||||
.onPatchsetLevel()
|
||||
.create();
|
||||
newComment(patchset1Id).message("Patchset-level comment").onPatchsetLevel().create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
|
||||
@@ -344,8 +330,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String commentUuid =
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().onParentCommit().create();
|
||||
String commentUuid = newComment(patchset1Id).onParentCommit().create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
|
||||
@@ -359,7 +344,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid = changeOps.change(changeId).patchset(patchset1Id).newComment().create();
|
||||
String commentUuid = newComment(patchset1Id).create();
|
||||
|
||||
List<CommentInfo> portedComments = flatten(getPortedComments(patchset2Id));
|
||||
|
||||
@@ -373,7 +358,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid = changeOps.change(changeId).patchset(patchset1Id).newComment().create();
|
||||
String commentUuid = newComment(patchset1Id).create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -388,13 +373,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newDraftComment()
|
||||
.author(authorId)
|
||||
.create();
|
||||
String commentUuid = newDraftComment(patchset1Id).author(authorId).create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments =
|
||||
getPortedDraftCommentsOfUser(patchset2Id, authorId);
|
||||
@@ -413,8 +392,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
TestPatchset patchset1 = changeOps.change(changeId).currentPatchset().get();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps.change(changeId).patchset(patchset1.patchsetId()).newComment().create();
|
||||
String commentUuid = newComment(patchset1.patchsetId()).create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -428,13 +406,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
TestPatchset patchset1 = changeOps.change(changeId).currentPatchset().get();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1.patchsetId())
|
||||
.newComment()
|
||||
.message("My comment text")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1.patchsetId()).message("My comment text").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -448,15 +420,9 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
TestPatchset patchset1 = changeOps.change(changeId).currentPatchset().get();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comments.
|
||||
String rootCommentUuid =
|
||||
changeOps.change(changeId).patchset(patchset1.patchsetId()).newComment().create();
|
||||
String rootCommentUuid = newComment(patchset1.patchsetId()).create();
|
||||
String childCommentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1.patchsetId())
|
||||
.newComment()
|
||||
.parentUuid(rootCommentUuid)
|
||||
.create();
|
||||
newComment(patchset1.patchsetId()).parentUuid(rootCommentUuid).create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, childCommentUuid);
|
||||
|
||||
@@ -471,8 +437,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().author(authorId).create();
|
||||
String commentUuid = newComment(patchset1Id).author(authorId).create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -487,13 +452,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newDraftComment()
|
||||
.author(authorId)
|
||||
.create();
|
||||
String commentUuid = newDraftComment(patchset1Id).author(authorId).create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments =
|
||||
getPortedDraftCommentsOfUser(patchset2Id, authorId);
|
||||
@@ -510,13 +469,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
TestPatchset patchset1 = changeOps.change(changeId).currentPatchset().get();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1.patchsetId())
|
||||
.newComment()
|
||||
.tag("My comment tag")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1.patchsetId()).tag("My comment tag").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -530,7 +483,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid = changeOps.change(changeId).patchset(patchset1Id).newComment().create();
|
||||
String commentUuid = newComment(patchset1Id).create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -544,7 +497,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid = changeOps.change(changeId).patchset(patchset1Id).newComment().create();
|
||||
String commentUuid = newComment(patchset1Id).create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -561,13 +514,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
|
||||
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onFileLevelOf("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onFileLevelOf("myFile").create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
|
||||
@@ -591,10 +538,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(3)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -625,10 +569,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(3)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -654,10 +595,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
changeOps.change(changeId).newPatchset().file("myFile").renameTo("newFileName").create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(3)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -692,10 +630,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(3)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -735,10 +670,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(3)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -778,10 +710,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(3)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -810,10 +739,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(2)
|
||||
.charOffset(2)
|
||||
.toLine(3)
|
||||
@@ -844,10 +770,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(1)
|
||||
.charOffset(2)
|
||||
.toLine(2)
|
||||
@@ -878,10 +801,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(1)
|
||||
.charOffset(2)
|
||||
.toLine(3)
|
||||
@@ -912,10 +832,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(1)
|
||||
.charOffset(2)
|
||||
.toLine(3)
|
||||
@@ -944,10 +861,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(3)
|
||||
.charOffset(2)
|
||||
.toLine(3)
|
||||
@@ -977,10 +891,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(2)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -1009,10 +920,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(3)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -1049,10 +957,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(2)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -1076,10 +981,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
changeOps.change(changeId).newPatchset().file("myFile").delete().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
.fromLine(3)
|
||||
.charOffset(2)
|
||||
.toLine(4)
|
||||
@@ -1108,14 +1010,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine 1.1\nLine 1.2\nLine 2\nLine 3\nLine 4\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(3)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(3).ofFile("myFile").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -1136,14 +1031,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 2\nLine 3\nLine 4\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(3)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(3).ofFile("myFile").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -1159,14 +1047,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset2Id =
|
||||
changeOps.change(changeId).newPatchset().file("myFile").renameTo("newFileName").create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(3)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(3).ofFile("myFile").create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
|
||||
@@ -1190,14 +1071,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset3Id =
|
||||
changeOps.change(changeId).newPatchset().file("myFile").renameTo("newFileName").create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(3)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(3).ofFile("myFile").create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset3Id);
|
||||
|
||||
@@ -1227,14 +1101,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine 1.1\nLine 1.2\nLine 2\nLine 3\nLine 4\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(3)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(3).ofFile("myFile").create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
|
||||
@@ -1261,14 +1128,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine two\nLine three\nLine 4\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(2)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(2).ofFile("myFile").create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
|
||||
@@ -1291,14 +1151,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine 2\nLine three\nLine 4\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(2)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(2).ofFile("myFile").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -1319,14 +1172,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine 2\nSome completely\ndifferent\ncontent\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(3)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(3).ofFile("myFile").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -1347,14 +1193,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine 2\nSome completely\ndifferent\ncontent\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(4)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(4).ofFile("myFile").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -1375,14 +1214,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine 2\nLine three\nLine 4\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(4)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(4).ofFile("myFile").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -1398,14 +1230,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset2Id =
|
||||
changeOps.change(changeId).newPatchset().file("myFile").delete().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onLine(3)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onLine(3).ofFile("myFile").create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
assertThatMap(portedComments).keys().containsExactly(Patch.PATCHSET_LEVEL);
|
||||
@@ -1428,13 +1253,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine 1.1\nLine 1.2\nLine 2\nLine 3\nLine 4\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onFileLevelOf("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onFileLevelOf("myFile").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
|
||||
|
||||
@@ -1450,13 +1269,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset2Id =
|
||||
changeOps.change(changeId).newPatchset().file("myFile").renameTo("newFileName").create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onFileLevelOf("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onFileLevelOf("myFile").create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
|
||||
@@ -1481,7 +1294,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine 2\nLine 3\nLine 4\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().onFileLevelOf("myFile").create();
|
||||
newComment(patchset1Id).onFileLevelOf("myFile").create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
|
||||
@@ -1499,13 +1312,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset2Id =
|
||||
changeOps.change(changeId).newPatchset().file("myFile").delete().create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
.onFileLevelOf("myFile")
|
||||
.create();
|
||||
String commentUuid = newComment(patchset1Id).onFileLevelOf("myFile").create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
assertThatMap(portedComments).keys().containsExactly(Patch.PATCHSET_LEVEL);
|
||||
@@ -1528,7 +1335,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.content("Line 1\nLine 1.1\nLine 1.2\nLine 2\nLine 3\nLine 4\n")
|
||||
.create();
|
||||
// Add comment.
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().onPatchsetLevel().create();
|
||||
newComment(patchset1Id).onPatchsetLevel().create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
|
||||
@@ -1544,7 +1351,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
PatchSet.Id patchset2Id =
|
||||
changeOps.change(changeId).newPatchset().file("myFile").renameTo("newFileName").create();
|
||||
// Add comment.
|
||||
changeOps.change(changeId).patchset(patchset1Id).newComment().onPatchsetLevel().create();
|
||||
newComment(patchset1Id).onPatchsetLevel().create();
|
||||
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
|
||||
|
||||
@@ -1565,10 +1372,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(changeId)
|
||||
.patchset(patchset1Id)
|
||||
.newComment()
|
||||
newComment(patchset1Id)
|
||||
// The /COMMIT_MSG file has a header of 6 lines, so the summary line is in line 7.
|
||||
// Place comment on 'Text 2' which is line 10.
|
||||
.onLine(10)
|
||||
@@ -1605,14 +1409,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
changeOps.change(childChangeId).newPatchset().parent().patchset(parentPatchset2Id).create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(childChangeId)
|
||||
.patchset(childPatchset1Id)
|
||||
.newComment()
|
||||
.onParentCommit()
|
||||
.onLine(1)
|
||||
.ofFile("myFile")
|
||||
.create();
|
||||
newComment(childPatchset1Id).onParentCommit().onLine(1).ofFile("myFile").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(childPatchset2Id, commentUuid);
|
||||
|
||||
@@ -1654,14 +1451,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(childChangeId)
|
||||
.patchset(childPatchset1Id)
|
||||
.newComment()
|
||||
.onParentCommit()
|
||||
.onLine(1)
|
||||
.ofFile("file1")
|
||||
.create();
|
||||
newComment(childPatchset1Id).onParentCommit().onLine(1).ofFile("file1").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(childPatchset2Id, commentUuid);
|
||||
|
||||
@@ -1703,14 +1493,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(childChangeId)
|
||||
.patchset(childPatchset1Id)
|
||||
.newComment()
|
||||
.onSecondParentCommit()
|
||||
.onLine(1)
|
||||
.ofFile("file2")
|
||||
.create();
|
||||
newComment(childPatchset1Id).onSecondParentCommit().onLine(1).ofFile("file2").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(childPatchset2Id, commentUuid);
|
||||
|
||||
@@ -1758,14 +1541,7 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
.create();
|
||||
// Add comment.
|
||||
String commentUuid =
|
||||
changeOps
|
||||
.change(childChangeId)
|
||||
.patchset(childPatchset1Id)
|
||||
.newComment()
|
||||
.onAutoMergeCommit()
|
||||
.onLine(1)
|
||||
.ofFile("file1")
|
||||
.create();
|
||||
newComment(childPatchset1Id).onAutoMergeCommit().onLine(1).ofFile("file1").create();
|
||||
|
||||
CommentInfo portedComment = getPortedComment(childPatchset2Id, commentUuid);
|
||||
|
||||
@@ -1776,6 +1552,22 @@ public class PortedCommentsIT extends AbstractDaemonTest {
|
||||
assertThat(portedComment).line().isGreaterThan(2);
|
||||
}
|
||||
|
||||
private TestCommentCreation.Builder newComment(PatchSet.Id patchsetId) {
|
||||
// Create unresolved comments by default as only those are ported. Tests get override the
|
||||
// unresolved state by explicitly setting it.
|
||||
return changeOps.change(patchsetId.changeId()).patchset(patchsetId).newComment().unresolved();
|
||||
}
|
||||
|
||||
private TestCommentCreation.Builder newDraftComment(PatchSet.Id patchsetId) {
|
||||
// Create unresolved comments by default as only those are ported. Tests get override the
|
||||
// unresolved state by explicitly setting it.
|
||||
return changeOps
|
||||
.change(patchsetId.changeId())
|
||||
.patchset(patchsetId)
|
||||
.newDraftComment()
|
||||
.unresolved();
|
||||
}
|
||||
|
||||
private CommentInfo getPortedComment(PatchSet.Id patchsetId, String commentUuid)
|
||||
throws RestApiException {
|
||||
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchsetId);
|
||||
|
||||
@@ -22,14 +22,19 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.truth.Correspondence;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.UseClockStep;
|
||||
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.change.ChangeOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.entities.Account;
|
||||
import com.google.gerrit.entities.AttentionSetUpdate;
|
||||
import com.google.gerrit.entities.Change;
|
||||
import com.google.gerrit.entities.Patch;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.AttentionSetInput;
|
||||
@@ -39,12 +44,17 @@ import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
import com.google.gerrit.extensions.client.Side;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gerrit.testing.FakeEmailSender;
|
||||
import com.google.gerrit.testing.TestCommentHelper;
|
||||
import com.google.gerrit.truth.NullAwareCorrespondence;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.LongSupplier;
|
||||
@@ -56,9 +66,13 @@ import org.junit.Test;
|
||||
@UseClockStep(clockStepUnit = TimeUnit.MINUTES)
|
||||
public class AttentionSetIT extends AbstractDaemonTest {
|
||||
|
||||
@Inject private ChangeOperations changeOperations;
|
||||
@Inject private AccountOperations accountOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Inject private FakeEmailSender email;
|
||||
@Inject private TestCommentHelper testCommentHelper;
|
||||
@Inject private Provider<InternalChangeQuery> changeQueryProvider;
|
||||
|
||||
/** Simulates a fake clock. Uses second granularity. */
|
||||
private static class FakeClock implements LongSupplier {
|
||||
@@ -165,7 +179,8 @@ public class AttentionSetIT extends AbstractDaemonTest {
|
||||
assertThat(emailBody)
|
||||
.contains(
|
||||
user.fullName()
|
||||
+ " removed themselves from the attention set of this change.\n The reason is: removed.");
|
||||
+ " removed themselves from the attention set of this change.\n"
|
||||
+ " The reason is: removed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -611,7 +626,8 @@ public class AttentionSetIT extends AbstractDaemonTest {
|
||||
|
||||
assertThat(exception.getMessage())
|
||||
.isEqualTo(
|
||||
"user can not be added/removed twice, and can not be added and removed at the same time");
|
||||
"user can not be added/removed twice, and can not be added and removed at the same"
|
||||
+ " time");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -627,7 +643,8 @@ public class AttentionSetIT extends AbstractDaemonTest {
|
||||
|
||||
assertThat(exception.getMessage())
|
||||
.isEqualTo(
|
||||
"user can not be added/removed twice, and can not be added and removed at the same time");
|
||||
"user can not be added/removed twice, and can not be added and removed at the same"
|
||||
+ " time");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -663,7 +680,8 @@ public class AttentionSetIT extends AbstractDaemonTest {
|
||||
|
||||
assertThat(exception.getMessage())
|
||||
.isEqualTo(
|
||||
"user can not be added/removed twice, and can not be added and removed at the same time");
|
||||
"user can not be added/removed twice, and can not be added and removed at the same"
|
||||
+ " time");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -957,6 +975,64 @@ public class AttentionSetIT extends AbstractDaemonTest {
|
||||
.isEqualTo("Someone else replied on a comment you posted");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reviewAddsAllUsersInCommentThreadEvenOfDifferentChildBranch() throws Exception {
|
||||
Account.Id changeOwner = accountOperations.newAccount().create();
|
||||
Change.Id changeId = changeOperations.newChange().owner(changeOwner).create();
|
||||
Account.Id user1 = accountOperations.newAccount().create();
|
||||
Account.Id user2 = accountOperations.newAccount().create();
|
||||
Account.Id user3 = accountOperations.newAccount().create();
|
||||
Account.Id user4 = accountOperations.newAccount().create();
|
||||
// Add users as reviewers.
|
||||
gApi.changes().id(changeId.get()).addReviewer(user1.toString());
|
||||
gApi.changes().id(changeId.get()).addReviewer(user2.toString());
|
||||
gApi.changes().id(changeId.get()).addReviewer(user3.toString());
|
||||
gApi.changes().id(changeId.get()).addReviewer(user4.toString());
|
||||
// Add a comment thread with branches. Such threads occur if people reply in parallel without
|
||||
// having seen/loaded the reply of another person.
|
||||
String root =
|
||||
changeOperations.change(changeId).currentPatchset().newComment().author(user1).create();
|
||||
String sibling1 =
|
||||
changeOperations
|
||||
.change(changeId)
|
||||
.currentPatchset()
|
||||
.newComment()
|
||||
.author(user2)
|
||||
.parentUuid(root)
|
||||
.create();
|
||||
String sibling2 =
|
||||
changeOperations
|
||||
.change(changeId)
|
||||
.currentPatchset()
|
||||
.newComment()
|
||||
.author(user3)
|
||||
.parentUuid(root)
|
||||
.create();
|
||||
changeOperations
|
||||
.change(changeId)
|
||||
.currentPatchset()
|
||||
.newComment()
|
||||
.author(user4)
|
||||
.parentUuid(sibling2)
|
||||
.create();
|
||||
// Clear the attention set. Necessary as we used Gerrit APIs above which affect the attention
|
||||
// set.
|
||||
AttentionSetInput clearAttention = new AttentionSetInput("clear attention set");
|
||||
gApi.changes().id(changeId.get()).attention(user1.toString()).remove(clearAttention);
|
||||
gApi.changes().id(changeId.get()).attention(user2.toString()).remove(clearAttention);
|
||||
gApi.changes().id(changeId.get()).attention(user3.toString()).remove(clearAttention);
|
||||
gApi.changes().id(changeId.get()).attention(user4.toString()).remove(clearAttention);
|
||||
|
||||
requestScopeOperations.setApiUser(changeOwner);
|
||||
// Simulate that this reply is a child of sibling1 and thus parallel to sibling2 and its child.
|
||||
gApi.changes().id(changeId.get()).current().review(reviewInReplyToComment(sibling1));
|
||||
|
||||
List<AttentionSetUpdate> attentionSetUpdates = getAttentionSetUpdates(changeId);
|
||||
assertThat(attentionSetUpdates)
|
||||
.comparingElementsUsing(hasAccount())
|
||||
.containsExactly(user1, user2, user3, user4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reviewAddsAllUsersInCommentThreadWhenPostedAsDraft() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
@@ -1281,11 +1357,20 @@ public class AttentionSetIT extends AbstractDaemonTest {
|
||||
|
||||
private List<AttentionSetUpdate> getAttentionSetUpdatesForUser(
|
||||
PushOneCommit.Result r, TestAccount account) {
|
||||
return r.getChange().attentionSet().stream()
|
||||
.filter(a -> a.account().get() == account.id().get())
|
||||
return getAttentionSetUpdates(r.getChange().getId()).stream()
|
||||
.filter(a -> a.account().equals(account.id()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<AttentionSetUpdate> getAttentionSetUpdates(Change.Id changeId) {
|
||||
List<ChangeData> changeData = changeQueryProvider.get().byLegacyChangeId(changeId);
|
||||
if (changeData.size() != 1) {
|
||||
throw new IllegalStateException(
|
||||
String.format("Not exactly one change found for ID %s.", changeId));
|
||||
}
|
||||
return new ArrayList<>(Iterables.getOnlyElement(changeData).attentionSet());
|
||||
}
|
||||
|
||||
private ReviewInput reviewWithComment() {
|
||||
return reviewInReplyToComment(null);
|
||||
}
|
||||
@@ -1301,4 +1386,8 @@ public class AttentionSetIT extends AbstractDaemonTest {
|
||||
reviewInput.comments = ImmutableMap.of(Patch.COMMIT_MSG, ImmutableList.of(comment));
|
||||
return reviewInput;
|
||||
}
|
||||
|
||||
private Correspondence<AttentionSetUpdate, Account.Id> hasAccount() {
|
||||
return NullAwareCorrespondence.transforming(AttentionSetUpdate::account, "hasAccount");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.acceptance.testsuite.change;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.extensions.common.testing.CommentInfoSubject.assertThat;
|
||||
import static com.google.gerrit.extensions.common.testing.CommentInfoSubject.assertThatList;
|
||||
import static com.google.gerrit.extensions.common.testing.RobotCommentInfoSubject.assertThat;
|
||||
@@ -33,6 +34,12 @@ import com.google.gerrit.extensions.common.RobotCommentInfo;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.truth.NullAwareCorrespondence;
|
||||
import com.google.inject.Inject;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Month;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -314,6 +321,59 @@ public class PatchsetOperationsImplTest extends AbstractDaemonTest {
|
||||
assertThat(comment).author().id().isEqualTo(accountId.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commentIsCreatedWithSpecifiedCreationTime() throws Exception {
|
||||
Change.Id changeId = changeOperations.newChange().create();
|
||||
|
||||
// Don't use nanos. NoteDb supports only second precision.
|
||||
Instant creationTime =
|
||||
LocalDateTime.of(2020, Month.SEPTEMBER, 15, 12, 10, 43).atZone(ZoneOffset.UTC).toInstant();
|
||||
String commentUuid =
|
||||
changeOperations
|
||||
.change(changeId)
|
||||
.currentPatchset()
|
||||
.newComment()
|
||||
.createdOn(creationTime)
|
||||
.create();
|
||||
|
||||
Timestamp creationTimestamp = Timestamp.from(creationTime);
|
||||
CommentInfo comment = getCommentFromServer(changeId, commentUuid);
|
||||
assertThat(comment).updated().isEqualTo(creationTimestamp);
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void draftCommentCanBeCreatedWithoutSpecifyingAnyParameters() throws Exception {
|
||||
Change.Id changeId = changeOperations.newChange().create();
|
||||
@@ -625,6 +685,59 @@ public class PatchsetOperationsImplTest extends AbstractDaemonTest {
|
||||
assertThatList(comments).comparingElementsUsing(hasUuid()).containsExactly(commentUuid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void draftCommentIsCreatedWithSpecifiedCreationTime() throws Exception {
|
||||
Change.Id changeId = changeOperations.newChange().create();
|
||||
|
||||
// Don't use nanos. NoteDb supports only second precision.
|
||||
Instant creationTime =
|
||||
LocalDateTime.of(2020, Month.SEPTEMBER, 15, 12, 10, 43).atZone(ZoneOffset.UTC).toInstant();
|
||||
String commentUuid =
|
||||
changeOperations
|
||||
.change(changeId)
|
||||
.currentPatchset()
|
||||
.newDraftComment()
|
||||
.createdOn(creationTime)
|
||||
.create();
|
||||
|
||||
Timestamp creationTimestamp = Timestamp.from(creationTime);
|
||||
CommentInfo comment = getDraftCommentFromServer(changeId, commentUuid);
|
||||
assertThat(comment).updated().isEqualTo(creationTimestamp);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zoneOfCreationDateOfDraftCommentCanBeOmitted() 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()
|
||||
.newDraftComment()
|
||||
.createdOn(creationTime1)
|
||||
.create();
|
||||
String commentUuid2 =
|
||||
changeOperations
|
||||
.change(changeId)
|
||||
.currentPatchset()
|
||||
.newDraftComment()
|
||||
.createdOn(creationTime2)
|
||||
.create();
|
||||
|
||||
CommentInfo comment1 = getDraftCommentFromServer(changeId, commentUuid1);
|
||||
Instant comment1Creation = comment1.updated.toInstant();
|
||||
CommentInfo comment2 = getDraftCommentFromServer(changeId, commentUuid2);
|
||||
Instant comment2Creation = comment2.updated.toInstant();
|
||||
Duration commentCreationDifference = Duration.between(comment1Creation, comment2Creation);
|
||||
assertThat(commentCreationDifference).isEqualTo(Duration.ofMinutes(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noDraftCommentsAreCreatedOnCreationOfPublishedComment() throws Exception {
|
||||
Change.Id changeId = changeOperations.newChange().create();
|
||||
|
||||
Reference in New Issue
Block a user