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);
}
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);
}
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);
}
}
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");
}
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);
}
Aggregations