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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user