use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class ChangeNotesTest method revertOfIsNullByDefault.
@Test
public void revertOfIsNullByDefault() throws Exception {
Change c = newChange();
ChangeNotes notes = newNotes(c);
assertThat(notes.getChange().getRevertOf()).isNull();
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class ChangeNotesTest method tagApprovals.
@Test
public void tagApprovals() throws Exception {
String tag1 = "jenkins";
String tag2 = "ip";
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
update.putApproval(LabelId.VERIFIED, (short) -1);
update.setTag(tag1);
update.commit();
update = newUpdate(c, changeOwner);
update.putApproval(LabelId.VERIFIED, (short) 1);
update.setTag(tag2);
update.commit();
ChangeNotes notes = newNotes(c);
ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals = notes.getApprovals();
assertThat(approvals).hasSize(1);
assertThat(approvals.entries().asList().get(0).getValue().tag()).hasValue(tag2);
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchSetDescription.
@Test
public void patchSetDescription() throws Exception {
String description = "descriptive";
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
update.setPsDescription(description);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getCurrentPatchSet().description()).hasValue(description);
description = "new, now more descriptive!";
update = newUpdate(c, changeOwner);
update.setPsDescription(description);
update.commit();
notes = newNotes(c);
assertThat(notes.getCurrentPatchSet().description()).hasValue(description);
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class ChangeNotesTest method reissuedApproval_samePatchSet_differentUUID.
@Test
public void reissuedApproval_samePatchSet_differentUUID() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
update.putApproval(LabelId.CODE_REVIEW, (short) -1);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getApprovals().keySet()).containsExactly(c.currentPatchSetId());
PatchSetApproval originalPsa = Iterables.getOnlyElement(notes.getApprovals().get(c.currentPatchSetId()));
assertThat(originalPsa.patchSetId()).isEqualTo(c.currentPatchSetId());
assertThat(originalPsa.accountId()).isEqualTo(changeOwner.getAccountId());
assertThat(originalPsa.label()).isEqualTo(LabelId.CODE_REVIEW);
assertThat(originalPsa.value()).isEqualTo((short) -1);
assertParsedUuid(originalPsa);
// Remove approval from current patch set
update = newUpdate(c, changeOwner);
update.removeApproval(LabelId.CODE_REVIEW);
update.commit();
notes = newNotes(c);
assertThat(notes.getApprovals().keySet()).hasSize(1);
PatchSetApproval removedPsa = Iterables.getOnlyElement(notes.getApprovals().get(c.currentPatchSetId()));
assertThat(removedPsa.key()).isEqualTo(originalPsa.key());
assertThat(removedPsa.value()).isEqualTo(0);
// Add approval with the same author, label, value to the current patch set
update = newUpdate(c, changeOwner);
update.putApproval(LabelId.CODE_REVIEW, (short) -1);
update.commit();
notes = newNotes(c);
assertThat(notes.getApprovals().keySet()).hasSize(1);
PatchSetApproval reAddedPsa = Iterables.getOnlyElement(notes.getApprovals().get(c.currentPatchSetId()));
assertThat(reAddedPsa.key()).isEqualTo(originalPsa.key());
assertThat(reAddedPsa.value()).isEqualTo(originalPsa.value());
// The re-added approval has a different UUID
assertParsedUuid(reAddedPsa);
assertThat(reAddedPsa.uuid().get()).isNotEqualTo(originalPsa.uuid().get());
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class ChangeNotesTest method commitChangeNotesUnique.
@Test
public void commitChangeNotesUnique() throws Exception {
// PatchSetId -> ObjectId must be a one to one mapping
Change c = newChange();
ChangeNotes notes = newNotes(c);
PatchSet ps = notes.getCurrentPatchSet();
assertThat(ps).isNotNull();
// new revId for the same patch set, ps1
ChangeUpdate update = newUpdate(c, changeOwner);
RevCommit commit = tr.commit().message("PS1 again").create();
update.setCommit(rw, commit);
update.commit();
StorageException e = assertThrows(StorageException.class, () -> newNotes(c));
assertCause(e, ConfigInvalidException.class, "Multiple revisions parsed for patch set 1:" + " " + commit.name() + " and " + ps.commitId().name());
}
Aggregations