CopyTwitterStrategy implements TweetHarvester<T> { @Override public Collection<CloseFXTradeTweet<T>> harvestHistoricTradeTweets(String userId, TradeableInstrument<T> instrument) { FXTweetHandler<T> tweetHandler = tweetHandlerMap.get(userId); if (tweetHandler == null) { return Collections.emptyList(); } Collection<Tweet> tweets = tweetHandler.findHistoricPnlTweetsForInstrument(instrument); if (tweets.size() > 0) { LOG.info(String.format("found %d historic pnl tweets for user %s and instrument %s", tweets.size(), userId, instrument.getInstrument())); } else { return Collections.emptyList(); } Collection<CloseFXTradeTweet<T>> pnlTradeTweets = Lists.newArrayList(); for (Tweet tweet : tweets) { FXTradeTweet<T> tradeTweet = tweetHandler.handleTweet(tweet); if (tradeTweet instanceof CloseFXTradeTweet) { pnlTradeTweets.add((CloseFXTradeTweet<T>) tradeTweet); } } return pnlTradeTweets; }  @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 harvestHistoricTradeTweetsTest() { CopyTwitterStrategy<String> copyTwitterStrategy = new CopyTwitterStrategy<String>(); FXTweetHandler<String> tweetHandlerFoo = createTweetHandlerFoo(copyTwitterStrategy); TradeableInstrument<String> gbpusd = new TradeableInstrument<String>("GBP_USD"); Collection<CloseFXTradeTweet<String>> closeTradeTweets = copyTwitterStrategy.harvestHistoricTradeTweets( userIdbar, gbpusd); assertTrue(closeTradeTweets.isEmpty()); Tweet tweet1 = mock(Tweet.class); Tweet tweet2 = mock(Tweet.class); Collection<Tweet> footweets = Lists.newArrayList(tweet1, tweet2); when(tweetHandlerFoo.findHistoricPnlTweetsForInstrument(gbpusd)).thenReturn(footweets); when(tweetHandlerFoo.handleTweet(tweet1)).thenReturn(mock(CloseFXTradeTweet.class)); when(tweetHandlerFoo.handleTweet(tweet2)).thenReturn(mock(CloseFXTradeTweet.class)); closeTradeTweets = copyTwitterStrategy.harvestHistoricTradeTweets(userIdfoo, gbpusd); assertEquals(2, closeTradeTweets.size()); }