CopyTwitterStrategy implements TweetHarvester<T> { @Override public Collection<NewFXTradeTweet<T>> harvestNewTradeTweets(String userId) { FXTweetHandler<T> tweetHandler = tweetHandlerMap.get(userId); if (tweetHandler == null) { return Collections.emptyList(); } Collection<Tweet> tweets = tweetHandler.findNewTweets(); if (tweets.size() > 0) { LOG.info(String.format("found %d new tweets for user %s", tweets.size(), userId)); } else { return Collections.emptyList(); } Collection<NewFXTradeTweet<T>> newTradeTweets = Lists.newArrayList(); for (Tweet tweet : tweets) { FXTradeTweet<T> tradeTweet = tweetHandler.handleTweet(tweet); if (tradeTweet instanceof NewFXTradeTweet) { newTradeTweets.add((NewFXTradeTweet<T>) tradeTweet); } } return newTradeTweets; }  @PostConstruct void init(); synchronized void harvestAndTrade(); @Override Collection<NewFXTradeTweet<T>> harvestNewTradeTweets(String userId); @Override Collection<CloseFXTradeTweet<T>> harvestHistoricTradeTweets(String userId,
			TradeableInstrument<T> instrument);  }
@Test public void harvestNewTradeTest() { CopyTwitterStrategy<String> copyTwitterStrategy = new CopyTwitterStrategy<String>(); FXTweetHandler<String> tweetHandlerFoo = createTweetHandlerFoo(copyTwitterStrategy); Collection<NewFXTradeTweet<String>> newTradeTweets = copyTwitterStrategy.harvestNewTradeTweets(userIdbar); assertTrue(newTradeTweets.isEmpty()); Tweet tweet1 = mock(Tweet.class); Tweet tweet2 = mock(Tweet.class); Collection<Tweet> footweets = Lists.newArrayList(tweet1, tweet2); when(tweetHandlerFoo.findNewTweets()).thenReturn(footweets); when(tweetHandlerFoo.handleTweet(tweet1)).thenReturn(mock(CloseFXTradeTweet.class)); when(tweetHandlerFoo.handleTweet(tweet2)).thenReturn(mock(NewFXTradeTweet.class)); newTradeTweets = copyTwitterStrategy.harvestNewTradeTweets(userIdfoo); assertEquals(1, newTradeTweets.size()); }