@Test public void getServers_whenEmpty_returnsDefault() { assertThat(repository.getServers(), contains(defaultServer)); }
@Override public List<String> getServers() { String urlListString = getSharedPreferences().getString(MetaKeys.SERVER_LIST, null); return urlListString == null || urlListString.isEmpty() ? new ArrayList<>(Collections.singletonList(defaultServer)) : new Gson().fromJson(urlListString, new TypeToken<List<String>>() {}.getType()); }
SharedPreferencesServerRepository implements ServerRepository { @Override public List<String> getServers() { String urlListString = getSharedPreferences().getString(MetaKeys.SERVER_LIST, null); return urlListString == null || urlListString.isEmpty() ? new ArrayList<>(Collections.singletonList(defaultServer)) : new Gson().fromJson(urlListString, new TypeToken<List<String>>() {}.getType()); } }
SharedPreferencesServerRepository implements ServerRepository { @Override public List<String> getServers() { String urlListString = getSharedPreferences().getString(MetaKeys.SERVER_LIST, null); return urlListString == null || urlListString.isEmpty() ? new ArrayList<>(Collections.singletonList(defaultServer)) : new Gson().fromJson(urlListString, new TypeToken<List<String>>() {}.getType()); } SharedPreferencesServerRepository(String defaultServer, SharedPreferences sharedPreferences); }
SharedPreferencesServerRepository implements ServerRepository { @Override public List<String> getServers() { String urlListString = getSharedPreferences().getString(MetaKeys.SERVER_LIST, null); return urlListString == null || urlListString.isEmpty() ? new ArrayList<>(Collections.singletonList(defaultServer)) : new Gson().fromJson(urlListString, new TypeToken<List<String>>() {}.getType()); } SharedPreferencesServerRepository(String defaultServer, SharedPreferences sharedPreferences); @Override void save(String url); @Override List<String> getServers(); @Override void clear(); }
SharedPreferencesServerRepository implements ServerRepository { @Override public List<String> getServers() { String urlListString = getSharedPreferences().getString(MetaKeys.SERVER_LIST, null); return urlListString == null || urlListString.isEmpty() ? new ArrayList<>(Collections.singletonList(defaultServer)) : new Gson().fromJson(urlListString, new TypeToken<List<String>>() {}.getType()); } SharedPreferencesServerRepository(String defaultServer, SharedPreferences sharedPreferences); @Override void save(String url); @Override List<String> getServers(); @Override void clear();  }