SignalFactoryFXTweetHandler extends AbstractFXTweetHandler<String> { @Override public FXTradeTweet<String> handleTweet(Tweet tweet) { String tweetTxt = tweet.getText(); String tokens[] = StringUtils.split(tweetTxt, TradingConstants.PIPE_CHR); if (tokens.length >= 5) { String action = tokens[1].trim(); if (action.startsWith(BUY) || action.startsWith(SELL)) { return parseNewTrade(tokens); } else if (action.startsWith(CLOSE)) { return parseCloseTrade(tokens); } } return null; } SignalFactoryFXTweetHandler(String userid); @Override FXTradeTweet<String> handleTweet(Tweet tweet); @Override Collection<Tweet> findHistoricPnlTweetsForInstrument(TradeableInstrument<String> instrument);  }
@Test public void handleTweetTest() { AbstractFXTweetHandler<String> tweetHandler = new SignalFactoryFXTweetHandler(userId); ProviderHelper providerHelper = mock(ProviderHelper.class); tweetHandler.providerHelper = providerHelper; when(providerHelper.fromIsoFormat(eq("GBPCAD"))).thenReturn("GBP_CAD"); when(providerHelper.fromIsoFormat(eq("USDCHF"))).thenReturn("USD_CHF"); when(providerHelper.fromIsoFormat(eq("EURNZD"))).thenReturn("EUR_NZD"); when(providerHelper.fromIsoFormat(eq("GBPCHF"))).thenReturn("GBP_CHF"); newTradeType1(tweetHandler); newTradeType2(tweetHandler); closeTradeType1(tweetHandler); closeTradeType2(tweetHandler); nonTradeType(tweetHandler); }