Search in sources :

Example 66 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class CreateChangeIT method assertCreateSucceeds.

private ChangeInfo assertCreateSucceeds(ChangeInput in) throws Exception {
    ChangeInfo out = gApi.changes().create(in).get();
    assertThat(out.project).isEqualTo(in.project);
    assertThat(RefNames.fullName(out.branch)).isEqualTo(RefNames.fullName(in.branch));
    assertThat(out.subject).isEqualTo(Splitter.on("\n").splitToList(in.subject).get(0));
    assertThat(out.topic).isEqualTo(in.topic);
    assertThat(out.status).isEqualTo(in.status);
    if (in.isPrivate) {
        assertThat(out.isPrivate).isTrue();
    } else {
        assertThat(out.isPrivate).isNull();
    }
    if (in.workInProgress) {
        assertThat(out.workInProgress).isTrue();
    } else {
        assertThat(out.workInProgress).isNull();
    }
    assertThat(out.revisions).hasSize(1);
    assertThat(out.submitted).isNull();
    assertThat(out.containsGitConflicts).isNull();
    assertThat(in.status).isEqualTo(ChangeStatus.NEW);
    return out;
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo)

Example 67 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class CreateChangeIT method createChangeWithParentChange.

@Test
public void createChangeWithParentChange() throws Exception {
    Result change = createChange();
    ChangeInput input = newChangeInput(ChangeStatus.NEW);
    input.baseChange = change.getChangeId();
    ChangeInfo result = assertCreateSucceeds(input);
    assertThat(gApi.changes().id(result.id).current().commit(false).parents.get(0).commit).isEqualTo(change.getCommit().getId().name());
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Result(com.google.gerrit.acceptance.PushOneCommit.Result) BinaryResult(com.google.gerrit.extensions.restapi.BinaryResult) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 68 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class CreateChangeIT method createMergeChange.

@Test
public void createMergeChange() throws Exception {
    changeInTwoBranches("branchA", "a.txt", "branchB", "b.txt");
    ChangeInput in = newMergeChangeInput("branchA", "branchB", "");
    ChangeInfo change = assertCreateSucceeds(in);
    // Verify the message that has been posted on the change.
    List<ChangeMessageInfo> messages = gApi.changes().id(change._number).messages();
    assertThat(messages).hasSize(1);
    assertThat(Iterables.getOnlyElement(messages).message).isEqualTo("Uploaded patch set 1.");
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 69 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class CreateChangeIT method createWithMergeConflictAuthorAddedAsCcNotNotifiedWithNotifyNone.

@Test
public void createWithMergeConflictAuthorAddedAsCcNotNotifiedWithNotifyNone() throws Exception {
    String fileName = "shared.txt";
    String sourceBranch = "sourceBranch";
    String sourceSubject = "source change";
    String sourceContent = "source content";
    String targetBranch = "targetBranch";
    String targetSubject = "target change";
    String targetContent = "target content";
    changeInTwoBranches(sourceBranch, sourceSubject, fileName, sourceContent, targetBranch, targetSubject, fileName, targetContent);
    ChangeInput input = newMergeChangeInput(targetBranch, sourceBranch, "", true);
    input.workInProgress = true;
    input.author = new AccountInput();
    input.author.email = user.email();
    input.author.name = user.fullName();
    input.notify = NotifyHandling.NONE;
    ChangeInfo info = assertCreateSucceeds(input);
    assertThat(info.reviewers.get(ReviewerState.CC)).hasSize(1);
    assertThat(Iterables.getOnlyElement(info.reviewers.get(ReviewerState.CC)).email).isEqualTo(user.email());
    assertThat(sender.getMessages()).isEmpty();
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) AccountInput(com.google.gerrit.extensions.api.accounts.AccountInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 70 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class CreateChangeIT method createMergeChange_ConflictsAllowed.

@Test
public void createMergeChange_ConflictsAllowed() throws Exception {
    String fileName = "shared.txt";
    String sourceBranch = "sourceBranch";
    String sourceSubject = "source change";
    String sourceContent = "source content";
    String targetBranch = "targetBranch";
    String targetSubject = "target change";
    String targetContent = "target content";
    changeInTwoBranches(sourceBranch, sourceSubject, fileName, sourceContent, targetBranch, targetSubject, fileName, targetContent);
    ChangeInput in = newMergeChangeInput(targetBranch, sourceBranch, "", true);
    ChangeInfo change = assertCreateSucceedsWithConflicts(in);
    // Verify that the file content in the created change is correct.
    // We expect that it has conflict markers to indicate the conflict.
    BinaryResult bin = gApi.changes().id(change._number).current().file(fileName).content();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    bin.writeTo(os);
    String fileContent = new String(os.toByteArray(), UTF_8);
    String sourceSha1 = abbreviateName(projectOperations.project(project).getHead(sourceBranch), 6);
    String targetSha1 = abbreviateName(projectOperations.project(project).getHead(targetBranch), 6);
    assertThat(fileContent).isEqualTo("<<<<<<< TARGET BRANCH (" + targetSha1 + " " + targetSubject + ")\n" + targetContent + "\n" + "=======\n" + sourceContent + "\n" + ">>>>>>> SOURCE BRANCH (" + sourceSha1 + " " + sourceSubject + ")\n");
    // Verify the message that has been posted on the change.
    List<ChangeMessageInfo> messages = gApi.changes().id(change._number).messages();
    assertThat(messages).hasSize(1);
    assertThat(Iterables.getOnlyElement(messages).message).isEqualTo("Uploaded patch set 1.\n\n" + "The following files contain Git conflicts:\n" + "* " + fileName + "\n");
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BinaryResult(com.google.gerrit.extensions.restapi.BinaryResult) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)504 Test (org.junit.Test)434 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)393 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)276 Change (com.google.gerrit.entities.Change)73 RevCommit (org.eclipse.jgit.revwalk.RevCommit)67 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)52 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)50 Project (com.google.gerrit.entities.Project)45 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)45 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)36 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)36 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)35 Repository (org.eclipse.jgit.lib.Repository)35 CommitInfo (com.google.gerrit.extensions.common.CommitInfo)32 LabelInfo (com.google.gerrit.extensions.common.LabelInfo)32 TestRepository (org.eclipse.jgit.junit.TestRepository)32 ObjectId (org.eclipse.jgit.lib.ObjectId)30 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)29 List (java.util.List)29