use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverTest method shortCircuit.
@Test
public void shortCircuit() throws Exception {
ImmutableList<Searcher<?>> searchers = ImmutableList.of(new TestSearcher("f.*", true), new TestSearcher("foo|bar", false, newAccount(1)));
Result result = search("foo", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(result.input()).isEqualTo("foo");
assertThat(result.asIdSet()).isEmpty();
result = search("bar", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(result.input()).isEqualTo("bar");
assertThat(result.asIdSet()).containsExactlyElementsIn(ids(1));
}
use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverTest method exceptionMessageMe.
@Test
public void exceptionMessageMe() throws Exception {
AccountResolver resolver = newAccountResolver();
UnresolvableAccountException e = new UnresolvableAccountException(resolver.new Result("me", ImmutableList.of(), ImmutableList.of()));
assertThat(e.isSelf()).isTrue();
assertThat(e).hasMessageThat().isEqualTo("Resolving account 'me' requires login");
}
use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverTest method exceptionMessageSelf.
@Test
public void exceptionMessageSelf() throws Exception {
AccountResolver resolver = newAccountResolver();
UnresolvableAccountException e = new UnresolvableAccountException(resolver.new Result("self", ImmutableList.of(), ImmutableList.of()));
assertThat(e.isSelf()).isTrue();
assertThat(e).hasMessageThat().isEqualTo("Resolving account 'self' requires login");
}
use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverTest method exceptionMessageOnlyInactive.
@Test
public void exceptionMessageOnlyInactive() throws Exception {
AccountResolver resolver = newAccountResolver();
assertThat(new UnresolvableAccountException(resolver.new Result("foo", ImmutableList.of(), ImmutableList.of(newInactiveAccount(3), newInactiveAccount(1))))).hasMessageThat().isEqualTo("Account 'foo' only matches inactive accounts. To use an inactive account, retry" + " with one of the following exact account IDs:\n" + "1: Anonymous Name (1)\n" + "3: Anonymous Name (3)");
}
use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverTest method shouldUseCustomAccountActivityPredicate.
@Test
public void shouldUseCustomAccountActivityPredicate() 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, (a) -> true);
// Searchers always short-circuit when finding a non-empty result list,
// and this one didn't filter out inactive results,
// so the second searcher never ran.
assertThat(result.asIdSet()).containsExactlyElementsIn(ids(1));
assertThat(getOnlyElement(result.asList()).account().isActive()).isFalse();
assertThat(filteredInactiveIds(result)).isEmpty();
}
Aggregations