LoginServiceImpl extends BaseRetrofitService<LoginRepository> implements org.unicef.rapidreg.service
        .LoginService { @Override public boolean isUsernameValid(String username) { return username != null && username.matches("\\A[^ ]+\\z"); } LoginServiceImpl(ConnectivityManager connectivityManager,
                            TelephonyManager telephonyManager,
                            UserDao userDao); @Override boolean isOnline(); @Override void loginOnline(final String username,
                            final String password,
                            final String url,
                            String imei,
                            final LoginCallback callback); @Override void loginOffline(String username, String password, String url, LoginCallback callback); @Override void destroy(); @Override String loadLastLoginServerUrl(); @Override boolean isUsernameValid(String username); @Override boolean isPasswordValid(String password); @Override boolean isUrlValid(String url);  }
@Test public void should_return_true_when_username_is_valid() { assertThat(loginService.isUsernameValid("Jack"), CoreMatchers.is(true)); }
@Test public void should_return_false_when_username_is_empty() { assertThat(loginService.isUsernameValid(null), CoreMatchers.is(false)); assertThat(loginService.isUsernameValid(""), CoreMatchers.is(false)); }
@Test public void should_return_false_when_username_is_invalid() { assertThat(loginService.isUsernameValid("Ja ck"), CoreMatchers.is(false)); }