ChangePasswordTask extends AsyncTask<String, Boolean, Boolean> { @Override protected Boolean doInBackground(String... params) { try { currentPassword = params[0]; newPassword = params[1]; HttpResponse response = changePasswordService.updatePassword(currentPassword, newPassword , params[2]); return response.getStatusLine().getStatusCode() == SC_OK; } catch (IOException e) { return false; } } @Inject  ChangePasswordTask(ChangePasswordService changePasswordService, RapidFtrApplication context); void setActivity(Activity activity);  }
@Test public void shouldCallUpdatePassword() throws IOException { doReturn(new FluentResponse(new TestHttpResponse(201, "created"))).when(changePasswordService).updatePassword("param1", "param2", "param3"); changePasswordTask.doInBackground("param1", "param2", "param3"); verify(changePasswordService).updatePassword("param1", "param2", "param3"); }