use of com.google.gerrit.extensions.client.Comment.Range in project gerrit by GerritCodeReview.
the class PostReview method ensureRangesDoNotOverlap.
private static void ensureRangesDoNotOverlap(String commentPath, List<FixReplacementInfo> fixReplacementInfos) throws BadRequestException {
List<Range> sortedRanges = fixReplacementInfos.stream().map(fixReplacementInfo -> fixReplacementInfo.range).sorted().collect(toList());
int previousEndLine = 0;
int previousOffset = -1;
for (Range range : sortedRanges) {
if (range.startLine < previousEndLine || (range.startLine == previousEndLine && range.startCharacter < previousOffset)) {
throw new BadRequestException(String.format("Replacements overlap for the robot comment on %s", commentPath));
}
previousEndLine = range.endLine;
previousOffset = range.endCharacter;
}
}
use of com.google.gerrit.extensions.client.Comment.Range in project gerrit by GerritCodeReview.
the class ChangeIT method invalidRange.
@Test
public void invalidRange() throws Exception {
String changeId = createChange().getChangeId();
ReviewInput review = new ReviewInput();
ReviewInput.CommentInput comment = new ReviewInput.CommentInput();
comment.range = new Range();
comment.range.startLine = 1;
comment.range.endLine = 1;
comment.range.startCharacter = -1;
comment.range.endCharacter = 0;
comment.path = PushOneCommit.FILE_NAME;
comment.side = Side.REVISION;
comment.message = "comment 1";
review.comments = ImmutableMap.of(comment.path, Lists.newArrayList(comment));
exception.expect(BadRequestException.class);
gApi.changes().id(changeId).current().review(review);
}
Aggregations