use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class ChangeEditIT method publishEditRest.
@Test
public void publishEditRest() throws Exception {
PatchSet oldCurrentPatchSet = getCurrentPatchSet(changeId);
createArbitraryEditFor(changeId);
adminRestSession.post(urlPublish(changeId)).assertNoContent();
assertThat(getEdit(changeId)).isAbsent();
PatchSet newCurrentPatchSet = getCurrentPatchSet(changeId);
assertThat(newCurrentPatchSet.id()).isNotEqualTo(oldCurrentPatchSet.id());
assertChangeMessages(changeId, ImmutableList.of("Uploaded patch set 1.", "Uploaded patch set 2.", "Patch Set 3: Published edit on patch set 2."));
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class ChangeEditIT method rebaseEditRest.
@Test
public void rebaseEditRest() throws Exception {
PatchSet previousPatchSet = getCurrentPatchSet(changeId2);
createEmptyEditFor(changeId2);
gApi.changes().id(changeId2).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
addNewPatchSet(changeId2);
PatchSet currentPatchSet = getCurrentPatchSet(changeId2);
Optional<EditInfo> originalEdit = getEdit(changeId2);
assertThat(originalEdit).value().baseRevision().isEqualTo(previousPatchSet.commitId().name());
Timestamp beforeRebase = originalEdit.get().commit.committer.date;
adminRestSession.post(urlRebase(changeId2)).assertNoContent();
ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME), CONTENT_NEW);
ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME2), CONTENT_NEW2);
Optional<EditInfo> rebasedEdit = getEdit(changeId2);
assertThat(rebasedEdit).value().baseRevision().isEqualTo(currentPatchSet.commitId().name());
assertThat(rebasedEdit).value().commit().committer().date().isNotEqualTo(beforeRebase);
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class ChangeEditIT method rebaseEditWithConflictsRest_conflict.
@Test
public void rebaseEditWithConflictsRest_conflict() throws Exception {
PatchSet currentPatchSet = getCurrentPatchSet(changeId2);
createEmptyEditFor(changeId2);
gApi.changes().id(changeId2).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
Optional<EditInfo> edit = getEdit(changeId2);
assertThat(edit).value().baseRevision().isEqualTo(currentPatchSet.commitId().name());
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, PushOneCommit.SUBJECT, FILE_NAME, new String(CONTENT_NEW2, UTF_8), changeId2);
push.to("refs/for/master").assertOkStatus();
adminRestSession.post(urlRebase(changeId2)).assertConflict();
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class PatchSetProtoConverterTest method allValuesConvertedToProtoAndBackAgain.
@Test
public void allValuesConvertedToProtoAndBackAgain() {
PatchSet patchSet = PatchSet.builder().id(PatchSet.id(Change.id(103), 73)).commitId(ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef")).uploader(Account.id(452)).createdOn(Instant.ofEpochMilli(930349320L)).groups(ImmutableList.of("group1", " group2")).pushCertificate("my push certificate").description("This is a patch set description.").build();
PatchSet convertedPatchSet = patchSetProtoConverter.fromProto(patchSetProtoConverter.toProto(patchSet));
Truth.assertThat(convertedPatchSet).isEqualTo(patchSet);
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class PatchSetProtoConverterTest method previouslyOptionalValuesMayBeMissingFromProto.
@Test
public void previouslyOptionalValuesMayBeMissingFromProto() {
Entities.PatchSet proto = Entities.PatchSet.newBuilder().setId(Entities.PatchSet_Id.newBuilder().setChangeId(Entities.Change_Id.newBuilder().setId(103)).setId(73)).build();
PatchSet convertedPatchSet = patchSetProtoConverter.fromProto(proto);
Truth.assertThat(convertedPatchSet).isEqualTo(PatchSet.builder().id(PatchSet.id(Change.id(103), 73)).commitId(ObjectId.fromString("0000000000000000000000000000000000000000")).uploader(Account.id(0)).createdOn(Instant.EPOCH).build());
}
Aggregations