use of com.google.gerrit.server.notedb.ChangeNotes in project gerrit by GerritCodeReview.
the class CommentPorterTest method commentsAreNotDroppedWhenRetrievingCommitSha1sHasUnexpectedError.
@Test
public void commentsAreNotDroppedWhenRetrievingCommitSha1sHasUnexpectedError() {
Project.NameKey project = Project.nameKey("myProject");
Change.Id changeId = Change.id(1);
Change change = createChange(project, changeId);
PatchSet patchset1 = createPatchset(PatchSet.id(changeId, 1));
PatchSet patchset2 = createPatchset(PatchSet.id(changeId, 2));
ChangeNotes changeNotes = mockChangeNotes(project, change, patchset1, patchset2);
CommentPorter commentPorter = new CommentPorter(diffOperations, commentsUtil, metrics);
HumanComment comment = createComment(patchset1.id(), "myFile");
when(commentsUtil.determineCommitId(any(), any(), anyShort())).thenThrow(IllegalStateException.class);
ImmutableList<HumanComment> portedComments = commentPorter.portComments(changeNotes, patchset2, ImmutableList.of(comment), ImmutableList.of());
assertThat(portedComments).isNotEmpty();
}
use of com.google.gerrit.server.notedb.ChangeNotes in project gerrit by GerritCodeReview.
the class CommentPorterTest method commentsAreNotDroppedWhenDiffHasUnexpectedError.
@Test
public void commentsAreNotDroppedWhenDiffHasUnexpectedError() throws Exception {
Project.NameKey project = Project.nameKey("myProject");
Change.Id changeId = Change.id(1);
Change change = createChange(project, changeId);
PatchSet patchset1 = createPatchset(PatchSet.id(changeId, 1));
PatchSet patchset2 = createPatchset(PatchSet.id(changeId, 2));
ChangeNotes changeNotes = mockChangeNotes(project, change, patchset1, patchset2);
CommentPorter commentPorter = new CommentPorter(diffOperations, commentsUtil, metrics);
HumanComment comment = createComment(patchset1.id(), "myFile");
when(commentsUtil.determineCommitId(any(), any(), anyShort())).thenReturn(Optional.of(dummyObjectId));
when(diffOperations.listModifiedFiles(any(Project.NameKey.class), any(ObjectId.class), any(ObjectId.class), any(DiffOptions.class))).thenThrow(IllegalStateException.class);
ImmutableList<HumanComment> portedComments = commentPorter.portComments(changeNotes, patchset2, ImmutableList.of(comment), ImmutableList.of());
assertThat(portedComments).isNotEmpty();
}
use of com.google.gerrit.server.notedb.ChangeNotes in project gerrit by GerritCodeReview.
the class CommentPorterTest method commentsAreNotDroppedWhenDiffNotAvailable.
@Test
public void commentsAreNotDroppedWhenDiffNotAvailable() throws Exception {
Project.NameKey project = Project.nameKey("myProject");
Change.Id changeId = Change.id(1);
Change change = createChange(project, changeId);
PatchSet patchset1 = createPatchset(PatchSet.id(changeId, 1));
PatchSet patchset2 = createPatchset(PatchSet.id(changeId, 2));
ChangeNotes changeNotes = mockChangeNotes(project, change, patchset1, patchset2);
CommentPorter commentPorter = new CommentPorter(diffOperations, commentsUtil, metrics);
HumanComment comment = createComment(patchset1.id(), "myFile");
when(commentsUtil.determineCommitId(any(), any(), anyShort())).thenReturn(Optional.of(dummyObjectId));
when(diffOperations.listModifiedFiles(any(Project.NameKey.class), any(ObjectId.class), any(ObjectId.class), any(DiffOptions.class))).thenThrow(DiffNotAvailableException.class);
ImmutableList<HumanComment> portedComments = commentPorter.portComments(changeNotes, patchset2, ImmutableList.of(comment), ImmutableList.of());
assertThat(portedComments).isNotEmpty();
}
use of com.google.gerrit.server.notedb.ChangeNotes in project gerrit by GerritCodeReview.
the class CommentPorterTest method commentsAreMappedToPatchsetLevelOnDiffError.
@Test
public void commentsAreMappedToPatchsetLevelOnDiffError() throws Exception {
Project.NameKey project = Project.nameKey("myProject");
Change.Id changeId = Change.id(1);
Change change = createChange(project, changeId);
PatchSet patchset1 = createPatchset(PatchSet.id(changeId, 1));
PatchSet patchset2 = createPatchset(PatchSet.id(changeId, 2));
ChangeNotes changeNotes = mockChangeNotes(project, change, patchset1, patchset2);
CommentPorter commentPorter = new CommentPorter(diffOperations, commentsUtil, metrics);
HumanComment comment = createComment(patchset1.id(), "myFile");
when(commentsUtil.determineCommitId(any(), any(), anyShort())).thenReturn(Optional.of(dummyObjectId));
when(diffOperations.listModifiedFiles(any(Project.NameKey.class), any(ObjectId.class), any(ObjectId.class), any(DiffOptions.class))).thenThrow(IllegalStateException.class);
ImmutableList<HumanComment> portedComments = commentPorter.portComments(changeNotes, patchset2, ImmutableList.of(comment), ImmutableList.of());
assertThat(portedComments).comparingElementsUsing(hasFilePath()).containsExactly(Patch.PATCHSET_LEVEL);
}
use of com.google.gerrit.server.notedb.ChangeNotes in project gerrit by GerritCodeReview.
the class ChangeRebuilderIT method emptyTopic.
@Test
public void emptyTopic() throws Exception {
PushOneCommit.Result r = createChange();
Change.Id id = r.getPatchSetId().getParentKey();
Change c = db.changes().get(id);
assertThat(c.getTopic()).isNull();
c.setTopic("");
db.changes().update(Collections.singleton(c));
checker.rebuildAndCheckChanges(id);
setNotesMigration(true, true);
// Rebuild and check was successful, but NoteDb doesn't support storing an
// empty topic, so it comes out as null.
ChangeNotes notes = notesFactory.create(db, project, id);
assertThat(notes.getChange().getTopic()).isNull();
}
Aggregations