Store { boolean isEmpty() { String objJson = prefs.getString(TAG, null); obj = new Gson().fromJson(objJson, cls); return obj == null; } Store(SharedPreferences prefs, Class<T> cls);   }
@Test public void isEmptyReturnsFalse() { when(prefs.getString("object", null)).thenReturn(new Gson().toJson(entity)); assertThat(store.isEmpty(), equalTo(false)); }
@Test public void isEmptyReturnsTrue() { when(prefs.getString("object", null)).thenReturn(null); assertThat(store.isEmpty(), equalTo(true)); }