Search in sources :

Example 21 with PatchSet

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."));
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 22 with PatchSet

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);
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) EditInfo(com.google.gerrit.extensions.common.EditInfo) Timestamp(java.sql.Timestamp) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 23 with PatchSet

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();
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) EditInfo(com.google.gerrit.extensions.common.EditInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 24 with PatchSet

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);
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) Test(org.junit.Test)

Example 25 with 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());
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) Entities(com.google.gerrit.proto.Entities) Test(org.junit.Test)

Aggregations

PatchSet (com.google.gerrit.entities.PatchSet)123 Change (com.google.gerrit.entities.Change)61 Test (org.junit.Test)48 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)41 ObjectId (org.eclipse.jgit.lib.ObjectId)35 RevCommit (org.eclipse.jgit.revwalk.RevCommit)29 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)28 Project (com.google.gerrit.entities.Project)25 StorageException (com.google.gerrit.exceptions.StorageException)25 Repository (org.eclipse.jgit.lib.Repository)22 IOException (java.io.IOException)20 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)19 ChangeData (com.google.gerrit.server.query.change.ChangeData)18 HumanComment (com.google.gerrit.entities.HumanComment)16 RevWalk (org.eclipse.jgit.revwalk.RevWalk)16 Inject (com.google.inject.Inject)14 Map (java.util.Map)14 List (java.util.List)13 ImmutableList (com.google.common.collect.ImmutableList)12 AuthException (com.google.gerrit.extensions.restapi.AuthException)11