@Rule
public ExpectedException thrown = ExpectedException.none();
:
Account account = new Account("any name", CarCloudAuthUtil.ACCOUNT_TYPE);
Application application = spy(RuntimeEnvironment.application);
util = new CarCloudAuthUtil(application);
AccountManager manager = spy(AccountManager.get(application));
doReturn(manager)
.when(application)
.getSystemService(Context.ACCOUNT_SERVICE);
manager.addAccountExplicitly(account, "any key", new Bundle());
manager.setAuthToken(account, CarCloudAuthUtil.AUTH_TOKEN_TYPE, "any string");
doThrow(AuthenticationException.class)
.when(manager)
.blockingGetAuthToken(eq(account), eq(CarCloudAuthUtil.AUTH_TOKEN_TYPE), eq(true));
thrown.expect(AuthenticationException.class);
thrown.expectMessage(new IsNull());