@Test public void testExecuteWithExistingRhyme() throws TwitterException { ReplyCommand replyCommand = createReplyCommand("Este test es casi perfecto"); replyCommand.execute(); assertTrue(twitter.getLastUpdatedStatus().contains("Rima por defecto")); }
@Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme with the screen name: {}", targetUser); rhyme = rhymeStore.getRhyme(targetUser); } } if (rhyme == null) { rhyme = wordParser.getDefaultRhyme(); LOGGER.info("No rhyme found. Using default rhyme: {}", rhyme); } } catch (IOException ex) { LOGGER.error( "An error occured while connecting to the rhyme store. Could not reply to {}", targetUser, ex); } try { String tweet = TwitterUtils.reply(targetUser, rhyme); LOGGER.info("Replying to {} with: {}", targetUser, tweet); StatusUpdate newStatus = new StatusUpdate(tweet); newStatus.setInReplyToStatusId(status.getId()); twitter.updateStatus(newStatus); } catch (TwitterException ex) { LOGGER.error("Could not send reply to tweet " + status.getId(), ex); } }
ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme with the screen name: {}", targetUser); rhyme = rhymeStore.getRhyme(targetUser); } } if (rhyme == null) { rhyme = wordParser.getDefaultRhyme(); LOGGER.info("No rhyme found. Using default rhyme: {}", rhyme); } } catch (IOException ex) { LOGGER.error( "An error occured while connecting to the rhyme store. Could not reply to {}", targetUser, ex); } try { String tweet = TwitterUtils.reply(targetUser, rhyme); LOGGER.info("Replying to {} with: {}", targetUser, tweet); StatusUpdate newStatus = new StatusUpdate(tweet); newStatus.setInReplyToStatusId(status.getId()); twitter.updateStatus(newStatus); } catch (TwitterException ex) { LOGGER.error("Could not send reply to tweet " + status.getId(), ex); } } }
ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme with the screen name: {}", targetUser); rhyme = rhymeStore.getRhyme(targetUser); } } if (rhyme == null) { rhyme = wordParser.getDefaultRhyme(); LOGGER.info("No rhyme found. Using default rhyme: {}", rhyme); } } catch (IOException ex) { LOGGER.error( "An error occured while connecting to the rhyme store. Could not reply to {}", targetUser, ex); } try { String tweet = TwitterUtils.reply(targetUser, rhyme); LOGGER.info("Replying to {} with: {}", targetUser, tweet); StatusUpdate newStatus = new StatusUpdate(tweet); newStatus.setInReplyToStatusId(status.getId()); twitter.updateStatus(newStatus); } catch (TwitterException ex) { LOGGER.error("Could not send reply to tweet " + status.getId(), ex); } } ReplyCommand(final Twitter twitter, final WordParser wordParser,
        final RedisStore rhymeStore, final Status status); }
ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme with the screen name: {}", targetUser); rhyme = rhymeStore.getRhyme(targetUser); } } if (rhyme == null) { rhyme = wordParser.getDefaultRhyme(); LOGGER.info("No rhyme found. Using default rhyme: {}", rhyme); } } catch (IOException ex) { LOGGER.error( "An error occured while connecting to the rhyme store. Could not reply to {}", targetUser, ex); } try { String tweet = TwitterUtils.reply(targetUser, rhyme); LOGGER.info("Replying to {} with: {}", targetUser, tweet); StatusUpdate newStatus = new StatusUpdate(tweet); newStatus.setInReplyToStatusId(status.getId()); twitter.updateStatus(newStatus); } catch (TwitterException ex) { LOGGER.error("Could not send reply to tweet " + status.getId(), ex); } } ReplyCommand(final Twitter twitter, final WordParser wordParser,
        final RedisStore rhymeStore, final Status status); @Override void execute(); }
ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme with the screen name: {}", targetUser); rhyme = rhymeStore.getRhyme(targetUser); } } if (rhyme == null) { rhyme = wordParser.getDefaultRhyme(); LOGGER.info("No rhyme found. Using default rhyme: {}", rhyme); } } catch (IOException ex) { LOGGER.error( "An error occured while connecting to the rhyme store. Could not reply to {}", targetUser, ex); } try { String tweet = TwitterUtils.reply(targetUser, rhyme); LOGGER.info("Replying to {} with: {}", targetUser, tweet); StatusUpdate newStatus = new StatusUpdate(tweet); newStatus.setInReplyToStatusId(status.getId()); twitter.updateStatus(newStatus); } catch (TwitterException ex) { LOGGER.error("Could not send reply to tweet " + status.getId(), ex); } } ReplyCommand(final Twitter twitter, final WordParser wordParser,
        final RedisStore rhymeStore, final Status status); @Override void execute();  }