Search in sources :

Example 6 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class AbstractDaemonTest method createMergeCommitChange.

protected PushOneCommit.Result createMergeCommitChange(String ref, String file) throws Exception {
    ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
    PushOneCommit.Result p1 = pushFactory.create(admin.newIdent(), testRepo, "parent 1", ImmutableMap.of(file, "foo-1", "bar", "bar-1")).to(ref);
    // reset HEAD in order to create a sibling of the first change
    testRepo.reset(initial);
    PushOneCommit.Result p2 = pushFactory.create(admin.newIdent(), testRepo, "parent 2", ImmutableMap.of(file, "foo-2", "bar", "bar-2")).to(ref);
    PushOneCommit m = pushFactory.create(admin.newIdent(), testRepo, "merge", ImmutableMap.of(file, "foo-1", "bar", "bar-2"));
    m.setParents(ImmutableList.of(p1.getCommit(), p2.getCommit()));
    PushOneCommit.Result result = m.to(ref);
    result.assertOkStatus();
    return result;
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) ObjectId(org.eclipse.jgit.lib.ObjectId)

Example 7 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class AbstractDaemonTest method createChange.

protected PushOneCommit.Result createChange(TestRepository<InMemoryRepository> repo) throws Exception {
    PushOneCommit push = pushFactory.create(admin.newIdent(), repo);
    PushOneCommit.Result result = push.to("refs/for/master");
    result.assertOkStatus();
    return result;
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result)

Example 8 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class RevisionDiffIT method diffAgainstAutoMergeCanBeRetrievedForCommitMessageAndMergeList.

@Test
public void diffAgainstAutoMergeCanBeRetrievedForCommitMessageAndMergeList() throws Exception {
    PushOneCommit.Result result = createMergeCommitChange("refs/for/master", "my_file.txt");
    String changeId = result.getChangeId();
    addModifiedPatchSet(changeId, "my_file.txt", content -> content.concat("Line I\nLine II\n"));
    DiffInfo commitMessageDiffInfo = getDiffRequest(changeId, CURRENT, COMMIT_MSG).get();
    DiffInfo mergeListDiffInfo = getDiffRequest(changeId, CURRENT, MERGE_LIST).get();
    assertThat(commitMessageDiffInfo).changeType().isEqualTo(ChangeType.ADDED);
    assertThat(commitMessageDiffInfo).content().hasSize(1);
    assertThat(mergeListDiffInfo).changeType().isEqualTo(ChangeType.ADDED);
    assertThat(mergeListDiffInfo).content().hasSize(1);
    assertThat(mergeListDiffInfo).content().element(0).linesOfB().element(0).isEqualTo("Merge List:");
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) DiffInfo(com.google.gerrit.extensions.common.DiffInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 9 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class PortedCommentsIT method addCommit.

private ObjectId addCommit(ObjectId parentCommit, String fileName, String fileContent) throws Exception {
    testRepo.reset(parentCommit);
    PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, "Adjust files of repo", ImmutableMap.of(fileName, fileContent));
    PushOneCommit.Result result = push.to("refs/for/master");
    return result.getCommit();
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit)

Example 10 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class RevisionDiffIT method diff.

@Test
public void diff() throws Exception {
    // The assertions assume that intraline is false.
    assume().that(intraline).isFalse();
    String fileName = "a_new_file.txt";
    String fileContent = "First line\nSecond line\n";
    PushOneCommit.Result result = createChange("Add a file", fileName, fileContent);
    assertDiffForNewFile(result, fileName, fileContent);
    assertDiffForNewFile(result, COMMIT_MSG, result.getCommit().getFullMessage());
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

Result (com.google.gerrit.acceptance.PushOneCommit.Result)75 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)59 Test (org.junit.Test)59 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)28 RestResponse (com.google.gerrit.acceptance.RestResponse)17 ObjectId (org.eclipse.jgit.lib.ObjectId)11 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)9 DraftInput (com.google.gerrit.extensions.api.changes.DraftInput)8 DiffInfo (com.google.gerrit.extensions.common.DiffInfo)7 BasicHeader (org.apache.http.message.BasicHeader)7 Request (org.apache.http.client.fluent.Request)6 FileInfo (com.google.gerrit.extensions.common.FileInfo)5 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)4 TagInput (com.google.gerrit.extensions.api.projects.TagInput)4 Project (com.google.gerrit.entities.Project)3 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)3 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)3 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 Before (org.junit.Before)3