### Question:
GoogleAsrKey { public void store(SharedPreferences pref){ pref.edit() .putString(PREF_KEY,key) .apply(); } GoogleAsrKey(CharSequence k); static @Nullable GoogleAsrKey loadKey(SharedPreferences pref); String getKey(); void store(SharedPreferences pref);  }### Answer:
@Test @SuppressLint("CommitPrefEdits") public void keyIsStoredInPreference(){ SharedPreferences pref = mock(SharedPreferences.class); SharedPreferences.Editor editor = mock(SharedPreferences.Editor.class); when(pref.edit()).thenReturn(editor); when(editor.putString(anyString(),anyString())).thenReturn(editor); GoogleAsrKey key = new GoogleAsrKey(FAKE_KEY); key.store(pref); verify(pref).edit(); verify(editor).putString(anyString(),eq(FAKE_KEY)); }