use of com.google.gerrit.reviewdb.client.Comment.Range in project gerrit by GerritCodeReview.
the class FixReplacementInterpreterTest method replacementsMustNotReferToNegativeOffset.
@Test
public void replacementsMustNotReferToNegativeOffset() throws Exception {
FixReplacement fixReplacement = new FixReplacement(filePath1, new Range(1, -1, 1, 5), "modified");
mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
replay(fileContentUtil);
expectedException.expect(ResourceConflictException.class);
toTreeModifications(fixReplacement);
}
use of com.google.gerrit.reviewdb.client.Comment.Range in project gerrit by GerritCodeReview.
the class FixReplacementInterpreterTest method replacementsCanDeleteALine.
@Test
public void replacementsCanDeleteALine() throws Exception {
FixReplacement fixReplacement = new FixReplacement(filePath1, new Range(2, 0, 3, 0), "");
mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
replay(fileContentUtil);
List<TreeModification> treeModifications = toTreeModifications(fixReplacement);
assertThatList(treeModifications).onlyElement().asChangeFileContentModification().newContent().isEqualTo("First line\nThird line\n");
}
use of com.google.gerrit.reviewdb.client.Comment.Range in project gerrit by GerritCodeReview.
the class FixReplacementInterpreterTest method replacementsMustNotReferToNotExistingOffsetOfIntermediateLine.
@Test
public void replacementsMustNotReferToNotExistingOffsetOfIntermediateLine() throws Exception {
FixReplacement fixReplacement = new FixReplacement(filePath1, new Range(1, 0, 1, 11), "modified");
mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
replay(fileContentUtil);
expectedException.expect(ResourceConflictException.class);
toTreeModifications(fixReplacement);
}
use of com.google.gerrit.reviewdb.client.Comment.Range in project gerrit by GerritCodeReview.
the class FixReplacementInterpreterTest method replacementsMayOccurOnSameLine.
@Test
public void replacementsMayOccurOnSameLine() throws Exception {
FixReplacement fixReplacement1 = new FixReplacement(filePath1, new Range(2, 0, 2, 6), "A");
FixReplacement fixReplacement2 = new FixReplacement(filePath1, new Range(2, 7, 2, 11), "modification");
mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
replay(fileContentUtil);
List<TreeModification> treeModifications = toTreeModifications(fixReplacement1, fixReplacement2);
assertThatList(treeModifications).onlyElement().asChangeFileContentModification().newContent().isEqualTo("First line\nA modification\nThird line\n");
}
use of com.google.gerrit.reviewdb.client.Comment.Range in project gerrit by GerritCodeReview.
the class FixReplacementInterpreterTest method replacementsMustNotReferToNotExistingLine.
@Test
public void replacementsMustNotReferToNotExistingLine() throws Exception {
FixReplacement fixReplacement = new FixReplacement(filePath1, new Range(5, 0, 5, 0), "A new line\n");
mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
replay(fileContentUtil);
expectedException.expect(ResourceConflictException.class);
toTreeModifications(fixReplacement);
}
Aggregations