title: How would you write a test for this method using Mockito?
body: <p>Please assist in this. I can't seem to create a suitable test for this method:</p>
  
  <pre><code>protected void startInterfacing() {
  
      mLiveAuthClient.login(mView.context(), Arrays.asList(SCOPES), new LiveAuthListener() {
  
          @Override
          public void onAuthComplete(final LiveStatus liveStatus, final LiveConnectSession liveConnectSession,
                                     Object o) {
  
              // Login successful and user consented, now retrieve user ID and connect with backend server
              getUserIdAndConnectWithBackendServer(liveConnectSession, mLiveAuthClient);
          }
  
          @Override
          public void onAuthError(LiveAuthException e, Object o) {
              // We failed to authenticate with auth service... show error
              if (e.getError().equals("access_denied") ||
                      e.getMessage().equals("The user cancelled the login operation.")) {
  
                  // When user cancels in either the login or consent page, we need to log the user out to enable
                  // the login screen again when trying to connect later on
                  logUserOut(mLiveAuthClient, false);
              } else {
                  onErrorOccured();
              }
          }
      });
  }
  </code></pre>
  
  <p>I'll explain abit what goes on here:
  I'm trying to authenticate my client and log into OneDrive.
  The method starts with a call to the Live SDK's login method. That SDK object is given to me from outside this class. So I can basically mock it.
  Here's what I'm struggling with:</p>
  
  <ol>
  <li><p>I do not need to test the call to the login method because it is not mine. I do need to test the call to  getUserIdAndConnectWithBackendServer() inside onAuthComplete. But this method requires a liveConnectSession object. How do I provide that? It is given to me on the onAuthComplete method.</p></li>
  <li><p>How do I mock the calls to onAuthComplete and onAuthError? I read about ArgumentCaptor but when I use that, I need to provide the arguments to those methods when I call the actual method.
  For instance, argument.getValue().onAuthComplete() requires me to add arguments to this call. What do I actually provide here?</p></li>
  </ol>
  
  <p>Here is the next method which is roughly the same but has its own issues:</p>
  
  <pre><code> protected void getUserIdAndConnectWithBackendServer(final LiveConnectSession liveConnectSession, final LiveAuthClient
          authClient) {
  
      final LiveConnectClient connectClient =  new LiveConnectClient(liveConnectSession);
  
      connectClient.getAsync("me", new LiveOperationListener() {
          @Override
          public void onComplete(LiveOperation liveOperation) {
  
              // We got a result. Check for errors...
              JSONObject result = liveOperation.getResult();
              if (result.has(ERROR)) {
                  JSONObject error = result.optJSONObject(ERROR);
                  String code = error.optString(CODE);
                  String message = error.optString(MESSAGE);
                  onErrorOccured();
              } else {
                  connectWithBackend(result, liveConnectSession, authClient);
              }
          }
  
          @Override
          public void onError(LiveOperationException e, LiveOperation liveOperation) {
              // We failed to retrieve user information.... show error
              onErrorOccured();
              logUserOut(authClient, false);
          }
      });
  }
  </code></pre>
  
  <p>In here I would like to mock the JSONObject for instance. But how do I call the onComplete method, or the onError method. And what would I provide as the arguments the methods provide me with. LiveOperation for instance?</p>
  
  <p>Thank you!!</p>