Package org.rssowl.core.internal.persist

Examples of org.rssowl.core.internal.persist.News


   * Tests {@link INewsDAO#setState(Collection, State, boolean, boolean)}.
   */
  @Test
  public void testNewsManagerSetStateWithGuidNull() {
    final IFeed feed = DynamicDAO.save(createFeed());
    final News initialNews = (News) createNews(feed);
    initialNews.setState(State.NEW);
    initialNews.setGuid(null);
    INews newsItem = null;
    NewsReference newsRef = null;
    newsItem = DynamicDAO.save(initialNews);
    newsRef = new NewsReference(newsItem.getId());
    List<INews> newsList = new ArrayList<INews>();
View Full Code Here


      fDb.ext().set(news, 1);
    }
  }

  private RuntimeException createIllegalException(String message, INews newsItem) {
    News dbNews = (News) fDb.ext().peekPersisted(newsItem, 2, true);
    if (dbNews == null)
      return new IllegalArgumentException("The news has been deleted from the persistence layer: " + newsItem);

    return new IllegalStateException(message + ". This news in the db looks like: " //$NON-NLS-1$
        + dbNews.toLongString());
  }
View Full Code Here

  @Test
  public void testIsDateChange() throws Exception {
    Date now = new Date();

    IFeed feed = new Feed(new URI("http://www.link.com"));
    INews news1 = new News(null, feed, new Date());
    news1.setPublishDate(now);

    INews news2 = new News(null, feed, new Date());
    news2.setPublishDate(now);

    INews news3 = new News(null, feed, new Date());
    news3.setPublishDate(new Date(System.currentTimeMillis() + 1000));

    feed.addNews(news1);
    feed.addNews(news2);
    feed.addNews(news3);
View Full Code Here

    IPerson author2 = new Person(null);
    author2.setName("Bar");

    IFeed feed = new Feed(new URI("http://www.link.com"));
    INews news1 = new News(null, feed, new Date());
    news1.setAuthor(author1);

    INews news2 = new News(null, feed, new Date());
    news2.setAuthor(author1);

    INews news3 = new News(null, feed, new Date());
    news3.setPublishDate(new Date(System.currentTimeMillis() + 1000));
    news3.setAuthor(author2);

    INews news4 = new News(null, feed, new Date());

    feed.addNews(news1);
    feed.addNews(news2);
    feed.addNews(news3);
    feed.addNews(news4);
View Full Code Here

    ICategory cat3 = new Category();
    cat3.setName("Cat3");

    IFeed feed = new Feed(new URI("http://www.link.com"));
    INews news1 = new News(null, feed, new Date());
    news1.addCategory(cat1);

    INews news2 = new News(null, feed, new Date());
    news2.addCategory(cat1);

    INews news3 = new News(null, feed, new Date());
    news3.setPublishDate(new Date(System.currentTimeMillis() + 1000));
    news3.addCategory(cat2);

    INews news4 = new News(null, feed, new Date());
    news4.addCategory(cat1);
    news4.addCategory(cat2);

    INews news5 = new News(null, feed, new Date());

    INews news6 = new News(null, feed, new Date());
    news6.addCategory(cat1);
    news6.addCategory(cat2);
    news6.addCategory(cat3);

    INews news7 = new News(null, feed, new Date());
    news7.addCategory(cat1);
    news7.addCategory(cat3);

    feed.addNews(news1);
    feed.addNews(news2);
    feed.addNews(news3);
    feed.addNews(news4);
View Full Code Here

  public void testIsLabelChange() throws Exception {
    ILabel label1 = new Label(null, "Label1");
    ILabel label2 = new Label(null, "Label1");

    IFeed feed = new Feed(new URI("http://www.link.com"));
    INews news1 = new News(null, feed, new Date());
    news1.setLabel(label1);

    INews news2 = new News(null, feed, new Date());
    news2.setLabel(label1);

    INews news3 = new News(null, feed, new Date());
    news3.setPublishDate(new Date(System.currentTimeMillis() + 1000));
    news3.setLabel(label2);

    INews news4 = new News(null, feed, new Date());

    feed.addNews(news1);
    feed.addNews(news2);
    feed.addNews(news3);
    feed.addNews(news4);
View Full Code Here

        IFeed feed = new Feed(feedLink);

        if (withRetention) {
          for (int j = 0; j < 10; j++) {
            INews news = new News(feed);
            news.setTitle("Random Title " + j);
            news.setDescription(getLongDecription());
            news.setLink(new URI("http://www." + System.currentTimeMillis() + ".com/" + rand.nextInt(10000) + j));
            news.setComments("Comments");
            news.setState(INews.State.READ);
            feed.addNews(news);
          }
        }

        feed = DynamicDAO.save(feed);
View Full Code Here

      feed = DynamicDAO.save(createFeed());
    } catch (PersistenceException e) {
      fail(e.getMessage());
      return;
    }
    final News initialNews = (News) createNews(feed);
    final Feed[] initialFeed = new Feed[1];
    final Person[] initialAuthor = new Person[1];
    final Source[] initialSource = new Source[1];
    final Guid[] initialGuid = new Guid[1];
    final News[] updatedNews = new News[1];
    final boolean[] NewsAddedCalled = new boolean[] { false };
    final boolean[] NewsUpdatedCalled = new boolean[] { false };
    NewsListener newsListener = null;
    try {
      newsListener = new NewsAdapter() {
        @Override
        public void entitiesAdded(Set<NewsEvent> events) {
          NewsEvent event = events.iterator().next();
          NewsAddedCalled[0] = true;
          initialFeed[0] = (Feed) initialNews.getFeedReference().resolve();
          initialAuthor[0] = (Person) initialNews.getAuthor();
          initialSource[0] = (Source) initialNews.getSource();
          initialGuid[0] = (Guid) initialNews.getGuid();
          final News dbNews = (News) event.getEntity();
          initialAuthor[0].setId(dbNews.getAuthor().getId());
          initialAuthor[0].isIdentical(dbNews.getAuthor());
          //FIXME Find a way to verify this without changing the id from the
          //event handler
//          initialNews.setId(dbNews.getId());
//          assertTrue(initialNews.isIdentical(dbNews));
        }

        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          NewsEvent event = events.iterator().next();
          NewsUpdatedCalled[0] = true;
          News dbNews = (News) event.getEntity();
          assertTrue(updatedNews[0].isIdentical(dbNews));
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);
      INews news = DynamicDAO.save(initialNews);
View Full Code Here

      feed = DynamicDAO.save(createFeed());
    } catch (PersistenceException e) {
      fail(e.getMessage());
      return;
    }
    final News initialNews = (News) createNews(feed);
    initialNews.setState(State.NEW);
    INews news = null;
    try {
      news = DynamicDAO.save(initialNews);
    } catch (PersistenceException e) {
      fail(e.getMessage());
View Full Code Here

   */
  @Test
  public void testNewsManagerSetState() {
    final IFeed feed;
    feed = DynamicDAO.save(createFeed());
    final News initialNews = (News) createNews(feed);
    initialNews.setState(State.NEW);
    INews newsItem = null;
    NewsReference newsRef = null;
    newsItem = DynamicDAO.save(initialNews);
    newsRef = new NewsReference(newsItem.getId());
    List<INews> newsList = new ArrayList<INews>();
View Full Code Here

TOP

Related Classes of org.rssowl.core.internal.persist.News

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.