Package org.rssowl.core.model.events

Examples of org.rssowl.core.model.events.NewsAdapter


    feed = fDao.saveFeed(feed);

    final INews savedNews = feed.getNews().get(0);
    savedNews.setTitle("News Title Updated #1");

    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(true, event.getEntity().equals(savedNews));
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UNREAD, event.getEntity().getState());
      }
    };
    fModel.addNewsListener(newsListener);
    try {
      feed = fDao.saveFeed(feed);
    } finally {
      fModel.removeNewsListener(newsListener);
    }
    newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(savedNews.getId(), event.getEntity().getId());
View Full Code Here


    INews savedNews = feed.getNews().get(0);
    final Long savedNewsId = savedNews.getId();
    savedNews.setTitle("News Title Updated #1");

    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(savedNewsId, event.getEntity().getId());
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UNREAD, event.getEntity().getState());
      }
    };
    fModel.addNewsListener(newsListener);
    try {
      savedNews = fDao.saveNews(savedNews);
    } finally {
      fModel.removeNewsListener(newsListener);
    }
    newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(savedNewsId, event.getEntity().getId());
View Full Code Here

      news2.setLink(new URI("http://www.news.com/news2.html"));
      final INews news3 = fFactory.createNews(null, feed, new Date());
      news3.setTitle("News3 Title");
      news3.setLink(new URI("http://www.news.com/news3.html"));
      final boolean newsReceived[] = new boolean[3];
      newsListener = new NewsAdapter() {
        @Override
        public void newsAdded(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());
View Full Code Here

      /* Check News Added */
      final INews news = fFactory.createNews(null, feedReference.resolve(), new Date());
      news.setTitle("News Title");
      final boolean newsAdded[] = new boolean[1];
      newsListener = new NewsAdapter() {
        @Override
        public void newsAdded(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            if (event.getEntity().getTitle().equals(news.getTitle()))
View Full Code Here

      final IAttachment attachment1 = fFactory.createAttachment(null, news);
      attachment1.setUrl(new URI("http://www.attachment1.com"));
      fDao.saveNews(news);

      final boolean[] newsUpdated = new boolean[1];
      newsListener = new NewsAdapter() {
        @Override
        public void newsUpdated(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());
            if (event.getEntity().getTitle().equals(news.getTitle()))
View Full Code Here

    FeedListener feedListener = null;
    NewsListener newsListener = null;
    AttachmentListener attachmentListener = null;
    PersonListener personListener = null;
    CategoryListener categoryListener = null;
    NewsAdapter newsAdapter = null;
    try {

      /* Check Feed Deleted and News Deleted */
      final IFeed feed = fFactory.createFeed(null, new URL("http://www.foobar.com"));
      final IPerson person1 = fFactory.createPerson(null, feed);
      person1.setName("Person1");
      final FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());
      final PersonReference personRef1 = new PersonReference(feedRef.resolve().getAuthor().getId());
      final boolean feedDeleted[] = new boolean[1];
      final boolean newsDeletedFromFeed[] = new boolean[1];
      feedListener = new FeedAdapter() {
        @Override
        public void feedDeleted(Set<FeedEvent> events) {
          for (FeedEvent event : events) {
            assertFalse("Already received feedDeleted Event", feedDeleted[0]);
            assertTrue("Expected this Event to be Root Event", event.isRoot());

            if (feedRef.references(event.getEntity()))
              feedDeleted[0] = true;
          }
        }
      };
      fModel.addFeedListener(feedListener);

      /* Check News Deleted */
      final INews news1 = fFactory.createNews(null, feedRef.resolve(), new Date());
      news1.setTitle("News1 Title");
      news1.setLink(new URI("http://www.news.com/news1.html"));
      final IPerson person2 = fFactory.createPerson(null, news1);
      person2.setName("Person2");
      fFactory.createSource(news1).setUrl(new URI("http://www.source1.com"));
      fFactory.createGuid(news1, "Guid1");

      final NewsReference[] newsRef = new NewsReference[1];
      newsAdapter = new NewsAdapter() {
        @Override
        public void newsAdded(Set<NewsEvent> events) {
          assertEquals(1, events.size());
          newsRef[0] = new NewsReference(events.iterator().next().getEntity().getId());
        }
      };
      fModel.addNewsListener(newsAdapter);
      /* Must save parent because it gets changed during creation of news */
      fDao.saveFeed(feedRef.resolve());
      final NewsReference newsRef1 = newsRef[0];
      final PersonReference personRef2 = new PersonReference(newsRef1.resolve().getAuthor().getId());

      final INews news2 = fFactory.createNews(null, feedRef.resolve(), new Date());
      news2.setTitle("News2 Title");
      news2.setLink(new URI("http://www.news.com/news2.html"));
      fFactory.createSource(news2).setUrl(new URI("http://www.source2.com"));
      fFactory.createGuid(news2, "Guid2");
      /* Must save parent because it gets changed during creation of news */
      fDao.saveFeed(feedRef.resolve());
      final NewsReference newsRef2 = newsRef[0];

      final INews news3 = fFactory.createNews(null, feedRef.resolve(), new Date());
      news3.setTitle("News3 Title");
      news3.setLink(new URI("http://www.news.com/news3.html"));
      fFactory.createSource(news3).setUrl(new URI("http://www.source3.com"));
      fFactory.createGuid(news3, "Guid3");
      /* Must save parent because it gets changed during creation of news */
      fDao.saveFeed(feedRef.resolve());
      final NewsReference newsRef3 = newsRef[0];

      final boolean newsDeleted[] = new boolean[3];
      newsListener = new NewsAdapter() {
        @Override
        public void newsDeleted(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());

View Full Code Here

      final AttachmentReference attachmentRef3 = new AttachmentReference(fDao.loadNews(newsRef.getId()).getAttachments().get(2).getId());
      final CategoryReference categoryRef = new CategoryReference(fDao.loadNews(newsRef.getId()).getCategories().get(0).getId());

      /* Check News Deleted */
      final boolean newsDeleted[] = new boolean[1];
      newsListener = new NewsAdapter() {
        @Override
        public void newsDeleted(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            if (newsRef.references(event.getEntity()))
View Full Code Here

      news3 = fDao.loadFeed(feedRef.getId()).getNews().get(2);
      news3.setState(INews.State.READ);

      final boolean newsUpdatedEvents[] = new boolean[2];

      newsListener = new NewsAdapter() {
        @Override
        public void newsUpdated(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            INews news = event.getEntity();
            if (news.getLink().equals(news1Link))
View Full Code Here

    try {
      IFeed feed = NewsModel.getDefault().getTypesFactory().createFeed(null, new URL("http://www.feed.com"));
      final boolean addedEvent[] = new boolean[1];
      final boolean deletedEvent[] = new boolean[1];

      feedListener = new NewsAdapter() {
        @Override
        public void newsAdded(Set<NewsEvent> events) {
          addedEvent[0] = true;
        }
View Full Code Here

    fDao.saveFeed(feed1);
    feed2 = fDao.saveFeed(feed2);
    List<INews> newsList = new ArrayList<INews>(1);
    newsList.add(news2);
    final boolean[] newsUpdatedCalled = new boolean[1];
    newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(Set<NewsEvent> events) {
        newsUpdatedCalled[0] = true;
        assertEquals(2, events.size());
      }
View Full Code Here

TOP

Related Classes of org.rssowl.core.model.events.NewsAdapter

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.