use of com.google.gerrit.reviewdb.client.FixReplacement in project gerrit by GerritCodeReview.
the class FixReplacementInterpreterTest method replacementsCanAddContentAtEndOfFile.
@Test
public void replacementsCanAddContentAtEndOfFile() throws Exception {
FixReplacement fixReplacement = new FixReplacement(filePath1, new Range(4, 0, 4, 0), "New content");
mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
replay(fileContentUtil);
List<TreeModification> treeModifications = toTreeModifications(fixReplacement);
assertThatList(treeModifications).onlyElement().asChangeFileContentModification().newContent().isEqualTo("First line\nSecond line\nThird line\nNew content");
}
use of com.google.gerrit.reviewdb.client.FixReplacement in project gerrit by GerritCodeReview.
the class FixReplacementInterpreterTest method replacementsMustNotReferToZeroLine.
@Test
public void replacementsMustNotReferToZeroLine() throws Exception {
FixReplacement fixReplacement = new FixReplacement(filePath1, new Range(0, 0, 0, 0), "A new line\n");
mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
replay(fileContentUtil);
expectedException.expect(ResourceConflictException.class);
toTreeModifications(fixReplacement);
}
use of com.google.gerrit.reviewdb.client.FixReplacement in project gerrit by GerritCodeReview.
the class FixReplacementInterpreterTest method replacementsCanAddALine.
@Test
public void replacementsCanAddALine() throws Exception {
FixReplacement fixReplacement = new FixReplacement(filePath1, new Range(2, 0, 2, 0), "A new line\n");
mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
replay(fileContentUtil);
List<TreeModification> treeModifications = toTreeModifications(fixReplacement);
assertThatList(treeModifications).onlyElement().asChangeFileContentModification().newContent().isEqualTo("First line\nA new line\nSecond line\nThird line\n");
}
use of com.google.gerrit.reviewdb.client.FixReplacement in project gerrit by GerritCodeReview.
the class FixReplacementInterpreterTest method replacementsMaySpanMultipleLines.
@Test
public void replacementsMaySpanMultipleLines() throws Exception {
FixReplacement fixReplacement = new FixReplacement(filePath1, new Range(1, 6, 3, 1), "and t");
mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
replay(fileContentUtil);
List<TreeModification> treeModifications = toTreeModifications(fixReplacement);
assertThatList(treeModifications).onlyElement().asChangeFileContentModification().newContent().isEqualTo("First and third line\n");
}
use of com.google.gerrit.reviewdb.client.FixReplacement 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);
}
Aggregations