    @Test
    public void testFailedLogin() {

        final String username = "username";
        final String password = "password";

        authenticator.mAuthenticator = mock(fi.bitrite.android.ws.auth.Authenticator.class);
        when(authenticator.mAuthenticator.login(
                new Account(username, MOCK_ACCOUNT_TYPE),
                password,
                false))
                .thenReturn(Observable.just(Authenticator.AuthResult.error(
                        401,
                        "[\"Wrong username or password.\"]",
                        Authenticator.AuthResult.ErrorCause.WrongUsernameOrPassword)));

        authenticator.mTxtUsername.setText(username);
        authenticator.mTxtPassword.setText(password);
        authenticator.mCkbRememberPassword.setChecked(false);
        authenticator.mBtnLogin.performClick();

        Robolectric.flushBackgroundThreadScheduler();
        Robolectric.flushForegroundThreadScheduler();

        assertThat(authenticator.isFinishing()).isFalse();
    }