use of com.google.gerrit.extensions.common.FixReplacementInfo in project gerrit by GerritCodeReview.
the class PostReview method ensureFixReplacementsAreAddable.
private static void ensureFixReplacementsAreAddable(String commentPath, List<FixReplacementInfo> fixReplacementInfos) throws BadRequestException {
ensureReplacementsArePresent(commentPath, fixReplacementInfos);
for (FixReplacementInfo fixReplacementInfo : fixReplacementInfos) {
ensureReplacementPathIsSetAndNotPatchsetLevel(commentPath, fixReplacementInfo.path);
ensureRangeIsSet(commentPath, fixReplacementInfo.range);
ensureRangeIsValid(commentPath, fixReplacementInfo.range);
ensureReplacementStringIsSet(commentPath, fixReplacementInfo.replacement);
}
Map<String, List<FixReplacementInfo>> replacementsPerFilePath = fixReplacementInfos.stream().collect(groupingBy(fixReplacement -> fixReplacement.path));
for (List<FixReplacementInfo> sameFileReplacements : replacementsPerFilePath.values()) {
ensureRangesDoNotOverlap(commentPath, sameFileReplacements);
}
}
use of com.google.gerrit.extensions.common.FixReplacementInfo in project gerrit by GerritCodeReview.
the class ChangesRestApiBindingsIT method fixEndpoints.
@Test
public void fixEndpoints() throws Exception {
String changeId = createChange("Subject", FILENAME, "content").getChangeId();
RobotCommentInput robotCommentInput = new RobotCommentInput();
robotCommentInput.robotId = "happyRobot";
robotCommentInput.robotRunId = "1";
robotCommentInput.line = 1;
robotCommentInput.message = "nit: trailing whitespace";
robotCommentInput.path = FILENAME;
FixReplacementInfo fixReplacementInfo = new FixReplacementInfo();
fixReplacementInfo.path = FILENAME;
fixReplacementInfo.replacement = "some replacement code";
fixReplacementInfo.range = createRange(1, 1, 1, 2);
FixSuggestionInfo fixSuggestionInfo = new FixSuggestionInfo();
fixSuggestionInfo.fixId = "An ID which must be overwritten.";
fixSuggestionInfo.description = "A description for a suggested fix.";
fixSuggestionInfo.replacements = ImmutableList.of(fixReplacementInfo);
robotCommentInput.fixSuggestions = ImmutableList.of(fixSuggestionInfo);
ReviewInput reviewInput = new ReviewInput();
reviewInput.robotComments = Collections.singletonMap(robotCommentInput.path, ImmutableList.of(robotCommentInput));
reviewInput.message = "robot comment test";
gApi.changes().id(changeId).current().review(reviewInput);
List<RobotCommentInfo> robotCommentInfos = gApi.changes().id(changeId).current().robotCommentsAsList();
List<String> fixIds = getFixIds(robotCommentInfos);
String fixId = Iterables.getOnlyElement(fixIds);
RestApiCallHelper.execute(adminRestSession, FIX_ENDPOINTS, changeId, "current", fixId);
}
Aggregations