use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byParentRepo.
@Test
public void byParentRepo() throws Exception {
TestRepository<Repo> repo1 = createProject("repo1");
TestRepository<Repo> repo2 = createProject("repo2", "repo1");
Change change1 = insert(repo1, newChange(repo1));
Change change2 = insert(repo2, newChange(repo2));
assertQuery("parentrepo:repo1", change2, change1);
assertQuery("parentrepo:repo2", change2);
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byBranchAndRef.
@Test
public void byBranchAndRef() throws Exception {
TestRepository<Repo> repo = createProject("repo");
Change change1 = insert(repo, newChangeForBranch(repo, "master"));
Change change2 = insert(repo, newChangeForBranch(repo, "branch"));
assertQuery("branch:foo");
assertQuery("branch:master", change1);
assertQuery("branch:refs/heads/master", change1);
assertQuery("ref:master");
assertQuery("ref:refs/heads/master", change1);
assertQuery("branch:refs/heads/master", change1);
assertQuery("branch:branch", change2);
assertQuery("branch:refs/heads/branch", change2);
assertQuery("ref:branch");
assertQuery("ref:refs/heads/branch", change2);
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byUploader.
@Test
public void byUploader() throws Exception {
assume().that(getSchema().hasField(ChangeField.UPLOADER)).isTrue();
Account.Id user2 = accountManager.authenticate(authRequestFactory.createForUser("anotheruser")).getAccountId();
CurrentUser user2CurrentUser = userFactory.create(user2);
TestRepository<Repo> repo = createProject("repo");
Change change1 = insert(repo, newChange(repo), userId);
assertQuery("is:uploader", change1);
assertQuery("uploader:" + userId.get(), change1);
change1 = newPatchSet(repo, change1, user2CurrentUser);
// Uploader has changed
assertQuery("uploader:" + userId.get());
assertQuery("uploader:" + user2.get(), change1);
requestContext.setContext(newRequestContext(user2));
// self (user2)
assertQuery("is:uploader", change1);
String nameEmail = user2CurrentUser.asIdentifiedUser().getNameEmail();
assertQuery("uploader: \"" + nameEmail + "\"", change1);
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byMergedBefore.
@Test
public void byMergedBefore() 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));
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("mergedbefore:2009-10-01");
// Changes excluded on the date submitted.
assertQuery("mergedbefore:2009-10-02");
assertQuery("mergedbefore:\"2009-10-01 22:59:00 -0400\"");
assertQuery("mergedbefore:\"2009-10-01 02:59:00\"");
assertQuery("mergedbefore:\"2009-10-01 23:02:00 -0400\"", change3);
assertQuery("mergedbefore:\"2009-10-02 03:02:00 -0000\"", change3);
assertQuery("mergedbefore:\"2009-10-02 03:02:00\"", change3);
assertQuery("mergedbefore:2009-10-03", change3);
// Changes are sorted by lastUpdatedOn first, then by mergedOn.
// Even though Change2 was merged after Change3, Change3 is returned first.
assertQuery("mergedbefore:2009-10-04", change3, change2);
// Same test as above, but using filter code path.
assertQuery(makeIndexedPredicateFilterQuery("mergedbefore:2009-10-01"));
assertQuery(makeIndexedPredicateFilterQuery("mergedbefore:2009-10-02"));
assertQuery(makeIndexedPredicateFilterQuery("mergedbefore:\"2009-10-01 22:59:00 -0400\""));
assertQuery(makeIndexedPredicateFilterQuery("mergedbefore:\"2009-10-01 02:59:00\""));
assertQuery(makeIndexedPredicateFilterQuery("mergedbefore:\"2009-10-01 23:02:00 -0400\""), change3);
assertQuery(makeIndexedPredicateFilterQuery("mergedbefore:\"2009-10-02 03:02:00 -0000\""), change3);
assertQuery(makeIndexedPredicateFilterQuery("mergedbefore:\"2009-10-02 03:02:00\""), change3);
assertQuery(makeIndexedPredicateFilterQuery("mergedbefore:2009-10-03"), change3);
assertQuery(makeIndexedPredicateFilterQuery("mergedbefore:2009-10-04"), change3, change2);
}
use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method isPureRevert.
@Test
public void isPureRevert() throws Exception {
assume().that(getSchema().hasField(ChangeField.IS_PURE_REVERT)).isTrue();
TestRepository<Repo> repo = createProject("repo");
// Create two commits and revert second commit (initial commit can't be reverted)
Change initial = insert(repo, newChange(repo));
gApi.changes().id(initial.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(initial.getChangeId()).current().submit();
ChangeInfo changeToRevert = gApi.changes().create(new ChangeInput("repo", "master", "commit to revert")).get();
gApi.changes().id(changeToRevert.id).current().review(ReviewInput.approve());
gApi.changes().id(changeToRevert.id).current().submit();
ChangeInfo changeThatReverts = gApi.changes().id(changeToRevert.id).revert().get();
Change.Id changeThatRevertsId = Change.id(changeThatReverts._number);
assertQueryByIds("is:pure-revert", changeThatRevertsId);
// Update the change that reverts such that it's not a pure revert
gApi.changes().id(changeThatReverts.id).edit().modifyFile("some-file.txt", RawInputUtil.create("newcontent".getBytes(UTF_8)));
gApi.changes().id(changeThatReverts.id).edit().publish();
assertQueryByIds("is:pure-revert");
}
Aggregations