You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streams.apache.org by mf...@apache.org on 2014/08/18 18:29:37 UTC
[1/7] git commit: STREAMS-145 | Updated TypeConverter and added in:
Page serializer, EventClassifier, Page JSON schema and a multitude of tests
Repository: incubator-streams
Updated Branches:
refs/heads/master c33f66544 -> 92a8bef2a
STREAMS-145 | Updated TypeConverter and added in: Page serializer, EventClassifier, Page JSON schema and a multitude of tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/2b96a286
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/2b96a286
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/2b96a286
Branch: refs/heads/master
Commit: 2b96a28631a310d1df719067ab4b2da7dd993592
Parents: 2977287
Author: Robert Douglas <rd...@w2odigital.com>
Authored: Wed Aug 13 15:34:32 2014 -0500
Committer: Robert Douglas <rd...@w2odigital.com>
Committed: Wed Aug 13 16:32:58 2014 -0500
----------------------------------------------------------------------
pom.xml | 1 +
.../streams-provider-facebook/pom.xml | 5 +-
.../api/FacebookPageActivitySerializer.java | 66 ++++++++
.../processor/FacebookTypeConverter.java | 41 +++--
.../provider/FacebookEventClassifier.java | 53 ++++++
.../serializer/FacebookActivityUtil.java | 125 ++++++++++++++
.../org/apache/streams/facebook/Page.json | 168 +++++++++++++++++++
.../test/FacebookActivityActorSerDeTest.java | 72 ++++++++
.../test/FacebookActivitySerDeTest.java | 7 -
.../test/FacebookEventClassifierTest.java | 55 ++++++
.../facebook/test/FacebookPageSerDeTest.java | 75 +++++++++
.../facebook/test/FacebookPostSerDeTest.java | 1 -
.../streams/facebook/test/SimplePageTest.java | 106 ++++++++++++
.../src/test/resources/testpage.json | 1 +
14 files changed, 748 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 419ef89..da30926 100644
--- a/pom.xml
+++ b/pom.xml
@@ -87,6 +87,7 @@
<netty.version>3.8.0.Final</netty.version>
<json-path.version>0.9.1</json-path.version>
<build-helper.version>1.8</build-helper.version>
+ <facebook4j.version>2.1.1-W2O-SNAPSHOT</facebook4j.version>
</properties>
<modules>
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/pom.xml
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/pom.xml b/streams-contrib/streams-provider-facebook/pom.xml
index d688a00..1ccf20e 100644
--- a/streams-contrib/streams-provider-facebook/pom.xml
+++ b/streams-contrib/streams-provider-facebook/pom.xml
@@ -5,7 +5,7 @@
<parent>
<artifactId>streams-contrib</artifactId>
<groupId>org.apache.streams</groupId>
- <version>0.1-SNAPSHOT</version>
+ <version>0.1.0-W2O-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>streams-provider-facebook</artifactId>
@@ -56,7 +56,7 @@
<dependency>
<groupId>org.facebook4j</groupId>
<artifactId>facebook4j-core</artifactId>
- <version>2.1.0</version>
+ <version>${facebook4.version}</version>
</dependency>
</dependencies>
@@ -105,6 +105,7 @@
<sourcePath>src/main/jsonschema/org/apache/streams/facebook/FacebookUserInformationConfiguration.json</sourcePath>
<sourcePath>src/main/jsonschema/org/apache/streams/facebook/FacebookUserstreamConfiguration.json</sourcePath>
<sourcePath>src/main/jsonschema/org/apache/streams/facebook/graph/Post.json</sourcePath>
+ <sourcePath>src/main/jsonschema/org/apache/streams/facebook/Page.json</sourcePath>
</sourcePaths>
<outputDirectory>target/generated-sources/jsonschema2pojo</outputDirectory>
<targetPackage>com.facebook</targetPackage>
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/api/FacebookPageActivitySerializer.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/api/FacebookPageActivitySerializer.java b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/api/FacebookPageActivitySerializer.java
new file mode 100644
index 0000000..f59ab1e
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/api/FacebookPageActivitySerializer.java
@@ -0,0 +1,66 @@
+/*
+ * 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
+ *
+ * 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.facebook.api;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.streams.data.ActivitySerializer;
+import org.apache.streams.exceptions.ActivitySerializerException;
+import org.apache.streams.facebook.serializer.FacebookActivityUtil;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.apache.streams.pojo.json.*;
+import org.apache.streams.facebook.Page;
+
+import java.util.List;
+
+/**
+ * Serializes activity posts
+ * sblackmon: This class needs a rewrite
+ */
+public class FacebookPageActivitySerializer implements ActivitySerializer<Page> {
+
+ public static ObjectMapper mapper;
+ static {
+ mapper = StreamsJacksonMapper.getInstance();
+ }
+
+ @Override
+ public String serializationFormat() {
+ return "facebook_post_json_v1";
+ }
+
+ @Override
+ public Page serialize(Activity deserialized) throws ActivitySerializerException {
+ throw new NotImplementedException("Not currently supported by this deserializer");
+ }
+
+ @Override
+ public Activity deserialize(Page page) throws ActivitySerializerException {
+ Activity activity = new Activity();
+
+ FacebookActivityUtil.updateActivity(page, activity);
+
+ return activity;
+ }
+
+ @Override
+ public List<Activity> deserializeAll(List<Page> serializedList) {
+ throw new NotImplementedException("Not currently supported by this deserializer");
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/processor/FacebookTypeConverter.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/processor/FacebookTypeConverter.java b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/processor/FacebookTypeConverter.java
index 2c6fd8e..7eb0e65 100644
--- a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/processor/FacebookTypeConverter.java
+++ b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/processor/FacebookTypeConverter.java
@@ -24,11 +24,14 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Lists;
+import org.apache.streams.facebook.Page;
import org.apache.streams.core.StreamsDatum;
import org.apache.streams.core.StreamsProcessor;
import org.apache.streams.exceptions.ActivitySerializerException;
import org.apache.streams.facebook.Post;
+import org.apache.streams.facebook.api.FacebookPageActivitySerializer;
import org.apache.streams.facebook.api.FacebookPostActivitySerializer;
+import org.apache.streams.facebook.provider.FacebookEventClassifier;
import org.apache.streams.jackson.StreamsJacksonMapper;
import org.apache.streams.pojo.json.Activity;
import org.slf4j.Logger;
@@ -38,12 +41,9 @@ import java.io.IOException;
import java.util.List;
import java.util.Queue;
-/**
- * Created by sblackmon on 12/10/13.
- */
public class FacebookTypeConverter implements StreamsProcessor {
- public final static String STREAMS_ID = "TwitterTypeConverter";
+ public final static String STREAMS_ID = "FacebookTypeConverter";
private final static Logger LOGGER = LoggerFactory.getLogger(FacebookTypeConverter.class);
@@ -56,6 +56,7 @@ public class FacebookTypeConverter implements StreamsProcessor {
private Class outClass;
private FacebookPostActivitySerializer facebookPostActivitySerializer;
+ private FacebookPageActivitySerializer facebookPageActivitySerializer;
private int count = 0;
@@ -80,10 +81,19 @@ public class FacebookTypeConverter implements StreamsProcessor {
if( outClass.equals( Activity.class )) {
LOGGER.debug("ACTIVITY");
- result = facebookPostActivitySerializer.deserialize(mapper.convertValue(event, Post.class));
+ if(inClass.equals(Post.class)) {
+ LOGGER.debug("POST");
+ result = facebookPostActivitySerializer.deserialize(mapper.convertValue(event, Post.class));
+ } else if(inClass.equals(Page.class)) {
+ LOGGER.debug("PAGE");
+ result = facebookPageActivitySerializer.deserialize(mapper.convertValue(event, Page.class));
+ }
} else if( outClass.equals( Post.class )) {
LOGGER.debug("POST");
result = mapper.convertValue(event, Post.class);
+ } else if( outClass.equals(Page.class)) {
+ LOGGER.debug("PAGE");
+ result = mapper.convertValue(event, Page.class);
} else if( outClass.equals( ObjectNode.class )) {
LOGGER.debug("OBJECTNODE");
result = mapper.convertValue(event, ObjectNode.class);
@@ -98,7 +108,6 @@ public class FacebookTypeConverter implements StreamsProcessor {
LOGGER.debug("CONVERT FAILED");
return null;
-
}
public boolean validate(Object document, Class klass) {
@@ -130,7 +139,6 @@ public class FacebookTypeConverter implements StreamsProcessor {
StreamsDatum result = null;
try {
-
Object item = entry.getDocument();
ObjectNode node;
@@ -148,28 +156,26 @@ public class FacebookTypeConverter implements StreamsProcessor {
// since data is coming from outside provider, we don't know what type the events are
// for now we'll assume post
+ Class inClass = FacebookEventClassifier.detectClass((String) item);
- Object out = convert(node, Post.class, outClass);
+ Object out = convert(node, inClass, outClass);
if( out != null && validate(out, outClass))
result = new StreamsDatum(out);
}
- } else if( item instanceof ObjectNode || item instanceof Post) {
+ } else if( item instanceof ObjectNode) {
// first check for valid json
node = (ObjectNode)mapper.valueToTree(item);
- // since data is coming from outside provider, we don't know what type the events are
- // for now we'll assume post
+ Class inClass = FacebookEventClassifier.detectClass(mapper.writeValueAsString(item));
- Object out = convert(node, Post.class, outClass);
+ Object out = convert(node, inClass, outClass);
if( out != null && validate(out, outClass))
result = new StreamsDatum(out);
-
}
-
} catch (Exception e) {
e.printStackTrace();
}
@@ -183,12 +189,11 @@ public class FacebookTypeConverter implements StreamsProcessor {
@Override
public void prepare(Object o) {
mapper = new StreamsJacksonMapper();
+
+ facebookPageActivitySerializer = new FacebookPageActivitySerializer();
facebookPostActivitySerializer = new FacebookPostActivitySerializer();
}
@Override
- public void cleanUp() {
-
- }
-
+ public void cleanUp() {}
}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookEventClassifier.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookEventClassifier.java b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookEventClassifier.java
new file mode 100644
index 0000000..89abc74
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookEventClassifier.java
@@ -0,0 +1,53 @@
+/*
+ * 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
+ *
+ * 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.facebook.provider;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.IOException;
+
+import org.apache.streams.facebook.Page;
+import org.apache.streams.facebook.Post;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+
+public class FacebookEventClassifier {
+
+ public static Class detectClass( String json ) {
+
+ Preconditions.checkNotNull(json);
+ Preconditions.checkArgument(StringUtils.isNotEmpty(json));
+
+ ObjectNode objectNode;
+ try {
+ objectNode = (ObjectNode) StreamsJacksonMapper.getInstance().readTree(json);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ if( objectNode.findValue("about") != null)
+ return Page.class;
+ else if( objectNode.findValue("statusType") != null )
+ return Post.class;
+ else
+ return Post.class;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/serializer/FacebookActivityUtil.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/serializer/FacebookActivityUtil.java b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/serializer/FacebookActivityUtil.java
new file mode 100644
index 0000000..06053b5
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/serializer/FacebookActivityUtil.java
@@ -0,0 +1,125 @@
+/*
+ * 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
+ *
+ * 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.facebook.serializer;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Optional;
+import com.google.common.collect.Lists;
+import org.apache.streams.exceptions.ActivitySerializerException;
+import org.apache.streams.facebook.Cover;
+import org.apache.streams.facebook.Location;
+import org.apache.streams.facebook.Page;
+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.pojo.json.Provider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.streams.data.util.ActivityUtil.ensureExtensions;
+
+public class FacebookActivityUtil {
+ /**
+ * Updates the given Activity object with the values from the Page
+ * @param page the object to use as the source
+ * @param activity the target of the updates. Will receive all values from the Page.
+ * @throws org.apache.streams.exceptions.ActivitySerializerException
+ */
+ public static void updateActivity(Page page, Activity activity) throws ActivitySerializerException {
+ activity.setActor(buildActor(page));
+ activity.setId(null);
+ activity.setProvider(getProvider());
+ }
+
+ /**
+ * Gets the common facebook {@link org.apache.streams.pojo.json.Provider} object
+ * @return a provider object representing Facebook
+ */
+ public static Provider getProvider() {
+ Provider provider = new Provider();
+ provider.setId("id:providers:facebook");
+ provider.setDisplayName("Facebook");
+
+ return provider;
+ }
+
+ /**
+ * Builds the activity {@link org.apache.streams.pojo.json.Actor} object from the Page
+ * @param page the object to use as the source
+ * @return a valid Actor populated from the Page
+ */
+ public static Actor buildActor(Page page) {
+ Actor actor = new Actor();
+ actor.setId(formatId(
+ Optional.fromNullable(
+ page.getId())
+ .or(Optional.of(page.getId().toString()))
+ .orNull()
+ ));
+
+ actor.setDisplayName(page.getName());
+ actor.setAdditionalProperty("handle", page.getUsername());
+ actor.setSummary(page.getAbout());
+
+ if (page.getLink()!=null){
+ actor.setUrl(page.getLink());
+ }
+
+ Image profileImage = new Image();
+ Cover cover = page.getCover();
+
+ if(cover != null)
+ profileImage.setUrl(cover.getSource());
+ actor.setImage(profileImage);
+
+ buildExtensions(actor, page);
+
+ return actor;
+ }
+
+ /**
+ * Builds the actor extensions given the page object
+ * @param actor
+ * @param page
+ */
+ public static void buildExtensions(Actor actor, Page page) {
+ Map<String, Object> extensions = new HashMap<String, Object>();
+ Location location = page.getLocation();
+
+ if(location != null)
+ extensions.put("location", page.getLocation().toString());
+
+ extensions.put("favorites", page.getLikes());
+ extensions.put("followers", page.getTalkingAboutCount());
+
+ extensions.put("screenName", page.getUsername());
+
+ actor.setAdditionalProperty("extensions", extensions);
+ }
+
+ /**
+ * Formats the ID to conform with the Apache Streams activity ID convention
+ * @param idparts the parts of the ID to join
+ * @return a valid Activity ID in format "id:facebook:part1:part2:...partN"
+ */
+ public static String formatId(String... idparts) {
+ return Joiner.on(":").join(Lists.asList("id:facebook", idparts));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/main/jsonschema/org/apache/streams/facebook/Page.json
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/main/jsonschema/org/apache/streams/facebook/Page.json b/streams-contrib/streams-provider-facebook/src/main/jsonschema/org/apache/streams/facebook/Page.json
new file mode 100644
index 0000000..31a3bc5
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/main/jsonschema/org/apache/streams/facebook/Page.json
@@ -0,0 +1,168 @@
+{
+ "type":"object",
+ "$schema":"http://json-schema.org/draft-03/schema",
+ "id":"#",
+ "javaType":"org.apache.streams.facebook.Page",
+ "javaInterfaces":[
+ "java.io.Serializable"
+ ],
+ "properties":{
+ "about":{
+ "type":"string",
+ "required":false
+ },
+ "username":{
+ "type":"string",
+ "required":false
+ },
+ "accessToken":{
+ "type":"null",
+ "id":"http://jsonschema.net/accessToken",
+ "required":false
+ },
+ "category":{
+ "type":"string",
+ "id":"http://jsonschema.net/category",
+ "required":false
+ },
+ "checkins":{
+ "type":"integer",
+ "id":"http://jsonschema.net/checkins",
+ "required":false
+ },
+ "communityPage":{
+ "type":"boolean",
+ "id":"http://jsonschema.net/communityPage",
+ "required":false
+ },
+ "cover":{
+ "type":"object",
+ "id":"http://jsonschema.net/cover",
+ "required":false,
+ "properties":{
+ "id":{
+ "type":"null",
+ "id":"http://jsonschema.net/cover/id",
+ "required":false
+ },
+ "offsetY":{
+ "type":"number",
+ "id":"http://jsonschema.net/cover/offsetY",
+ "required":false
+ },
+ "source":{
+ "type":"string",
+ "id":"http://jsonschema.net/cover/source",
+ "required":false
+ }
+ }
+ },
+ "createdTime":{
+ "type":"null",
+ "id":"http://jsonschema.net/createdTime",
+ "required":false
+ },
+ "id":{
+ "type":"string",
+ "id":"http://jsonschema.net/id",
+ "required":false
+ },
+ "likes":{
+ "type":"integer",
+ "id":"http://jsonschema.net/likes",
+ "required":false
+ },
+ "link":{
+ "type":"string",
+ "id":"http://jsonschema.net/link",
+ "required":false
+ },
+ "location":{
+ "type":"object",
+ "id":"http://jsonschema.net/location",
+ "required":false,
+ "properties":{
+ "city":{
+ "type":"string",
+ "id":"http://jsonschema.net/location/city",
+ "required":false
+ },
+ "country":{
+ "type":"string",
+ "id":"http://jsonschema.net/location/country",
+ "required":false
+ },
+ "latitude":{
+ "type":"null",
+ "id":"http://jsonschema.net/location/latitude",
+ "required":false
+ },
+ "longitude":{
+ "type":"null",
+ "id":"http://jsonschema.net/location/longitude",
+ "required":false
+ },
+ "state":{
+ "type":"string",
+ "id":"http://jsonschema.net/location/state",
+ "required":false
+ },
+ "street":{
+ "type":"string",
+ "id":"http://jsonschema.net/location/street",
+ "required":false
+ },
+ "text":{
+ "type":"null",
+ "id":"http://jsonschema.net/location/text",
+ "required":false
+ },
+ "zip":{
+ "type":"string",
+ "id":"http://jsonschema.net/location/zip",
+ "required":false
+ }
+ }
+ },
+ "metadata":{
+ "type":"null",
+ "id":"http://jsonschema.net/metadata",
+ "required":false
+ },
+ "name":{
+ "type":"string",
+ "id":"http://jsonschema.net/name",
+ "required":false
+ },
+ "phone":{
+ "type":"string",
+ "id":"http://jsonschema.net/phone",
+ "required":false
+ },
+ "picture":{
+ "type":"null",
+ "id":"http://jsonschema.net/picture",
+ "required":false
+ },
+ "published":{
+ "type":"boolean",
+ "id":"http://jsonschema.net/published",
+ "required":false
+ },
+ "talkingAboutCount":{
+ "type":"integer",
+ "id":"http://jsonschema.net/talkingAboutCount",
+ "required":false
+ },
+ "website":{
+ "type":"string",
+ "id":"http://jsonschema.net/website",
+ "required":false
+ },
+ "wereHereCount":{
+ "type":"integer",
+ "id":"http://jsonschema.net/wereHereCount",
+ "required":false
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivityActorSerDeTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivityActorSerDeTest.java b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivityActorSerDeTest.java
new file mode 100644
index 0000000..b30cb90
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivityActorSerDeTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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
+ *
+ * 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.facebook.test;
+
+import org.apache.streams.facebook.Page;
+import org.apache.streams.facebook.api.FacebookPageActivitySerializer;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Joiner;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.BoundedInputStream;
+import org.apache.streams.facebook.Post;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.apache.streams.pojo.json.Activity;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+
+public class FacebookActivityActorSerDeTest {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger(FacebookActivityActorSerDeTest.class);
+ private FacebookPageActivitySerializer serializer = new FacebookPageActivitySerializer();
+ private ObjectMapper mapper = StreamsJacksonMapper.getInstance();
+
+ @Test
+ public void Tests()
+ {
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.TRUE);
+ mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
+ mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);
+
+ InputStream is = FacebookActivityActorSerDeTest.class.getResourceAsStream("/testpage.json");
+ Joiner joiner = Joiner.on(" ").skipNulls();
+ is = new BoundedInputStream(is, 10000);
+ String json;
+
+ try {
+ json = joiner.join(IOUtils.readLines(is));
+ LOGGER.debug(json);
+
+ Page page = mapper.readValue(json, Page.class);
+
+ Activity activity = serializer.deserialize(page);
+
+ LOGGER.debug(mapper.writeValueAsString(activity));
+
+ } catch( Exception e ) {
+ System.out.println(e);
+ e.printStackTrace();
+ Assert.fail();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivitySerDeTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivitySerDeTest.java b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivitySerDeTest.java
index 4de9ab3..13623cf 100644
--- a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivitySerDeTest.java
+++ b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivitySerDeTest.java
@@ -34,13 +34,6 @@ import org.slf4j.LoggerFactory;
import java.io.InputStream;
-/**
-* Created with IntelliJ IDEA.
-* User: sblackmon
-* Date: 8/20/13
-* Time: 5:57 PM
-* To change this template use File | Settings | File Templates.
-*/
public class FacebookActivitySerDeTest {
private final static Logger LOGGER = LoggerFactory.getLogger(FacebookActivitySerDeTest.class);
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookEventClassifierTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookEventClassifierTest.java b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookEventClassifierTest.java
new file mode 100644
index 0000000..9cf7196
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookEventClassifierTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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
+ *
+ * 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.facebook.test;
+
+import org.apache.streams.facebook.Page;
+import org.apache.streams.facebook.Post;
+import org.apache.streams.facebook.provider.FacebookEventClassifier;
+import org.junit.Test;
+
+public class FacebookEventClassifierTest {
+ private String empty = "";
+ private String def = "{}";
+ private String post = "{\"metadata\":null,\"id\":\"687664828_10153082499914829\",\"from\":{\"metadata\":null,\"id\":\"687664828\",\"name\":\"Steve Blackmon\",\"category\":null,\"createdTime\":null},\"message\":null,\"picture\":\"https://fbexternal-a.akamaihd.net/app_full_proxy.php?app=184136951108&v=1&size=z&cksum=7f4094dff37cedd69072cd2c0b3728b7&src=https%3A%2F%2Fstatic.tripit.com%2Fimages%2Fplaces%2Fsantamonica.jpg%3Fv%3D2014-08-13\",\"link\":\"http://www.tripit.com/trip/show/id/130372979/traveler_fb_uid/687664828?us=fc&um=fa&un=fd\",\"name\":\"Steve is about to leave on a trip to Santa Monica, CA.\",\"caption\":\"Aug 2014 for 3 days\",\"description\":\"TripIt - Free online trip planner and free travel itinerary website for organizing vacations, group trips or business travel\",\"source\":null,\"icon\":\"https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-xpa1/t39.2080-0/851580_10151367869221109_1073679965_n.gif\",\"actions\":[{\"name\":\"Comment\",\"link\":\"https://www.facebook
.com/687664828/posts/10153082499914829\"},{\"name\":\"Like\",\"link\":\"https://www.facebook.com/687664828/posts/10153082499914829\"},{\"name\":\"Plan a trip on TripIt\",\"link\":\"http://www.tripit.com/?us=fc&um=fa&un=fd\"}],\"privacy\":{\"value\":\"ALL_FRIENDS\",\"friends\":\"EMPTY\",\"description\":[\"Your friends\"]},\"type\":\"link\",\"sharesCount\":null,\"place\":null,\"statusType\":\"app_created_story\",\"story\":null,\"objectId\":null,\"application\":{\"id\":\"184136951108\",\"name\":\"TripIt\",\"description\":null,\"category\":null,\"company\":null,\"iconUrl\":null,\"subcategory\":null,\"link\":null,\"logoUrl\":null,\"dailyActiveUsers\":null,\"weeklyActiveUsers\":null,\"monthlyActiveUsers\":null,\"namespace\":\"tripitcom\",\"authDialogDataHelpUrl\":null,\"authDialogDescription\":null,\"authDialogHeadline\":null,\"authDialogPermsExplanation\":null,\"authReferralDefaultActivityPrivacy\":null,\"authReferralResponseType\":null,\"canvasUrl\":null,\"contactEmail\":null,\"createdT
ime\":null,\"creatorUid\":null,\"deauthCallbackUrl\":null,\"iphoneAppStoreId\":null,\"hostingUrl\":null,\"mobileWebUrl\":null,\"pageTabDefaultName\":null,\"pageTabUrl\":null,\"privacyPolicyUrl\":null,\"secureCanvasUrl\":null,\"securePageTabUrl\":null,\"serverIpWhitelist\":null,\"termsOfServiceUrl\":null,\"userSupportEmail\":null,\"userSupportUrl\":null,\"websiteUrl\":null,\"canvasName\":null},\"createdTime\":\"2014-08-13T12:22:20.000+0000\",\"updatedTime\":\"2014-08-13T12:22:20.000+0000\",\"scheduledPublishTime\":null,\"targeting\":null,\"published\":null}";
+ private String page = "{\"metadata\":null,\"id\":\"142803045874943\",\"name\":\"Senator Angus S. King, Jr.\",\"category\":\"Government official\",\"createdTime\":null,\"link\":\"https://www.facebook.com/SenatorAngusSKingJr\",\"likes\":10246,\"location\":{\"street\":\"359 Dirksen Senate Office Building\",\"city\":\"Washington, District of Columbia\",\"state\":\"DC\",\"country\":\"United States\",\"zip\":\"20510\",\"latitude\":null,\"longitude\":null,\"text\":null},\"phone\":\"202-224-5344\",\"checkins\":0,\"picture\":null,\"cover\":{\"id\":null,\"source\":\"https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/10288792_321537751334804_8200105519500362465_n.jpg?oh=fbcde9b3e1e011dfa3e699628629bc53&oe=546FB617&__gda__=1416717487_3fa5781d7d9c3d58f2bc798a36ac6fc0\",\"offsetY\":9},\"website\":\"http://www.king.senate.gov\",\"talkingAboutCount\":5034,\"accessToken\":null,\"wereHereCount\":0,\"about\":\"Welcome to the official Facebook page of Senator Angus S. King, Jr. (I-ME).
\\nhttp://king.senate.gov\\nhttps://twitter.com/SenAngusKing\\nhttps://www.youtube.com/SenatorAngusKing\",\"username\":\"SenatorAngusSKingJr\",\"published\":true,\"communityPage\":false}";
+
+
+ @Test(expected=IllegalArgumentException.class)
+ public void emptyJSONTest() {
+ Class inClass = FacebookEventClassifier.detectClass(empty);
+ }
+
+ @Test
+ public void defaultDetectTest() {
+ Class inClass = FacebookEventClassifier.detectClass(post);
+ assert(inClass.equals(Post.class));
+ }
+
+ @Test
+ public void postDetectTest() {
+ Class inClass = FacebookEventClassifier.detectClass(post);
+ assert(inClass.equals(Post.class));
+ }
+
+ @Test
+ public void pageDetectTest() {
+ Class inClass = FacebookEventClassifier.detectClass(page);
+ assert(inClass.equals(Page.class));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookPageSerDeTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookPageSerDeTest.java b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookPageSerDeTest.java
new file mode 100644
index 0000000..2edffaa
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookPageSerDeTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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
+ *
+ * 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.facebook.test;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Joiner;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.BoundedInputStream;
+import org.apache.streams.facebook.Page;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+
+public class FacebookPageSerDeTest {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger(FacebookPostSerDeTest.class);
+ private ObjectMapper mapper = StreamsJacksonMapper.getInstance();
+
+ @Test
+ public void Tests()
+ {
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.TRUE);
+ mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
+ mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);
+
+ InputStream is = FacebookPostSerDeTest.class.getResourceAsStream("/testpage.json");
+ Joiner joiner = Joiner.on(" ").skipNulls();
+ is = new BoundedInputStream(is, 10000);
+ String json;
+
+ try {
+ json = joiner.join(IOUtils.readLines(is));
+ LOGGER.debug(json);
+
+ Page ser = mapper.readValue(json, Page.class);
+
+ String de = mapper.writeValueAsString(ser);
+
+ LOGGER.debug(de);
+
+ Page serde = mapper.readValue(de, Page.class);
+
+ Assert.assertEquals(ser, serde);
+
+ LOGGER.debug(mapper.writeValueAsString(serde));
+
+ } catch( Exception e ) {
+ System.out.println(e);
+ e.printStackTrace();
+ Assert.fail();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookPostSerDeTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookPostSerDeTest.java b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookPostSerDeTest.java
index 6a761cb..bbe2eeb 100644
--- a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookPostSerDeTest.java
+++ b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookPostSerDeTest.java
@@ -45,7 +45,6 @@ public class FacebookPostSerDeTest {
private final static Logger LOGGER = LoggerFactory.getLogger(FacebookPostSerDeTest.class);
private ObjectMapper mapper = StreamsJacksonMapper.getInstance();
- @Ignore
@Test
public void Tests()
{
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/SimplePageTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/SimplePageTest.java b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/SimplePageTest.java
new file mode 100644
index 0000000..0dd57ca
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/SimplePageTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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
+ *
+ * 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.facebook.test;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.streams.core.StreamsDatum;
+import org.apache.streams.exceptions.ActivitySerializerException;
+import org.apache.streams.facebook.Page;
+import org.apache.streams.facebook.api.FacebookPageActivitySerializer;
+import org.apache.streams.facebook.processor.FacebookTypeConverter;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.apache.streams.pojo.json.Activity;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+public class SimplePageTest {
+ private final static Logger LOGGER = LoggerFactory.getLogger(SimplePageTest.class);
+ private ObjectMapper mapper = StreamsJacksonMapper.getInstance();
+
+ private static final String FACEBOOK_JSON= "{\"metadata\":null,\"id\":\"142803045874943\",\"name\":\"Senator Angus S. King, Jr.\",\"category\":\"Government official\",\"createdTime\":null,\"link\":\"https://www.facebook.com/SenatorAngusSKingJr\",\"likes\":10246,\"location\":{\"street\":\"359 Dirksen Senate Office Building\",\"city\":\"Washington, District of Columbia\",\"state\":\"DC\",\"country\":\"United States\",\"zip\":\"20510\",\"latitude\":null,\"longitude\":null,\"text\":null},\"phone\":\"202-224-5344\",\"checkins\":0,\"picture\":null,\"cover\":{\"id\":null,\"source\":\"https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/10288792_321537751334804_8200105519500362465_n.jpg?oh=fbcde9b3e1e011dfa3e699628629bc53&oe=546FB617&__gda__=1416717487_3fa5781d7d9c3d58f2bc798a36ac6fc0\",\"offsetY\":9},\"website\":\"http://www.king.senate.gov\",\"talkingAboutCount\":5034,\"accessToken\":null,\"wereHereCount\":0,\"about\":\"Welcome to the official Facebook page of Senator Angus
S. King, Jr. (I-ME).\\nhttp://king.senate.gov\\nhttps://twitter.com/SenAngusKing\\nhttps://www.youtube.com/SenatorAngusKing\",\"username\":\"SenatorAngusSKingJr\",\"published\":true,\"communityPage\":false}";
+
+ private FacebookPageActivitySerializer facebookPageActivitySerializer = new FacebookPageActivitySerializer();
+
+ @Test
+ public void Tests()
+ {
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.TRUE);
+ mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
+ mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);
+
+ InputStream is = SimplePageTest.class.getResourceAsStream("/testpage.json");
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader br = new BufferedReader(isr);
+
+ ObjectNode event = null;
+ try {
+ event = (ObjectNode) mapper.readTree(FACEBOOK_JSON);
+ } catch (IOException e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+
+ assertThat(event, is(not(nullValue())));
+
+ Page page = mapper.convertValue(event, Page.class);
+
+ assertThat(page, is(not(nullValue())));
+ assertThat(page.getAbout(), is(not(nullValue())));
+ assertThat(page.getLikes(), is(not(nullValue())));
+ assertThat(page.getTalkingAboutCount(), is(not(nullValue())));
+
+ Activity activity = null;
+ try {
+ activity = facebookPageActivitySerializer.deserialize(page);
+ } catch (ActivitySerializerException e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+
+ try {
+ FacebookTypeConverter converter = new FacebookTypeConverter(String.class, Activity.class);
+ converter.prepare(null);
+ converter.process(new StreamsDatum(FACEBOOK_JSON));
+ } catch (Throwable e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+
+ assertThat(activity, is(not(nullValue())));
+
+ assertThat(activity.getActor(), is(not(nullValue())));
+ assertThat(activity.getActor().getId(), is(not(nullValue())));
+ assertThat(activity.getVerb(), is(not(nullValue())));
+ assertThat(activity.getProvider(), is(not(nullValue())));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2b96a286/streams-contrib/streams-provider-facebook/src/test/resources/testpage.json
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/resources/testpage.json b/streams-contrib/streams-provider-facebook/src/test/resources/testpage.json
new file mode 100644
index 0000000..19d5135
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/test/resources/testpage.json
@@ -0,0 +1 @@
+{"metadata":null,"id":"142803045874943","name":"Senator Angus S. King, Jr.","category":"Government official","createdTime":null,"link":"https://www.facebook.com/SenatorAngusSKingJr","likes":10246,"location":{"street":"359 Dirksen Senate Office Building","city":"Washington, District of Columbia","state":"DC","country":"United States","zip":"20510","latitude":null,"longitude":null,"text":null},"phone":"202-224-5344","checkins":0,"picture":null,"cover":{"id":null,"source":"https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/10288792_321537751334804_8200105519500362465_n.jpg?oh=fbcde9b3e1e011dfa3e699628629bc53&oe=546FB617&__gda__=1416717487_3fa5781d7d9c3d58f2bc798a36ac6fc0","offsetY":9},"website":"http://www.king.senate.gov","talkingAboutCount":5034,"accessToken":null,"wereHereCount":0,"about":"Welcome to the official Facebook page of Senator Angus S. King, Jr. (I-ME).\nhttp://king.senate.gov\nhttps://twitter.com/SenAngusKing\nhttps://www.youtube.com/SenatorAngusKing","usern
ame":"SenatorAngusSKingJr","published":true,"communityPage":false}
\ No newline at end of file
[2/7] git commit: STREAMS-145 | Fixed facebook4j version naming error
Posted by mf...@apache.org.
STREAMS-145 | Fixed facebook4j version naming error
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/d027bfd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/d027bfd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/d027bfd7
Branch: refs/heads/master
Commit: d027bfd7e987ef7263bbd8ed137d985e7094de97
Parents: 2b96a28
Author: Robert Douglas <rd...@w2odigital.com>
Authored: Wed Aug 13 16:33:30 2014 -0500
Committer: Robert Douglas <rd...@w2odigital.com>
Committed: Wed Aug 13 16:33:30 2014 -0500
----------------------------------------------------------------------
streams-contrib/streams-provider-facebook/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d027bfd7/streams-contrib/streams-provider-facebook/pom.xml
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/pom.xml b/streams-contrib/streams-provider-facebook/pom.xml
index 1ccf20e..a267653 100644
--- a/streams-contrib/streams-provider-facebook/pom.xml
+++ b/streams-contrib/streams-provider-facebook/pom.xml
@@ -56,7 +56,7 @@
<dependency>
<groupId>org.facebook4j</groupId>
<artifactId>facebook4j-core</artifactId>
- <version>${facebook4.version}</version>
+ <version>${facebook4j.version}</version>
</dependency>
</dependencies>
[7/7] git commit: Merge PR#68 from 'robdouglas/STREAMS-145'
Posted by mf...@apache.org.
Merge PR#68 from 'robdouglas/STREAMS-145'
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/92a8bef2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/92a8bef2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/92a8bef2
Branch: refs/heads/master
Commit: 92a8bef2a028655a39b1d7d32979fdcac93c7363
Parents: c33f665 02951c5
Author: mfranklin <mf...@apache.org>
Authored: Mon Aug 18 11:11:16 2014 -0500
Committer: mfranklin <mf...@apache.org>
Committed: Mon Aug 18 11:11:16 2014 -0500
----------------------------------------------------------------------
pom.xml | 1 +
.../streams-provider-facebook/pom.xml | 2 +
.../api/FacebookPageActivitySerializer.java | 66 ++++++++
.../processor/FacebookTypeConverter.java | 41 +++--
.../provider/FacebookEventClassifier.java | 57 +++++++
.../provider/FacebookStreamConfigurator.java | 66 ++++++++
.../serializer/FacebookActivityUtil.java | 125 ++++++++++++++
.../org/apache/streams/facebook/Page.json | 168 +++++++++++++++++++
.../test/FacebookActivityActorSerDeTest.java | 65 +++++++
.../test/FacebookActivitySerDeTest.java | 7 -
.../test/FacebookEventClassifierTest.java | 57 +++++++
.../facebook/test/FacebookPageSerDeTest.java | 75 +++++++++
.../facebook/test/FacebookPostSerDeTest.java | 1 -
.../streams/facebook/test/SimplePageTest.java | 100 +++++++++++
.../src/test/resources/testpage.json | 1 +
15 files changed, 806 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
[4/7] git commit: STREAMS-145 | Removed W2O specific version number
Posted by mf...@apache.org.
STREAMS-145 | Removed W2O specific version number
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/17f32cd4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/17f32cd4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/17f32cd4
Branch: refs/heads/master
Commit: 17f32cd47267a9102e5224d6b4ed2da411d89cd8
Parents: b9597d0
Author: Robert Douglas <rd...@w2odigital.com>
Authored: Wed Aug 13 16:43:53 2014 -0500
Committer: Robert Douglas <rd...@w2odigital.com>
Committed: Wed Aug 13 16:43:53 2014 -0500
----------------------------------------------------------------------
streams-contrib/streams-provider-facebook/pom.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/17f32cd4/streams-contrib/streams-provider-facebook/pom.xml
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/pom.xml b/streams-contrib/streams-provider-facebook/pom.xml
index 3c4a6f2..50da134 100644
--- a/streams-contrib/streams-provider-facebook/pom.xml
+++ b/streams-contrib/streams-provider-facebook/pom.xml
@@ -5,7 +5,7 @@
<parent>
<artifactId>streams-contrib</artifactId>
<groupId>org.apache.streams</groupId>
- <version>0.1.0-W2O-SNAPSHOT</version>
+ <version>0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>streams-provider-facebook</artifactId>
@@ -63,6 +63,7 @@
<build>
<sourceDirectory>src/main/java</sourceDirectory>
+
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
[3/7] git commit: STREAMS-145 | Removed unnecessary facebook4j
version number
Posted by mf...@apache.org.
STREAMS-145 | Removed unnecessary facebook4j version number
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/b9597d0e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/b9597d0e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/b9597d0e
Branch: refs/heads/master
Commit: b9597d0ef2ec2efd5dfc80d3b52dc4acde854fa1
Parents: d027bfd
Author: Robert Douglas <rd...@w2odigital.com>
Authored: Wed Aug 13 16:41:17 2014 -0500
Committer: Robert Douglas <rd...@w2odigital.com>
Committed: Wed Aug 13 16:41:17 2014 -0500
----------------------------------------------------------------------
pom.xml | 2 +-
streams-contrib/streams-provider-facebook/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/b9597d0e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index da30926..b0c3f89 100644
--- a/pom.xml
+++ b/pom.xml
@@ -87,7 +87,7 @@
<netty.version>3.8.0.Final</netty.version>
<json-path.version>0.9.1</json-path.version>
<build-helper.version>1.8</build-helper.version>
- <facebook4j.version>2.1.1-W2O-SNAPSHOT</facebook4j.version>
+ <facebook4j.version>2.1.0</facebook4j.version>
</properties>
<modules>
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/b9597d0e/streams-contrib/streams-provider-facebook/pom.xml
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/pom.xml b/streams-contrib/streams-provider-facebook/pom.xml
index a267653..3c4a6f2 100644
--- a/streams-contrib/streams-provider-facebook/pom.xml
+++ b/streams-contrib/streams-provider-facebook/pom.xml
@@ -56,7 +56,7 @@
<dependency>
<groupId>org.facebook4j</groupId>
<artifactId>facebook4j-core</artifactId>
- <version>${facebook4j.version}</version>
+ <version>2.1.0</version>
</dependency>
</dependencies>
[5/7] git commit: STREAMS-145 | Responded to code review feedback
Posted by mf...@apache.org.
STREAMS-145 | Responded to code review feedback
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/df1b1615
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/df1b1615
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/df1b1615
Branch: refs/heads/master
Commit: df1b161595ae3c3916399e17fba0db376baf4ca2
Parents: 17f32cd
Author: Robert Douglas <rd...@w2odigital.com>
Authored: Thu Aug 14 11:01:09 2014 -0500
Committer: Robert Douglas <rd...@w2odigital.com>
Committed: Thu Aug 14 11:01:09 2014 -0500
----------------------------------------------------------------------
.../provider/FacebookEventClassifier.java | 6 +-
.../provider/FacebookStreamConfigurator.java | 64 ++++++++++++++++++++
.../test/FacebookActivityActorSerDeTest.java | 19 ++----
.../test/FacebookEventClassifierTest.java | 8 ++-
.../streams/facebook/test/SimplePageTest.java | 50 +++++++--------
5 files changed, 102 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/df1b1615/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookEventClassifier.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookEventClassifier.java b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookEventClassifier.java
index 89abc74..16e2a25 100644
--- a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookEventClassifier.java
+++ b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookEventClassifier.java
@@ -27,9 +27,13 @@ import java.io.IOException;
import org.apache.streams.facebook.Page;
import org.apache.streams.facebook.Post;
import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class FacebookEventClassifier {
+ private final static Logger LOGGER = LoggerFactory.getLogger(FacebookEventClassifier.class);
+
public static Class detectClass( String json ) {
Preconditions.checkNotNull(json);
@@ -39,7 +43,7 @@ public class FacebookEventClassifier {
try {
objectNode = (ObjectNode) StreamsJacksonMapper.getInstance().readTree(json);
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Exception while trying to detect class: {}", e.getMessage());
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/df1b1615/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookStreamConfigurator.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookStreamConfigurator.java b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookStreamConfigurator.java
new file mode 100644
index 0000000..91c5027
--- /dev/null
+++ b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookStreamConfigurator.java
@@ -0,0 +1,64 @@
+/*
+ * 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
+ *
+ * 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.facebook.provider;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigException;
+import org.apache.streams.facebook.FacebookConfiguration;
+import org.apache.streams.facebook.FacebookOAuthConfiguration;
+import org.apache.streams.facebook.FacebookUserInformationConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class FacebookStreamConfigurator {
+ private final static Logger LOGGER = LoggerFactory.getLogger(FacebookStreamConfigurator.class);
+ private final static ObjectMapper mapper = new ObjectMapper();
+
+
+ public static FacebookUserInformationConfiguration detectFacebookConfiguration(Config config) {
+ FacebookUserInformationConfiguration facebookUserInformationConfiguration = new FacebookUserInformationConfiguration();
+
+ try {
+ Config oauth = config.getConfig("oauth");
+ FacebookOAuthConfiguration facebookOAuthConfiguration = new FacebookOAuthConfiguration();
+ facebookOAuthConfiguration.setAppAccessToken(oauth.getString("appAccessToken"));
+ facebookOAuthConfiguration.setAppSecret(oauth.getString("appSecret"));
+ facebookOAuthConfiguration.setUserAccessToken(oauth.getString("userAccessToken"));
+ facebookOAuthConfiguration.setAppId(oauth.getString("appId"));
+
+ facebookUserInformationConfiguration.setOauth(facebookOAuthConfiguration);
+ } catch( ConfigException ce ) {}
+
+ return facebookUserInformationConfiguration;
+ }
+
+ public static FacebookConfiguration detectConfiguration(Config config) {
+
+ FacebookConfiguration facebookConfiguration = mapper.convertValue(detectFacebookConfiguration(config), FacebookConfiguration.class);
+
+ return facebookConfiguration;
+ }
+
+ public static FacebookUserInformationConfiguration detectFacebookUserInformationConfiguration(Config config) {
+ return mapper.convertValue(detectFacebookConfiguration(config), FacebookUserInformationConfiguration.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/df1b1615/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivityActorSerDeTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivityActorSerDeTest.java b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivityActorSerDeTest.java
index b30cb90..38e6860 100644
--- a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivityActorSerDeTest.java
+++ b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookActivityActorSerDeTest.java
@@ -42,7 +42,7 @@ public class FacebookActivityActorSerDeTest {
private ObjectMapper mapper = StreamsJacksonMapper.getInstance();
@Test
- public void Tests()
+ public void Tests() throws Exception
{
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.TRUE);
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
@@ -53,20 +53,13 @@ public class FacebookActivityActorSerDeTest {
is = new BoundedInputStream(is, 10000);
String json;
- try {
- json = joiner.join(IOUtils.readLines(is));
- LOGGER.debug(json);
+ json = joiner.join(IOUtils.readLines(is));
+ LOGGER.debug(json);
- Page page = mapper.readValue(json, Page.class);
+ Page page = mapper.readValue(json, Page.class);
- Activity activity = serializer.deserialize(page);
+ Activity activity = serializer.deserialize(page);
- LOGGER.debug(mapper.writeValueAsString(activity));
-
- } catch( Exception e ) {
- System.out.println(e);
- e.printStackTrace();
- Assert.fail();
- }
+ LOGGER.debug(mapper.writeValueAsString(activity));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/df1b1615/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookEventClassifierTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookEventClassifierTest.java b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookEventClassifierTest.java
index 9cf7196..076aca9 100644
--- a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookEventClassifierTest.java
+++ b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/FacebookEventClassifierTest.java
@@ -23,6 +23,8 @@ import org.apache.streams.facebook.Post;
import org.apache.streams.facebook.provider.FacebookEventClassifier;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
public class FacebookEventClassifierTest {
private String empty = "";
private String def = "{}";
@@ -38,18 +40,18 @@ public class FacebookEventClassifierTest {
@Test
public void defaultDetectTest() {
Class inClass = FacebookEventClassifier.detectClass(post);
- assert(inClass.equals(Post.class));
+ assertEquals(inClass, Post.class);
}
@Test
public void postDetectTest() {
Class inClass = FacebookEventClassifier.detectClass(post);
- assert(inClass.equals(Post.class));
+ assertEquals(inClass, Post.class);
}
@Test
public void pageDetectTest() {
Class inClass = FacebookEventClassifier.detectClass(page);
- assert(inClass.equals(Page.class));
+ assertEquals(inClass, Page.class);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/df1b1615/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/SimplePageTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/SimplePageTest.java b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/SimplePageTest.java
index 0dd57ca..856ad36 100644
--- a/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/SimplePageTest.java
+++ b/streams-contrib/streams-provider-facebook/src/test/java/org/apache/streams/facebook/test/SimplePageTest.java
@@ -22,19 +22,17 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.streams.core.StreamsDatum;
-import org.apache.streams.exceptions.ActivitySerializerException;
import org.apache.streams.facebook.Page;
import org.apache.streams.facebook.api.FacebookPageActivitySerializer;
import org.apache.streams.facebook.processor.FacebookTypeConverter;
import org.apache.streams.jackson.StreamsJacksonMapper;
import org.apache.streams.pojo.json.Activity;
-import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -46,14 +44,14 @@ import static org.junit.Assert.assertThat;
public class SimplePageTest {
private final static Logger LOGGER = LoggerFactory.getLogger(SimplePageTest.class);
private ObjectMapper mapper = StreamsJacksonMapper.getInstance();
+ private ObjectNode event;
private static final String FACEBOOK_JSON= "{\"metadata\":null,\"id\":\"142803045874943\",\"name\":\"Senator Angus S. King, Jr.\",\"category\":\"Government official\",\"createdTime\":null,\"link\":\"https://www.facebook.com/SenatorAngusSKingJr\",\"likes\":10246,\"location\":{\"street\":\"359 Dirksen Senate Office Building\",\"city\":\"Washington, District of Columbia\",\"state\":\"DC\",\"country\":\"United States\",\"zip\":\"20510\",\"latitude\":null,\"longitude\":null,\"text\":null},\"phone\":\"202-224-5344\",\"checkins\":0,\"picture\":null,\"cover\":{\"id\":null,\"source\":\"https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/10288792_321537751334804_8200105519500362465_n.jpg?oh=fbcde9b3e1e011dfa3e699628629bc53&oe=546FB617&__gda__=1416717487_3fa5781d7d9c3d58f2bc798a36ac6fc0\",\"offsetY\":9},\"website\":\"http://www.king.senate.gov\",\"talkingAboutCount\":5034,\"accessToken\":null,\"wereHereCount\":0,\"about\":\"Welcome to the official Facebook page of Senator Angus
S. King, Jr. (I-ME).\\nhttp://king.senate.gov\\nhttps://twitter.com/SenAngusKing\\nhttps://www.youtube.com/SenatorAngusKing\",\"username\":\"SenatorAngusSKingJr\",\"published\":true,\"communityPage\":false}";
private FacebookPageActivitySerializer facebookPageActivitySerializer = new FacebookPageActivitySerializer();
- @Test
- public void Tests()
- {
+ @Before
+ public void setUp() throws Exception {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.TRUE);
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);
@@ -62,14 +60,12 @@ public class SimplePageTest {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
- ObjectNode event = null;
- try {
- event = (ObjectNode) mapper.readTree(FACEBOOK_JSON);
- } catch (IOException e) {
- e.printStackTrace();
- Assert.fail();
- }
+ event = null;
+ event = (ObjectNode) mapper.readTree(FACEBOOK_JSON);
+ }
+ @Test
+ public void TestSerialization() {
assertThat(event, is(not(nullValue())));
Page page = mapper.convertValue(event, Page.class);
@@ -78,23 +74,14 @@ public class SimplePageTest {
assertThat(page.getAbout(), is(not(nullValue())));
assertThat(page.getLikes(), is(not(nullValue())));
assertThat(page.getTalkingAboutCount(), is(not(nullValue())));
+ }
+
+ @Test
+ public void TestDeserialization() throws Exception {
+ Page page = mapper.convertValue(event, Page.class);
Activity activity = null;
- try {
- activity = facebookPageActivitySerializer.deserialize(page);
- } catch (ActivitySerializerException e) {
- e.printStackTrace();
- Assert.fail();
- }
-
- try {
- FacebookTypeConverter converter = new FacebookTypeConverter(String.class, Activity.class);
- converter.prepare(null);
- converter.process(new StreamsDatum(FACEBOOK_JSON));
- } catch (Throwable e) {
- e.printStackTrace();
- Assert.fail();
- }
+ activity = facebookPageActivitySerializer.deserialize(page);
assertThat(activity, is(not(nullValue())));
@@ -103,4 +90,11 @@ public class SimplePageTest {
assertThat(activity.getVerb(), is(not(nullValue())));
assertThat(activity.getProvider(), is(not(nullValue())));
}
+
+ @Test
+ public void TestConverter() throws Exception {
+ FacebookTypeConverter converter = new FacebookTypeConverter(String.class, Activity.class);
+ converter.prepare(null);
+ converter.process(new StreamsDatum(FACEBOOK_JSON));
+ }
}
\ No newline at end of file
[6/7] git commit: STREAMS-145 | Code review feedback
Posted by mf...@apache.org.
STREAMS-145 | Code review feedback
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/02951c53
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/02951c53
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/02951c53
Branch: refs/heads/master
Commit: 02951c53f216a21d727151aee72991c895b6cc5a
Parents: df1b161
Author: Robert Douglas <rd...@w2odigital.com>
Authored: Thu Aug 14 11:18:47 2014 -0500
Committer: Robert Douglas <rd...@w2odigital.com>
Committed: Thu Aug 14 11:18:47 2014 -0500
----------------------------------------------------------------------
.../streams/facebook/provider/FacebookStreamConfigurator.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/02951c53/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookStreamConfigurator.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookStreamConfigurator.java b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookStreamConfigurator.java
index 91c5027..da1b778 100644
--- a/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookStreamConfigurator.java
+++ b/streams-contrib/streams-provider-facebook/src/main/java/org/apache/streams/facebook/provider/FacebookStreamConfigurator.java
@@ -45,7 +45,9 @@ public class FacebookStreamConfigurator {
facebookOAuthConfiguration.setAppId(oauth.getString("appId"));
facebookUserInformationConfiguration.setOauth(facebookOAuthConfiguration);
- } catch( ConfigException ce ) {}
+ } catch( ConfigException ce ) {
+ LOGGER.error("Exception while extracting Facebook oauth token: {}", ce.getMessage());
+ }
return facebookUserInformationConfiguration;
}