use of com.google.gerrit.server.account.AccountResolver.Searcher in project gerrit by GerritCodeReview.
the class AccountResolverTest method shortCircuitAfterFilteringInactiveCandidatesResultsInEmptyList.
@Test
public void shortCircuitAfterFilteringInactiveCandidatesResultsInEmptyList() throws Exception {
AccountState account1 = newAccount(1);
AccountState account2 = newInactiveAccount(2);
TestSearcher searcher1 = new TestSearcher("foo", true, account2);
searcher1.setCallerShouldFilterOutInactiveCandidates();
TestSearcher searcher2 = new TestSearcher("foo", false, account1, account2);
ImmutableList<Searcher<?>> searchers = ImmutableList.of(searcher1, searcher2);
// searcher1 matched and then filtered out all candidates because account2 is inactive, but
// still short-circuited.
Result result = search("foo", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(result.asIdSet()).isEmpty();
assertThat(filteredInactiveIds(result)).containsExactlyElementsIn(ids(2));
}
use of com.google.gerrit.server.account.AccountResolver.Searcher in project gerrit by GerritCodeReview.
the class AccountResolverTest method filterInactiveEventuallyFindingNoResults.
@Test
public void filterInactiveEventuallyFindingNoResults() throws Exception {
TestSearcher searcher1 = new TestSearcher("foo", false, newInactiveAccount(1));
searcher1.setCallerShouldFilterOutInactiveCandidates();
TestSearcher searcher2 = new TestSearcher("f.*", false, newInactiveAccount(2));
searcher2.setCallerShouldFilterOutInactiveCandidates();
ImmutableList<Searcher<?>> searchers = ImmutableList.of(searcher1, searcher2);
Result result = search("foo", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(result.asIdSet()).isEmpty();
assertThat(filteredInactiveIds(result)).containsExactlyElementsIn(ids(1, 2));
}
use of com.google.gerrit.server.account.AccountResolver.Searcher in project gerrit by GerritCodeReview.
the class AccountResolverTest method filterInactiveEventuallyFindingResults.
@Test
public void filterInactiveEventuallyFindingResults() throws Exception {
TestSearcher searcher1 = new TestSearcher("foo", false, newInactiveAccount(1));
searcher1.setCallerShouldFilterOutInactiveCandidates();
TestSearcher searcher2 = new TestSearcher("f.*", false, newAccount(2));
searcher2.setCallerShouldFilterOutInactiveCandidates();
ImmutableList<Searcher<?>> searchers = ImmutableList.of(searcher1, searcher2);
Result result = search("foo", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(search("foo", searchers, AccountResolverTest::allVisiblePredicate).asIdSet()).containsExactlyElementsIn(ids(2));
// No info about inactive results exposed if there was at least one active result.
assertThat(filteredInactiveIds(result)).isEmpty();
}
use of com.google.gerrit.server.account.AccountResolver.Searcher in project gerrit by GerritCodeReview.
the class AccountResolverTest method dontShortCircuitAfterFilteringInactiveCandidatesResultsInEmptyList.
@Test
public void dontShortCircuitAfterFilteringInactiveCandidatesResultsInEmptyList() throws Exception {
AccountState account1 = newAccount(1);
AccountState account2 = newInactiveAccount(2);
TestSearcher searcher1 = new TestSearcher("foo", false, account2);
searcher1.setCallerShouldFilterOutInactiveCandidates();
TestSearcher searcher2 = new TestSearcher("foo", false, account1, account2);
ImmutableList<Searcher<?>> searchers = ImmutableList.of(searcher1, searcher2);
// searcher1 matched, but filtered out all candidates because account2 is inactive. Actual
// result came from searcher2 instead.
Result result = search("foo", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(result.asIdSet()).containsExactlyElementsIn(ids(1, 2));
}
use of com.google.gerrit.server.account.AccountResolver.Searcher in project gerrit by GerritCodeReview.
the class AccountResolverTest method asUniqueWithNoResults.
@Test
public void asUniqueWithNoResults() throws Exception {
String input = "foo";
ImmutableList<Searcher<?>> searchers = ImmutableList.of();
UnresolvableAccountException thrown = assertThrows(UnresolvableAccountException.class, () -> search(input, searchers, AccountResolverTest::allVisiblePredicate).asUnique());
assertThat(thrown).hasMessageThat().isEqualTo("Account 'foo' not found");
}
Aggregations