use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class DeleteDraftPatchSetIT method deleteDraftPatchSetAndChange.
@Test
public void deleteDraftPatchSetAndChange() throws Exception {
String changeId = createDraftChangeWith2PS();
PatchSet ps = getCurrentPatchSet(changeId);
Change.Id id = ps.getId().getParentKey();
DraftInput din = new DraftInput();
din.path = "a.txt";
din.message = "comment on a.txt";
gApi.changes().id(changeId).current().createDraft(din);
if (notesMigration.commitChangeWrites()) {
assertThat(getDraftRef(admin, id)).isNotNull();
}
ChangeData cd = getChange(changeId);
assertThat(cd.patchSets()).hasSize(2);
assertThat(cd.change().currentPatchSetId().get()).isEqualTo(2);
assertThat(cd.change().getStatus()).isEqualTo(Change.Status.DRAFT);
deletePatchSet(changeId, ps);
cd = getChange(changeId);
assertThat(cd.patchSets()).hasSize(1);
assertThat(cd.change().currentPatchSetId().get()).isEqualTo(1);
ps = getCurrentPatchSet(changeId);
deletePatchSet(changeId, ps);
assertThat(queryProvider.get().byKeyPrefix(changeId)).isEmpty();
if (notesMigration.commitChangeWrites()) {
assertThat(getDraftRef(admin, id)).isNull();
assertThat(getMetaRef(id)).isNull();
}
exception.expect(ResourceNotFoundException.class);
gApi.changes().id(id.get());
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class DeleteDraftPatchSetIT method deleteDraftPatchSetNoACL.
@Test
public void deleteDraftPatchSetNoACL() throws Exception {
String changeId = createDraftChangeWith2PS();
PatchSet ps = getCurrentPatchSet(changeId);
String triplet = project.get() + "~master~" + changeId;
ChangeInfo c = get(triplet);
assertThat(c.id).isEqualTo(triplet);
assertThat(c.status).isEqualTo(ChangeStatus.DRAFT);
exception.expect(ResourceNotFoundException.class);
exception.expectMessage("Not found: " + changeId);
setApiUser(user);
deletePatchSet(changeId, ps);
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class DeleteDraftPatchSetIT method deletePatchSetNotDraft.
@Test
public void deletePatchSetNotDraft() throws Exception {
String changeId = createChange().getChangeId();
PatchSet ps = getCurrentPatchSet(changeId);
String triplet = project.get() + "~master~" + changeId;
ChangeInfo c = get(triplet);
assertThat(c.id).isEqualTo(triplet);
assertThat(c.status).isEqualTo(ChangeStatus.NEW);
exception.expect(ResourceConflictException.class);
exception.expectMessage("Patch set is not a draft");
setApiUser(admin);
deletePatchSet(changeId, ps);
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ChangeRebuilderIT method pushCert.
@Test
public void pushCert() throws Exception {
// We don't have the code in our test harness to do signed pushes, so just
// use a hard-coded cert. This cert was actually generated by C git 2.2.0
// (albeit not for sending to Gerrit).
String cert = "certificate version 0.1\n" + "pusher Dave Borowitz <dborowitz@google.com> 1433954361 -0700\n" + "pushee git://localhost/repo.git\n" + "nonce 1433954361-bde756572d665bba81d8\n" + "\n" + "0000000000000000000000000000000000000000" + "b981a177396fb47345b7df3e4d3f854c6bea7" + "s/heads/master\n" + "-----BEGIN PGP SIGNATURE-----\n" + "Version: GnuPG v1\n" + "\n" + "iQEcBAABAgAGBQJVeGg5AAoJEPfTicJkUdPkUggH/RKAeI9/i/LduuiqrL/SSdIa\n" + "9tYaSqJKLbXz63M/AW4Sp+4u+dVCQvnAt/a35CVEnpZz6hN4Kn/tiswOWVJf4CO7\n" + "htNubGs5ZMwvD6sLYqKAnrM3WxV/2TbbjzjZW6Jkidz3jz/WRT4SmjGYiEO7aA+V\n" + "4ZdIS9f7sW5VsHHYlNThCA7vH8Uu48bUovFXyQlPTX0pToSgrWV3JnTxDNxfn3iG\n" + "IL0zTY/qwVCdXgFownLcs6J050xrrBWIKqfcWr3u4D2aCLyR0v+S/KArr7ulZygY\n" + "+SOklImn8TAZiNxhWtA6ens66IiammUkZYFv7SSzoPLFZT4dC84SmGPWgf94NoQ=\n" + "=XFeC\n" + "-----END PGP SIGNATURE-----\n";
PushOneCommit.Result r = createChange();
PatchSet.Id psId = r.getPatchSetId();
Change.Id id = psId.getParentKey();
PatchSet ps = db.patchSets().get(psId);
ps.setPushCertificate(cert);
db.patchSets().update(Collections.singleton(ps));
indexer.index(db, project, id);
checker.rebuildAndCheckChanges(id);
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ChangeRebuilderIT method nullPatchSetId.
@Test
public void nullPatchSetId() throws Exception {
PushOneCommit.Result r = createChange();
PatchSet.Id psId1 = r.getPatchSetId();
Change.Id id = psId1.getParentKey();
// Events need to be otherwise identical for the PatchSet.ID to be compared.
ChangeMessage msg1 = insertMessage(id, null, user.getId(), TimeUtil.nowTs(), "message 1");
insertMessage(id, null, user.getId(), msg1.getWrittenOn(), "message 2");
PatchSet.Id psId2 = amendChange(r.getChangeId()).getPatchSetId();
ChangeMessage msg3 = insertMessage(id, null, user.getId(), TimeUtil.nowTs(), "message 3");
insertMessage(id, null, user.getId(), msg3.getWrittenOn(), "message 4");
checker.rebuildAndCheckChanges(id);
setNotesMigration(true, true);
ChangeNotes notes = notesFactory.create(db, project, id);
Map<String, PatchSet.Id> psIds = new HashMap<>();
for (ChangeMessage msg : notes.getChangeMessages()) {
PatchSet.Id psId = msg.getPatchSetId();
assertThat(psId).named("patchset for " + msg).isNotNull();
psIds.put(msg.getMessage(), psId);
}
// Patch set IDs were replaced during conversion process.
assertThat(psIds).containsEntry("message 1", psId1);
assertThat(psIds).containsEntry("message 2", psId1);
assertThat(psIds).containsEntry("message 3", psId2);
assertThat(psIds).containsEntry("message 4", psId2);
}
Aggregations