Search in sources :

Example 16 with Result

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

the class CorsIT method putWithServerOriginAcceptedWithNoCorsResponseHeaders.

@Test
public void putWithServerOriginAcceptedWithNoCorsResponseHeaders() throws Exception {
    Result change = createChange();
    String origin = adminRestSession.url();
    RestResponse r = adminRestSession.putWithHeaders("/changes/" + change.getChangeId() + "/topic", /* content = */
    "A", new BasicHeader(ORIGIN, origin));
    r.assertOK();
    checkCors(r, false, origin);
    checkTopic(change, "A");
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) BasicHeader(org.apache.http.message.BasicHeader) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 17 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result 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 18 with Result

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

the class CreateChangeIT method createMergeChangeFailsWithConflictIfThereAreTooManyCommonPredecessors.

@Test
public void createMergeChangeFailsWithConflictIfThereAreTooManyCommonPredecessors() throws Exception {
    // Create an initial commit in master.
    Result initialCommit = pushFactory.create(user.newIdent(), testRepo, "initial commit", "readme.txt", "initial commit").to("refs/heads/master");
    initialCommit.assertOkStatus();
    String file = "shared.txt";
    List<RevCommit> parents = new ArrayList<>();
    // RecursiveMerger#MAX_BASES = 200, cannot use RecursiveMerger#MAX_BASES as it is not static.
    int maxBases = 200;
    // Create more than RecursiveMerger#MAX_BASES base commits.
    for (int i = 1; i <= maxBases + 1; i++) {
        parents.add(testRepo.commit().message("Base " + i).add(file, "content " + i).parent(initialCommit.getCommit()).create());
    }
    // Create 2 branches.
    String branchA = "branchA";
    String branchB = "branchB";
    createBranch(BranchNameKey.create(project, branchA));
    createBranch(BranchNameKey.create(project, branchB));
    // Push an octopus merge to both of the branches.
    Result octopusA = pushFactory.create(user.newIdent(), testRepo).setParents(parents).to("refs/heads/" + branchA);
    octopusA.assertOkStatus();
    Result octopusB = pushFactory.create(user.newIdent(), testRepo).setParents(parents).to("refs/heads/" + branchB);
    octopusB.assertOkStatus();
    // Creating a merge commit for the 2 octopus commits fails, because they have more than
    // RecursiveMerger#MAX_BASES common predecessors.
    assertCreateFails(newMergeChangeInput("branchA", "branchB", ""), ResourceConflictException.class, "Cannot create merge commit: No merge base could be determined." + " Reason=TOO_MANY_MERGE_BASES.");
}
Also used : ArrayList(java.util.ArrayList) Result(com.google.gerrit.acceptance.PushOneCommit.Result) BinaryResult(com.google.gerrit.extensions.restapi.BinaryResult) RevCommit(org.eclipse.jgit.revwalk.RevCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 19 with Result

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

the class RevisionDiffIT method diffBetweenPatchSetsOfMergeCommitCanBeRetrievedForCommitMessageAndMergeList.

@Test
public void diffBetweenPatchSetsOfMergeCommitCanBeRetrievedForCommitMessageAndMergeList() throws Exception {
    PushOneCommit.Result result = createMergeCommitChange("refs/for/master", "my_file.txt");
    String changeId = result.getChangeId();
    String previousPatchSetId = gApi.changes().id(changeId).get().currentRevision;
    addModifiedPatchSet(changeId, "my_file.txt", content -> content.concat("Line I\nLine II\n"));
    // Call both of them in succession to ensure that they don't share the same cache keys.
    DiffInfo commitMessageDiffInfo = getDiffRequest(changeId, CURRENT, COMMIT_MSG).withBase(previousPatchSetId).get();
    DiffInfo mergeListDiffInfo = getDiffRequest(changeId, CURRENT, MERGE_LIST).withBase(previousPatchSetId).get();
    assertThat(commitMessageDiffInfo).content().hasSize(3);
    assertThat(mergeListDiffInfo).content().hasSize(1);
}
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 20 with Result

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

the class TopicIT method illegalTopics.

@Test
public void illegalTopics() throws Exception {
    Result result = createChange();
    char illegalChar = '"';
    String endpoint = "/changes/" + result.getChangeId() + "/topic";
    RestResponse response = adminRestSession.put(endpoint, "topic" + illegalChar);
    response.assertBadRequest();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) Result(com.google.gerrit.acceptance.PushOneCommit.Result) 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