@Test public void testConvertStatus() { TwitterConverter converter = new TwitterConverter(); Status tweet = EasyMock.createMock(Status.class); EasyMock.expect(tweet.getSource()).andReturn("schneider_chris").anyTimes(); Date now = new Date(); EasyMock.expect(tweet.getCreatedAt()).andReturn(now).anyTimes(); EasyMock.expect(tweet.getText()).andReturn("#camel mytopic 2").anyTimes(); EasyMock.replay(tweet); Vote vote = converter.convert(tweet); Assert.assertEquals(tweet.getSource(), vote.getFromUser()); Assert.assertEquals(now, vote.getVoteDateTime()); Assert.assertEquals(2, vote.getVote()); Assert.assertEquals("mytopic", vote.getTopic()); EasyMock.verify(tweet); }
public Vote convert(DirectMessage message) { try { String text = message.getText(); String[] parts = text.split(" "); String topic = parts[0]; int voteNum = Integer.parseInt(parts[1]); String fromUser = message.getSender().getName(); return new Vote(topic, voteNum, fromUser, message.getCreatedAt()); } catch (Throwable e) { LOG.info("Invalid tweet " + message.getText() + ": " + e.getMessage()); return null; } }
TwitterConverter { public Vote convert(DirectMessage message) { try { String text = message.getText(); String[] parts = text.split(" "); String topic = parts[0]; int voteNum = Integer.parseInt(parts[1]); String fromUser = message.getSender().getName(); return new Vote(topic, voteNum, fromUser, message.getCreatedAt()); } catch (Throwable e) { LOG.info("Invalid tweet " + message.getText() + ": " + e.getMessage()); return null; } } }
TwitterConverter { public Vote convert(DirectMessage message) { try { String text = message.getText(); String[] parts = text.split(" "); String topic = parts[0]; int voteNum = Integer.parseInt(parts[1]); String fromUser = message.getSender().getName(); return new Vote(topic, voteNum, fromUser, message.getCreatedAt()); } catch (Throwable e) { LOG.info("Invalid tweet " + message.getText() + ": " + e.getMessage()); return null; } }  }
TwitterConverter { public Vote convert(DirectMessage message) { try { String text = message.getText(); String[] parts = text.split(" "); String topic = parts[0]; int voteNum = Integer.parseInt(parts[1]); String fromUser = message.getSender().getName(); return new Vote(topic, voteNum, fromUser, message.getCreatedAt()); } catch (Throwable e) { LOG.info("Invalid tweet " + message.getText() + ": " + e.getMessage()); return null; } }  Vote convert(DirectMessage message); Vote convert(Status tweet); }
TwitterConverter { public Vote convert(DirectMessage message) { try { String text = message.getText(); String[] parts = text.split(" "); String topic = parts[0]; int voteNum = Integer.parseInt(parts[1]); String fromUser = message.getSender().getName(); return new Vote(topic, voteNum, fromUser, message.getCreatedAt()); } catch (Throwable e) { LOG.info("Invalid tweet " + message.getText() + ": " + e.getMessage()); return null; } }  Vote convert(DirectMessage message); Vote convert(Status tweet);  }