### Question:
GoogleAsrKey { public static @Nullable GoogleAsrKey loadKey(SharedPreferences pref) { String key = pref.getString(PREF_KEY, null); if (key != null) try { return new GoogleAsrKey(key); } catch (IllegalArgumentException e){ return null; } else return null; } GoogleAsrKey(CharSequence k); static @Nullable GoogleAsrKey loadKey(SharedPreferences pref); String getKey(); void store(SharedPreferences pref);  }### Answer:
@Test public void returnNullIfKeyIsNotStoredInPreference(){ SharedPreferences pref = mock(SharedPreferences.class); when(pref.getString(anyString(),anyString())).thenReturn(null); GoogleAsrKey key = GoogleAsrKey.loadKey(pref); assertNull(key); }
@Test public void returnNullIfInvalidKeyIsStoredInPreference(){ SharedPreferences pref = mock(SharedPreferences.class); when(pref.getString(anyString(),anyString())).thenReturn(INVALID_SMALL_KEY); GoogleAsrKey key = GoogleAsrKey.loadKey(pref); assertNull(key); }