Search in sources :

Example 6 with CommitModification

use of com.google.gerrit.server.edit.CommitModification in project gerrit by GerritCodeReview.

the class FixReplacementInterpreterTest method replacementIsTranslatedToTreeModification.

@Test
public void replacementIsTranslatedToTreeModification() throws Exception {
    FixReplacement fixReplacement = new FixReplacement(filePath1, new Range(1, 1, 3, 2), "Modified content");
    mockFileContent(filePath1, "First line\nSecond line\nThird line\n");
    CommitModification commitModification = toCommitModification(fixReplacement);
    ImmutableList<TreeModification> treeModifications = commitModification.treeModifications();
    assertThatList(treeModifications).onlyElement().asChangeFileContentModification().filePaths().containsExactly(filePath1);
    assertThatList(treeModifications).onlyElement().asChangeFileContentModification().newContent().isEqualTo("FModified contentird line\n");
}
Also used : CommitModification(com.google.gerrit.server.edit.CommitModification) TreeModification(com.google.gerrit.server.edit.tree.TreeModification) FixReplacement(com.google.gerrit.entities.FixReplacement) Range(com.google.gerrit.entities.Comment.Range) Test(org.junit.Test)

Aggregations

CommitModification (com.google.gerrit.server.edit.CommitModification)6 Range (com.google.gerrit.entities.Comment.Range)4 FixReplacement (com.google.gerrit.entities.FixReplacement)4 TreeModification (com.google.gerrit.server.edit.tree.TreeModification)4 Test (org.junit.Test)4 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)2 ProjectState (com.google.gerrit.server.project.ProjectState)2 Repository (org.eclipse.jgit.lib.Repository)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 RawInputUtil (com.google.gerrit.common.RawInputUtil)1 Patch (com.google.gerrit.entities.Patch)1 PatchSet (com.google.gerrit.entities.PatchSet)1 Project (com.google.gerrit.entities.Project)1 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 FileContentUtil (com.google.gerrit.server.change.FileContentUtil)1 RevisionResource (com.google.gerrit.server.change.RevisionResource)1 ChangeEdit (com.google.gerrit.server.edit.ChangeEdit)1