GoogleApiClientConnectTask extends AsyncTask<SmartLock, Void, SmartLock> { @Override protected SmartLock doInBackground(SmartLock... smartLocks) { Log.v(TAG, "Connecting GoogleApiClient...."); final SmartLock smartLock = smartLocks[0]; GoogleApiClient client = smartLock.getCredentialClient(); ConnectionResult result = client.blockingConnect(5, TimeUnit.SECONDS); if (!result.isSuccess()) { Log.e(TAG, "Failed to connect with GoogleApiClient with code " + result.getErrorCode()); } return smartLock; } GoogleApiClientConnectTask(Activity activity);   }
@Test public void shouldBlockUntilConnectionIsMade() throws Exception { assertThat(task.doInBackground(smartLock), is(smartLock)); verify(client).blockingConnect(eq(5l), eq(TimeUnit.SECONDS)); }