AbstractIndexTests#assertQuery: Rename to assertChangeQuery

Rename the method to disambiguate from account and group query methods
that will potentially be added.

Also add missing braces around if-else blocks.

Change-Id: I03efbd1fc242887d8056cc066736d1c0bbba7a5e
This commit is contained in:
David Pursehouse
2018-06-15 16:38:16 +09:00
parent 5de7e17364
commit c33e0a442d

View File

@@ -45,20 +45,24 @@ public abstract class AbstractIndexTests extends AbstractDaemonTest {
disableChangeIndexWrites();
amendChange(changeId, "second test", "test2.txt", "test2");
assertQuery("message:second", change.getChange(), false);
assertChangeQuery("message:second", change.getChange(), false);
enableChangeIndexWrites();
String cmd = Joiner.on(" ").join("gerrit", "index", "changes", changeLegacyId);
adminSshSession.exec(cmd);
assertQuery("message:second", change.getChange(), true);
assertChangeQuery("message:second", change.getChange(), true);
}
protected void assertQuery(String q, ChangeData change, Boolean assertTrue) throws Exception {
protected void assertChangeQuery(String q, ChangeData change, Boolean assertTrue)
throws Exception {
List<ChangeInfo> result = query(q);
Iterable<Integer> ids = ids(result);
if (assertTrue) assertThat(ids).contains(change.getId().get());
else assertThat(ids).doesNotContain(change.getId().get());
if (assertTrue) {
assertThat(ids).contains(change.getId().get());
} else {
assertThat(ids).doesNotContain(change.getId().get());
}
}
protected static Iterable<Integer> ids(Iterable<ChangeInfo> changes) {