Search in sources :

Example 1 with Result

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

the class CommitIncludedInIT method includedInOpenChange.

@Test
public void includedInOpenChange() throws Exception {
    Result result = createChange();
    assertThat(getIncludedIn(result.getCommit().getId()).branches).isEmpty();
    assertThat(getIncludedIn(result.getCommit().getId()).tags).isEmpty();
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with Result

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

the class CommitIncludedInIT method includedInMergedChange.

@Test
public void includedInMergedChange() throws Exception {
    Result result = createChange();
    gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).review(ReviewInput.approve());
    gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
    assertThat(getIncludedIn(result.getCommit().getId()).branches).containsExactly("master");
    assertThat(getIncludedIn(result.getCommit().getId()).tags).isEmpty();
    grantTagPermissions();
    gApi.projects().name(result.getChange().project().get()).tag("test-tag").create(new TagInput());
    assertThat(getIncludedIn(result.getCommit().getId()).tags).containsExactly("test-tag");
    createBranch(new Branch.NameKey(project.get(), "test-branch"));
    assertThat(getIncludedIn(result.getCommit().getId()).branches).containsExactly("master", "test-branch");
}
Also used : Branch(com.google.gerrit.reviewdb.client.Branch) TagInput(com.google.gerrit.extensions.api.projects.TagInput) Result(com.google.gerrit.acceptance.PushOneCommit.Result) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 3 with Result

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

the class CorsIT method origin.

@Test
public void origin() throws Exception {
    Result change = createChange();
    String url = "/changes/" + change.getChangeId() + "/detail";
    RestResponse r = adminRestSession.get(url);
    r.assertOK();
    assertThat(r.getHeader(ACCESS_CONTROL_ALLOW_ORIGIN)).isNull();
    assertThat(r.getHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS)).isNull();
    check(url, true, "http://example.com");
    check(url, true, "https://sub.example.com");
    check(url, true, "http://friend.ly");
    check(url, false, "http://evil.attacker");
    check(url, false, "http://friendsly");
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with Result

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

the class DeleteDraftPatchSetIT method createDraftChangeWith2PS.

private String createDraftChangeWith2PS() throws Exception {
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
    Result result = push.to("refs/drafts/master");
    push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "4711", result.getChangeId());
    return push.to("refs/drafts/master").getChangeId();
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Result(com.google.gerrit.acceptance.PushOneCommit.Result)

Example 5 with Result

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

the class AbstractDaemonTest method createNParentsMergeCommitChange.

protected PushOneCommit.Result createNParentsMergeCommitChange(String ref, List<String> fileNames) throws Exception {
    // This method creates n different commits and creates a merge commit pointing to all n parents.
    // Each commit will contain all the fileNames. Commit i will have the following file names and
    // their contents:
    // {$file_1_name, ${file_1_name}-1}
    // {$file_2_name, ${file_2_name}-1}, etc...
    // The merge commit will have:
    // {$file_1_name, ${file_1_name}-1}
    // {$file_2_name, ${file_2_name}-2},
    // {$file_3_name, ${file_3_name}-3}, etc...
    // i.e. taking the ith file from the ith commit.
    int n = fileNames.size();
    ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
    List<PushOneCommit.Result> pushResults = new ArrayList<>();
    for (int i = 1; i <= n; i++) {
        int finalI = i;
        pushResults.add(pushFactory.create(admin.newIdent(), testRepo, "parent " + i, fileNames.stream().collect(Collectors.toMap(f -> f, f -> f + "-" + finalI))).to(ref));
        // reset HEAD in order to create a sibling of the first change
        if (i < n) {
            testRepo.reset(initial);
        }
    }
    PushOneCommit m = pushFactory.create(admin.newIdent(), testRepo, "merge", IntStream.range(1, n + 1).boxed().collect(Collectors.toMap(i -> fileNames.get(i - 1), i -> fileNames.get(i - 1) + "-" + i)));
    m.setParents(pushResults.stream().map(PushOneCommit.Result::getCommit).collect(toList()));
    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) ArrayList(java.util.ArrayList) Result(com.google.gerrit.acceptance.PushOneCommit.Result) FetchResult(org.eclipse.jgit.transport.FetchResult) BinaryResult(com.google.gerrit.extensions.restapi.BinaryResult)

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