Package org.rssowl.ui.internal.editors.feed

Examples of org.rssowl.ui.internal.editors.feed.NewsBrowserViewModel


    EntityGroup group1 = new EntityGroup(100, "foo");
    EntityGroup group2 = new EntityGroup(101, "foo");

    Object[] elements = new Object[] { group1, news1, news2, group2, news3, feed };
    NewsBrowserViewModel model = new NewsBrowserViewModel(null);
    model.setInput(elements, 0);

    assertFalse(model.isFirstItemUnread());

    assertEquals(-1L, model.findGroup(5L));
    assertEquals(100L, model.findGroup(1L));
    assertEquals(100L, model.findGroup(2L));
    assertEquals(101L, model.findGroup(3L));

    assertEquals(-1L, model.getExpandedNews());
    model.setNewsExpanded(news3, true);
    assertEquals(3L, model.getExpandedNews());

    assertEquals(2, model.getGroups().size());
    assertEquals(2, model.getGroupSize(100L));
    assertEquals(1, model.getGroupSize(101L));

    Map<Long, List<Long>> groups = model.getGroups();
    List<Long> group_1 = groups.get(100L);
    List<Long> group_2 = groups.get(101L);
    assertEquals(1, group_1.get(0).longValue());
    assertEquals(2, group_1.get(1).longValue());
    assertEquals(3, group_2.get(0).longValue());

    List<Long> newsIds = model.getNewsIds(100L);
    assertEquals(1, newsIds.get(0).longValue());
    assertEquals(2, newsIds.get(1).longValue());

    assertFalse(model.hasGroup(5L));
    assertTrue(model.hasGroup(100L));
    assertTrue(model.hasGroup(101L));

    assertFalse(model.isNewsExpanded(news2));
    assertTrue(model.isNewsExpanded(news3));

    assertTrue(model.isGroupExpanded(5L));
    model.setGroupExpanded(100L, false);
    assertFalse(model.isGroupExpanded(100L));

    assertEquals(1L, model.nextNews(false, -1L));
    assertEquals(1L, model.nextNews(true, -1L));
    assertEquals(2L, model.nextNews(false, 1L));
    assertEquals(3L, model.nextNews(true, 1L));
    assertEquals(-1L, model.nextNews(true, 3L));
    assertEquals(1L, model.nextNews(true, 5L));
    assertEquals(-1L, model.nextNews(false, 3L));
    assertEquals(1L, model.nextNews(false, 5L));

    assertEquals(3L, model.previousNews(false, -1L));
    assertEquals(3L, model.previousNews(true, -1L));
    assertEquals(-1L, model.previousNews(false, 1L));
    assertEquals(-1L, model.previousNews(true, 1L));
    assertEquals(2L, model.previousNews(false, 3L));
    assertEquals(1L, model.previousNews(true, 3L));
    assertEquals(3L, model.previousNews(true, 5L));
    assertEquals(3L, model.previousNews(false, 5L));

    assertEquals(100L, model.removeNews(news1));
    assertTrue(model.hasGroup(100L));
    assertEquals(100L, model.removeNews(news2));
    assertFalse(model.hasGroup(100L));
    assertEquals(101L, model.removeNews(news3));
    assertFalse(model.hasGroup(101L));

    assertFalse(model.isNewsExpanded(news1));
    assertFalse(model.isNewsExpanded(news2));
    assertFalse(model.isNewsExpanded(news3));

    assertEquals(0, model.getGroups().size());
    assertEquals(0, model.getGroupSize(100L));
    assertEquals(0, model.getGroupSize(101L));

    assertTrue(model.getNewsIds(100L).isEmpty());

    Pair<List<Long>, List<Long>> nextPage = model.getNextPage(0);
    assertTrue(nextPage.getFirst().isEmpty());
    assertTrue(nextPage.getSecond().isEmpty());

    nextPage = model.getNextPage(5);
    assertTrue(nextPage.getFirst().isEmpty());
    assertTrue(nextPage.getSecond().isEmpty());

    Pair<List<Long>, List<Long>> revealed = model.revealPage(5L, 0);
    assertTrue(revealed.getFirst().isEmpty());
    assertTrue(revealed.getSecond().isEmpty());
  }
View Full Code Here

TOP

Related Classes of org.rssowl.ui.internal.editors.feed.NewsBrowserViewModel

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.