@Test public void testTest1() throws Exception { String jsonObjectString = "{\"filter_level\":\"medium\",\"contributors\":null,\"text\":\"@gvicks @OneLastStranger Dude-Thats such POOR taste, Respect a missing Plane of humans Its an #aviation tragedy #MH370 #MalaysiaAirlines\",\"geo\":null,\"retweeted\":false,\"in_reply_to_screen_name\":\"gvicks\",\"truncated\":false,\"lang\":\"en\",\"entities\":{\"hashtags\":[{\"text\":\"aviation\",\"indices\":[95,104]},{\"text\":\"MH370\",\"indices\":[113,119]},{\"text\":\"MalaysiaAirlines\",\"indices\":[120,137]}],\"symbols\":[],\"urls\":[],\"user_mentions\":[{\"id\":20862797,\"indices\":[0,7],\"screen_name\":\"gvicks\",\"id_str\":\"20862797\",\"name\":\"Vikram\"},{\"id\":31354692,\"indices\":[8,24],\"screen_name\":\"OneLastStranger\",\"id_str\":\"31354692\",\"name\":\"Busy Stranger\"}]},\"in_reply_to_status_id_str\":\"444322825088684033\",\"aidr\":{\"crisis_code\":\"2014-03-mh370\",\"doctype\":\"twitter\",\"crisis_name\":\"Malaysia Airlines flight #MH370\"},\"id\":445127578831966208,\"in_reply_to_user_id_str\":\"20862797\",\"source\":\"\",\"favorited\":false,\"in_reply_to_status_id\":444322825088684033,\"in_reply_to_user_id\":20862797,\"created_at\":\"Sun Mar 16 09:20:59 +0000 2014\",\"retweet_count\":0,\"favorite_count\":0,\"id_str\":\"445127578831966208\",\"place\":null,\"user\":{\"location\":\"Let Me Own Your Mind & Soul xx\",\"default_profile\":false,\"statuses_count\":15830,\"profile_background_tile\":false,\"lang\":\"en\",\"profile_link_color\":\"0084B4\",\"profile_banner_url\":\"https: JsonReader jsonReader = Json.createReader(new StringReader(jsonObjectString)); JsonObject object = jsonReader.readObject(); jsonReader.close(); boolean test = followFilter.test(object); assertTrue(test); String jsonObjectString1 = "{\"filter_level\":\"medium\",\"contributors\":null,\"text\":\"@gvicks @OneLastStranger Dude-Thats such POOR taste, Respect a missing Plane of humans Its an #aviation tragedy #MH370 #MalaysiaAirlines\",\"geo\":null,\"retweeted\":false,\"in_reply_to_screen_name\":\"gvicks\",\"truncated\":false,\"lang\":\"en\",\"entities\":{\"hashtags\":[{\"text\":\"aviation\",\"indices\":[95,104]},{\"text\":\"MH370\",\"indices\":[113,119]},{\"text\":\"MalaysiaAirlines\",\"indices\":[120,137]}],\"symbols\":[],\"urls\":[],\"user_mentions\":[{\"id\":20862797,\"indices\":[0,7],\"screen_name\":\"gvicks\",\"id_str\":\"20862797\",\"name\":\"Vikram\"},{\"id\":31354692,\"indices\":[8,24],\"screen_name\":\"OneLastStranger\",\"id_str\":\"31354692\",\"name\":\"Busy Stranger\"}]},\"in_reply_to_status_id_str\":\"444322825088684033\",\"aidr\":{\"crisis_code\":\"2014-03-mh370\",\"doctype\":\"twitter\",\"crisis_name\":\"Malaysia Airlines flight #MH370\"},\"id\":445127578831966208,\"in_reply_to_user_id_str\":\"20862797\",\"source\":\"\",\"favorited\":false,\"in_reply_to_status_id\":444322825088684033,\"in_reply_to_user_id\":20862797,\"created_at\":\"Sun Mar 16 09:20:59 +0000 2014\",\"retweet_count\":0,\"favorite_count\":0,\"id_str\":\"445127578831966208\",\"place\":null,\"user\":{\"location\":\"Let Me Own Your Mind & Soul xx\",\"default_profile\":false,\"statuses_count\":15830,\"profile_background_tile\":false,\"lang\":\"en\",\"profile_link_color\":\"0084B4\",\"profile_banner_url\":\"https: JsonReader jsonReader1 = Json.createReader(new StringReader(jsonObjectString1)); JsonObject object1 = jsonReader1.readObject(); jsonReader1.close(); boolean test1 = followFilter.test(object1); assertFalse(test1); }
@Override public boolean test(JsonObject t) { try { if (null == toFollow) return true; JsonObject user = t.getJsonObject("user"); if (null == user) { return false; } String tweetFrom = user.get("id").toString(); if (null == tweetFrom) { return false; } if (toFollow != null) { for (int i = 0; i < toFollow.length; i++) { if (tweetFrom.equals(toFollow[i])) { return true; } } } return false; } catch (Exception e) { logger.error("Exception:", e); return false; } }
FollowFilter implements Predicate<JsonObject> { @Override public boolean test(JsonObject t) { try { if (null == toFollow) return true; JsonObject user = t.getJsonObject("user"); if (null == user) { return false; } String tweetFrom = user.get("id").toString(); if (null == tweetFrom) { return false; } if (toFollow != null) { for (int i = 0; i < toFollow.length; i++) { if (tweetFrom.equals(toFollow[i])) { return true; } } } return false; } catch (Exception e) { logger.error("Exception:", e); return false; } } }
FollowFilter implements Predicate<JsonObject> { @Override public boolean test(JsonObject t) { try { if (null == toFollow) return true; JsonObject user = t.getJsonObject("user"); if (null == user) { return false; } String tweetFrom = user.get("id").toString(); if (null == tweetFrom) { return false; } if (toFollow != null) { for (int i = 0; i < toFollow.length; i++) { if (tweetFrom.equals(toFollow[i])) { return true; } } } return false; } catch (Exception e) { logger.error("Exception:", e); return false; } } FollowFilter();  FollowFilter(TwitterCollectionTask task);  FollowFilter(String toFollow); }
FollowFilter implements Predicate<JsonObject> { @Override public boolean test(JsonObject t) { try { if (null == toFollow) return true; JsonObject user = t.getJsonObject("user"); if (null == user) { return false; } String tweetFrom = user.get("id").toString(); if (null == tweetFrom) { return false; } if (toFollow != null) { for (int i = 0; i < toFollow.length; i++) { if (tweetFrom.equals(toFollow[i])) { return true; } } } return false; } catch (Exception e) { logger.error("Exception:", e); return false; } } FollowFilter();  FollowFilter(TwitterCollectionTask task);  FollowFilter(String toFollow); void setToFollow(final String toFollow); @Override boolean test(JsonObject t); @Override String getFilterName(); }
FollowFilter implements Predicate<JsonObject> { @Override public boolean test(JsonObject t) { try { if (null == toFollow) return true; JsonObject user = t.getJsonObject("user"); if (null == user) { return false; } String tweetFrom = user.get("id").toString(); if (null == tweetFrom) { return false; } if (toFollow != null) { for (int i = 0; i < toFollow.length; i++) { if (tweetFrom.equals(toFollow[i])) { return true; } } } return false; } catch (Exception e) { logger.error("Exception:", e); return false; } } FollowFilter();  FollowFilter(TwitterCollectionTask task);  FollowFilter(String toFollow); void setToFollow(final String toFollow); @Override boolean test(JsonObject t); @Override String getFilterName();  }