Search in sources :

Example 1 with ChangeInserter

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

the class AbstractQueryChangesTest method byStatusDraft.

@Test
public void byStatusDraft() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    insert(repo, newChangeWithStatus(repo, Change.Status.NEW));
    ChangeInserter ins2 = newChangeWithStatus(repo, Change.Status.DRAFT);
    Change change2 = insert(repo, ins2);
    Change[] expected = new Change[] { change2 };
    assertQuery("status:draft", expected);
    assertQuery("status:DRAFT", expected);
    assertQuery("status:d", expected);
    assertQuery("status:dr", expected);
    assertQuery("status:dra", expected);
    assertQuery("status:draf", expected);
    assertQuery("is:draft", expected);
}
Also used : Repo(com.google.gerrit.testutil.InMemoryRepositoryManager.Repo) ChangeInserter(com.google.gerrit.server.change.ChangeInserter) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 2 with ChangeInserter

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

the class AbstractQueryChangesTest method byTopicRegex.

@Test
public void byTopicRegex() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    ChangeInserter ins1 = newChangeWithTopic(repo, "feature1");
    Change change1 = insert(repo, ins1);
    ChangeInserter ins2 = newChangeWithTopic(repo, "Cherrypick-feature1");
    Change change2 = insert(repo, ins2);
    ChangeInserter ins3 = newChangeWithTopic(repo, "feature1-fixup");
    Change change3 = insert(repo, ins3);
    assertQuery("intopic:^feature1.*", change3, change1);
    assertQuery("intopic:{^.*feature1$}", change2, change1);
}
Also used : Repo(com.google.gerrit.testutil.InMemoryRepositoryManager.Repo) ChangeInserter(com.google.gerrit.server.change.ChangeInserter) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 3 with ChangeInserter

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

the class AbstractQueryChangesTest method testByCommitsOnBranchNotMerged.

private void testByCommitsOnBranchNotMerged(TestRepository<Repo> repo, Collection<ObjectId> extra) throws Exception {
    int n = 10;
    List<String> shas = new ArrayList<>(n + extra.size());
    extra.forEach(i -> shas.add(i.name()));
    List<Integer> expectedIds = new ArrayList<>(n);
    Branch.NameKey dest = null;
    for (int i = 0; i < n; i++) {
        ChangeInserter ins = newChange(repo);
        insert(repo, ins);
        if (dest == null) {
            dest = ins.getChange().getDest();
        }
        shas.add(ins.getCommitId().name());
        expectedIds.add(ins.getChange().getId().get());
    }
    for (int i = 1; i <= 11; i++) {
        Iterable<ChangeData> cds = internalChangeQuery.byCommitsOnBranchNotMerged(repo.getRepository(), db, dest, shas, i);
        Iterable<Integer> ids = FluentIterable.from(cds).transform(in -> in.getId().get());
        String name = "limit " + i;
        assertThat(ids).named(name).hasSize(n);
        assertThat(ids).named(name).containsExactlyElementsIn(expectedIds);
    }
}
Also used : Branch(com.google.gerrit.reviewdb.client.Branch) ArrayList(java.util.ArrayList) ChangeInserter(com.google.gerrit.server.change.ChangeInserter)

Example 4 with ChangeInserter

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

the class AbstractQueryChangesTest method byStatusPrefix.

@Test
public void byStatusPrefix() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    ChangeInserter ins1 = newChangeWithStatus(repo, Change.Status.NEW);
    Change change1 = insert(repo, ins1);
    insert(repo, newChangeWithStatus(repo, Change.Status.MERGED));
    assertQuery("status:n", change1);
    assertQuery("status:ne", change1);
    assertQuery("status:new", change1);
    assertQuery("status:N", change1);
    assertQuery("status:nE", change1);
    assertQuery("status:neW", change1);
    assertThatQueryException("status:nx").hasMessageThat().isEqualTo("invalid change status: nx");
    assertThatQueryException("status:newx").hasMessageThat().isEqualTo("invalid change status: newx");
}
Also used : Repo(com.google.gerrit.testutil.InMemoryRepositoryManager.Repo) ChangeInserter(com.google.gerrit.server.change.ChangeInserter) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 5 with ChangeInserter

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

the class AbstractQueryChangesTest method updatedOrder.

@Test
public void updatedOrder() throws Exception {
    resetTimeWithClockStep(1, SECONDS);
    TestRepository<Repo> repo = createProject("repo");
    ChangeInserter ins1 = newChange(repo);
    Change change1 = insert(repo, ins1);
    Change change2 = insert(repo, newChange(repo));
    assertThat(lastUpdatedMs(change1)).isLessThan(lastUpdatedMs(change2));
    assertQuery("status:new", change2, change1);
    gApi.changes().id(change1.getId().get()).topic("new-topic");
    change1 = notesFactory.create(db, change1.getProject(), change1.getId()).getChange();
    assertThat(lastUpdatedMs(change1)).isGreaterThan(lastUpdatedMs(change2));
    assertThat(lastUpdatedMs(change1) - lastUpdatedMs(change2)).isAtLeast(MILLISECONDS.convert(1, SECONDS));
    // change1 moved to the top.
    assertQuery("status:new", change1, change2);
}
Also used : Repo(com.google.gerrit.testutil.InMemoryRepositoryManager.Repo) ChangeInserter(com.google.gerrit.server.change.ChangeInserter) Change(com.google.gerrit.reviewdb.client.Change) 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