Search in sources :

Example 1 with OrSource

use of com.google.gerrit.server.query.change.OrSource in project gerrit by GerritCodeReview.

the class LazyDataSourceTest method orSourceIsLazy.

@Test
public void orSourceIsLazy() {
    OrSource or = new OrSource(ImmutableList.of(new LazyPredicate()));
    ResultSet<ChangeData> resultSet = or.read();
    assertThrows(AssertionError.class, () -> resultSet.toList());
}
Also used : OrSource(com.google.gerrit.server.query.change.OrSource) ChangeData(com.google.gerrit.server.query.change.ChangeData) Test(org.junit.Test)

Example 2 with OrSource

use of com.google.gerrit.server.query.change.OrSource in project gerrit by GerritCodeReview.

the class ChangeIndexRewriterTest method threeLevelTreeWithMultipleSources.

@Test
public void threeLevelTreeWithMultipleSources() throws Exception {
    Predicate<ChangeData> in = parse("-status:abandoned (foo:a OR file:b)");
    Predicate<ChangeData> out = rewrite(in);
    assertThat(out.getClass()).isSameInstanceAs(AndChangeSource.class);
    Predicate<ChangeData> firstIndexedSubQuery = parse("-status:abandoned");
    assertThat(out.getChild(0)).isEqualTo(query(firstIndexedSubQuery));
    assertThat(out.getChild(1).getClass()).isSameInstanceAs(OrSource.class);
    OrSource indexedSubTree = (OrSource) out.getChild(1);
    Predicate<ChangeData> secondIndexedSubQuery = parse("foo:a OR file:b");
    assertThat(indexedSubTree.getChildren()).containsExactly(query(secondIndexedSubQuery.getChild(1)), secondIndexedSubQuery.getChild(0)).inOrder();
    // Same at the assertions above, that were added for readability
    assertThat(out.getChild(0)).isEqualTo(query(in.getChild(0)));
    assertThat(indexedSubTree.getChildren()).containsExactly(query(in.getChild(1).getChild(1)), in.getChild(1).getChild(0)).inOrder();
}
Also used : OrSource(com.google.gerrit.server.query.change.OrSource) ChangeData(com.google.gerrit.server.query.change.ChangeData) Test(org.junit.Test)

Aggregations

ChangeData (com.google.gerrit.server.query.change.ChangeData)2 OrSource (com.google.gerrit.server.query.change.OrSource)2 Test (org.junit.Test)2