AllSharedPreferences { public String fetchRegisteredANM() { return preferences.getString(ANM_IDENTIFIER_PREFERENCE_KEY, "").trim(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); String fetchLanguagePreference(); void saveLanguagePreference(String languagePreference); Boolean fetchIsSyncInProgress(); void saveIsSyncInProgress(Boolean isSyncInProgress); static final String ANM_IDENTIFIER_PREFERENCE_KEY; }
@Test public void shouldFetchANMIdentifierFromPreferences() throws Exception { when(preferences.getString("anmIdentifier", "")).thenReturn("1234"); String actual = allSharedPreferences.fetchRegisteredANM(); verify(preferences).getString("anmIdentifier", ""); assertEquals("1234", actual); }
@Test public void shouldTrimANMIdentifier() throws Exception { when(preferences.getString("anmIdentifier", "")).thenReturn(" 1234 "); String actual = allSharedPreferences.fetchRegisteredANM(); verify(preferences).getString("anmIdentifier", ""); assertEquals("1234", actual); }