use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byUnresolved.
@Test
public void byUnresolved() throws Exception {
TestRepository<Repo> repo = createProject("repo");
Change change1 = insert(repo, newChange(repo));
Change change2 = insert(repo, newChange(repo));
Change change3 = insert(repo, newChange(repo));
// Change1 has one resolved comment (unresolvedcount = 0)
// Change2 has one unresolved comment (unresolvedcount = 1)
// Change3 has one resolved comment and one unresolved comment (unresolvedcount = 1)
addComment(change1.getChangeId(), "comment 1", false);
addComment(change2.getChangeId(), "comment 2", true);
addComment(change3.getChangeId(), "comment 3", false);
addComment(change3.getChangeId(), "comment 4", true);
assertQuery("has:unresolved", change3, change2);
assertQuery("unresolved:0", change1);
List<ChangeInfo> changeInfos = assertQuery("unresolved:>=0", change3, change2, change1);
// Change3
assertThat(changeInfos.get(0).unresolvedCommentCount).isEqualTo(1);
// Change2
assertThat(changeInfos.get(1).unresolvedCommentCount).isEqualTo(1);
// Change1
assertThat(changeInfos.get(2).unresolvedCommentCount).isEqualTo(0);
assertQuery("unresolved:>0", change3, change2);
assertQuery("unresolved:<1", change1);
assertQuery("unresolved:<=1", change3, change2, change1);
assertQuery("unresolved:1", change3, change2);
assertQuery("unresolved:>1");
assertQuery("unresolved:>=1", change3, change2);
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byCommit.
@Test
public void byCommit() throws Exception {
TestRepository<Repo> repo = createProject("repo");
ChangeInserter ins = newChange(repo);
Change change = insert(repo, ins);
String sha = ins.getCommitId().name();
assertQuery("0000000000000000000000000000000000000000");
assertQuery("commit:0000000000000000000000000000000000000000");
for (int i = 0; i <= 36; i++) {
String q = sha.substring(0, 40 - i);
assertQuery(q, change);
assertQuery("commit:" + q, change);
}
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byAge.
@Test
public void byAge() throws Exception {
long thirtyHoursInMs = MILLISECONDS.convert(30, HOURS);
resetTimeWithClockStep(thirtyHoursInMs, MILLISECONDS);
TestRepository<Repo> repo = createProject("repo");
long startMs = TestTimeUtil.START.toEpochMilli();
Change change1 = insert(repo, newChange(repo), null, Instant.ofEpochMilli(startMs));
Change change2 = insert(repo, newChange(repo), null, Instant.ofEpochMilli(startMs + thirtyHoursInMs));
// Stop time so age queries use the same endpoint.
TestTimeUtil.setClockStep(0, MILLISECONDS);
TestTimeUtil.setClock(new Timestamp(startMs + 2 * thirtyHoursInMs));
long nowMs = TimeUtil.nowMs();
assertThat(lastUpdatedMs(change2) - lastUpdatedMs(change1)).isEqualTo(thirtyHoursInMs);
assertThat(nowMs - lastUpdatedMs(change2)).isEqualTo(thirtyHoursInMs);
assertThat(TimeUtil.nowMs()).isEqualTo(nowMs);
// Change1 was last updated on 2009-09-30 21:00:00 -0000
// Change2 was last updated on 2009-10-02 03:00:00 -0000
// The endpoint is 2009-10-03 09:00:00 -0000
assertQuery("-age:1d");
assertQuery("-age:" + (30 * 60 - 1) + "m");
assertQuery("-age:2d", change2);
assertQuery("-age:3d", change2, change1);
assertQuery("age:3d");
assertQuery("age:2d", change1);
assertQuery("age:1d", change2, change1);
// Same test as above, but using filter code path.
assertQuery(makeIndexedPredicateFilterQuery("-age:1d"));
assertQuery(makeIndexedPredicateFilterQuery("-age:" + (30 * 60 - 1) + "m"));
assertQuery(makeIndexedPredicateFilterQuery("-age:2d"), change2);
assertQuery(makeIndexedPredicateFilterQuery("-age:3d"), change2, change1);
assertQuery(makeIndexedPredicateFilterQuery("age:3d"));
assertQuery(makeIndexedPredicateFilterQuery("age:2d"), change1);
assertQuery(makeIndexedPredicateFilterQuery("age:1d"), change2, change1);
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byStatusClosed.
@Test
public void byStatusClosed() throws Exception {
TestRepository<Repo> repo = createProject("repo");
ChangeInserter ins1 = newChangeWithStatus(repo, Change.Status.MERGED);
Change change1 = insert(repo, ins1);
ChangeInserter ins2 = newChangeWithStatus(repo, Change.Status.ABANDONED);
Change change2 = insert(repo, ins2);
insert(repo, newChangeWithStatus(repo, Change.Status.NEW));
Change[] expected = new Change[] { change2, change1 };
assertQuery("status:closed", expected);
assertQuery("status:CLOSED", expected);
assertQuery("status:c", expected);
assertQuery("status:cl", expected);
assertQuery("status:clo", expected);
assertQuery("status:clos", expected);
assertQuery("status:close", expected);
assertQuery("status:closed", expected);
assertQuery("is:closed", expected);
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byPathExact.
@Test
public void byPathExact() throws Exception {
TestRepository<Repo> repo = createProject("repo");
Change change = insert(repo, newChangeWithFiles(repo, "dir/file1", "dir/file2"));
assertQuery("path:file");
assertQuery("path:dir");
assertQuery("path:file1");
assertQuery("path:file2");
assertQuery("path:dir/file1", change);
assertQuery("path:dir/file2", change);
}
Aggregations