### Question:
TwitterSocialQueryResult implements SocialQueryResult { public static List<SocialMessage> translate(List<Status> statuses) { if (statuses == null) { return null; } List<SocialMessage> socialMessages = statuses.stream().map(status -> { SocialMessage message = new SocialMessage(status.getText()); message.setId(status.getId()); message.setNumOfLikes(status.getFavoriteCount()); message.setNumOfShares(status.getRetweetCount()); message.setSource(SOURCE_NAME); message.setLang(status.getLang()); message.setShareOrRetweet(status.isRetweet()); message.setTimestamp(status.getCreatedAt().getTime()); return message; }).collect(Collectors.toList()); return socialMessages; } TwitterSocialQueryResult(QueryResult queryResult); @Override List<SocialMessage> getMessages(); @Override String getQuery(); @Override SocialQuery nextQuery(); @Override boolean hasNext(); static List<SocialMessage> translate(List<Status> statuses); static SocialQuery translate(Query query); static final String SOURCE_NAME; }### Answer:
@Test public void test_message_translation1() { String text = "Hello"; Date date = new Date(); int retweetCount = 5; String language = "EN"; boolean isRetweeted = false; int id = 8; Status someStatus = new MockStatus(text, isRetweeted, date, id, retweetCount, language); List<SocialMessage> translate = TwitterSocialQueryResult.translate(Arrays.asList(someStatus)); SocialMessage response = translate.get(0); Assert.assertEquals(response.getId(), id); Assert.assertEquals(response.getText(), text); Assert.assertEquals(response.getSource(), TwitterSocialQueryResult.SOURCE_NAME); Assert.assertEquals(response.isShareOrRetweet(), isRetweeted); Assert.assertEquals(response.getNumOfShares(),retweetCount); }
@Test public void test_message_translation2() { String text = "Hello"; Date date = new Date(); int retweetCount = 5; String language = "EN"; boolean isRetweeted = true; int id = 8; Status someStatus = new MockStatus(text, isRetweeted, date, id, retweetCount, language); List<SocialMessage> translate = TwitterSocialQueryResult.translate(Arrays.asList(someStatus)); SocialMessage response = translate.get(0); Assert.assertEquals(response.getId(), id); Assert.assertEquals(response.getText(), text); Assert.assertEquals(response.getSource(), TwitterSocialQueryResult.SOURCE_NAME); Assert.assertEquals(response.isShareOrRetweet(), isRetweeted); Assert.assertEquals(response.getNumOfShares(),retweetCount); }
@Test public void test_message_translation3() { String text = "Hello"; Date date = new Date(); int retweetCount = 5; String language = "EN"; boolean isRetweeted = false; int id = 8; Status someStatus = new MockStatus(text, isRetweeted, date, id, retweetCount, language); List<SocialMessage> translate = TwitterSocialQueryResult.translate(Arrays.asList(someStatus)); SocialMessage response = translate.get(0); Assert.assertEquals(response.getId(), id); Assert.assertEquals(response.getText(), text); Assert.assertEquals(response.getSource(), TwitterSocialQueryResult.SOURCE_NAME); Assert.assertEquals(response.isShareOrRetweet(), isRetweeted); Assert.assertEquals(response.getNumOfShares(),retweetCount); Assert.assertEquals(response.getTimestamp(),date.getTime()); Assert.assertEquals(response.getSentiment(),0,0.001); }