BaseRx { protected GoogleApiClient createApiClient(ApiClientConnectionCallbacks apiClientConnectionCallbacks) { GoogleApiClient.Builder apiClientBuilder = getApiClientBuilder(); for (Api<? extends Api.ApiOptions.NotRequiredOptions> service : services) { apiClientBuilder.addApi(service); } if(scopes != null) { for (Scope scope : scopes) { apiClientBuilder.addScope(scope); } } apiClientBuilder.addConnectionCallbacks(apiClientConnectionCallbacks); apiClientBuilder.addOnConnectionFailedListener(apiClientConnectionCallbacks); GoogleApiClient apiClient = apiClientBuilder.build(); apiClientConnectionCallbacks.setClient(apiClient); return apiClient; } protected  BaseRx(@NonNull RxWear rxWear, Long timeout, TimeUnit timeUnit); protected  BaseRx(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] services, Scope[] scopes);   }
@Test public void createApiClient() { GoogleApiClient.Builder builder = Mockito.mock(GoogleApiClient.Builder.class); BaseRx<Object> baseRx = spy(new BaseRx<Object>(rxWear, null, null) { }); doReturn(builder).when(baseRx).getApiClientBuilder(); doReturn(apiClient).when(builder).build(); BaseRx.ApiClientConnectionCallbacks callbacks = Mockito.mock(BaseRx.ApiClientConnectionCallbacks.class); assertEquals(apiClient, baseRx.createApiClient(callbacks)); verify(builder).addApi(Wearable.API); verify(builder).addConnectionCallbacks(callbacks); verify(builder).addOnConnectionFailedListener(callbacks); verify(builder, never()).addScope(Matchers.any(Scope.class)); verify(callbacks).setClient(Matchers.any(GoogleApiClient.class)); }