FromAddressGeneratorProvider: Use AccountCache#maybeGet instead of AccountCache#get

AccountCache#get returns an empty AccountState to represent a missing
account and the full name and preferred email of the empty AccountState
are always null. Handle the missing account case explicitly instead of
using an empty AccountState.

Change-Id: I03d7eeb4139e8756f25b4aebd33b88cd13eeb41c
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-01-30 12:54:42 +01:00
parent 4405a7bf05
commit 08b85e0d67
2 changed files with 9 additions and 6 deletions

View File

@@ -30,6 +30,7 @@ import com.google.gerrit.server.config.AllUsersNameProvider;
import com.google.gerrit.server.mail.Address;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.PersonIdent;
import org.junit.Before;
@@ -368,7 +369,7 @@ public class FromAddressGeneratorProviderTest {
private Account.Id user(String name, String email) {
final AccountState s = makeUser(name, email);
expect(accountCache.get(eq(s.getAccount().getId()))).andReturn(s);
expect(accountCache.maybeGet(eq(s.getAccount().getId()))).andReturn(Optional.of(s));
return s.getAccount().getId();
}