@Test public void whenPreferencesAreAdded_returnsTrue() { PreferenceFragmentCompat fragment = mock(PreferenceFragmentCompat.class); AggregatePreferencesAdder loader = new AggregatePreferencesAdder(fragment); boolean result = loader.add(); assertTrue(result); }
public boolean add() { try { fragment.addPreferencesFromResource(R.xml.odk_server_preferences); return true; } catch (ClassCastException e) { Toast.makeText(fragment.getActivity(), R.string.corrupt_imported_preferences_error, Toast.LENGTH_LONG).show(); return false; } }
AggregatePreferencesAdder { public boolean add() { try { fragment.addPreferencesFromResource(R.xml.odk_server_preferences); return true; } catch (ClassCastException e) { Toast.makeText(fragment.getActivity(), R.string.corrupt_imported_preferences_error, Toast.LENGTH_LONG).show(); return false; } } }
AggregatePreferencesAdder { public boolean add() { try { fragment.addPreferencesFromResource(R.xml.odk_server_preferences); return true; } catch (ClassCastException e) { Toast.makeText(fragment.getActivity(), R.string.corrupt_imported_preferences_error, Toast.LENGTH_LONG).show(); return false; } } AggregatePreferencesAdder(PreferenceFragmentCompat fragment); }
AggregatePreferencesAdder { public boolean add() { try { fragment.addPreferencesFromResource(R.xml.odk_server_preferences); return true; } catch (ClassCastException e) { Toast.makeText(fragment.getActivity(), R.string.corrupt_imported_preferences_error, Toast.LENGTH_LONG).show(); return false; } } AggregatePreferencesAdder(PreferenceFragmentCompat fragment); boolean add(); }
AggregatePreferencesAdder { public boolean add() { try { fragment.addPreferencesFromResource(R.xml.odk_server_preferences); return true; } catch (ClassCastException e) { Toast.makeText(fragment.getActivity(), R.string.corrupt_imported_preferences_error, Toast.LENGTH_LONG).show(); return false; } } AggregatePreferencesAdder(PreferenceFragmentCompat fragment); boolean add();  }