feed = fDao.saveFeed(feed);
fFactory.createBookMark(null, folder, feed.getLink(),
new FeedReference(feed.getId()), "BookMark");
folder = fDao.saveFolder(folder);
IPreferencesScope entityScope = NewsModel.getDefault().getEntityScope(folder);
/* Test Defaults Taken */
assertEquals(true, entityScope.getBoolean(TEST_BOOLEAN));
assertEquals(1, entityScope.getInteger(TEST_INTEGER));
assertEquals(true, Arrays.equals(new int[] { 1, 2, 3 }, entityScope.getIntegers(TEST_INTEGERS)));
assertEquals("foo", entityScope.getString(TEST_STRING));
assertEquals(true, Arrays.equals(new String[] { "foo", "bar" }, entityScope.getStrings(TEST_STRINGS)));
assertEquals(1L, entityScope.getLong(TEST_LONG));
assertEquals(true, Arrays.equals(new long[] { 1L, 2L, 3L }, entityScope.getLongs(TEST_LONGS)));
/* Change Settings and test again */
entityScope.putBoolean(TEST_BOOLEAN, false);
entityScope.putInteger(TEST_INTEGER, 2);
entityScope.putIntegers(TEST_INTEGERS, new int[] { 4, 5, 6, 7, 8 });
entityScope.putString(TEST_STRING, "hello");
entityScope.putStrings(TEST_STRINGS, new String[] { "hello", "world", "!" });
entityScope.putLong(TEST_LONG, 2L);
entityScope.putLongs(TEST_LONGS, new long[] { 4L, 5L, 6L, 7L, 8L });
entityScope.flush();
/* Test new Settings */
assertEquals(false, entityScope.getBoolean(TEST_BOOLEAN));
assertEquals(2, entityScope.getInteger(TEST_INTEGER));
assertEquals(true, Arrays.equals(new int[] { 4, 5, 6, 7, 8 }, entityScope.getIntegers(TEST_INTEGERS)));
assertEquals("hello", entityScope.getString(TEST_STRING));
assertEquals(true, Arrays.equals(new String[] { "hello", "world", "!" }, entityScope.getStrings(TEST_STRINGS)));
assertEquals(2L, entityScope.getLong(TEST_LONG));
assertEquals(true, Arrays.equals(new long[] { 4L, 5L, 6L, 7L, 8L }, entityScope.getLongs(TEST_LONGS)));
/* Delete Settings */
entityScope.delete(TEST_BOOLEAN);
entityScope.delete(TEST_INTEGER);
entityScope.delete(TEST_INTEGERS);
entityScope.delete(TEST_STRING);
entityScope.delete(TEST_STRINGS);
entityScope.delete(TEST_LONG);
entityScope.delete(TEST_LONGS);
entityScope.flush();
/* Test Defaults Again */
assertEquals(true, entityScope.getBoolean(TEST_BOOLEAN));
assertEquals(1, entityScope.getInteger(TEST_INTEGER));
assertEquals(true, Arrays.equals(new int[] { 1, 2, 3 }, entityScope.getIntegers(TEST_INTEGERS)));
assertEquals("foo", entityScope.getString(TEST_STRING));
assertEquals(true, Arrays.equals(new String[] { "foo", "bar" }, entityScope.getStrings(TEST_STRINGS)));
assertEquals(1L, entityScope.getLong(TEST_LONG));
assertEquals(true, Arrays.equals(new long[] { 1L, 2L, 3L }, entityScope.getLongs(TEST_LONGS)));
/* Test Global Settings Taken */
IPreferencesScope globalScope = NewsModel.getDefault().getGlobalScope();
globalScope.putBoolean(TEST_BOOLEAN, false);
globalScope.putInteger(TEST_INTEGER, 2);
globalScope.putIntegers(TEST_INTEGERS, new int[] { 4, 5, 6, 7, 8 });
globalScope.putString(TEST_STRING, "hello");
globalScope.putStrings(TEST_STRINGS, new String[] { "hello", "world", "!" });
globalScope.putLong(TEST_LONG, 2L);
globalScope.putLongs(TEST_LONGS, new long[] { 4L, 5L, 6L, 7L, 8L });
assertEquals(false, entityScope.getBoolean(TEST_BOOLEAN));
assertEquals(2, entityScope.getInteger(TEST_INTEGER));
assertEquals(true, Arrays.equals(new int[] { 4, 5, 6, 7, 8 }, entityScope.getIntegers(TEST_INTEGERS)));
assertEquals("hello", entityScope.getString(TEST_STRING));