streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject [9/9] incubator-streams git commit: revamped testing, more cases more conditions per test
Date Tue, 11 Nov 2014 23:51:40 GMT
revamped testing, more cases more conditions per test


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/99e70b48
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/99e70b48
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/99e70b48

Branch: refs/heads/master
Commit: 99e70b48c426a2753f6e385c561df7286f15e3f6
Parents: dabc511
Author: sblackmon <sblackmon@apache.org>
Authored: Tue Nov 11 13:50:18 2014 -0600
Committer: sblackmon <sblackmon@apache.org>
Committed: Tue Nov 11 13:50:18 2014 -0600

----------------------------------------------------------------------
 .../serializer/DatasiftEventClassifier.java     |   2 +-
 .../DatasiftTweetActivitySerializer.java        | 272 -------------------
 .../DatasiftTwitterActivitySerializer.java      | 272 +++++++++++++++++++
 .../DatasiftActivitySerializerTest.java         |  80 ++----
 .../serializer/DatasiftEventClassifierTest.java |  14 +-
 ...DatasiftInstagramActivitySerializerTest.java |  43 +++
 ...tasiftInteractionActivitySerializerTest.java |  48 ++++
 .../DatasiftTwitterActivitySerializerTest.java  |  43 +++
 8 files changed, 437 insertions(+), 337 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/99e70b48/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftEventClassifier.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftEventClassifier.java
b/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftEventClassifier.java
index 0169f17..7d7d547 100644
--- a/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftEventClassifier.java
+++ b/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftEventClassifier.java
@@ -43,7 +43,7 @@ public class DatasiftEventClassifier {
     public static ActivitySerializer bestSerializer(Datasift event) {
 
         if(event.getTwitter() != null) {
-            return DatasiftTweetActivitySerializer.getInstance();
+            return DatasiftTwitterActivitySerializer.getInstance();
         } else if(event.getInstagram() != null) {
             return DatasiftInstagramActivitySerializer.getInstance();
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/99e70b48/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTweetActivitySerializer.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTweetActivitySerializer.java
b/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTweetActivitySerializer.java
deleted file mode 100644
index 6fd19e7..0000000
--- a/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTweetActivitySerializer.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-package org.apache.streams.datasift.serializer;
-
-
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.apache.streams.datasift.Datasift;
-import org.apache.streams.datasift.interaction.Author;
-import org.apache.streams.datasift.interaction.Interaction;
-import org.apache.streams.datasift.twitter.DatasiftTwitterUser;
-import org.apache.streams.datasift.twitter.Retweet;
-import org.apache.streams.datasift.twitter.Twitter;
-import org.apache.streams.pojo.json.Activity;
-import org.apache.streams.pojo.json.Actor;
-import org.apache.streams.pojo.json.Image;
-import org.apache.streams.twitter.serializer.util.TwitterActivityUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.streams.data.util.ActivityUtil.ensureExtensions;
-
-/**
- *
- */
-public class DatasiftTweetActivitySerializer extends DatasiftInteractionActivitySerializer
{
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(DatasiftTweetActivitySerializer.class);
-
-    private static DatasiftTweetActivitySerializer instance = new DatasiftTweetActivitySerializer();
-
-    public static DatasiftTweetActivitySerializer getInstance() {
-        return instance;
-    }
-
-    @Override
-    public Activity convert(Datasift event) {
-        Activity activity = new Activity();
-        Twitter twitter = event.getTwitter();
-        boolean retweet = twitter.getRetweet() != null;
-
-        activity.setActor(buildActor(event, twitter)); //TODO
-        if(retweet) {
-            activity.setVerb("share");
-        } else {
-            activity.setVerb("post");
-        }
-        activity.setObject(buildActivityObject(event.getInteraction()));
-        activity.setId(formatId(activity.getVerb(), event.getInteraction().getId()));
-        activity.setTarget(buildTarget(event.getInteraction()));
-        activity.setPublished(event.getInteraction().getCreatedAt());
-        activity.setGenerator(buildGenerator(event.getInteraction()));
-        activity.setIcon(getIcon(event.getInteraction()));
-        activity.setProvider(TwitterActivityUtil.getProvider());
-        activity.setTitle(event.getInteraction().getTitle());
-        activity.setContent(event.getInteraction().getContent());
-        activity.setUrl(event.getInteraction().getLink());
-        if(retweet)
-            activity.setLinks(getLinks(twitter.getRetweet()));
-        else
-            activity.setLinks(getLinks(twitter));
-        addDatasiftExtension(activity, event);
-        if( twitter.getGeo() != null) {
-            addLocationExtension(activity, twitter);
-        }
-        addTwitterExtensions(activity, twitter, event.getInteraction());
-        return activity;
-    }
-
-    /**
-     * Get the links from this tweet as a list
-     * @param twitter
-     * @return the links from the tweet
-     */
-    public List<String> getLinks(Twitter twitter) {
-        return getLinks(twitter.getLinks());
-    }
-
-    /**
-     * Get the links from this tweet as a list
-     * @param retweet
-     * @return the links from the tweet
-     */
-    public List<String> getLinks(Retweet retweet) {
-        return getLinks(retweet.getLinks());
-    }
-
-    /**
-     * Converts the list of objects to a list of strings
-     * @param links
-     * @return
-     */
-    private List<String> getLinks(List<Object> links) {
-        if(links == null)
-            return Lists.newArrayList();
-        List<String> result = Lists.newLinkedList();
-        for(Object obj : links) {
-            if(obj instanceof String) {
-                result.add((String) obj);
-            } else {
-                LOGGER.warn("Links is not instance of String : {}", obj.getClass().getName());
-            }
-        }
-        return result;
-    }
-
-    public Actor buildActor(Datasift event, Twitter twitter) {
-        DatasiftTwitterUser user = twitter.getUser();
-        Actor actor = super.buildActor(event.getInteraction());
-        if(user == null) {
-            user = twitter.getRetweet().getUser();
-        }
-
-        actor.setDisplayName(user.getName());
-        actor.setId(formatId(Optional.fromNullable(
-                user.getIdStr())
-                .or(Optional.of(user.getId().toString()))
-                .orNull()));
-        actor.setSummary(user.getDescription());
-        try {
-            actor.setPublished(user.getCreatedAt());
-        } catch (Exception e) {
-            LOGGER.warn("Exception trying to parse date : {}", e);
-        }
-
-        if(user.getUrl() != null) {
-            actor.setUrl(user.getUrl());
-        }
-
-        Map<String, Object> extensions = new HashMap<String,Object>();
-        extensions.put("location", user.getLocation());
-        extensions.put("posts", user.getStatusesCount());
-        extensions.put("followers", user.getFollowersCount());
-        extensions.put("screenName", user.getScreenName());
-        if(user.getAdditionalProperties() != null) {
-            extensions.put("favorites", user.getFavouritesCount());
-        }
-
-        Image profileImage = new Image();
-        String profileUrl = null;
-        Author author = event.getInteraction().getAuthor();
-        if( author != null )
-            profileUrl = author.getAvatar();
-        if(profileUrl == null && user.getProfileImageUrlHttps() != null) {
-            Object url = user.getProfileImageUrlHttps();
-            if(url instanceof String)
-                profileUrl = (String) url;
-        }
-        if(profileUrl == null) {
-            profileUrl = user.getProfileImageUrl();
-        }
-        profileImage.setUrl(profileUrl);
-        actor.setImage(profileImage);
-
-        actor.setAdditionalProperty("extensions", extensions);
-        return actor;
-    }
-
-    public void addLocationExtension(Activity activity, Twitter twitter) {
-        Map<String, Object> extensions = ensureExtensions(activity);
-        Map<String, Object> location = Maps.newHashMap();
-        double[] coordiantes = new double[] { twitter.getGeo().getLongitude(), twitter.getGeo().getLatitude()
};
-        Map<String, Object> coords = Maps.newHashMap();
-        coords.put("coordinates", coordiantes);
-        coords.put("type", "geo_point");
-        location.put("coordinates", coords);
-        extensions.put("location", location);
-    }
-
-    public void addTwitterExtensions(Activity activity, Twitter twitter, Interaction interaction)
{
-        Retweet retweet = twitter.getRetweet();
-        Map<String, Object> extensions = ensureExtensions(activity);
-        List<String> hashTags = Lists.newLinkedList();
-        List<Object> hts = Lists.newLinkedList();
-        if(twitter.getHashtags() != null) {
-            hts = twitter.getHashtags();
-        } else if (retweet != null) {
-            hts = retweet.getHashtags();
-        }
-        if(hts != null) {
-            for(Object ht : twitter.getHashtags()) {
-                if(ht instanceof String) {
-                    hashTags.add((String) ht);
-                } else {
-                    LOGGER.warn("Hashtag was not instance of String : {}", ht.getClass().getName());
-                }
-            }
-        }
-        extensions.put("hashtags", hashTags);
-
-
-        if(retweet != null) {
-            Map<String, Object> rebroadcasts = Maps.newHashMap();
-            rebroadcasts.put("perspectival", true);
-            rebroadcasts.put("count", retweet.getCount());
-            extensions.put("rebroadcasts", rebroadcasts);
-        }
-
-        if(interaction.getAdditionalProperties() != null) {
-            ArrayList<Map<String,Object>> userMentions = createUserMentions(interaction);
-
-            if(userMentions.size() > 0)
-                extensions.put("user_mentions", userMentions);
-        }
-
-        extensions.put("keywords", interaction.getContent());
-    }
-
-    /**
-     * Returns an ArrayList of all UserMentions in this interaction
-     * Note: The ID list and the handle lists do not necessarily correspond 1:1 for this
provider
-     * If those lists are the same size, then they will be merged into individual UserMention
-     * objects. However, if they are not the same size, a new UserMention object will be
created
-     * for each entry in both lists.
-     *
-     * @param interaction
-     * @return
-     */
-    private ArrayList<Map<String,Object>> createUserMentions(Interaction interaction)
{
-        ArrayList<String> mentions = (ArrayList<String>) interaction.getAdditionalProperties().get("mentions");
-        ArrayList<Long> mentionIds = (ArrayList<Long>) interaction.getAdditionalProperties().get("mention_ids");
-        ArrayList<Map<String,Object>> userMentions = new ArrayList<Map<String,Object>>();
-
-        if(mentions != null && !mentions.isEmpty()) {
-            for(int x = 0; x < mentions.size(); x ++) {
-                Map<String, Object> actor = new HashMap<String, Object>();
-                actor.put("displayName", mentions.get(x));
-                actor.put("handle", mentions.get(x));
-
-                userMentions.add(actor);
-            }
-        }
-        if(mentionIds != null && !mentionIds.isEmpty()) {
-            for(int x = 0; x < mentionIds.size(); x ++) {
-                Map<String, Object> actor = new HashMap<String, Object>();
-                actor.put("id", "id:twitter:" + mentionIds.get(x));
-
-                userMentions.add(actor);
-            }
-        }
-
-        return userMentions;
-    }
-
-    public static String formatId(String... idparts) {
-        return Joiner.on(":").join(Lists.asList("id:twitter", idparts));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/99e70b48/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTwitterActivitySerializer.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTwitterActivitySerializer.java
b/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTwitterActivitySerializer.java
new file mode 100644
index 0000000..8ac84f6
--- /dev/null
+++ b/streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/serializer/DatasiftTwitterActivitySerializer.java
@@ -0,0 +1,272 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+package org.apache.streams.datasift.serializer;
+
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Optional;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.streams.datasift.Datasift;
+import org.apache.streams.datasift.interaction.Author;
+import org.apache.streams.datasift.interaction.Interaction;
+import org.apache.streams.datasift.twitter.DatasiftTwitterUser;
+import org.apache.streams.datasift.twitter.Retweet;
+import org.apache.streams.datasift.twitter.Twitter;
+import org.apache.streams.pojo.json.Activity;
+import org.apache.streams.pojo.json.Actor;
+import org.apache.streams.pojo.json.Image;
+import org.apache.streams.twitter.serializer.util.TwitterActivityUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.streams.data.util.ActivityUtil.ensureExtensions;
+
+/**
+ *
+ */
+public class DatasiftTwitterActivitySerializer extends DatasiftInteractionActivitySerializer
{
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DatasiftTwitterActivitySerializer.class);
+
+    private static DatasiftTwitterActivitySerializer instance = new DatasiftTwitterActivitySerializer();
+
+    public static DatasiftTwitterActivitySerializer getInstance() {
+        return instance;
+    }
+
+    @Override
+    public Activity convert(Datasift event) {
+        Activity activity = new Activity();
+        Twitter twitter = event.getTwitter();
+        boolean retweet = twitter.getRetweet() != null;
+
+        activity.setActor(buildActor(event, twitter)); //TODO
+        if(retweet) {
+            activity.setVerb("share");
+        } else {
+            activity.setVerb("post");
+        }
+        activity.setObject(buildActivityObject(event.getInteraction()));
+        activity.setId(formatId(activity.getVerb(), event.getInteraction().getId()));
+        activity.setTarget(buildTarget(event.getInteraction()));
+        activity.setPublished(event.getInteraction().getCreatedAt());
+        activity.setGenerator(buildGenerator(event.getInteraction()));
+        activity.setIcon(getIcon(event.getInteraction()));
+        activity.setProvider(TwitterActivityUtil.getProvider());
+        activity.setTitle(event.getInteraction().getTitle());
+        activity.setContent(event.getInteraction().getContent());
+        activity.setUrl(event.getInteraction().getLink());
+        if(retweet)
+            activity.setLinks(getLinks(twitter.getRetweet()));
+        else
+            activity.setLinks(getLinks(twitter));
+        addDatasiftExtension(activity, event);
+        if( twitter.getGeo() != null) {
+            addLocationExtension(activity, twitter);
+        }
+        addTwitterExtensions(activity, twitter, event.getInteraction());
+        return activity;
+    }
+
+    /**
+     * Get the links from this tweet as a list
+     * @param twitter
+     * @return the links from the tweet
+     */
+    public List<String> getLinks(Twitter twitter) {
+        return getLinks(twitter.getLinks());
+    }
+
+    /**
+     * Get the links from this tweet as a list
+     * @param retweet
+     * @return the links from the tweet
+     */
+    public List<String> getLinks(Retweet retweet) {
+        return getLinks(retweet.getLinks());
+    }
+
+    /**
+     * Converts the list of objects to a list of strings
+     * @param links
+     * @return
+     */
+    private List<String> getLinks(List<Object> links) {
+        if(links == null)
+            return Lists.newArrayList();
+        List<String> result = Lists.newLinkedList();
+        for(Object obj : links) {
+            if(obj instanceof String) {
+                result.add((String) obj);
+            } else {
+                LOGGER.warn("Links is not instance of String : {}", obj.getClass().getName());
+            }
+        }
+        return result;
+    }
+
+    public Actor buildActor(Datasift event, Twitter twitter) {
+        DatasiftTwitterUser user = twitter.getUser();
+        Actor actor = super.buildActor(event.getInteraction());
+        if(user == null) {
+            user = twitter.getRetweet().getUser();
+        }
+
+        actor.setDisplayName(user.getName());
+        actor.setId(formatId(Optional.fromNullable(
+                user.getIdStr())
+                .or(Optional.of(user.getId().toString()))
+                .orNull()));
+        actor.setSummary(user.getDescription());
+        try {
+            actor.setPublished(user.getCreatedAt());
+        } catch (Exception e) {
+            LOGGER.warn("Exception trying to parse date : {}", e);
+        }
+
+        if(user.getUrl() != null) {
+            actor.setUrl(user.getUrl());
+        }
+
+        Map<String, Object> extensions = new HashMap<String,Object>();
+        extensions.put("location", user.getLocation());
+        extensions.put("posts", user.getStatusesCount());
+        extensions.put("followers", user.getFollowersCount());
+        extensions.put("screenName", user.getScreenName());
+        if(user.getAdditionalProperties() != null) {
+            extensions.put("favorites", user.getFavouritesCount());
+        }
+
+        Image profileImage = new Image();
+        String profileUrl = null;
+        Author author = event.getInteraction().getAuthor();
+        if( author != null )
+            profileUrl = author.getAvatar();
+        if(profileUrl == null && user.getProfileImageUrlHttps() != null) {
+            Object url = user.getProfileImageUrlHttps();
+            if(url instanceof String)
+                profileUrl = (String) url;
+        }
+        if(profileUrl == null) {
+            profileUrl = user.getProfileImageUrl();
+        }
+        profileImage.setUrl(profileUrl);
+        actor.setImage(profileImage);
+
+        actor.setAdditionalProperty("extensions", extensions);
+        return actor;
+    }
+
+    public void addLocationExtension(Activity activity, Twitter twitter) {
+        Map<String, Object> extensions = ensureExtensions(activity);
+        Map<String, Object> location = Maps.newHashMap();
+        double[] coordiantes = new double[] { twitter.getGeo().getLongitude(), twitter.getGeo().getLatitude()
};
+        Map<String, Object> coords = Maps.newHashMap();
+        coords.put("coordinates", coordiantes);
+        coords.put("type", "geo_point");
+        location.put("coordinates", coords);
+        extensions.put("location", location);
+    }
+
+    public void addTwitterExtensions(Activity activity, Twitter twitter, Interaction interaction)
{
+        Retweet retweet = twitter.getRetweet();
+        Map<String, Object> extensions = ensureExtensions(activity);
+        List<String> hashTags = Lists.newLinkedList();
+        List<Object> hts = Lists.newLinkedList();
+        if(twitter.getHashtags() != null) {
+            hts = twitter.getHashtags();
+        } else if (retweet != null) {
+            hts = retweet.getHashtags();
+        }
+        if(hts != null) {
+            for(Object ht : twitter.getHashtags()) {
+                if(ht instanceof String) {
+                    hashTags.add((String) ht);
+                } else {
+                    LOGGER.warn("Hashtag was not instance of String : {}", ht.getClass().getName());
+                }
+            }
+        }
+        extensions.put("hashtags", hashTags);
+
+
+        if(retweet != null) {
+            Map<String, Object> rebroadcasts = Maps.newHashMap();
+            rebroadcasts.put("perspectival", true);
+            rebroadcasts.put("count", retweet.getCount());
+            extensions.put("rebroadcasts", rebroadcasts);
+        }
+
+        if(interaction.getAdditionalProperties() != null) {
+            ArrayList<Map<String,Object>> userMentions = createUserMentions(interaction);
+
+            if(userMentions.size() > 0)
+                extensions.put("user_mentions", userMentions);
+        }
+
+        extensions.put("keywords", interaction.getContent());
+    }
+
+    /**
+     * Returns an ArrayList of all UserMentions in this interaction
+     * Note: The ID list and the handle lists do not necessarily correspond 1:1 for this
provider
+     * If those lists are the same size, then they will be merged into individual UserMention
+     * objects. However, if they are not the same size, a new UserMention object will be
created
+     * for each entry in both lists.
+     *
+     * @param interaction
+     * @return
+     */
+    private ArrayList<Map<String,Object>> createUserMentions(Interaction interaction)
{
+        ArrayList<String> mentions = (ArrayList<String>) interaction.getAdditionalProperties().get("mentions");
+        ArrayList<Long> mentionIds = (ArrayList<Long>) interaction.getAdditionalProperties().get("mention_ids");
+        ArrayList<Map<String,Object>> userMentions = new ArrayList<Map<String,Object>>();
+
+        if(mentions != null && !mentions.isEmpty()) {
+            for(int x = 0; x < mentions.size(); x ++) {
+                Map<String, Object> actor = new HashMap<String, Object>();
+                actor.put("displayName", mentions.get(x));
+                actor.put("handle", mentions.get(x));
+
+                userMentions.add(actor);
+            }
+        }
+        if(mentionIds != null && !mentionIds.isEmpty()) {
+            for(int x = 0; x < mentionIds.size(); x ++) {
+                Map<String, Object> actor = new HashMap<String, Object>();
+                actor.put("id", "id:twitter:" + mentionIds.get(x));
+
+                userMentions.add(actor);
+            }
+        }
+
+        return userMentions;
+    }
+
+    public static String formatId(String... idparts) {
+        return Joiner.on(":").join(Lists.asList("id:twitter", idparts));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/99e70b48/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftActivitySerializerTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftActivitySerializerTest.java
b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftActivitySerializerTest.java
index 162526b..8f7ad43 100644
--- a/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftActivitySerializerTest.java
+++ b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftActivitySerializerTest.java
@@ -4,10 +4,13 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.collect.Lists;
 import org.apache.commons.lang.StringUtils;
+import org.apache.streams.data.ActivitySerializer;
+import org.apache.streams.datasift.Datasift;
 import org.apache.streams.datasift.util.StreamsDatasiftMapper;
 import org.apache.streams.jackson.StreamsJacksonMapper;
 import org.apache.streams.pojo.json.Activity;
 import org.apache.streams.pojo.json.Actor;
+import org.junit.Before;
 import org.junit.Test;
 
 import java.util.Scanner;
@@ -17,18 +20,27 @@ import static org.junit.Assert.assertNotNull;
 
 public class DatasiftActivitySerializerTest {
 
-    private static final DatasiftActivitySerializer SERIALIZER = new DatasiftActivitySerializer();
+    protected ActivitySerializer SERIALIZER;
 
-    private static final ObjectMapper MAPPER = StreamsJacksonMapper.getInstance(Lists.newArrayList(StreamsDatasiftMapper.DATASIFT_FORMAT));
+    protected static ObjectMapper MAPPER = StreamsJacksonMapper.getInstance(Lists.newArrayList(StreamsDatasiftMapper.DATASIFT_FORMAT));
+
+    @Before
+    public void initSerializer() {
+        SERIALIZER = new DatasiftActivitySerializer();
+    }
 
     @Test
-    public void testGeneralConversion() throws Exception {
+    public void testConversion() throws Exception {
         Scanner scanner = new Scanner(DatasiftActivitySerializerTest.class.getResourceAsStream("/rand_sample_datasift_json.txt"));
         String line = null;
         while(scanner.hasNextLine()) {
             try {
                 line = scanner.nextLine();
-                testGeneralConversion(line);
+                Datasift item = MAPPER.readValue(line, Datasift.class);
+                testConversion(item);
+                String json = MAPPER.writeValueAsString(item);
+                testDeserNoNull(json);
+                testDeserNoAddProps(json);
             } catch (Exception e) {
                 System.err.println(line);
                 throw e;
@@ -36,59 +48,27 @@ public class DatasiftActivitySerializerTest {
         }
     }
 
-    @Test
-    public void testTwitterConversion() throws Exception {
-        Scanner scanner = new Scanner(DatasiftActivitySerializerTest.class.getResourceAsStream("/twitter_datasift_json.txt"));
-        String line = null;
-        while(scanner.hasNextLine()) {
-            line = scanner.nextLine();
-            testGeneralConversion(line);
-            testDeserNoNull(line);
-            testDeserNoAddProps(line);
-
-            System.out.println("ORIGINAL -> "+line);
-            System.out.println("ACTIVITY -> "+MAPPER.writeValueAsString(SERIALIZER.deserialize(line)));
-            System.out.println("NODE     -> "+MAPPER.convertValue(SERIALIZER.deserialize(line),
JsonNode.class));
-        }
-    }
-
-    @Test
-    public void testInstagramConversion() throws Exception {
-        Scanner scanner = new Scanner(DatasiftActivitySerializerTest.class.getResourceAsStream("/instagram_datasift_json.txt"));
-        String line = null;
-        while(scanner.hasNextLine()) {
-            line = scanner.nextLine();
-            testGeneralConversion(line);
-            System.out.println("ORIGINAL -> "+line);
-            System.out.println("ACTIVITY -> "+MAPPER.writeValueAsString(SERIALIZER.deserialize(line)));
-            System.out.println("NODE     -> "+MAPPER.convertValue(SERIALIZER.deserialize(line),
JsonNode.class));
-        }
-    }
-
     /**
      * Test that the minimum number of things that an activity has
-     * @param json
+     * @param item
      */
-    private void testGeneralConversion(String json) throws Exception {
-        Activity activity = SERIALIZER.deserialize(json);
-        assertNotNull(json, activity.getId());
-        assertNotNull(json, activity.getPublished());
-        assertNotNull(json, activity.getProvider());
-        assertNotNull(json, activity.getUrl());
-        assertNotNull(json, activity.getVerb());
+    protected void testConversion(Datasift item) throws Exception {
+        Activity activity = SERIALIZER.deserialize(item);
+        assertNotNull("activity.id", activity.getId());
+        assertNotNull("activity.published", activity.getPublished());
+        assertNotNull("activity.provider", activity.getProvider());
+        assertNotNull("activity.url", activity.getUrl());
+        assertNotNull("activity.verb", activity.getVerb());
         Actor actor = activity.getActor();
-        assertNotNull(json, actor);
-
+        assertNotNull("activity.actor", actor);
     }
 
     /**
      * Test that null fields are not present
      * @param json
      */
-    private void testDeserNoNull(String json) throws Exception {
-        Activity ser = SERIALIZER.deserialize(json);
-        String deser = MAPPER.writeValueAsString(ser);
-        int nulls = StringUtils.countMatches(deser, ":null");
+    protected void testDeserNoNull(String json) throws Exception {
+        int nulls = StringUtils.countMatches(json, ":null");
         assertEquals(0l, (long)nulls);
 
     }
@@ -97,10 +77,8 @@ public class DatasiftActivitySerializerTest {
      * Test that null fields are not present
      * @param json
      */
-    private void testDeserNoAddProps(String json) throws Exception {
-        Activity ser = SERIALIZER.deserialize(json);
-        String deser = MAPPER.writeValueAsString(ser);
-        int nulls = StringUtils.countMatches(deser, "additionalProperties:{");
+    protected void testDeserNoAddProps(String json) throws Exception {
+        int nulls = StringUtils.countMatches(json, "additionalProperties:{");
         assertEquals(0l, (long)nulls);
 
     }

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/99e70b48/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftEventClassifierTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftEventClassifierTest.java
b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftEventClassifierTest.java
index 2004654..fda57c4 100644
--- a/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftEventClassifierTest.java
+++ b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftEventClassifierTest.java
@@ -18,25 +18,13 @@
 
 package org.apache.streams.datasift.serializer;
 
-import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.collect.Lists;
-import org.apache.streams.data.ActivitySerializer;
 import org.apache.streams.datasift.Datasift;
 import org.apache.streams.datasift.instagram.Instagram;
 import org.apache.streams.datasift.twitter.Twitter;
 import org.apache.streams.datasift.util.StreamsDatasiftMapper;
 import org.apache.streams.jackson.StreamsJacksonMapper;
-import org.apache.streams.twitter.pojo.Delete;
-import org.apache.streams.twitter.pojo.Retweet;
-import org.apache.streams.twitter.pojo.Tweet;
-import org.apache.streams.twitter.pojo.User;
-import org.apache.streams.twitter.provider.TwitterEventClassifier;
-import org.apache.streams.twitter.serializer.TwitterJsonDeleteActivitySerializer;
-import org.apache.streams.twitter.serializer.TwitterJsonRetweetActivitySerializer;
-import org.apache.streams.twitter.serializer.TwitterJsonTweetActivitySerializer;
-import org.apache.streams.twitter.serializer.TwitterJsonUserActivitySerializer;
-import org.junit.Assert;
 import org.junit.Test;
 
 import java.util.Scanner;
@@ -56,7 +44,7 @@ public class DatasiftEventClassifierTest {
             line = scanner.nextLine();
             Datasift datasift = MAPPER.readValue(line, Datasift.class);
             assert(DatasiftEventClassifier.detectClass(datasift) == Twitter.class);
-            assert(DatasiftEventClassifier.bestSerializer(datasift) instanceof DatasiftTweetActivitySerializer);
+            assert(DatasiftEventClassifier.bestSerializer(datasift) instanceof DatasiftTwitterActivitySerializer);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/99e70b48/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftInstagramActivitySerializerTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftInstagramActivitySerializerTest.java
b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftInstagramActivitySerializerTest.java
new file mode 100644
index 0000000..5350d74
--- /dev/null
+++ b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftInstagramActivitySerializerTest.java
@@ -0,0 +1,43 @@
+package org.apache.streams.datasift.serializer;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.StringUtils;
+import org.apache.streams.datasift.Datasift;
+import org.apache.streams.datasift.util.StreamsDatasiftMapper;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.apache.streams.pojo.json.Activity;
+import org.apache.streams.pojo.json.Actor;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Scanner;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class DatasiftInstagramActivitySerializerTest extends DatasiftActivitySerializerTest
{
+
+    @Before
+    @Override
+    public void initSerializer() {
+        SERIALIZER = new DatasiftInstagramActivitySerializer();
+    }
+
+    @Test
+    @Override
+    public void testConversion() throws Exception {
+        Scanner scanner = new Scanner(DatasiftActivitySerializerTest.class.getResourceAsStream("/instagram_datasift_json.txt"));
+        String line = null;
+        while(scanner.hasNextLine()) {
+            line = scanner.nextLine();
+            Datasift item = MAPPER.readValue(line, Datasift.class);
+            testConversion(item);
+            String json = MAPPER.writeValueAsString(item);
+            testDeserNoNull(json);
+            testDeserNoAddProps(json);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/99e70b48/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftInteractionActivitySerializerTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftInteractionActivitySerializerTest.java
b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftInteractionActivitySerializerTest.java
new file mode 100644
index 0000000..21d4ebb
--- /dev/null
+++ b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftInteractionActivitySerializerTest.java
@@ -0,0 +1,48 @@
+package org.apache.streams.datasift.serializer;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.StringUtils;
+import org.apache.streams.datasift.Datasift;
+import org.apache.streams.datasift.util.StreamsDatasiftMapper;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.apache.streams.pojo.json.Activity;
+import org.apache.streams.pojo.json.Actor;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Scanner;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class DatasiftInteractionActivitySerializerTest extends DatasiftActivitySerializerTest
{
+
+    @Before
+    @Override
+    public void initSerializer() {
+        SERIALIZER = new DatasiftInteractionActivitySerializer();
+    }
+
+    @Test
+    @Override
+    public void testConversion() throws Exception {
+        Scanner scanner = new Scanner(DatasiftInteractionActivitySerializerTest.class.getResourceAsStream("/rand_sample_datasift_json.txt"));
+        String line = null;
+        while(scanner.hasNextLine()) {
+            try {
+                line = scanner.nextLine();
+                Datasift item = MAPPER.readValue(line, Datasift.class);
+                testConversion(item);
+                String json = MAPPER.writeValueAsString(item);
+                testDeserNoNull(json);
+                testDeserNoAddProps(json);
+            } catch (Exception e) {
+                System.err.println(line);
+                throw e;
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/99e70b48/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftTwitterActivitySerializerTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftTwitterActivitySerializerTest.java
b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftTwitterActivitySerializerTest.java
new file mode 100644
index 0000000..33b1f77
--- /dev/null
+++ b/streams-contrib/streams-provider-datasift/src/test/java17/org/apache/streams/datasift/serializer/DatasiftTwitterActivitySerializerTest.java
@@ -0,0 +1,43 @@
+package org.apache.streams.datasift.serializer;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.StringUtils;
+import org.apache.streams.datasift.Datasift;
+import org.apache.streams.datasift.util.StreamsDatasiftMapper;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.apache.streams.pojo.json.Activity;
+import org.apache.streams.pojo.json.Actor;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Scanner;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class DatasiftTwitterActivitySerializerTest extends DatasiftActivitySerializerTest
{
+
+    @Before
+    @Override
+    public void initSerializer() {
+        SERIALIZER = new DatasiftTwitterActivitySerializer();
+    }
+
+    @Test
+    @Override
+    public void testConversion() throws Exception {
+        Scanner scanner = new Scanner(DatasiftTwitterActivitySerializerTest.class.getResourceAsStream("/twitter_datasift_json.txt"));
+        String line = null;
+        while(scanner.hasNextLine()) {
+            line = scanner.nextLine();
+            Datasift item = MAPPER.readValue(line, Datasift.class);
+            testConversion(item);
+            String json = MAPPER.writeValueAsString(item);
+            testDeserNoNull(json);
+            testDeserNoAddProps(json);
+        }
+    }
+
+}


Mime
View raw message