Package org.rssowl.core.model.preferences

Examples of org.rssowl.core.model.preferences.IPreferencesScope


    assertEquals(0, getNewCount(feed));

    FeedReference feedRef = new FeedReference(feed.getId());

    IBookMark bookmark = createBookMark(feed);
    IPreferencesScope preferences = NewsModel.getDefault().getEntityScope(bookmark);
    preferences.putInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE, 0);
    preferences.putBoolean(DefaultPreferences.DEL_NEWS_BY_COUNT_STATE, true);

    /* First Reload */
    InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null);
    fController.reload(bookmark, null, new NullProgressMonitor());
    assertEquals(1, feedRef.resolve().getNews().size());
View Full Code Here


      };
      NewsModel.getDefault().addBookMarkListener(bookmarkListener);

      IMark mark = folder.getMarks().get(0);

      IPreferencesScope bookmarkScope = NewsModel.getDefault().getEntityScope(mark);
      bookmarkScope.putString("key1", "value1");
      bookmarkScope.flush();

      assertEquals(1, eventsCounter[0]);

      bookmarkScope.putString("key2", "value2");
      bookmarkScope.flush();

      assertEquals(2, eventsCounter[0]);
    } finally {
      if (bookmarkListener != null)
        NewsModel.getDefault().removeBookMarkListener(bookmarkListener);
View Full Code Here

  /**
   * @throws Exception
   */
  @Test
  public final void testPreferencesInitializer() throws Exception {
    IPreferencesScope defaultScope = NewsModel.getDefault().getDefaultScope();
    assertEquals(true, defaultScope.getBoolean(TEST_BOOLEAN));
    assertEquals(1, defaultScope.getInteger(TEST_INTEGER));
    assertEquals(true, Arrays.equals(new int[] { 1, 2, 3 }, defaultScope.getIntegers(TEST_INTEGERS)));
    assertEquals("foo", defaultScope.getString(TEST_STRING));
    assertEquals(true, Arrays.equals(new String[] { "foo", "bar" }, defaultScope.getStrings(TEST_STRINGS)));
    assertEquals(1L, defaultScope.getLong(TEST_LONG));
    assertEquals(true, Arrays.equals(new long[] { 1L, 2L, 3L }, defaultScope.getLongs(TEST_LONGS)));
  }
View Full Code Here

  /**
   * @throws Exception
   */
  @Test
  public final void testGlobalScope() throws Exception {
    IPreferencesScope globalScope = NewsModel.getDefault().getGlobalScope();

    /* Test Defaults Taken */
    assertEquals(true, globalScope.getBoolean(TEST_BOOLEAN));
    assertEquals(1, globalScope.getInteger(TEST_INTEGER));
    assertEquals(true, Arrays.equals(new int[] { 1, 2, 3 }, globalScope.getIntegers(TEST_INTEGERS)));
    assertEquals("foo", globalScope.getString(TEST_STRING));
    assertEquals(true, Arrays.equals(new String[] { "foo", "bar" }, globalScope.getStrings(TEST_STRINGS)));
    assertEquals(1L, globalScope.getLong(TEST_LONG));
    assertEquals(true, Arrays.equals(new long[] { 1L, 2L, 3L }, globalScope.getLongs(TEST_LONGS)));

    /* Change Settings and test again */
    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 });

    /* Test new Settings */
    assertEquals(false, globalScope.getBoolean(TEST_BOOLEAN));
    assertEquals(2, globalScope.getInteger(TEST_INTEGER));
    assertEquals(true, Arrays.equals(new int[] { 4, 5, 6, 7, 8 }, globalScope.getIntegers(TEST_INTEGERS)));
    assertEquals("hello", globalScope.getString(TEST_STRING));
    assertEquals(true, Arrays.equals(new String[] { "hello", "world", "!" }, globalScope.getStrings(TEST_STRINGS)));
    assertEquals(2L, globalScope.getLong(TEST_LONG));
    assertEquals(true, Arrays.equals(new long[] { 4L, 5L, 6L, 7L, 8L }, globalScope.getLongs(TEST_LONGS)));

    /* Delete Settings */
    globalScope.delete(TEST_BOOLEAN);
    globalScope.delete(TEST_INTEGER);
    globalScope.delete(TEST_INTEGERS);
    globalScope.delete(TEST_STRING);
    globalScope.delete(TEST_STRINGS);
    globalScope.delete(TEST_LONG);
    globalScope.delete(TEST_LONGS);

    /* Test Defaults Again */
    assertEquals(true, globalScope.getBoolean(TEST_BOOLEAN));
    assertEquals(1, globalScope.getInteger(TEST_INTEGER));
    assertEquals(true, Arrays.equals(new int[] { 1, 2, 3 }, globalScope.getIntegers(TEST_INTEGERS)));
    assertEquals("foo", globalScope.getString(TEST_STRING));
    assertEquals(true, Arrays.equals(new String[] { "foo", "bar" }, globalScope.getStrings(TEST_STRINGS)));
    assertEquals(1L, globalScope.getLong(TEST_LONG));
    assertEquals(true, Arrays.equals(new long[] { 1L, 2L, 3L }, globalScope.getLongs(TEST_LONGS)));
  }
View Full Code Here

    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));
View Full Code Here

      else if (mark.getName().equals("BookMark3"))
        bookMark3 = (IBookMark) mark;
    }

    /* Preferences */
    IPreferencesScope prefs1 = NewsModel.getDefault().getEntityScope(bookMark1);
    IPreferencesScope prefs2 = NewsModel.getDefault().getEntityScope(bookMark2);
    IPreferencesScope prefs3 = NewsModel.getDefault().getEntityScope(bookMark3);

    /* Setup Retention */
    prefs1.putBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE, true);
    prefs2.putBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE, true);
    prefs3.putBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE, true);

    /* Run and Validate Retention */
    prefs1.putInteger(DefaultPreferences.DEL_NEWS_BY_AGE_VALUE, 20);
    prefs2.putInteger(DefaultPreferences.DEL_NEWS_BY_AGE_VALUE, 20);
    prefs3.putInteger(DefaultPreferences.DEL_NEWS_BY_AGE_VALUE, 20);
    RetentionStrategy.process(folder);
    assertEquals(200, countNews(folder));
    assertEquals(100, countNews(bookMark1));
    assertEquals(100, countNews(bookMark2));
    assertEquals(0, countNews(bookMark3));
View Full Code Here

      else if (mark.getName().equals("BookMark3"))
        bookMark3 = (IBookMark) mark;
    }

    /* Preferences */
    IPreferencesScope prefs1 = NewsModel.getDefault().getEntityScope(bookMark1);
    IPreferencesScope prefs2 = NewsModel.getDefault().getEntityScope(bookMark2);
    IPreferencesScope prefs3 = NewsModel.getDefault().getEntityScope(bookMark3);

    /* Setup Retention */
    prefs1.putBoolean(DefaultPreferences.DEL_READ_NEWS_STATE, true);
    prefs2.putBoolean(DefaultPreferences.DEL_READ_NEWS_STATE, true);
    prefs3.putBoolean(DefaultPreferences.DEL_READ_NEWS_STATE, true);

    /* Run and Validate Retention */
    RetentionStrategy.process(folder);
    assertEquals(150, countNews(folder));
    assertEquals(100, countNews(bookMark1));
View Full Code Here

      else if (mark.getName().equals("BookMark3"))
        bookMark3 = (IBookMark) mark;
    }

    /* Preferences */
    IPreferencesScope prefs1 = NewsModel.getDefault().getEntityScope(bookMark1);
    IPreferencesScope prefs2 = NewsModel.getDefault().getEntityScope(bookMark2);
    IPreferencesScope prefs3 = NewsModel.getDefault().getEntityScope(bookMark3);

    /* Setup Retention */
    prefs1.putBoolean(DefaultPreferences.DEL_NEWS_BY_COUNT_STATE, true);
    prefs2.putBoolean(DefaultPreferences.DEL_NEWS_BY_COUNT_STATE, true);
    prefs3.putBoolean(DefaultPreferences.DEL_NEWS_BY_COUNT_STATE, true);

    /* Run and Validate Retention */
    prefs1.putInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE, 20);
    prefs2.putInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE, 40);
    prefs3.putInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE, 80);
    RetentionStrategy.process(folder);
    assertEquals(140, countNews(folder));
    assertEquals(20, countNews(bookMark1));
    assertEquals(40, countNews(bookMark2));
    assertEquals(80, countNews(bookMark3));
View Full Code Here

      else if (mark.getName().equals("BookMark3"))
        bookMark3 = (IBookMark) mark;
    }

    /* Preferences */
    IPreferencesScope prefs1 = NewsModel.getDefault().getEntityScope(bookMark1);
    IPreferencesScope prefs2 = NewsModel.getDefault().getEntityScope(bookMark2);
    IPreferencesScope prefs3 = NewsModel.getDefault().getEntityScope(bookMark3);

    /* Setup Retention */
    prefs1.putBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE, true);
    prefs2.putBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE, true);
    prefs3.putBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE, true);
    prefs1.putBoolean(DefaultPreferences.DEL_NEWS_BY_COUNT_STATE, true);
    prefs2.putBoolean(DefaultPreferences.DEL_NEWS_BY_COUNT_STATE, true);
    prefs3.putBoolean(DefaultPreferences.DEL_NEWS_BY_COUNT_STATE, true);

    /* Run and Validate Retention */
    prefs1.putInteger(DefaultPreferences.DEL_NEWS_BY_AGE_VALUE, 20);
    prefs2.putInteger(DefaultPreferences.DEL_NEWS_BY_AGE_VALUE, 20);
    prefs3.putInteger(DefaultPreferences.DEL_NEWS_BY_AGE_VALUE, 20);
    prefs1.putInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE, 20);
    prefs2.putInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE, 40);
    prefs3.putInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE, 80);
    RetentionStrategy.process(folder);
    assertEquals(60, countNews(folder));
    assertEquals(20, countNews(bookMark1));
    assertEquals(40, countNews(bookMark2));
    assertEquals(0, countNews(bookMark3));
View Full Code Here

      else if (mark.getName().equals("BookMark3"))
        bookMark3 = (IBookMark) mark;
    }

    /* Preferences */
    IPreferencesScope prefs1 = NewsModel.getDefault().getEntityScope(bookMark1);
    IPreferencesScope prefs2 = NewsModel.getDefault().getEntityScope(bookMark2);
    IPreferencesScope prefs3 = NewsModel.getDefault().getEntityScope(bookMark3);

    /* Setup Retention */
    prefs1.putBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE, true);
    prefs2.putBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE, true);
    prefs3.putBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE, true);
    prefs1.putBoolean(DefaultPreferences.DEL_READ_NEWS_STATE, true);
    prefs2.putBoolean(DefaultPreferences.DEL_READ_NEWS_STATE, true);
    prefs3.putBoolean(DefaultPreferences.DEL_READ_NEWS_STATE, true);

    /* Run and Validate Retention */
    prefs1.putInteger(DefaultPreferences.DEL_NEWS_BY_AGE_VALUE, 20);
    prefs2.putInteger(DefaultPreferences.DEL_NEWS_BY_AGE_VALUE, 20);
    prefs3.putInteger(DefaultPreferences.DEL_NEWS_BY_AGE_VALUE, 20);
    RetentionStrategy.process(folder);
    assertEquals(150, countNews(folder));
    assertEquals(100, countNews(bookMark1));
    assertEquals(50, countNews(bookMark2));
    assertEquals(0, countNews(bookMark3));
View Full Code Here

TOP

Related Classes of org.rssowl.core.model.preferences.IPreferencesScope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.