Search in sources :

Example 16 with ChangeInserter

use of com.google.gerrit.server.change.ChangeInserter in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method byDefault.

@Test
public void byDefault() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    Change change1 = insert(repo, newChange(repo));
    RevCommit commit2 = repo.parseBody(repo.commit().message("foosubject").create());
    Change change2 = insert(repo, newChangeForCommit(repo, commit2));
    RevCommit commit3 = repo.parseBody(repo.commit().add("Foo.java", "foo contents").create());
    Change change3 = insert(repo, newChangeForCommit(repo, commit3));
    ChangeInserter ins4 = newChange(repo);
    Change change4 = insert(repo, ins4);
    ReviewInput ri4 = new ReviewInput();
    ri4.message = "toplevel";
    ri4.labels = ImmutableMap.<String, Short>of("Code-Review", (short) 1);
    gApi.changes().id(change4.getId().get()).current().review(ri4);
    ChangeInserter ins5 = newChangeWithTopic(repo, "feature5");
    Change change5 = insert(repo, ins5);
    Change change6 = insert(repo, newChangeForBranch(repo, "branch6"));
    assertQuery(change1.getId().get(), change1);
    assertQuery(ChangeTriplet.format(change1), change1);
    assertQuery("foosubject", change2);
    assertQuery("Foo.java", change3);
    assertQuery("Code-Review+1", change4);
    assertQuery("toplevel", change4);
    assertQuery("feature5", change5);
    assertQuery("branch6", change6);
    assertQuery("refs/heads/branch6", change6);
    Change[] expected = new Change[] { change6, change5, change4, change3, change2, change1 };
    assertQuery("user@example.com", expected);
    assertQuery("repo", expected);
}
Also used : Repo(com.google.gerrit.testutil.InMemoryRepositoryManager.Repo) ChangeInserter(com.google.gerrit.server.change.ChangeInserter) Change(com.google.gerrit.reviewdb.client.Change) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Aggregations

ChangeInserter (com.google.gerrit.server.change.ChangeInserter)16 Change (com.google.gerrit.reviewdb.client.Change)14 Repo (com.google.gerrit.testutil.InMemoryRepositoryManager.Repo)13 Test (org.junit.Test)13 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)2 ArrayList (java.util.ArrayList)2 ObjectId (org.eclipse.jgit.lib.ObjectId)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 ImmutableList (com.google.common.collect.ImmutableList)1 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)1 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)1 CommentInfo (com.google.gerrit.extensions.common.CommentInfo)1 Account (com.google.gerrit.reviewdb.client.Account)1 Branch (com.google.gerrit.reviewdb.client.Branch)1 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)1 ExternalId (com.google.gerrit.server.account.externalids.ExternalId)1 BatchUpdate (com.google.gerrit.server.update.BatchUpdate)1 TestChanges.newPatchSet (com.google.gerrit.testutil.TestChanges.newPatchSet)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1