@Test public void rawToPosts() throws Exception { Status mockStatus = mock(Status.class); when(mockStatus.getText()).thenReturn("mocktext"); User user = mock(User.class); when(user.getScreenName()).thenReturn("testuser"); when(mockStatus.getUser()).thenReturn(user); when(mockStatus.getCreatedAt()).thenReturn(new Date()); when(mockStatus.getId()).thenReturn((long) 5412); when(mockStatus.getRetweetCount()).thenReturn(100); HashtagEntity hashtag = mock(HashtagEntity.class); when(hashtag.getText()).thenReturn("hastak"); HashtagEntity[] entities = new HashtagEntity[]{hashtag}; when(mockStatus.getHashtagEntities()).thenReturn(entities); ArrayList<Status> rawTweets = new ArrayList<>(); rawTweets.add(mockStatus); TweetBundle tweetBundle = new TweetBundle("hastak"); tweetBundle.addTweets(rawTweets); List<Post> posts = twitterCrawler.rawToPosts(tweetBundle); assertTrue(posts.size() > 0); }
public List<Post> rawToPosts(TweetBundle tweets) { Date d = new Date(System.currentTimeMillis() - 3600 * 1000); return tweets.getTweets().stream() .filter(status -> !status.isPossiblySensitive() && status.getText().matches("\\A\\p{ASCII}*\\z") && status.getCreatedAt().after(d) && !status.getText().contains("RT") && status.getRetweetCount() > 0) .map(this::convertStatusToPost) .collect(Collectors.toList()); }
TwitterCrawler extends Crawler<TweetBundle> { public List<Post> rawToPosts(TweetBundle tweets) { Date d = new Date(System.currentTimeMillis() - 3600 * 1000); return tweets.getTweets().stream() .filter(status -> !status.isPossiblySensitive() && status.getText().matches("\\A\\p{ASCII}*\\z") && status.getCreatedAt().after(d) && !status.getText().contains("RT") && status.getRetweetCount() > 0) .map(this::convertStatusToPost) .collect(Collectors.toList()); } }
TwitterCrawler extends Crawler<TweetBundle> { public List<Post> rawToPosts(TweetBundle tweets) { Date d = new Date(System.currentTimeMillis() - 3600 * 1000); return tweets.getTweets().stream() .filter(status -> !status.isPossiblySensitive() && status.getText().matches("\\A\\p{ASCII}*\\z") && status.getCreatedAt().after(d) && !status.getText().contains("RT") && status.getRetweetCount() > 0) .map(this::convertStatusToPost) .collect(Collectors.toList()); } TwitterCrawler(); }
TwitterCrawler extends Crawler<TweetBundle> { public List<Post> rawToPosts(TweetBundle tweets) { Date d = new Date(System.currentTimeMillis() - 3600 * 1000); return tweets.getTweets().stream() .filter(status -> !status.isPossiblySensitive() && status.getText().matches("\\A\\p{ASCII}*\\z") && status.getCreatedAt().after(d) && !status.getText().contains("RT") && status.getRetweetCount() > 0) .map(this::convertStatusToPost) .collect(Collectors.toList()); } TwitterCrawler(); @Override void crawl(); List<Post> rawToPosts(TweetBundle tweets); }
TwitterCrawler extends Crawler<TweetBundle> { public List<Post> rawToPosts(TweetBundle tweets) { Date d = new Date(System.currentTimeMillis() - 3600 * 1000); return tweets.getTweets().stream() .filter(status -> !status.isPossiblySensitive() && status.getText().matches("\\A\\p{ASCII}*\\z") && status.getCreatedAt().after(d) && !status.getText().contains("RT") && status.getRetweetCount() > 0) .map(this::convertStatusToPost) .collect(Collectors.toList()); } TwitterCrawler(); @Override void crawl(); List<Post> rawToPosts(TweetBundle tweets);  }