RegisterUnverifiedUserAsyncTask extends AsyncTask<String, String, Boolean> { @Override protected Boolean doInBackground(String... url) { this.serverUrl = url[0]; try { HttpResponse response = registerUserService.register(user); return response.getStatusLine().getStatusCode() == SC_CREATED; } catch (IOException e) { return false; } } @Inject  RegisterUnverifiedUserAsyncTask(RegisterUserService registerUserService, User user, RapidFtrApplication context);   }
@Test public void shouldCallRegisterUserServiceToRegisterUser() throws IOException { RegisterUnverifiedUserAsyncTask registerUserTask = new RegisterUnverifiedUserAsyncTask(registerUserService, user, context); given(registerUserService.register(user)).willReturn(new FluentResponse(new TestHttpResponse(201, "created"))); assertThat(registerUserTask.doInBackground("url"), is(true)); }