use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class WalkSorterTest method seriesOfChangesAtSameTimestamp.
@Test
public void seriesOfChangesAtSameTimestamp() throws Exception {
TestRepository<Repo> p = newRepo("p");
RevCommit c0 = p.commit().tick(0).create();
RevCommit c1 = p.commit().tick(0).parent(c0).create();
RevCommit c2 = p.commit().tick(0).parent(c1).create();
RevCommit c3 = p.commit().tick(0).parent(c2).create();
RevCommit c4 = p.commit().tick(0).parent(c3).create();
RevWalk rw = p.getRevWalk();
rw.parseCommit(c1);
assertThat(rw.parseCommit(c2).getCommitTime()).isEqualTo(c1.getCommitTime());
assertThat(rw.parseCommit(c3).getCommitTime()).isEqualTo(c1.getCommitTime());
assertThat(rw.parseCommit(c4).getCommitTime()).isEqualTo(c1.getCommitTime());
ChangeData cd1 = newChange(p, c1);
ChangeData cd2 = newChange(p, c2);
ChangeData cd3 = newChange(p, c3);
ChangeData cd4 = newChange(p, c4);
List<ChangeData> changes = ImmutableList.of(cd1, cd2, cd3, cd4);
WalkSorter sorter = new WalkSorter(repoManager);
assertSorted(sorter, changes, ImmutableList.of(patchSetData(cd4, c4), patchSetData(cd3, c3), patchSetData(cd2, c2), patchSetData(cd1, c1)));
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class WalkSorterTest method projectsSortedByName.
@Test
public void projectsSortedByName() throws Exception {
TestRepository<Repo> pa = newRepo("a");
TestRepository<Repo> pb = newRepo("b");
RevCommit c1 = pa.commit().create();
RevCommit c2 = pb.commit().create();
RevCommit c3 = pa.commit().parent(c1).create();
RevCommit c4 = pb.commit().parent(c2).create();
ChangeData cd1 = newChange(pa, c1);
ChangeData cd2 = newChange(pb, c2);
ChangeData cd3 = newChange(pa, c3);
ChangeData cd4 = newChange(pb, c4);
assertSorted(new WalkSorter(repoManager), ImmutableList.of(cd1, cd2, cd3, cd4), ImmutableList.of(patchSetData(cd3, c3), patchSetData(cd1, c1), patchSetData(cd4, c4), patchSetData(cd2, c2)));
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byStatusOpen.
@Test
public void byStatusOpen() 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));
Change[] expected = new Change[] { change1 };
assertQuery("status:open", expected);
assertQuery("status:OPEN", expected);
assertQuery("status:o", expected);
assertQuery("status:op", expected);
assertQuery("status:ope", expected);
assertQuery("status:pending", expected);
assertQuery("status:PENDING", expected);
assertQuery("status:p", expected);
assertQuery("status:pe", expected);
assertQuery("status:pen", expected);
assertQuery("is:open", expected);
assertQuery("is:pending", expected);
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byAfterSince.
@Test
public void byAfterSince() 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));
TestTimeUtil.setClockStep(0, MILLISECONDS);
// Change2 was last updated on 2009-10-02 03:00:00 -0000
for (String predicate : Lists.newArrayList("after:", "since:")) {
assertQuery(predicate + "2009-10-03");
assertQuery(predicate + "\"2009-10-01 20:59:59 -0400\"", change2);
assertQuery(predicate + "\"2009-10-01 20:59:59 -0000\"", change2);
assertQuery(predicate + "2009-10-01", change2);
assertQuery(predicate + "2009-09-30", change2, change1);
assertQuery(predicate + "\"2009-09-30 21:00:00 -0000\"", change2, change1);
assertQuery(predicate + "\"2009-10-02 03:00:00 -0000\"", change2);
}
// Same test as above, but using filter code path.
for (String predicate : Lists.newArrayList("after:", "since:")) {
assertQuery(makeIndexedPredicateFilterQuery(predicate + "2009-10-03"));
assertQuery(makeIndexedPredicateFilterQuery(predicate + "\"2009-10-01 20:59:59 -0400\""), change2);
assertQuery(makeIndexedPredicateFilterQuery(predicate + "\"2009-10-01 20:59:59 -0000\""), change2);
assertQuery(makeIndexedPredicateFilterQuery(predicate + "2009-10-01"), change2);
assertQuery(makeIndexedPredicateFilterQuery(predicate + "2009-09-30"), change2, change1);
assertQuery(makeIndexedPredicateFilterQuery(predicate + "\"2009-09-30 21:00:00 -0000\""), change2, change1);
assertQuery(makeIndexedPredicateFilterQuery(predicate + "\"2009-10-02 03:00:00 -0000\""), change2);
}
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method reindexIfStale.
@Test
public void reindexIfStale() throws Exception {
Account.Id user = createAccount("user");
Project.NameKey project = Project.nameKey("repo");
TestRepository<Repo> repo = createProject(project.get());
Change change = insert(repo, newChange(repo));
String changeId = change.getKey().get();
ChangeNotes notes = notesFactory.create(change.getProject(), change.getId());
PatchSet ps = psUtil.get(notes, change.currentPatchSetId());
requestContext.setContext(newRequestContext(user));
gApi.changes().id(changeId).edit().create();
assertQuery("has:edit", change);
assertThat(indexer.reindexIfStale(project, change.getId()).get()).isFalse();
// Delete edit ref behind index's back.
RefUpdate ru = repo.getRepository().updateRef(RefNames.refsEdit(user, change.getId(), ps.id()));
ru.setForceUpdate(true);
assertThat(ru.delete()).isEqualTo(RefUpdate.Result.FORCED);
// Index is stale.
assertQuery("has:edit", change);
assertThat(indexer.reindexIfStale(project, change.getId()).get()).isTrue();
assertQuery("has:edit");
}
Aggregations