use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class WalkSorterTest method seriesOfChanges.
@Test
public void seriesOfChanges() throws Exception {
TestRepository<Repo> p = newRepo("p");
RevCommit c1_1 = p.commit().create();
RevCommit c2_1 = p.commit().parent(c1_1).create();
RevCommit c3_1 = p.commit().parent(c2_1).create();
ChangeData cd1 = newChange(p, c1_1);
ChangeData cd2 = newChange(p, c2_1);
ChangeData cd3 = newChange(p, c3_1);
List<ChangeData> changes = ImmutableList.of(cd1, cd2, cd3);
WalkSorter sorter = new WalkSorter(repoManager);
assertSorted(sorter, changes, ImmutableList.of(patchSetData(cd3, c3_1), patchSetData(cd2, c2_1), patchSetData(cd1, c1_1)));
// Add new patch sets whose commits are in reverse order, so output is in
// reverse order.
RevCommit c3_2 = p.commit().create();
RevCommit c2_2 = p.commit().parent(c3_2).create();
RevCommit c1_2 = p.commit().parent(c2_2).create();
addPatchSet(cd1, c1_2);
addPatchSet(cd2, c2_2);
addPatchSet(cd3, c3_2);
assertSorted(sorter, changes, ImmutableList.of(patchSetData(cd1, c1_2), patchSetData(cd2, c2_2), patchSetData(cd3, c3_2)));
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class WalkSorterTest method subsetOfSeriesOfChanges.
@Test
public void subsetOfSeriesOfChanges() throws Exception {
TestRepository<Repo> p = newRepo("p");
RevCommit c1_1 = p.commit().create();
RevCommit c2_1 = p.commit().parent(c1_1).create();
RevCommit c3_1 = p.commit().parent(c2_1).create();
ChangeData cd1 = newChange(p, c1_1);
ChangeData cd3 = newChange(p, c3_1);
List<ChangeData> changes = ImmutableList.of(cd1, cd3);
WalkSorter sorter = new WalkSorter(repoManager);
assertSorted(sorter, changes, ImmutableList.of(patchSetData(cd3, c3_1), patchSetData(cd1, c1_1)));
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class WalkSorterTest method oneChange.
@Test
public void oneChange() throws Exception {
TestRepository<Repo> p = newRepo("p");
RevCommit c = p.commit().create();
ChangeData cd = newChange(p, c);
List<ChangeData> changes = ImmutableList.of(cd);
WalkSorter sorter = new WalkSorter(repoManager);
assertSorted(sorter, changes, ImmutableList.of(patchSetData(cd, c)));
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class WalkSorterTest method subsetOfSeriesOfChangesWithReverseTimestamps.
@Test
public void subsetOfSeriesOfChangesWithReverseTimestamps() throws Exception {
TestRepository<Repo> p = newRepo("p");
RevCommit c0 = p.commit().tick(-1).create();
RevCommit c1 = p.commit().tick(-1).parent(c0).create();
RevCommit c2 = p.commit().tick(-1).parent(c1).create();
RevCommit c3 = p.commit().tick(-1).parent(c2).create();
RevCommit c4 = p.commit().tick(-1).parent(c3).create();
RevWalk rw = p.getRevWalk();
rw.parseCommit(c1);
assertThat(rw.parseCommit(c2).getCommitTime()).isLessThan(c1.getCommitTime());
assertThat(rw.parseCommit(c3).getCommitTime()).isLessThan(c2.getCommitTime());
assertThat(rw.parseCommit(c4).getCommitTime()).isLessThan(c3.getCommitTime());
ChangeData cd1 = newChange(p, c1);
ChangeData cd2 = newChange(p, c2);
ChangeData cd4 = newChange(p, c4);
List<ChangeData> changes = ImmutableList.of(cd1, cd2, cd4);
WalkSorter sorter = new WalkSorter(repoManager);
List<PatchSetData> expected = ImmutableList.of(patchSetData(cd4, c4), patchSetData(cd2, c2), patchSetData(cd1, c1));
for (List<ChangeData> list : permutations(changes)) {
// Not inOrder(); since child of c2 is missing, partial topo sort isn't
// guaranteed to work.
assertThat(sorter.sort(list)).containsExactlyElementsIn(expected);
}
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byMergedAfter.
@Test
public void byMergedAfter() throws Exception {
assume().that(getSchema().hasField(ChangeField.MERGED_ON)).isTrue();
long thirtyHoursInMs = MILLISECONDS.convert(30, HOURS);
// Stop the clock, will set time to specific test values.
resetTimeWithClockStep(0, MILLISECONDS);
TestRepository<Repo> repo = createProject("repo");
long startMs = TestTimeUtil.START.toEpochMilli();
TestTimeUtil.setClock(new Timestamp(startMs));
Change change1 = insert(repo, newChange(repo));
Change change2 = insert(repo, newChange(repo));
Change change3 = insert(repo, newChange(repo));
assertThat(TimeUtil.nowMs()).isEqualTo(startMs);
TestTimeUtil.setClock(new Timestamp(startMs + thirtyHoursInMs));
submit(change3);
TestTimeUtil.setClock(new Timestamp(startMs + 2 * thirtyHoursInMs));
submit(change2);
TestTimeUtil.setClock(new Timestamp(startMs + 3 * thirtyHoursInMs));
// Put another approval on the change, just to update it.
approve(change1);
approve(change3);
assertThat(TimeUtil.nowMs()).isEqualTo(startMs + 3 * thirtyHoursInMs);
assertThat(lastUpdatedMsApi(change3)).isEqualTo(startMs + 3 * thirtyHoursInMs);
assertThat(lastUpdatedMsApi(change2)).isEqualTo(startMs + 2 * thirtyHoursInMs);
assertThat(lastUpdatedMsApi(change1)).isEqualTo(startMs + 3 * thirtyHoursInMs);
// Verify that:
// 1. Change1 was not submitted and should be never returned.
// 2. Change2 was merged on 2009-10-02 03:00:00 -0000
// 3. Change3 was merged on 2009-10-03 09:00:00.0 -0000
assertQuery("mergedafter:2009-10-01", change3, change2);
// Changes are sorted by lastUpdatedOn first, then by mergedOn.
// Even though Change2 was merged after Change3, Change3 is returned first.
assertQuery("mergedafter:\"2009-10-01 22:59:00 -0400\"", change3, change2);
assertQuery("mergedafter:\"2009-10-02 02:59:00 -0000\"", change3, change2);
assertQuery("mergedafter:\"2009-10-01 23:02:00 -0400\"", change2);
assertQuery("mergedafter:\"2009-10-02 03:02:00 -0000\"", change2);
// Changes included on the date submitted.
assertQuery("mergedafter:2009-10-02", change3, change2);
assertQuery("mergedafter:2009-10-03", change2);
// Same test as above, but using filter code path.
assertQuery(makeIndexedPredicateFilterQuery("mergedafter:2009-10-01"), change3, change2);
// Changes are sorted by lastUpdatedOn first, then by mergedOn.
// Even though Change2 was merged after Change3, Change3 is returned first.
assertQuery(makeIndexedPredicateFilterQuery("mergedafter:\"2009-10-01 22:59:00 -0400\""), change3, change2);
assertQuery(makeIndexedPredicateFilterQuery("mergedafter:\"2009-10-02 02:59:00 -0000\""), change3, change2);
assertQuery(makeIndexedPredicateFilterQuery("mergedafter:\"2009-10-01 23:02:00 -0400\""), change2);
assertQuery(makeIndexedPredicateFilterQuery("mergedafter:\"2009-10-02 03:02:00 -0000\""), change2);
// Changes included on the date submitted.
assertQuery(makeIndexedPredicateFilterQuery("mergedafter:2009-10-02"), change3, change2);
assertQuery(makeIndexedPredicateFilterQuery("mergedafter:2009-10-03"), change2);
}
Aggregations